K B
asked on
How would I add "overall provisioning status" to the output of this script?
# The Output will be written to this file in the current working directory
$LogFile = ($(get-date -Format yyyy-MM-dd) + "-litholdRESULTS.csv")
# Run Script to Set Holds
$MBXs = Get-Mailbox -ResultSize 50 -Filter {LitigationHoldEnabled -eq "False"}
$(Foreach ($Mbx in $MBXs){
Try {
$Mbx | Set-Mailbox -LitigationHoldEnabled $true -ea STOP
New-Object PSobject -Property @{
Mailbox = $Mbx.DisplayName
Status = "Success"
}
}Catch{
New-Object PSobject -Property @{
Mailbox = $Mbx.DisplayName
Status = $_.Exception.Message
}
}
})| Export-Csv $LogFile -nti
*Credit to Subsun for the original script
ASKER
Thank you Vasil...
So would it look like this?
So would it look like this?
# The Output will be written to this file in the current working directory
$LogFile = ($(get-date -Format yyyy-MM-dd) + "-litholdRESULTS.csv")
# Run Script to Set Holds
$MBXs = Get-Mailbox -ResultSize 50 -Filter {LitigationHoldEnabled -eq "False"}
$(Foreach ($Mbx in $MBXs){
Try {
$Mbx | Set-Mailbox -LitigationHoldEnabled $true -ea STOP
New-Object PSobject -Property @{
Mailbox = $Mbx.DisplayName
Status = "Success"
}
}Catch{
New-Object PSobject -Property @{
Mailbox = $Mbx.DisplayName
Status = $_.Exception.Message
OverallProvisioningStatus = (Get-MsolUser -UserPrincipalName $mbx.UserPrincipalName).OverallProvisioningStatus
}
}
})| Export-Csv $LogFile -nti
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Vasil you rock!
Open in new window
OverallProvisioningStatus is not that reliable imo, you can use SKUAssigned instead. Well, depends on what you are actually trying to achieve :)