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
# some function we want available in our parallel runspace | |
function Get-DummyItem { | |
[CmdletBinding()] | |
Param ( | |
[Parameter(Mandatory)] | |
[string]$Name | |
) | |
$myIp = Invoke-WebRequest -Method Get -Uri 'https://api.my-ip.io/ip' | |
"[$Name] was processed by [$myIp]" |
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 Repair-AzureDevOpsConnection { | |
[CmdletBinding()] | |
Param ( | |
[Parameter(Mandatory)] | |
[string]$AzureDevOpsPAT # bad practice to pass secrests as strings, but this is a quick and dirty | |
, | |
[Parameter(Mandatory)] | |
[string]$Org | |
, | |
[Parameter(Mandatory)] |
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
pushd C:\inetpub\logs\LogFiles\W3SVC1 | |
[Regex]$regex = '^(?<date>[\d-]+)\s(?<time>[\d\:]+)\s(?<ServerIP>[\d\.]+)\s(?<method>\S+)\s(?<path>\S+)\s(?<querystring>\S+)\s(?<port>\d+)\s(?<username>\S+)\s(?<clientIP>[\d\.]+)\s(?<browser>\S+)\s(?<fulluri>\S+)\s(?<HttpStatus>\d+)\s(?<a>\d+)\s(?<b>\d+)\s(?<c>\d+)$' | |
cat 'u_ex201015.log' | ?{$_ -like '2020-10-15 07*'} | %{ | |
if ($_ -match $regex) { | |
([PSCustomObject]$Matches) | |
} else { | |
throw "Unexpected line format: '$_'" | |
} | |
} | ft time, ClientIP, username, httpstatus, port, path, querystring -AutoSize | |
popd |
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
[string[]]$Assemblies = @( | |
'C:\AOSService\webroot\bin\Microsoft.Dynamics.AX.Framework.EncryptionEngine.dll' | |
) | |
[string]$CSSource = @" | |
using System; | |
using Microsoft.Dynamics.Ax.Xpp.Security; | |
namespace n201903071243 //use an odd namespace so I don't have to reload powershell each time I want to tweak this code; just tweak the NS | |
{ | |
public class Dfo365CertificateThumbprintProvider: Microsoft.Dynamics.Ax.Xpp.Security.ICertificateThumbprintProvider |
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
Login-AzAccount # opens browser for interactive login | |
$subscriptions = Get-AzSubscription | | |
Where-Object {$_.State -eq 'Enabled'} | | |
Select-Object -ExpandProperty 'Id' | |
$script = @' | |
$driveInfo = Get-PSDrive -PSProvider FileSystem | Select-Object Root, Description | |
$pageFileDrive = Get-WmiObject Win32_Pagefile | Select-Object -ExpandProperty Drive | |
([PSCustomObject]@{ | |
DriveInfo = ($driveInfo | %{"$($_.Root) = $($_.Description)"}) -join '; ' |
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 Compare-ArrayItems { | |
[CmdletBinding()] | |
Param ( | |
[Parameter(Mandatory)] | |
[PSObject[]]$ReferenceArray | |
, | |
[Parameter(Mandatory)] | |
[PSObject[]]$DifferenceArray | |
) | |
# note: this treats the arrays as sets; i.e. doesn't care what position items are in within an array, or if the same item occurs multiple times |
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
void Main() | |
{ | |
var usr = @"myDomain\myUser"; | |
var pwd = Util.GetPassword(usr); //linqpad util library | |
var uri = "https://webdavendpoint.example.com/somefolder/"; | |
var fn = @"c:\temp\filetouploadTestData.txt"; | |
var rn = "remoteFilenameTestData.txt"; | |
var wd = new BasicWebDavClient(usr, pwd, uri); | |
wd.Put(fn, rn); |
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 Receive-TcpServerResponse { | |
[CmdletBinding()] | |
Param ( | |
[Parameter(Mandatory = $true)] | |
[System.IO.StreamReader]$StreamReader | |
) | |
# useful notes on SMTP https://www.rfc-editor.org/rfc/rfc5321.html / http://www.tcpipguide.com/free/t_SMTPRepliesandReplyCodes-3.htm / FTP on https://www.w3.org/Protocols/rfc959/4_FileTransfer.html | |
$return = [PSCustomObject]@{PSTypeName='TcpResponse';Code=$null;Text=''} # don't need code, but no harm in leaving it (it was here from: ) | |
$hasMoreData = $true | |
#Write-Verbose ': Awaiting Server Response' |
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-FilesInDirectory { | |
[CmdletBinding()] | |
Param ( | |
[Parameter(Mandatory)] | |
[string]$Path | |
, | |
[Parameter(Mandatory)] | |
[string]$SearchPattern | |
, |
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
$serviceVolume = Get-PSDrive -PSProvider 'Microsoft.PowerShell.Core\FileSystem' | ?{$_.Description -eq 'Service Volume'} | |
$adminProvTool = Join-Path -Path $serviceVolume.Root -ChildPath 'AosService\PackagesLocalDirectory\bin\AdminUserProvisioning.exe' | |
if (Test-Path -Path $adminProvTool) { | |
"Admin User Provisioning Tool Found: $adminProvTool" | |
& $adminProvTool | |
} else { | |
Write-Error "Could not find admin user provisitioning tool at: $adminProvTool" | |
} |