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 CartesianProduct($htRow, $currCol=0){ | |
$colCount = $htRow.Keys.Count | |
if ($currCol -eq 0){ | |
$wordIndices = New-Object int[] $colCount | |
} | |
$wordCount = ($htRow.Values | select)[$currCol].Count | |
#walk through the items in the current | |
for ($wordIndex = 0; $wordIndex -lt $wordCount; $wordIndex++){ | |
#add the index to the indices for the current column | |
$wordIndices[$currCol] = $wordIndex |
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
#build the cartesian product for an array of arrays | |
function CartesianProduct($row, $currCol=0){ | |
if ($currCol -eq 0){ | |
$wordIndices = New-Object int[] $row.Length | |
} | |
$wordIndex = 0 | |
#walk through the items in the current column | |
foreach($word in $row[$currCol]){ | |
#add the index to the indices for the current column | |
$wordIndices[$currCol] = $wordIndex |
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
$regeditInstance = [Diagnostics.Process]::Start("regedit","-m") | |
#wait the regedit window to appear | |
while ($regeditInstance.MainWindowHandle -eq 0){ | |
sleep -Milliseconds 100 | |
} |
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
Sub CrossJoinSheets() | |
Dim cn As ADODB.Connection | |
Dim sql As String | |
Dim outputSheet As Worksheet | |
Dim rs As ADODB.Recordset | |
Set rs = New ADODB.Recordset | |
Set cn = New ADODB.Connection | |
With cn | |
.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;" & _ | |
"Data Source=" & ActiveWorkbook.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 Get-FileInvokeWebRequest{ | |
param( | |
[Parameter(Mandatory=$true)] | |
$url, | |
$destinationFolder="$env:USERPROFILE\Downloads", | |
[switch]$includeStats | |
) | |
$destination = Join-Path $destinationFolder ($url | Split-Path -Leaf) | |
$start = Get-Date | |
Invoke-WebRequest $url -OutFile $destination |
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-FileBitsTransferSynchronous{ | |
param( | |
[Parameter(Mandatory=$true)] | |
$url, | |
$destinationFolder="$env:USERPROFILE\Downloads", | |
[switch]$includeStats | |
) | |
Import-Module BitsTransfer | |
$destination = Join-Path $destinationFolder ($url | Split-Path -Leaf) | |
$start = Get-Date |
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-Uninstaller { | |
[CmdletBinding()] | |
Param( | |
$DisplayName = '*', | |
[ValidateSet('HKLM', 'HKCU')] | |
[string[]]$Hive = @('HKLM','HKCU') | |
) | |
$keys =@' | |
:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall | |
:\SOFTWARE\WOW6432NODE\Microsoft\Windows\CurrentVersion\Uninstall |
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
#requires -Version 5 | |
Get-Package | foreach{ | |
$attributes = $_.meta.attributes | |
$htProps = [Ordered]@{msiGUID=''} | |
for ($i=0;$i -lt $attributes.keys.count;$i++){ | |
$htProps.Add($attributes.keys[$i].LocalName,$attributes.values[$i]) | |
} | |
if ($htProps.Contains('DisplayName')){ | |
$uninstallString = $htProps.UninstallString | |
$modifyPath = $htProps.ModifyPath |
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-RandomUser { | |
<# | |
.SYNOPSIS | |
Generate random user data. | |
.DESCRIPTION | |
This function uses the free API for generating random user data from https://randomuser.me/ | |
.EXAMPLE | |
Get-RandomUser 10 | |
.EXAMPLE | |
Get-RandomUser -Amount 25 -Nationality us,gb -Format csv -ExludeFields picture |
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
$htUsers = @{} | |
$htProps = @{} | |
$addADGroupMembers.Keys | foreach {$htProps.$_=$null} | |
foreach ($group in $addADGroupMembers.GetEnumerator()){ | |
foreach ($user in $group.Value){ | |
if (!$htUsers.ContainsKey($user)){ | |
$htProps.UserID = $user | |
$htUsers.$user = $htProps.Clone() | |
} | |
($htUsers.$user).$($group.Name) = 1 |
OlderNewer