Trouble running custom powershell scripts
Not sure what I'm missing, I've googled examples and mine looks okay from what I can tell. Probably missing something obvious. The error message I'm getting is:
Custom Script Result :c:\scripts\ADMmailboxlink.ps1 : The term 'c:\scripts\ADMmailboxlink.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. At line:1 char:1 + c:\scripts\ADMmailboxlink.ps1 -ExecutionPolicy bypass (username redacted) + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (c:\scripts\ADMmailboxlink.ps1:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException
To call the script, I'm using:
C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe "c:\scripts\ADMmailboxlink.ps1" -ExecutionPolicy bypass %username% (I've tried just using powershell and powershell.exe with the same results)
And the powershell script itself:
Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010
. $env:ExchangeInstallPath\bin\RemoteExchange.ps1
Connect-ExchangeServer -auto
Set-User -identity %username% -LinkedMasterAccount "domain\"%username% -LinkedDomainController mydomaincontroller
New to ADSelfService Plus?