Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Running Local Script to a Remote Host

$
0
0
I've been able to run the script below locally with success but I trying to figure out how to run the scrip on a remote server without the scrip 
residing on the remote server.
-Both computers reside on the same network
-these computers reside on an AD network and require AD credentials.
-I can run a Test-Connection with good results
-I've been heading down the New-PSSession path but I'm not sure if this is correct.  Note that when I do New-PSSession, Authentication works
but for some reason the computer cannot be found.  This is with Enable-PSRemoting -force.  Again I'm not sure if this is even the right direction 
to run a script locally to another server.
Thank you in advance!
Try {
    $State = Get-WebAppPoolState 
    Write-Host "IIS-Application Pool" $State.Value
    Write-Host "Script Check passed"
    Exit 0 # change to Sleep(10) if run script without GFI MAX RMM
} 
Catch {
    Write-Host "Script Check Failed"
    Write-Host "Try run script via ''Powershell Run as Administrator'' !"
    Exit 1001
}

Viewing all articles
Browse latest Browse all 6937

Trending Articles