24 February 2021

Search and install packages from powershellgallery

use this command to modify TLS settings if you get an error running the below commands
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12

search for all available package providers
Find-PackageProvider

search for a specific package provider
Find-PackageProvider -name nuget

install a package provider
Install-PackageProvider -Name nuget


after you have a package provider setup you can search for packages

search for a specific package. it supports wildcard in name
Find-Package -Name *AzureAD*

install package
Install-Package -Name AzureAD


Change domain for microsoft 365 / azure users from powershell

modify TLS settings if you get errors running commands below
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12


Install-Module -Name MSOnline
(from https://www.powershellgallery.com )

 

Connect-MsolService

$AllMsolUsers = Get-MsolUser -All
$AllToModify = $AllMsolUsers | Where-Object -FilterScript { ($PSItem.Licenses.AccountSkuId -eq 'o365:STANDARDPACK') -and ($PSItem.UserType -eq 'Member') -and $PSItem.IsLicensed}

foreach($User in $AllToModify){

    if($User.UserPrincipalName.Contains('@o365.onmicrosoft.com')){

        $NewPrincipal = $User.UserPrincipalName.Replace('@o365.onmicrosoft.com','@domain.com')

        Set-MsolUserPrincipalName -NewUserPrincipalName $NewPrincipal -UserPrincipalName $User.UserPrincipalName

    }

}


23 February 2021

21 February 2021

Create hashtable from PSObject

$GroupDataObjectHash = [ordered]@{}

$GroupDataObject.PSObject.Properties.Name | %{$GroupDataObjectHash.Add($PSItem, $GroupDataObject.$PSItem)}