Skip to content

Instantly share code, notes, and snippets.

View mczerniawski's full-sized avatar

mczerniawski mczerniawski

View GitHub Profile
ProductName;LicensePartNumber;LicenseSKUID
APP CONNECT IW;SPZA_IW;8f0c5670-4e56-4892-b06d-91c085d7004f
Microsoft 365 Audio Conferencing;MCOMEETADV;0c266dff-15dd-4b49-8397-2bb16070ed52
AZURE ACTIVE DIRECTORY BASIC;AAD_BASIC;2b9c8e7c-319c-43a2-a2a0-48c5c6161de7
AZURE ACTIVE DIRECTORY PREMIUM P1;AAD_PREMIUM;078d2b04-f1bd-4111-bbd4-b4b1b354cef4
AZURE ACTIVE DIRECTORY PREMIUM P2;AAD_PREMIUM_P2;84a661c4-e949-4bd2-a560-ed7766fcaf2b
AZURE INFORMATION PROTECTION PLAN 1;RIGHTSMANAGEMENT;c52ea49f-fe5d-4e95-93ba-1de91d380f89
DYNAMICS 365 CUSTOMER ENGAGEMENT PLAN ENTERPRISE EDITION;DYN365_ENTERPRISE_PLAN1;ea126fc5-a19e-42e2-a731-da9d437bffcf
DYNAMICS 365 FOR CUSTOMER SERVICE ENTERPRISE EDITION;DYN365_ENTERPRISE_CUSTOMER_SERVICE;749742bf-0d37-4158-a120-33567104deeb
DYNAMICS 365 FOR FINANCIALS BUSINESS EDITION;DYN365_FINANCIALS_BUSINESS_SKU;cc13a803-544e-4464-b4e4-6d6169a138fa
$UsersToClean = Get-Content -Path 'c:\AdminTools\disabled_onlinemembership.json ' -RAW | ConvertFrom-Json
#Remove from groups
foreach ($onlineUser in $UsersToClean) {
Write-Host "Processing user {$($onlineUser.DisplayName)}"
foreach ($group in $onlineUser.AADGroupID) {
Write-Host " Processing group {$($group)}"
Remove-AzureADGroupMember -ObjectId $group -MemberId $onlineUser.AADUserObjectID
}
}
$disks=Get-PhysicalDisk | where {$_.operationalstatus -eq 'Transient Error'}
#Set disks to retired state
$disks | Select-Object UniqueId | ForEach-Object {
Set-PhysicalDisk -UniqueId $PSItem.UniqueId -Usage Retired
}
#remove disks from pool
$disks | ForEach-Object {
Remove-PhysicalDisk -PhysicalDisks $PSItem -StoragePoolFriendlyName 'S2D on HVCL0' -Confirm:$false
function Set-ClusterVMAntiAffinity {
<#
.SYNOPSIS
Will configure Preferred Owners for Virtual Machine running on Failover Cluster
.DESCRIPTION
Uses Invoke-Command to allow for PSCredential
If Preferred Owner is provided will verify if it matches cluster Owner Nodes.
If yes - will set Preferred Owners for given VMs.
If no - will abort.
Function Get-PrivilegedGroupChanges {
<#
.SYNOPSIS
Will check for changes in Privileged Groups using Replication Metadata
.DESCRIPTION
Will return all members of Groups with 'AdminCount=1' that changed within last $Hours. Can target other domains - require ComputerName and Credential parameter then.
.PARAMETER ComputerName
Domain Controller of another domain. Provide FQDN name
#Get Credentials to O365 tenant
$credential = Get-Credential
Connect-AzureAD -Credential $credential
$disabled_OnlineMembership = foreach ($user in $disabledUsers) {
if ($user.UserPrincipalName) {
$userObjectId = Get-Msoluser -UserPrincipalName $user.UserPrincipalName | Select-Object -ExpandProperty ObjectId
$group = Get-AzureADUserMembership -ObjectId $userObjectId | Select-Object * | Where-Object {-not ($_.DirSyncEnabled)}
if ($group) {
[pscustomobject]@{
UserName = $user.SamAccountName
@mczerniawski
mczerniawski / Get-VMInventory.ps1
Created August 9, 2019 21:20
Get-VMInventory
function Get-VMInventory {
<#
.SYNOPSIS
Retrieves detailed information about VMs from Hyper-V host or cluster
.DESCRIPTION
Retrieves information about a VM, it's disk, path, current resources and network properties.
Will query Hyper-V host or all nodes in a cluster if [$Cluster] is provided. Accepts [$Credential] parameter.
.PARAMETER ComputerName
function Get-StorageJobReport {
<#
.SYNOPSIS
Get current storage jobs on cluster. Returns additional information from Get-VirtualDisk.
.DESCRIPTION
If there are storageJobs running on the cluster will match each job to virtual disk and return custom object.
.PARAMETER Cluster
Hyper-V cluster name.
function Get-ClusterCSVUsage {
<#
.SYNOPSIS
Retrieves CSV detailed information from Cluster
.DESCRIPTION
Will connect to cluster using Invoke-Command (to allow use of optional Credential Parameter) and retrieve detailed information on any CSV found
.PARAMETER Cluster
Cluster Name or array of Cluster Names
function Get-ClusterNodeMemory {
<#
.Synopsis
Get the available memory of each node in a cluster.
.DESCRIPTION
Get the available memory of each node in a cluster particularly for Hyper-V.
.PARAMETER Cluster
Provide Cluster Name. Will accept an array of cluter names