Determine smallest DB powershell from remote machine fails
Hi,
After invoking the PSSession I am able to execute the exchange powershell cmdlets from a remote computer against Exchange 2010.
However, when I try to run this script remotely, it fails:
# This script will return the smallest mailbox database, which can be useful when creating new mailboxes or re-distributing based on size
# Created by Jason Sherry (izzy@izzy.org) 3/25/2012
# Last Updated: 3/25/2012
# Source: http://izzy.org/scripts/Exchange/Admin/Get-SmallestDB.ps1
# Partial code source:
http://powershell.com/cs/media/p/3981.aspx
$MBXDbs = Get-MailboxDatabase | Where-Object {$_.Identity -like "Users-US-*"} # This will exclude any DB that started with "TCN-EU-"
# Loop through each of the MBXDbs
ForEach ($MBXDB in $MBXDbs) {
# Get current mailboxes sizes by summing the size of all mailboxes and "Deleted Items" in the database
$TotalItemSize = Get-MailboxStatistics -Database $MBXDB | %{$_.TotalItemSize.Value.ToMB()} | Measure-Object -sum
$TotalDeletedItemSize = Get-MailboxStatistics -Database $MBXDB| %{$_.TotalDeletedItemSize.Value.ToMB()} | Measure-Object -sum
#Get-MailboxDatabase and the DatabaseSize property was not used since it does not return a value in some environments as of 2010 SP2
$TotalDBSize = $TotalItemSize.Sum + $TotalDeletedItemSize.Sum
# Compare the sizes to find the smallest DB
If (($TotalDBSize -lt $SmallestDBsize) -or ($SmallestDBsize -eq $null))
{
$SmallestDBsize = $DBsize
$SmallestDB = $MBXDB
}
}
Write-host "Smallest DB: " $SmallestDB
Here is the error messages we keep getting:
Cannot process argument transformation on parameter 'Database'. Cannot convert the "Mailbox Database 003" value of type "Deserialized.Microsoft.Ex
change.Data.Directory.SystemConfiguration.MailboxDatabase" to type "Microsoft.Exchange.Configuration.Tasks.DatabaseIdParameter".
+ CategoryInfo : InvalidData: (:) [Get-MailboxStatistics], ParameterBindin...mationException
+ FullyQualifiedErrorId : ParameterArgumentTransformationError,Get-MailboxStatistics
Why does this ps1 work locally on the exchange server and not from a remote computer?
thank you
March 29th, 2012 9:21pm
You can add parameter -server with your servername to script to make it works better or you can try invoke-command like
http://technet.microsoft.com/en-us/library/dd819505.aspxRegards, Konrad Sagala, MCT, MCSE+M, MCITP: Exchange 2007/2010
Free Windows Admin Tool Kit Click here and download it now
March 30th, 2012 4:31am
You can add parameter -server with your servername to script to make it works better or you can try invoke-command like
http://technet.microsoft.com/en-us/library/dd819505.aspxRegards, Konrad Sagala, MCT, MCSE+M, MCITP: Exchange 2007/2010
March 30th, 2012 4:31am
Hi
Did you try Konrad's suggestion?
Did they have the same service packs and also the patch levels on both side? Perhaps the problem is on your environment.
Cheers
Zi FengZi Feng
TechNet Community Support
Free Windows Admin Tool Kit Click here and download it now
March 30th, 2012 4:34am
Hi
Did you try Konrad's suggestion?
Did they have the same service packs and also the patch levels on both side? Perhaps the problem is on your environment.
Cheers
Zi FengZi Feng
TechNet Community Support
March 30th, 2012 4:34am
You can add parameter -server with your servername to script to make it works better or you can try invoke-command like
http://technet.microsoft.com/en-us/library/dd819505.aspxRegards, Konrad Sagala, MCT, MCSE+M, MCITP: Exchange 2007/2010
Free Windows Admin Tool Kit Click here and download it now
March 30th, 2012 4:40am
Hi
Did you try Konrad's suggestion?
Did they have the same service packs and also the patch levels on both side? Perhaps the problem is on your environment.
Cheers
Zi FengZi Feng
TechNet Community Support
March 30th, 2012 4:43am
Hi S.Kwan,
Any update for your issue?
Regards!
TechNet Subscriber Support
in
forum if you have any feedback on our support, please contact
tngfb@microsoft.com
Please remember to click Mark as Answer on the post that helps you, and to click Unmark as Answer if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.<o:p></o:p>
Gavin
TechNet Community Support
Free Windows Admin Tool Kit Click here and download it now
April 2nd, 2012 3:20am
Hi S.Kwan,
Any update for your issue?
Regards!
TechNet Subscriber Support
in
forum if you have any feedback on our support, please contact
tngfb@microsoft.com
Please remember to click Mark as Answer on the post that helps you, and to click Unmark as Answer if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.<o:p></o:p>
Gavin
TechNet Community Support
April 2nd, 2012 3:20am
Hi S.Kwan,
Any update for your issue?
Regards!
TechNet Subscriber Support
in
forum if you have any feedback on our support, please contact
tngfb@microsoft.com
Please remember to click Mark as Answer on the post that helps you, and to click Unmark as Answer if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.<o:p></o:p>
Gavin
TechNet Community Support
Free Windows Admin Tool Kit Click here and download it now
April 2nd, 2012 3:24am
Hi,
Our coders rewrote the powershell from the ground up - they couldn't get the recommended one to work remotely.
Also, the recommended script rounded KBs up - which gave a different recommended DB to not rounding the KBs up.
Thank you for your assistance.
April 4th, 2012 10:12pm
Hi S.Kwan.
If you want to do more research about script related issue, I would suggest that you could post the issue on below forum, you will ge more help:
http://social.technet.microsoft.com/Forums/en-US/exchangesvrdevelopment/threads
It is specific for it.
Regards!
TechNet Subscriber Support
in
forum if you have any feedback on our support, please contact
tngfb@microsoft.com
Please remember to click Mark as Answer on the post that helps you, and to
click Unmark as Answer if a marked post does not actually answer your
question. This can be beneficial to other community members reading the thread.<o:p></o:p>
Gavin
TechNet Community Support
Free Windows Admin Tool Kit Click here and download it now
April 5th, 2012 4:35am