Hi,
I have a powershell script which loads active directory module and exchange commandlets. This works fine if I run file.ps1 within powershell ISE. When I try to run file.ps1 from a batch file I get an error saying
"The Error generated was: Cannot load Windows PowerShell snap-in Microsoft.Exchange.Management.PowerShell.E2010 because of the following error: The type initializer for 'Microsoft.Exchange.Data.Directory.Globals' threw an exception"
My batch file looks like this:
call C:\windows\system32\WindowsPowerShell\v1.0\powershell.exe -File C:\file\file.ps1
Please kindly shed some light on this.
Thank you.