I have the following cmd file:-
PowerShell.exe -noexit E:\\wwwroot\\domains\\processes\\AddDirectory.ps1 -Param testdomain.co.uk
which goes
You need to use a param block in the script, the argument you pass to the file will be assign to $domainName and you will use it to pass the value to the scriptblock :
PowerShell.exe -noexit E:\wwwroot\domains\processes\AddDirectory.ps1 testdomain.co.uk
# script file
param($domainName)
$script = {
Param($Param1)
...
$domain = $Param1
...
}
$Session = New-PSSession -ComputerName 192.168.0.25
Invoke-Command -Session $Session -ScriptBlock $script -ArgumentList $domainName