This file contains 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
# See Microsoft 365 Apps Version history https://learn.microsoft.com/en-us/officeupdates/update-history-microsoft365-apps-by-date#version-history | |
$targetVersions = @{ | |
'CurrentChannel' = [System.Version]::Parse('16.0.16130.20306') | |
'MonthlyEnterpriseChannel1' = [System.Version]::Parse('16.0.16026.20238') | |
'MonthlyEnterpriseChannel2' = [System.Version]::Parse('16.0.15928.20298') | |
'Semi-AnnualEnterpriseChannel(Preview)' = [System.Version]::Parse('16.0.16130.20306') | |
'Semi-AnnualEnterpriseChannel1' = [System.Version]::Parse('16.0.15601.20578') | |
'Semi-AnnualEnterpriseChannel2' = [System.Version]::Parse('16.0.14931.20944') | |
'CurrentChannel(Preview)' = [System.Version]::Parse('16.0.16227.20094') |
This file contains 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
name: Sign PowerShell Scripts | |
on: | |
push | |
env: | |
ARTIFACT_NAME: PowerShell.Workflows.ScriptSigning | |
jobs: | |
sign_scripts: | |
name: Sign and publish PowerShell scripts as pipeline artifacts |
This file contains 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-Service LxssManager | Restart-Service |
This file contains 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
#Binary search algorithm with O(logn) complexity written in PowerShell | |
function Invoke-BinarySearch { | |
[CmdletBinding()] | |
[OutputType([int])] | |
param ( | |
# Array which contains value to search, needs to be sorted | |
[Parameter(Mandatory)] | |
[int[]] | |
$Numbers, |
This file contains 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 |
This file contains 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
# Configure remediation threshold, e.g. 1 day | |
# Diduct this value from current datetime | |
$thresholdDateTime = (Get-Date).AddDays(-1) | |
# Get defender eventlog entries which indicate successful scan | |
$mostRecentScan = Get-WinEvent -LogName "Microsoft-Windows-Windows Defender/Operational" | Where-Object { $_.ID -in @(1001) } | Select-Object -First 1 | |
if ($mostRecentScan.TimeCreated -lt $thresholdDateTime) { | |
Write-Warning "No Microsoft Defender Antivirus scan has been completed sine `"$thresholdDateTime`"" | |
Exit 1 |
This file contains 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 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 Test-Guid | |
{ | |
<# | |
.SYNOPSIS | |
Validates a given input string and checks string is a valid GUID | |
.DESCRIPTION | |
Validates a given input string and checks string is a valid GUID by using the .NET method Guid.TryParse | |
.EXAMPLE | |
Test-Guid -InputObject "3363e9e1-00d8-45a1-9c0c-b93ee03f8c13" | |
.NOTES |
This file contains 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
# Check Azure AD Access token | |
if ($null -eq [Microsoft.Open.Azure.AD.CommonLibrary.AzureSession]::AccessTokens){ | |
Connect-AzureAD | |
} else { | |
$token = [Microsoft.Open.Azure.AD.CommonLibrary.AzureSession]::AccessTokens | |
Write-Verbose "Connected to tenant: $($token.AccessToken.TenantId) with user: $($token.AccessToken.UserId)" | |
} |
This file contains 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 |
NewerOlder