Powershell System.String anomaly
I have a PS script that dumps a bunch of status info from an Exchange 2010 environment and everything works great in EMS. I created a scheduled task which involves running powershell.exe and then importing an Exchange 2010 session. That is where I discovered the following anomaly: Steps to repro the problem: Start an EMS session as Adminstrator and then also start a normal powershell session as Administrator. In the normal powershell window create an Exchange 2010 session: $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri 'http://exserver01/PowerShell/' -Authentication Kerberos Import-PSSession -Session $Session Now create a the same variable in both of the PS windows with this command: $mbxDB = Get-MailboxDatabase <myDB> -status In the EMS windows one can run the following command: $mbxdb.DatabaseSize.ToGB() but in the normal PS window I get the following error: Method invocation failed because [System.String] doesn't contain a method named 'TOGB' Upon closer inspection it would appear that System.String in the EMS window and the normal PS window do not have the same properties For example mbxdb.DatabaseSize | gm in the normal PS window does not have any of the ToGB, ToMB etc properties. Does anyone have a workaround or a solution? Thanks /Simon
June 28th, 2010 10:56am

Found it. The datatype is: Microsoft.Exchange.Data.ByteQuantifiedSize which requries loading the Exchange Data dll $dll = "C:\Program Files\Microsoft\Exchange Server\V14\Bin\Microsoft.Exchange.Data.dll" [Reflection.Assembly]::LoadFile($dll) [Microsoft.Exchange.Data.ByteQuantifiedSize]$obj = $mbxdb.DatabaseSize /Simon
Free Windows Admin Tool Kit Click here and download it now
June 28th, 2010 11:09am

On Mon, 28 Jun 2010 07:56:01 +0000, DidiMaao wrote: "DiDiMaao"? YOW! I haven't used that since I left Viet Nam in 1968! --- Rich Matheisen MCSE+I, Exchange MVP --- Rich Matheisen MCSE+I, Exchange MVP
June 29th, 2010 4:06am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics