I have a script on my local c drive in a folder c:\util n script name is test3.ps1
I would like to run this script on any machine I can invoke-command to
PS C:\util> Invoke-Command -ComputerName tgcs011 -ScriptBlock { c:\util\test3.ps1 int }
The term ‘c:\util\test3.ps1’ is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
PS C:\util> invoke-command -ComputerName metro-12-fs02 -FilePath ‘c:\util\Get-WindowsUpdates.ps1’
Cannot validate argument on parameter ‘Source’. The argument is null or empty. Supply an argument that is not null or
empty and then try the command again.
Cannot validate argument on parameter ‘Source’. The argument is null or empty. Supply an argument that is not null or
empty and then try the command again.
Title : 2019-02 Preview of Monthly Quality Rollup for Windows Server 2012 for x64-based Systems
(KB4487024)
Description : Install this update to resolve issues in Windows. For a complete listing of the issues that are
included in this update, see the associated Microsoft Knowledge Base article for more
information. After you install this item, you may have to restart your computer.
SupportUrl : February 19, 2019—KB4487024 (Preview of Monthly Rollup)
UninstallationNotes : This software update can be removed by selecting View installed updates in the Programs and
Features Control Panel.
RebootRequired : False
Title : 2019-02 Preview of Quality Rollup for .NET Framework 3.5, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1,
4.7.2 for Windows Server 2012 for x64 (KB4487257)
Description : Install this update to resolve issues in Windows. For a complete listing of the issues that are
included in this update, see the associated Microsoft Knowledge Base article for more
information. After you install this item, you may have to restart your computer.
SupportUrl : http://support.microsoft.com
UninstallationNotes : This software update can be removed by selecting View installed updates in the Programs and
Features Control Panel.
RebootRequired : False
Cannot validate argument on parameter ‘Source’. The argument is null or empty. Supply an argument that is not null or
empty and then try the command again.
Without any parameters the script will return the title of each update that
is currently available.
Also when i run the script local without any arguments it runs fine.
PS C:\util> .\Get-WindowsUpdates.ps1
Title : 2019-02 Preview of Monthly Quality Rollup for Windows Server 2012 for x64-based Systems
(KB4487024)
Description : Install this update to resolve issues in Windows. For a complete listing of the issues that are
included in this update, see the associated Microsoft Knowledge Base article for more
information. After you install this item, you may have to restart your computer.
SupportUrl : February 19, 2019—KB4487024 (Preview of Monthly Rollup)
UninstallationNotes : This software update can be removed by selecting View installed updates in the Programs and
Features Control Panel.
RebootRequired : False
Title : 2019-02 Preview of Quality Rollup for .NET Framework 3.5, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1,
4.7.2 for Windows Server 2012 for x64 (KB4487257)
Description : Install this update to resolve issues in Windows. For a complete listing of the issues that are
included in this update, see the associated Microsoft Knowledge Base article for more
information. After you install this item, you may have to restart your computer.
SupportUrl : http://support.microsoft.com
UninstallationNotes : This software update can be removed by selecting View installed updates in the Programs and
Features Control Panel.
RebootRequired : False
Get-WindowsUpdates.ps1
Where is this file located, on your admin workstation or on the remote server?
Just curious… try…
# If it is on the remote server then - the script needs to be on this server UNC path
Invoke-Command -ComputerName 'metro-12-fs02' -ScriptBlock { & 'c:\util\Get-WindowsUpdates.ps1' }
# If the file is on your workstation - the script needs to be on this server UNC path
Invoke-Command -ComputerName 'metro-12-fs02' -ScriptBlock { & '\\YourWorkstationName\c$\util\Get-WindowsUpdates.ps1' }