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
| using namespace System.Management.Automation | |
| using namespace System.Collections.Generic | |
| using namespace System.Collections.Concurrent | |
| $baseUri = 'https://www.powershellgallery.com/api/v2/Packages?$orderby=Published desc&$skip=' | |
| $maxPackages = 700000 | |
| $interval = 100 | |
| $statusDictionary = [ConcurrentDictionary[string, bool]]::new() | |
| $existingpackagesjson = (iwr 'https://pwsh.gallery/sleet.packageindex.json').content -replace 'PSObject','__MODULEFASTIGNOREME' | convertfrom-json |% packages |
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
| using namespace System.Diagnostics.Eventing.Reader | |
| [CmdletBinding(DefaultParameterSetName = 'ByCount')] | |
| param( | |
| #A list of domain controllers to query. Leave blank if running directly on a domain controller. | |
| [string[]]$ComputerName, | |
| #Maximum amount of events to retrieve. This is set to 1000 for a quick initial fetch. Note this is max events *investigated* and not max events returned. | |
| [Parameter(ParameterSetName = 'ByCount')] | |
| [int]$MaxEvents = 1000, |
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
| [CmdletBinding(DefaultParameterSetName = 'ByCount')] | |
| param( | |
| #A list of domain controllers to query. Leave blank if running directly on a domain controller. | |
| [string[]]$ComputerName, | |
| #Maximum amount of events to retrieve. This is set to 1000 for a quick initial fetch. Note this is max events *investigated* and not max events returned. | |
| [Parameter(ParameterSetName = 'ByCount')] | |
| [int]$MaxEvents = 1000, | |
| #How long back to search for events. Overrides MaxEvents if specified. |
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
| param( | |
| [Parameter(Mandatory = $true)] | |
| [string[]]$ExchangeServers, | |
| [Parameter(Mandatory = $true)] | |
| [PSCredential]$Credential, | |
| [Parameter(Mandatory = $false)] | |
| [datetime]$StartTime = (Get-Date).AddDays(-1), |
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
| // The complete data we need gets split over multiple logs, so we have to recombine them. Export to CSV afterwards. | |
| AuditLogs | |
| | where OperationName == "Update policy" | |
| | where isnotempty(CorrelationId) and isnotempty(AdditionalDetails) | |
| | project TimeGenerated, CorrelationId, Identity, AdditionalDetails | |
| | mv-apply d = AdditionalDetails on ( | |
| summarize | |
| seq = tolong(take_anyif(tostring(d.value), tostring(coalesce(d.key, d.name)) == "seq")), | |
| b = take_anyif(tostring(d.value), tostring(coalesce(d.key, d.name)) == "b") |
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
| #You will have to screen-scrape your bearer token and account GUID from the DevTools | |
| $script:BaseUri = 'https://api.partnerbenefits.microsoft.com' | |
| function Connect-PartnerBenefit { | |
| [CmdletBinding()] | |
| param ( | |
| [Parameter(Mandatory)] | |
| [securestring]$ApiKey, | |
| #Will connect to partner global account by default, specify this to choose a different account | |
| [string]$AccountId | |
| ) |
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
| #This function gathers the login context from the .NET type and shows how you can pass that into Foreach -Parallel in order to run in parallel without using an AppID/Secret | |
| #You must be connected to Exchange Online PowerShell | |
| <# | |
| .SYNOPSIS | |
| Prepares the environment to use EXO cmdlets in parallel | |
| #> |
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
| #region ProfileBenchmark | |
| if ($ENV:PWSH_PROFILE_BENCHMARK -and -not $ENV:PWSH_PROFILE_BENCHMARK_RUN) { | |
| Write-Host -Fore Magenta '👷♂️ BENCHMARKING PROFILE SETUP' | |
| Invoke-WebRequest bit.ly/modulefast | Invoke-Expression | |
| Install-ModuleFast profiler | |
| # This will ensure we don't end up in a setup loop | |
| Write-Host -Fore Magenta '📈 BENCHMARKING PROFILE' | |
| $profilePath = $MyInvocation.MyCommand.Source | |
| $profileTrace = Trace-Script -ExportPath TEMP:/pwsh-profile -ScriptBlock { |
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
| Describe "Debugging Examples" { | |
| It 'Labs get Treats' { | |
| $recommendedTreat = & $PSScriptRoot/Get-DogTreat.ps1 -DogBreed 'Labrador' -SuperBugged | |
| $recommendedTreat.Calories | Should -BeGreaterThan 0 | |
| } | |
| } |
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 Get-InstalledModuleFast { | |
| param( | |
| #Modules to filter for. Wildcards are supported. | |
| [string]$Name, | |
| #Path(s) to search for modules. Defaults to your PSModulePath paths | |
| [string[]]$ModulePath = ($env:PSModulePath -split [System.IO.Path]::PathSeparator), | |
| #Return all installed modules and not just the latest versions | |
| [switch]$All | |
| ) |
NewerOlder