Find locked-out accounts Active Directory Lists every user account that is currently locked.
Copy
Search-ADAccount -LockedOut -UsersOnly |
Select-Object Name, SamAccountName, LastLogonDate, LockedOut
Unlock a user account Active Directory makes changes Clears the lockout on one account.
Copy
Unlock-ADAccount -Identity jdoe
Find which computer is locking an account Active Directory Reads lockout events (4740) from the PDC emulator to show the source computer.
Copy
$pdc = (Get-ADDomain).PDCEmulator
Get-WinEvent -ComputerName $pdc -FilterHashtable @{ LogName = 'Security'; Id = 4740 } -MaxEvents 50 |
Select-Object TimeCreated,
@{ n = 'User'; e = { $_.Properties[0].Value } },
@{ n = 'CallerComputer'; e = { $_.Properties[1].Value } }
Reset a password and force a change at next logon Active Directory makes changes Prompts for the new password so it never lands in your history.
Copy
$new = Read-Host -AsSecureString 'New password'
Set-ADAccountPassword -Identity jdoe -Reset -NewPassword $new
Set-ADUser -Identity jdoe -ChangePasswordAtLogon $true
Users who have not logged on in 90 days Active Directory Enabled accounts with no logon in the period. lastLogonTimestamp can lag by up to 14 days.
Copy
Search-ADAccount -AccountInactive -TimeSpan 90.00:00:00 -UsersOnly |
Where-Object Enabled |
Select-Object Name, SamAccountName, LastLogonDate |
Sort-Object LastLogonDate
Computers that have not checked in for 90 days Active Directory Stale computer objects that are candidates for disabling.
Copy
Search-ADAccount -AccountInactive -TimeSpan 90.00:00:00 -ComputersOnly |
Select-Object Name, LastLogonDate, DistinguishedName |
Sort-Object LastLogonDate
Accounts whose password never expires Active Directory Enabled users with the Password never expires flag set.
Copy
Get-ADUser -Filter 'PasswordNeverExpires -eq $true -and Enabled -eq $true' -Properties PasswordLastSet |
Select-Object Name, SamAccountName, PasswordLastSet
Passwords expiring in the next 14 days Active Directory Uses the computed expiry attribute, so fine-grained password policies are respected.
Copy
$limit = (Get-Date).AddDays(14)
Get-ADUser -Filter 'Enabled -eq $true -and PasswordNeverExpires -eq $false' -Properties 'msDS-UserPasswordExpiryTimeComputed', EmailAddress |
Select-Object Name, SamAccountName, EmailAddress,
@{ n = 'Expires'; e = { [datetime]::FromFileTime($_.'msDS-UserPasswordExpiryTimeComputed') } } |
Where-Object { $_.Expires -gt (Get-Date) -and $_.Expires -lt $limit } |
Sort-Object Expires
List members of a group, including nested groups Active Directory Flattens nested membership into a single list.
Copy
Get-ADGroupMember -Identity 'Domain Admins' -Recursive |
Select-Object Name, SamAccountName, objectClass
List the groups a user belongs to Active Directory Direct group memberships for one user.
Copy
Get-ADPrincipalGroupMembership -Identity jdoe |
Sort-Object Name |
Select-Object Name, GroupScope, GroupCategory
Copy group memberships from one user to another Active Directory makes changes Adds the target user to every group the source user is in.
Copy
Get-ADPrincipalGroupMembership -Identity source.user |
Where-Object Name -ne 'Domain Users' |
ForEach-Object { Add-ADGroupMember -Identity $_ -Members target.user }
Disable a leaver and move the account Active Directory makes changes Disables the account, stamps the description and moves it to a holding OU.
Copy
$user = Get-ADUser -Identity jdoe
Disable-ADAccount -Identity $user
Set-ADUser -Identity $user -Description "Disabled $(Get-Date -Format yyyy-MM-dd)"
Move-ADObject -Identity $user -TargetPath 'OU=Disabled Users,DC=contoso,DC=com'
Export all users to CSV Active Directory A quick inventory of users with the attributes most audits ask for.
Copy
Get-ADUser -Filter * -Properties DisplayName, EmailAddress, Department, Title, LastLogonDate, whenCreated |
Select-Object DisplayName, SamAccountName, EmailAddress, Department, Title, Enabled, LastLogonDate, whenCreated |
Export-Csv -Path .\ad-users.csv -NoTypeInformation -Encoding UTF8
Create users in bulk from a CSV Active Directory makes changes Expects columns First, Last, Sam, Upn and OU. Each user gets the same temporary password and must change it.
Copy
$temp = Read-Host -AsSecureString 'Temporary password'
Import-Csv .\new-users.csv | ForEach-Object {
New-ADUser -Name "$($_.First) $($_.Last)" -GivenName $_.First -Surname $_.Last `
-SamAccountName $_.Sam -UserPrincipalName $_.Upn -Path $_.OU `
-AccountPassword $temp -ChangePasswordAtLogon $true -Enabled $true
}
Show the FSMO role holders Active Directory Which domain controllers hold the five operations master roles.
Copy
Get-ADDomain | Select-Object PDCEmulator, RIDMaster, InfrastructureMaster
Get-ADForest | Select-Object SchemaMaster, DomainNamingMaster
Check replication health across the forest Active Directory Last successful replication and failure counts for every partner.
Copy
Get-ADReplicationPartnerMetadata -Target * -Scope Forest |
Select-Object Server, Partner, LastReplicationSuccess, LastReplicationResult, ConsecutiveReplicationFailures |
Sort-Object ConsecutiveReplicationFailures -Descending
# Classic one-line summary
repadmin /replsummary
Count computers by operating system Active Directory A quick view of which Windows versions are still in the domain.
Copy
Get-ADComputer -Filter 'Enabled -eq $true' -Properties OperatingSystem |
Group-Object OperatingSystem |
Sort-Object Count -Descending |
Select-Object Count, Name
Users created in the last 7 days Active Directory Useful for reviewing recent account creation.
Copy
$since = (Get-Date).AddDays(-7)
Get-ADUser -Filter 'whenCreated -ge $since' -Properties whenCreated |
Select-Object Name, SamAccountName, whenCreated |
Sort-Object whenCreated
Find empty groups Active Directory Groups with no members, which are often left over from old projects.
Copy
Get-ADGroup -Filter * -Properties Members |
Where-Object { -not $_.Members } |
Select-Object Name, GroupScope, DistinguishedName
Restore a deleted object from the Recycle Bin Active Directory makes changes Requires the AD Recycle Bin feature to have been enabled before the deletion.
Copy
Get-ADObject -Filter 'isDeleted -eq $true -and Name -like "*jdoe*"' -IncludeDeletedObjects |
Restore-ADObject
Repair a broken trust relationship Active Directory makes changes Run on the affected computer as a local administrator to reset its machine account password without rejoining the domain.
Copy
Test-ComputerSecureChannel -Verbose
Test-ComputerSecureChannel -Repair -Credential (Get-Credential)
Read a Windows LAPS password Active Directory Returns the managed local administrator password for a computer (Windows LAPS).
Copy
Get-LapsADPassword -Identity PC-0142 -AsPlainText
Connect to Microsoft Graph Entra ID Sign in with the scopes the read-only snippets below need. Add write scopes only when you need them.
Copy
Connect-MgGraph -Scopes 'User.Read.All', 'Group.Read.All', 'Directory.Read.All', 'AuditLog.Read.All'
Get-MgContext | Select-Object Account, TenantId, Scopes
List licensed users Entra ID Every user that has at least one licence assigned.
Copy
Get-MgUser -All -Property DisplayName, UserPrincipalName, AssignedLicenses, AccountEnabled |
Where-Object { $_.AssignedLicenses.Count -gt 0 } |
Select-Object DisplayName, UserPrincipalName, AccountEnabled
Licence usage by SKU Entra ID Purchased versus assigned counts for each subscription.
Copy
Get-MgSubscribedSku |
Select-Object SkuPartNumber, ConsumedUnits,
@{ n = 'Purchased'; e = { $_.PrepaidUnits.Enabled } },
@{ n = 'Free'; e = { $_.PrepaidUnits.Enabled - $_.ConsumedUnits } }
Assign a licence to a user Entra ID makes changes The user needs a usage location first. Needs the User.ReadWrite.All scope.
Copy
$upn = 'user@contoso.com'
$sku = Get-MgSubscribedSku | Where-Object SkuPartNumber -eq 'SPE_E3'
Update-MgUser -UserId $upn -UsageLocation 'US'
Set-MgUserLicense -UserId $upn -AddLicenses @{ SkuId = $sku.SkuId } -RemoveLicenses @()
List guest users Entra ID External (B2B) accounts and when they were created.
Copy
Get-MgUser -All -Filter "userType eq 'Guest'" -Property DisplayName, Mail, CreatedDateTime, AccountEnabled |
Select-Object DisplayName, Mail, CreatedDateTime, AccountEnabled |
Sort-Object CreatedDateTime
Last sign-in for every user Entra ID Needs AuditLog.Read.All and an Entra ID P1 or P2 licence in the tenant.
Copy
Get-MgUser -All -Property DisplayName, UserPrincipalName, SignInActivity, AccountEnabled |
Select-Object DisplayName, UserPrincipalName, AccountEnabled,
@{ n = 'LastSignIn'; e = { $_.SignInActivity.LastSignInDateTime } } |
Sort-Object LastSignIn
Block sign-in and revoke sessions Entra ID makes changes First response for a compromised account or a leaver. Needs User.ReadWrite.All.
Copy
$upn = 'user@contoso.com'
Update-MgUser -UserId $upn -AccountEnabled:$false
Revoke-MgUserSignInSession -UserId $upn
Reset a user's password Entra ID makes changes Sets a temporary password that must be changed at next sign-in.
Copy
$params = @{
passwordProfile = @{
password = Read-Host 'Temporary password'
forceChangePasswordNextSignIn = $true
}
}
Update-MgUser -UserId 'user@contoso.com' -BodyParameter $params
List Global Administrators Entra ID Members of the Global Administrator role. Roles assigned through PIM as eligible are not included.
Copy
$role = Get-MgDirectoryRole -Filter "displayName eq 'Global Administrator'"
Get-MgDirectoryRoleMember -DirectoryRoleId $role.Id -All |
ForEach-Object { $_.AdditionalProperties.userPrincipalName }
MFA registration status for all users Entra ID Shows who has registered MFA and which methods. Needs AuditLog.Read.All.
Copy
Get-MgReportAuthenticationMethodUserRegistrationDetail -All |
Select-Object UserPrincipalName, IsMfaRegistered, IsMfaCapable, IsPasswordlessCapable,
@{ n = 'Methods'; e = { $_.MethodsRegistered -join ', ' } }
List members of a group Entra ID Looks the group up by name, then lists its members.
Copy
$group = Get-MgGroup -Filter "displayName eq 'Sales Team'"
Get-MgGroupMember -GroupId $group.Id -All |
ForEach-Object { $_.AdditionalProperties.userPrincipalName }
Add a user to a group Entra ID makes changes Needs GroupMember.ReadWrite.All.
Copy
$group = Get-MgGroup -Filter "displayName eq 'Sales Team'"
$user = Get-MgUser -UserId 'user@contoso.com'
New-MgGroupMember -GroupId $group.Id -DirectoryObjectId $user.Id
App registrations with secrets or certificates expiring soon Entra ID Finds credentials that expire within 30 days. Needs Application.Read.All.
Copy
$limit = (Get-Date).AddDays(30)
Get-MgApplication -All | ForEach-Object {
$app = $_
@($app.PasswordCredentials) + @($app.KeyCredentials) |
Where-Object { $_.EndDateTime -and $_.EndDateTime -lt $limit } |
Select-Object @{ n = 'App'; e = { $app.DisplayName } }, @{ n = 'AppId'; e = { $app.AppId } }, DisplayName, EndDateTime
} | Sort-Object EndDateTime
Restore a deleted user Entra ID makes changes Deleted users stay recoverable for 30 days.
Copy
Get-MgDirectoryDeletedItemAsUser -All | Select-Object Id, DisplayName, UserPrincipalName, DeletedDateTime
Restore-MgDirectoryDeletedItem -DirectoryObjectId '<Id from the list above>'
Devices that have not signed in for 90 days Entra ID Stale device objects. Needs Device.Read.All.
Copy
$limit = (Get-Date).AddDays(-90)
Get-MgDevice -All |
Where-Object { $_.ApproximateLastSignInDateTime -lt $limit } |
Select-Object DisplayName, OperatingSystem, ApproximateLastSignInDateTime, AccountEnabled |
Sort-Object ApproximateLastSignInDateTime
Recent failed sign-ins for a user Entra ID The last 20 failed attempts with the reason and source address. Needs AuditLog.Read.All.
Copy
Get-MgAuditLogSignIn -Filter "userPrincipalName eq 'user@contoso.com' and status/errorCode ne 0" -Top 20 |
Select-Object CreatedDateTime, AppDisplayName, IpAddress,
@{ n = 'Error'; e = { $_.Status.ErrorCode } },
@{ n = 'Reason'; e = { $_.Status.FailureReason } }
List Conditional Access policies Entra ID Every policy and whether it is on, off or report-only. Needs Policy.Read.All.
Copy
Get-MgIdentityConditionalAccessPolicy -All |
Select-Object DisplayName, State, CreatedDateTime, ModifiedDateTime |
Sort-Object DisplayName
Connect to Exchange Online Exchange Online Opens a modern-auth session. Disconnect when finished to free the session.
Copy
Connect-ExchangeOnline -UserPrincipalName admin@contoso.com
# ...
Disconnect-ExchangeOnline -Confirm:$false
Mailbox sizes, largest first Exchange Online Item count and size for every mailbox.
Copy
Get-EXOMailbox -ResultSize Unlimited |
Get-EXOMailboxStatistics |
Sort-Object TotalItemSize -Descending |
Select-Object DisplayName, ItemCount, TotalItemSize -First 50
Trace a message Exchange Online Searches the last 48 hours of mail flow for a sender and recipient.
Copy
Get-MessageTraceV2 -SenderAddress sender@example.com -RecipientAddress user@contoso.com `
-StartDate (Get-Date).AddDays(-2) -EndDate (Get-Date) |
Select-Object Received, SenderAddress, RecipientAddress, Subject, Status
Grant Full Access to a shared mailbox Exchange Online makes changes With automapping on, the mailbox appears in the user's Outlook by itself.
Copy
Add-MailboxPermission -Identity shared@contoso.com -User user@contoso.com -AccessRights FullAccess -AutoMapping $true
Grant Send As on a mailbox Exchange Online makes changes Lets a user send mail that appears to come from the mailbox.
Copy
Add-RecipientPermission -Identity shared@contoso.com -Trustee user@contoso.com -AccessRights SendAs -Confirm:$false
See who has access to a mailbox Exchange Online Full Access and Send As holders, without the built-in system entries.
Copy
Get-EXOMailboxPermission -Identity shared@contoso.com |
Where-Object { $_.User -notlike 'NT AUTHORITY*' } |
Select-Object User, AccessRights
Get-EXORecipientPermission -Identity shared@contoso.com |
Where-Object { $_.Trustee -notlike 'NT AUTHORITY*' } |
Select-Object Trustee, AccessRights
Convert a user mailbox to a shared mailbox Exchange Online makes changes Common when someone leaves. Shared mailboxes under 50 GB need no licence.
Copy
Set-Mailbox -Identity user@contoso.com -Type Shared
Find mailboxes that forward mail Exchange Online Mailbox-level forwarding is a common sign of a compromised account.
Copy
Get-EXOMailbox -ResultSize Unlimited -Properties ForwardingSmtpAddress, ForwardingAddress, DeliverToMailboxAndForward |
Where-Object { $_.ForwardingSmtpAddress -or $_.ForwardingAddress } |
Select-Object UserPrincipalName, ForwardingSmtpAddress, ForwardingAddress, DeliverToMailboxAndForward
Find inbox rules that forward or redirect Exchange Online Checks one mailbox for rules that send mail elsewhere.
Copy
Get-InboxRule -Mailbox user@contoso.com |
Where-Object { $_.ForwardTo -or $_.RedirectTo -or $_.ForwardAsAttachmentTo } |
Select-Object Name, Enabled, ForwardTo, RedirectTo, ForwardAsAttachmentTo
Set an out-of-office reply for someone Exchange Online makes changes Turns on automatic replies with separate internal and external messages.
Copy
Set-MailboxAutoReplyConfiguration -Identity user@contoso.com -AutoReplyState Enabled `
-InternalMessage 'I am out of the office until Monday.' `
-ExternalMessage 'I am out of the office until Monday. For urgent matters contact support@contoso.com.'
Give someone access to a calendar Exchange Online makes changes Editor can create and change items. Use Reviewer for read-only.
Copy
Add-MailboxFolderPermission -Identity 'user@contoso.com:\Calendar' -User delegate@contoso.com -AccessRights Editor
Add an email alias Exchange Online makes changes Adds a secondary address. Use uppercase SMTP: to make an address the primary one.
Copy
Set-Mailbox -Identity user@contoso.com -EmailAddresses @{ add = 'smtp:alias@contoso.com' }
Read and enable DKIM for a domain Exchange Online makes changes Shows the exact CNAME targets to publish, then turns signing on once they resolve.
Copy
Get-DkimSigningConfig -Identity contoso.com | Format-List Name, Enabled, Status, Selector1CNAME, Selector2CNAME
# After both CNAME records are live in DNS:
Set-DkimSigningConfig -Identity contoso.com -Enabled $true
List members of a distribution group Exchange Online Members with their primary addresses.
Copy
Get-DistributionGroupMember -Identity 'Sales' -ResultSize Unlimited |
Select-Object DisplayName, PrimarySmtpAddress, RecipientType
Enable an archive mailbox Exchange Online makes changes Turns on the online archive for one user.
Copy
Enable-Mailbox -Identity user@contoso.com -Archive
Put a mailbox on litigation hold Exchange Online makes changes Preserves all content, including deleted items. Needs an Exchange Online Plan 2 or equivalent licence.
Copy
Set-Mailbox -Identity user@contoso.com -LitigationHoldEnabled $true
Release quarantined messages for a recipient Exchange Online makes changes Lists what is held, then releases it to all original recipients.
Copy
Get-QuarantineMessage -RecipientAddress user@contoso.com |
Select-Object ReceivedTime, SenderAddress, Subject, Type
Get-QuarantineMessage -RecipientAddress user@contoso.com | Release-QuarantineMessage -ReleaseToAll
Block a sender for the whole tenant Exchange Online makes changes Adds an entry to the Tenant Allow/Block List.
Copy
New-TenantAllowBlockListItems -ListType Sender -Block -Entries 'bad.actor@example.com' -NoExpiration
List mail flow (transport) rules Exchange Online Every rule with its state and order.
Copy
Get-TransportRule | Select-Object Priority, Name, State, Mode | Sort-Object Priority
Mailboxes with no activity in 90 days Exchange Online Uses the last user action time, which is more reliable than last logon time.
Copy
$limit = (Get-Date).AddDays(-90)
Get-EXOMailbox -ResultSize Unlimited -RecipientTypeDetails UserMailbox |
Get-EXOMailboxStatistics -Properties LastUserActionTime |
Where-Object { $_.LastUserActionTime -lt $limit } |
Select-Object DisplayName, LastUserActionTime
Connect and choose a subscription Azure Sign in, list subscriptions and set the one later commands run against.
Copy
Connect-AzAccount
Get-AzSubscription | Select-Object Name, Id, State
Set-AzContext -Subscription 'Production'
List virtual machines with their power state Azure Every VM in the subscription and whether it is running or deallocated.
Copy
Get-AzVM -Status |
Select-Object Name, ResourceGroupName, Location, PowerState,
@{ n = 'Size'; e = { $_.HardwareProfile.VmSize } }
Stop (deallocate) and start a VM Azure makes changes Stop-AzVM deallocates by default, which stops compute charges.
Copy
Stop-AzVM -ResourceGroupName rg-app -Name vm-app01 -Force
Start-AzVM -ResourceGroupName rg-app -Name vm-app01
Resize a VM Azure makes changes The VM restarts. Check the size is available in the region first.
Copy
Get-AzVMSize -ResourceGroupName rg-app -VMName vm-app01 | Select-Object Name, NumberOfCores, MemoryInMB
$vm = Get-AzVM -ResourceGroupName rg-app -Name vm-app01
$vm.HardwareProfile.VmSize = 'Standard_D4s_v5'
Update-AzVM -ResourceGroupName rg-app -VM $vm
Run a command inside a VM Azure makes changes Runs through the VM agent, so no RDP or WinRM access is needed.
Copy
Invoke-AzVMRunCommand -ResourceGroupName rg-app -VMName vm-app01 `
-CommandId RunPowerShellScript -ScriptString 'Get-Service W3SVC | Select-Object Status, Name'
Snapshot a VM's OS disk Azure makes changes A point-in-time copy to take before risky changes.
Copy
$vm = Get-AzVM -ResourceGroupName rg-app -Name vm-app01
$cfg = New-AzSnapshotConfig -SourceUri $vm.StorageProfile.OsDisk.ManagedDisk.Id -Location $vm.Location -CreateOption Copy
New-AzSnapshot -ResourceGroupName rg-app -SnapshotName "vm-app01-os-$(Get-Date -Format yyyyMMdd-HHmm)" -Snapshot $cfg
Find unattached managed disks Azure Disks that are not attached to any VM still cost money.
Copy
Get-AzDisk |
Where-Object DiskState -eq 'Unattached' |
Select-Object Name, ResourceGroupName, DiskSizeGB, @{ n = 'Sku'; e = { $_.Sku.Name } }, TimeCreated
Find public IP addresses that are not in use Azure Unassociated public IPs, another common source of waste.
Copy
Get-AzPublicIpAddress |
Where-Object { -not $_.IpConfiguration } |
Select-Object Name, ResourceGroupName, IpAddress, @{ n = 'Sku'; e = { $_.Sku.Name } }
Find empty resource groups Azure Resource groups that contain nothing. Slow on large subscriptions.
Copy
Get-AzResourceGroup |
Where-Object { -not (Get-AzResource -ResourceGroupName $_.ResourceGroupName) } |
Select-Object ResourceGroupName, Location
List role assignments for a user Azure Every scope where the user has been granted a role, including inherited ones.
Copy
Get-AzRoleAssignment -SignInName user@contoso.com |
Select-Object RoleDefinitionName, Scope
Assign a role at resource group scope Azure makes changes Grants Reader on one resource group. Prefer groups over individual users.
Copy
New-AzRoleAssignment -SignInName user@contoso.com -RoleDefinitionName Reader -ResourceGroupName rg-app
List who has Owner on the subscription Azure A quick privileged-access review.
Copy
$sub = (Get-AzContext).Subscription.Id
Get-AzRoleAssignment -Scope "/subscriptions/$sub" -RoleDefinitionName Owner |
Select-Object DisplayName, SignInName, ObjectType
Show the rules of a network security group Azure Custom rules in priority order.
Copy
Get-AzNetworkSecurityGroup -ResourceGroupName rg-net -Name nsg-app |
Get-AzNetworkSecurityRuleConfig |
Sort-Object Direction, Priority |
Select-Object Priority, Name, Direction, Access, Protocol, SourceAddressPrefix, DestinationPortRange
Find NSG rules open to the internet Azure Inbound allow rules whose source is any address.
Copy
Get-AzNetworkSecurityGroup | ForEach-Object {
$nsg = $_
$nsg.SecurityRules |
Where-Object { $_.Direction -eq 'Inbound' -and $_.Access -eq 'Allow' -and
($_.SourceAddressPrefix | Where-Object { $_ -in '*', '0.0.0.0/0', 'Internet' }) } |
Select-Object @{ n = 'NSG'; e = { $nsg.Name } }, Name, Priority, DestinationPortRange
}
Find resources by tag Azure Everything carrying a given tag name and value.
Copy
Get-AzResource -Tag @{ Environment = 'Production' } |
Select-Object Name, ResourceType, ResourceGroupName, Location
See who changed what in a resource group Azure Activity log entries for the last 24 hours.
Copy
Get-AzActivityLog -ResourceGroupName rg-app -StartTime (Get-Date).AddDays(-1) |
Select-Object EventTimestamp, Caller, OperationName, Status, ResourceId |
Sort-Object EventTimestamp -Descending
Protect a resource group from deletion Azure makes changes A CanNotDelete lock blocks deletion until the lock is removed.
Copy
New-AzResourceLock -LockName DoNotDelete -LockLevel CanNotDelete -ResourceGroupName rg-prod -Force
Read a secret from Key Vault Azure Returns the value as plain text, so avoid running it in a shared or logged session.
Copy
Get-AzKeyVaultSecret -VaultName kv-contoso -Name SqlAdminPassword -AsPlainText
Upload a file to blob storage Azure makes changes Uses your Entra ID sign-in instead of an account key. Needs the Storage Blob Data Contributor role.
Copy
$ctx = New-AzStorageContext -StorageAccountName stcontosobackup -UseConnectedAccount
Set-AzStorageBlobContent -File .\backup.zip -Container backups -Blob "backup-$(Get-Date -Format yyyyMMdd).zip" -Context $ctx
List and add records in an Azure DNS zone Azure makes changes Shows every record set, then adds a TXT record.
Copy
Get-AzDnsRecordSet -ResourceGroupName rg-dns -ZoneName contoso.com |
Select-Object Name, RecordType, Ttl
New-AzDnsRecordSet -ResourceGroupName rg-dns -ZoneName contoso.com -Name '_dmarc' -RecordType TXT -Ttl 3600 `
-DnsRecords (New-AzDnsRecordConfig -Value 'v=DMARC1; p=none; rua=mailto:dmarc@contoso.com')