Link to home
Start Free TrialLog in
Avatar of K B
K BFlag for United States of America

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 

Open in new window


*Credit to Subsun for the original script
Avatar of Vasil Michev (MVP)
Vasil Michev (MVP)
Flag of Bulgaria image

OverallProvisioningStatus is attribute for Get-MsolUser, so you need to make sure you are connected to WAAD as well. Then, you can do something like this:

OverallProvisioningStatus = (Get-MsolUser -UserPrincipalName $mbx.UserPrincipalName).OverallProvisioningStatus

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 :)
Avatar of K B

ASKER

Thank you Vasil...

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  

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Vasil Michev (MVP)
Vasil Michev (MVP)
Flag of Bulgaria image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of K B

ASKER

Vasil you rock!