Created
November 27, 2023 18:03
-
-
Save andy-schneider/f8b40c633ca8f24b9b80a05c1ae39e3b to your computer and use it in GitHub Desktop.
Github Copilot Practical 365
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Original code using MSOL | |
Connect-MSOlService | |
$licenses = Get-MSOlAccountSku | |
foreach($license in $licenses) | |
{ | |
if($license.AccountSkuId -eq "andylanddev:SPE_E3") | |
{ | |
$spe3Active = $license.ActiveUnits | |
$spe3Warning = $license.WarningUnits | |
$spe3Consumed = $license.ConsumedUnits | |
} | |
if($license.AccountSkuId -eq "andylanddev:SPE_E5") | |
{ | |
$spe5Active = $license.ActiveUnits | |
$spe5Warning = $license.WarningUnits | |
$spe5Consumed = $license.ConsumedUnits | |
} | |
} | |
$spe3Warning | |
$spe3Active | |
$spe3Consumed | |
$spe5Warning | |
$spe5Active | |
$spe5Consumed | |
# New code with the help of Github Copilot | |
$scopes = "Organization.Read.All" | |
# Connect to the Graph service | |
Connect-MgGraph -Scopes $scopes -NoWelcome | |
# Get the licenses | |
$licenses = Get-MgSubscribedSku | |
foreach($license in $licenses) | |
{ | |
if($license.SkuPartNumber -eq "SPE_E3") | |
{ | |
$spe3Active = $license.PrepaidUnits.Enabled | |
$spe3Warning = $license.PrepaidUnits.Warning | |
$spe3Consumed = $license.ConsumedUnits | |
} | |
if($license.SkuPartNumber -eq "SPE_E5") | |
{ | |
$spe5Active = $license.PrepaidUnits.Enabled | |
$spe5Warning = $license.PrepaidUnits.Warning | |
$spe5Consumed = $license.ConsumedUnits | |
} | |
} | |
$spe3Warning | |
$spe3Active | |
$spe3Consumed | |
$spe5Warning | |
$spe5Active | |
$spe5Consumed |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment