In this post I'll collect all my base powershell functions and snippets.
function InstallPSModuleAndCheckForUpdates()
Write host "Checking installed PSS Modules"
If not exists, the base azure PSS will be installed and imported
if (-not (Get-Module-Name AZ))
{
Install Modules Name Az -AllowClobber -Scope CurrentUser
• else
{
update modules -Name Az
}
Import Module Name Az
For KeyVault integration, the ManagedServiceIdentity PSS modules must be installed
if (-not (Get-Module-Name "Az.ManagedServiceIdentity"))
{
Install Modules Name Az.ManagedServiceIdentity -AllowClobber -Scope CurrentUser
"Else"
{
update Modules Name Az.ManagedServiceIdentity
}
Import Modules Name Az.ManagedServiceIdentity
For Azure AD (B2C) PSS modules must be installed
if (-not (get module name "azuread"))
{
Install Modules -Name azuread -AllowClobber -Scope CurrentUser
"Else"
{
update module name azuread
}
Import module name azuread
• #end Install PS Module or check for update