Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function Run-RemoteCMD {
- param(
- [Parameter(Mandatory=$true,valuefrompipeline=$true)]
- [string]$compname)
- begin {
- $command = Read-Host " Enter command to run"
- [string]$cmd = "CMD.EXE /C " +$command
- }
- process {
- $newproc = Invoke-WmiMethod -class Win32_process -name Create -ArgumentList ($cmd) -ComputerName $compname
- if ($newproc.ReturnValue -eq 0 )
- { Write-Output " Command $($command) invoked Sucessfully on $($compname)" }
- }
- End{Write-Output "Script ...END"}
- }
- Run-RemoteCMD
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement