Hi
Just starting to trial Adaxes and so far so good. Haven't quite grasped the PowerShell v ADSI features and was hoping someone could assist with my PS script.
Basically I am creating a scheduled task to send out a monthly report of our Office 365 subscriptions, I have the code for tyhis to work and know how to email this out via PS but was wondering if there is a cleanber way of doing with Adaxes.
Script:
{
$objectId = [Guid]$Context.TargetObject.Get("adm-O365ObjectId")
}
$scriptBlock = {
param($credential)
Import-Module MSOnline
Connect-MsolService -Credential $credential
Get-MSOLUser -All | Where-Object {$_.licenses[0].AccountSku.SkuPartNumber -ne “STANDARDWOFFPACK” -and $_.IsLicensed -eq $True} | select displayname,userprincipalname,Department,Office | Export-Csv C:\TEMP\O365_E3_License_Report.csv
}
# Get credentials for the tenant where the user's Office 365 account is hosted
$o365Credential = $Context.GetOffice365Credential()
# Start Windows PowerShell as a separate process and run the script block in that process
$job = Start-Job -ScriptBlock $scriptBlock -ArgumentList $o365Credential
$job | Wait-Job -Timeout 540
if ($job -eq $NULL)
{
return
}
I could add some PS code to email out the report but that would make the script quite long, just wondering if I can somehow use the Adaxes ADSI to make it better.
Thanks