$password = ConvertTo-SecureString 'Paper123!@#' -AsPlainText -Force $cred = New-Object System.Management.Automation.PSCredential('INTRANET\sysadmin', $password) Invoke-Command -ComputerName 192.168.0.6 -Credential $cred -ScriptBlock { Get-Content 'C:\Shares\test\scripts\sync-from-nas.ps1' | Select-String -Pattern "NAS_HOST|NAS_USER|NAS_BASE|scp" -Context 0,2 }