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
# Change Path | |
$path = "$env:userprofile\Downloads\Takeout\YouTube and YouTube Music\history\watch-history.json" | |
# $path2 = 'C:\Users\Mercier\Downloads\Takeout\YouTube and YouTube Music\history\search-history.json' # NOT USED | |
$Params = @{ | |
# Remove the "Watched" keyword from the title (might be another keyword in your language or default to english...) | |
# Do not change if not needed |
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-Port ($Hostname = 'yahoo.com', $Port = 80, $Timeout = 100) { | |
$requestCallback = $state = $null | |
$client = [System.Net.Sockets.TcpClient]::new() | |
$iar = $client.BeginConnect($Hostname, $Port, $null, $null) | |
$wait = $iar.AsyncWaitHandle.WaitOne($Timeout, $false) | |
if (!$wait) { | |
$client.Close() | |
$open = $false | |
} | |
else { |
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
$Now = new-object psobject | |
$Now.psobject.members.add((new-object System.Management.Automation.PSScriptMethod "ToString", { 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
$CertParams = @{ | |
CertStoreLocation = 'Cert:\CurrentUser\My' | |
Subject = 'ttt' | |
KeyExportPolicy = 'Exportable' | |
NotAfter = (get-date).AddYears(1000) | |
} | |
New-SelfSignedCertificate @CertParams -Provider 'Microsoft Enhanced Cryptographic Provider V1.0' -KeyAlgorithm 'RSA' -KeyLength 4096 -Type 'DocumentEncryptionCert' -KeySpec 'KeyExchange' | |
# |
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
for ($i = 1; $i -lt 10; $i++) { | |
$Currentnumstr = "$Currentnumstr$i" | |
Write-Host "$($Currentnumstr.PadLeft(9,' ')) x " -NoNewline | |
Write-Host "8" -NoNewline -ForegroundColor Red | |
Write-Host " + $i = $([int]$Currentnumstr * 8 + $i)" | |
} |
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 Search-Gist {$str = "https://gist.github.com/search?utf8=%E2%9C%93&q=language%3APowerShell+%s"; Start-Process ($str -replace '%s', [System.Web.HttpUtility]::UrlEncode([String[]]$args)) } | |
Function Search-Github {$str = "https://github.com/search?utf8=%E2%9C%93&q=language%3APowerShell+%s&type=Code"; Start-Process ($str -replace '%s', [System.Web.HttpUtility]::UrlEncode([String[]]$args -join ' '))} | |
Function Search-Google {$str = "https://www.google.ca/search?q=%s"; Start-Process ($str -replace '%s', [System.Web.HttpUtility]::UrlEncode([String[]]$args -join ' '))} | |
Function Search-Reddit {$str = "https://www.reddit.com/r/PowerShell/search?q=%s&restrict_sr=1"; Start-Process ($str -replace '%s', [System.Web.HttpUtility]::UrlEncode([String[]]$args)) } | |
Function Search-StackOverflow {$str = "https://stackoverflow.com/search?q=%5BPowershell%5D+%s"; Start-Process ($str -replace '%s', [System.Web.HttpUtility]::UrlEncode([String[]]$args)) } | |
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 Import if not found and not using IIS | |
Import-Module WebAdministration | |
Add-Type -TypeDefinition @" | |
[System.Flags] | |
public enum DashboardAction | |
{ | |
Undefined = 0, |
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 New-TempPassword($letters = 6,$digits=2, [Switch]$Capital) { | |
[Char[]]$Vowels = 'aeiouy' | |
[char[]]$Consonants = 'bcdfghjklmnpqrstvwxz' | |
$output = New-Object System.Text.StringBuilder | |
for ($i=0;$i -lt $letters;$i++) { | |
Switch ($i % 2 -eq 0) { |
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
$Subscriptions = Get-AzureRmSubscription | |
$rsx = $Subscriptions | % { | |
$SubName = $_.Name | |
Select-AzureRmSubscription $_.Id | Out-Null | |
Get-AzureRmResource | | |
Select *,@{n='SubscriptionName';e={$SubName}} | |
} | |
$rsx[0] | fl | |
$Vms = $rsx | where ResourceType -Like '*virtualMachines' | Select *,@{n='Classic';e={$_.ResourceType.Contains('Classic')}} | |
$Vms | ft Name,ResourceType,Classic,SubscriptionName |