This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [ValidateScript({ | |
| $requiredProperties=@("Property1","Property2","Property3", "Property4") | |
| $members=Get-Member -InputObject $_ -MemberType NoteProperty | |
| $missingProperties=Compare-Object -ReferenceObject $requiredProperties -DifferenceObject $members.Name -PassThru -ErrorAction SilentlyContinue | |
| if (-not($missingProperties)){ | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function New-Example{ | |
| [CmdletBinding()] | |
| Param( | |
| [Parameter( | |
| Mandatory=$true, | |
| Position=0)] | |
| [ValidateScript({ | |
| $requiredProperties=@("Property1","Property2","Property3", "Property4") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #requires -Modules AzureAD | |
| $UsageLocation = Get-AutomationVariable -Name "UsageLocation" -ErrorAction Stop | |
| $servicePrincipalConnection = Get-AutomationConnection -Name "AzureRunAsConnection" -ErrorAction Stop | |
| Connect-AzureAD -TenantId $servicePrincipalConnection.TenantId -ApplicationId $servicePrincipalConnection.ApplicationId ` | |
| -CertificateThumbprint $servicePrincipalConnection.CertificateThumbprint | |
| Get-AzureADUser | Where-Object{$_.UsageLocation -ne $UsageLocation} | ForEach-Object { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Import-Module "$env:ProgramFiles\Microsoft Azure Active Directory Connect\AzureADSSO.psd1" | |
| New-AzureADSSOAuthenticationContext | |
| $creds = Get-Credential | |
| Update-AzureADSSOForest -OnPremCredentials $creds |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Get-WinEvent -LogName "Microsoft-Windows-Windows Defender/Operational" | where {$_.ID -eq 1000} | Export-Csv "c:\mphistory.csv" -NoTypeInformation |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| servicePrincipalConnection = Get-AutomationConnection -Name "AzureRunAsConnection" -ErrorAction Stop | |
| Update-MSGraphEnvironment -AuthUrl "https://login.microsoftonline.com/$($servicePrincipalConnection.TenantId)" -AppId $servicePrincipalConnection.ApplicationId | |
| Connect-MSGraph -CertificateThumbprint $servicePrincipalConnection.CertificateThumbprint -Quiet | |
| Get-DeviceManagement_ManagedDevices |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $licenseAssignmentErrors = Get-MsolGroup -HasLicenseErrorsOnly $true | % { | |
| $groupId = $_.ObjectId | |
| Get-MsolGroupMember -All -GroupObjectId $groupId | | |
| Get-MsolUser -ObjectId {$_.ObjectId} | | |
| Where {$_.IndirectLicenseErrors -and $_.IndirectLicenseErrors.ReferencedObjectId -eq $groupId} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Disable Office 365 Self-Servicing Purchases | |
| # src: https://docs.microsoft.com/en-us/microsoft-365/commerce/subscriptions/allowselfservicepurchase-powershell?view=o365-worldwide | |
| # Install abd connect MSCommerce services with PowerShell | |
| Install-Module -Name MSCommerce -Scope CurrentUser | |
| Connect-MSCommerce | |
| Get-MSCommerceProductPolicies -PolicyId AllowSelfServicePurchase | |
| # Disable Self-Servicing for all products |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $displayName = "Microsoft Graph PowerShell Client Credentials" | |
| $notAfter = $(Get-Date).AddYears(1) | |
| $cert = New-SelfSignedCertificate -CertStoreLocation cert:\currentuser\my -DnsName graph.microsoft.com -Provider "Microsoft Enhanced RSA and AES Cryptographic Provider" -NotAfter $notAfter -FriendlyName $displayName | |
| $export = Export-Certificate -Cert "cert:\currentuser\my\$($cert.Thumbprint)" -FilePath "c:\temp\$displayName.cer" | |
| Write-Output "Exported certificate '$($cert.Thumbprint)' to '$($export.FullName)'" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Start-MpScan -ScanType QuickScan |
OlderNewer