With the update to Windows 11 24H2, wmic is going away.
In many versions of Windows it has been possible to get the Windows serial number saved in the BIOS using the command:wmic bios get serialnumber
This can also be done with PowerShell:get-ciminstance win32_bios | select SerialNumber
So you can still get the bios key out of the bios from the command line.
Tag Archives: Powershell
Export List of Office 365 Licenses by Type
It’s possible to to use Powershell to export lists of users who are allocated different licences in Office 365. This guide will help you export a csv file that contains a list of the users who have a specific license type.
Part 1 – Connecting to Office 365 with Powershell
- First open a powershell console enter the following:
$UserCredential = Get-Credential
- You will be prompted for your Office 365 username and password
- Now we must establish a conenction using the stored credentials:
Connect-MsolService -Credential $UserCredential
- Now that you are connected to Office 365’s powershell interface you can now issue commands to Office 365.
Part 2 – Listing Licences in your account
Enter the command:
Get-MsolAccountSku
This will display a list of licences and the number of each you own and are utilised.
AccountSkuiD: <instancename>:<licencename>
ActiveUnits: The number of licences available based on your subscription
WarningUnits: Licenses in warning state
ComsumedUnits: Licenses in use and assigned to users.
Part 3 – Exporting the Data for a specific Licenes Type
Enter the following command, this will export a list of users with Power BI Standard license assigned to them. Remember to change <instancename> to match the instance name displayed in your output from part 2.
get-MSOLUser -All | where {$_.isLicensed -eq "TRUE" -and $_.Licenses.AccountSKUID -eq "<instancename>:POWER_BI_STANDARD"} | select displayname,userprincipalname,isLicensed | export-CSV c:\crmstandardusers.csv
You will now have a CSV file containing a list of the users with the specified license. You can perform this with any licenses listed from the Get-MsolAccountSku command.
Get the Number of Mailboxes in Office 365
The following is a quick guide on how to get a count of the number of mailboxes in Office 365 for user mailboxes, room mailboxes and shared mailboxes.
Open an administrator powershell
$UserCredential = Get-Credential
The above command should trigger a prompt for a username and password, enter the details of an Office 365 administrator.
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/-Credential $UserCredential -Authentication Basic -AllowRedirection
Import-PSSession $Session
Now use one of the following commands in powershell:
Retrieve number of user mailboxes:
(Get-Recipient -RecipientTypeDetails usermailbox -ResultSize Unlimited).count
Retrieve number of shared mailboxes:
(Get-Recipient -RecipientTypeDetails sharedmailbox -ResultSize Unlimited).count
Retrieve number of room mailboxes:
(Get-Recipient -RecipientTypeDetails roommailbox -ResultSize Unlimited).count