I have a script which uses a set of cmdlets which are on a Windows 2012 Domain Controller. I am using a Windows 7 machine which does not have these (Get-DHCPServerV4Lease for example).
At first I created a script module and applied it like this:
Invoke-Command -Computername <Server> -scriptblock {Get-ComputerStatus}
I then get an error message stating that the cmdlet is not recognised. Then I just converted it into a straight-forward PS1 script:
icm -cn <server> -FilePath .\ComputerInfo.ps1 -ArgumentList "Computer"
After running this I get an error saying that the various cmdlets I am using in the script are not recognised.
Get-DnsServerResourceRecord : The term 'Get-DnsServerResourceRecord' is not recognized as the name of a cmdlet,......
How can I run my script against a DC using Invoke-Command?
Import-Module DNS*statement in the beginning of the script to import the dnsmodule on the remote computer (DC)? The first script failed because you didn't import the custom module on the remote computer. A remote computer can't use a module that you have imported on your local computer.