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
#Demonstrates listing an Active Directory group membership with PowerShell Core | |
using namespace Novell.Directory.LDAP.VQ | |
#region environment-specific config | |
$DCname = 'DomainControllerName' | |
# Don't store user credentials in your powerShell scripts!! | |
# This is just here to demonstrate POC. | |
$ldapUser = 'CN=powershell-ldap,CN=Users,DC=Corporate,DC=Contoso,DC=com' |
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 Get-HelpscoutToken | |
{ | |
#Fetches a cached bearer token for Helpscout authentication 2.0, refreshing it if necessary | |
#returns the token as plaintext for easy integration into invoke-restmethod | |
[CmdletBinding()] | |
Param( | |
[Parameter(Mandatory=$True)] | |
[string]$helpscout_token_path, |
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
#Remove all XML child nodes of the same name from a single parent node | |
#this works in PowerShell version 5.1 (older versions are not tested) | |
[xml]$xml = @" | |
<system.webServer> | |
<httpProtocol> | |
<customHeaders> | |
<!--Override the IE broweser's Compatibility View Settings for intranet sites.--> | |
<add name="X-UA-Compatible" value="IE=Edge" /> |
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
#region config | |
$customViewFile = "path to custom view XML file" | |
$newCustomViewFile = "path to updated custom view XML file" | |
$newQuery = "*[System[Provider[@Name='Microsoft-Windows-WAS'] and (Level=3) and (EventID=5210)]]" | |
#endregion | |
#region operations | |
[xml]$customView = gc $customViewFile | |
$customview.SelectSingleNode("//Query").InnerText = $newQuery | |
$customView.Save($newCustomViewFile) |
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
<# | |
Sieve of Eratosthenes in PowerShell | |
converted from C++ and Java code found here: | |
http://www.algolist.net/Algorithms/Number_theoretic/Sieve_of_Eratosthenes | |
2018 Matt Musante | |
Public Domain | |
#> | |
function runEratosthenesSieve{param ([int]$upperBound) | |
[int]$upperBoundSquareRoot = [Math]::Floor([math]::Sqrt($upperBound)) |