Hi All,
I need to install a software on multiple computers. The setup file is residing on one of the jump box. Below is the switch to install the software locally, I tried this below command locally on server and it works:
\\SCCMSources\Applications\CrowdStrike\CrowdStrike_3.1.5226.0\WindowsSensor.exe /install /quiet /norestart CID=000000000000000000000-00
I want to use this command in invoke-command. I tried below command on localhost and on remote computer. It does not give any error message but does not do anything also.
Invoke-Command -ScriptBlock {c:\temp\CrowdStrike_3.1.5226.0\WindowsSensor.exe /install /quiet /norestart CID=000000000000000000000-00} -ComputerName localhost
It just do nothing, once I press enter, it goes to c:>. Please help me running this command or let me know if you need any information my side.
Get-Help -Name Invoke-Command -Examples
NAME
Invoke-Command
SYNOPSIS
Runs commands on local and remote computers.
Example 1: Run a script on a server
Invoke-Command -FilePath c:\scripts\test.ps1 -ComputerName Server01
Example 2: Run a command on a remote server
Invoke-Command -ComputerName server01 -Credential domain01\user01 -ScriptBlock {Get-Culture}
…
In some cases, when running commends on servers, I’ve to build up the command line, like this:
$robocopyOptions = @('/E','/ZB','/J','/EFSRAW','/COPYALL','/XO','/R:3','/W:60','/NP','/xf','log*')
$robocopyOptions += "/LOG:$($log)"
$robocopyOptions += "/xf LOG* "
$CmdLine = @($source, $destination) + $robocopyOptions
& 'robocopy.exe' $CmdLine
In some cases when running commands on remote servers I use a PSSession, like this:
$pss = New-PSSession $Server -Credential (Import-Clixml "$codedeploy")
Invoke-Command -Session $pss -scriptblock {
yoursrcipt
}