HackGh Community Forum

Log in

I forgot my password



Who Is Online?
Guests : 0
Hidden : 0
Registered : 0
Users Online :
Refresh View the whole list

Latest topics
» AIRTEL FREE BROWSING
Yesterday at 1:20 pm by akokono

» Instagram Account hacked
Sun Aug 06, 2017 7:17 pm by saudseidu

» AIRTEL DATA TRANSFER
Sat Aug 05, 2017 7:22 pm by kbasante

» Watch Free 2CTV on any Vodafone line for the month of July
Thu Aug 03, 2017 2:45 pm by WhIPL4$h

» Tricks on How To Download Paid Android Apps For Free
Thu Jul 20, 2017 11:28 am by franknart12

» Psiphon Pro v125 [Subscribed] Cracked APK
Thu Jul 20, 2017 9:29 am by franknart12

» NSS posts over 91,000 service personnel for 2017/2018
Thu Jul 13, 2017 3:00 pm by chinesta10

» Kotoko team bus involved in accident
Thu Jul 13, 2017 1:00 pm by chinesta10

» Airtel Sika kokoo promo
Sun Jul 09, 2017 12:18 pm by willspanner

» My pc constantly gives me black screen and freezes when playing games
Sat Jul 08, 2017 1:10 pm by kbasante

Keywords

9  black  free  6  7  Unlimited  11  HackGh  browsing  2  2000  christian  keepCalmAndLoveHACKGH4Life  3  10  unlocking  cheat  8  books  5  busy  4  30  Tigo  1  dumsormuststop  

Top posting users this month
swiftblack
 
kbasante
 
Sannyz
 
WhIPL4$h
 
saudseidu
 
Awuah33
 
akokono
 



Free counters!
Staff Online
Staff Online
Members1993
Most Online179
Newest Member

You are not connected. Please login or register

 » Computer Tricks And Technology Tips » Pc ( Windows ) Tips & Downloads » 

How to write and run scripts in Windows PowerShell - Part 2

View previous topic View next topic Go down  Message [Page 1 of 1]

PhAnt0m

avatar
Administrator
Administrator
RUNNING SCRIPTS REMOTELY

To run a script on a remote computer, use the FilePath parameter of the Invoke-Command cmdlet.

Enter the path and file name of the script as the value of the FilePath parameter. The script must reside on the local computer or in a directory that the local computer can access.

The following command runs the ServicesLog.ps1 script on the Server01 remote computer.

invoke-command -computername Server01 -filepath C:\scripts\servicesLog.ps1

PARAMETERS IN SCRIPTS

To define parameters in a script, use a Param statement. The Param statement must be the first statement in a script, except for comments and any #Requires statements.

Script parameters work like function parameters. The parameter values are available to all of the commands in the script. All of the features of function parameters, including the Parameter attribute and its named arguments, are also valid in scripts.

When running the script, script users type the parameters after the script name.

The following example shows a Test-Remote.ps1 script that has a ComputerName parameter. Both of the script functions can access the ComputerName parameter value.

param ($ComputerName = $(throw "ComputerName parameter is required."))

function CanPing {
$error.clear()
$tmp = test-connection $computername -erroraction SilentlyContinue

if (!$?)
{write-host "Ping failed: $ComputerName."; return $false}
else
{write-host "Ping succeeded: $ComputerName"; return $true}
}

function CanRemote {
$s = new-pssession $computername -erroraction SilentlyContinue

if ($s -is [System.Management.Automation.Runspaces.PSSession])
{write-host "Remote test succeeded: $ComputerName."}
else
{write-host "Remote test failed: $ComputerName."}
}

if (CanPing $computername) {CanRemote $computername}


To run this script, type the parameter name after the script name. For example:

C:\PS> .\test-remote.ps1 -computername Server01

Ping succeeded: Server01
Remote test failed: Server01


For more information about the Param statement and the function parameters see about_Functions and about_Functions_Advanced_Parameters. You can find this additional information in you windows folder , usually on your drive C

Part 3 to follow.....


------------------------------------------------



Hacking Is My Religion ..Hackers Inside



[Useful Links]
Free Browsing
Betting Hack
Buy A Website
Reset Your Password
Free Cheat Book
View user profile

View previous topic View next topic Back to top  Message [Page 1 of 1]

Permissions in this forum:
You cannot reply to topics in this forum