original remote file
remote file after update
PS C:\Windows\System32> $contents = invoke-command -session $session -scriptblock {
>> $fileName = "C:\Users\zchen\Desktop\abc.txt"
>> (Get-Content -Path $fileName) |
>> ForEach-Object {$_ -Replace 'line2', $Env:COMPUTERNAME} |
>> Set-Content -Path $fileName
>> Get-Content -Path $fileName
>> }
PS C:\Windows\System32> $contents
line1
DESKTOP-K1RH4M9
line3
reference:
No comments:
Post a Comment