invoke command - Powershell passing arguments in ScriptBlock -
i'm trying last write time on file remote server.
this doesn not work:
$server = "myservername" $lastwrite = invoke-command -computername $server -scriptblock {get-childitem "\\$args[0]\hot.war" } -argumentlist $server | select -property lastwritetime
this work:
$lastwrite = invoke-command -computername $server -scriptblock {get-childitem "\\myservername\hot.war" } -argumentlist $server | select -property lastwritetime
can make first set work?
another way, if using powershell 3. can this:
$lastwrite = invoke-command -computername $server -scriptblock { get-childitem "\\$using:server\hot.war" } | select -property lastwritetime
Comments
Post a Comment