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
$Text = "EnVeLoPe" | |
$result = switch ($Text.ToCharArray()) { | |
{$_ -in ('a','b','c')} { "2"; continue } | |
{$_ -in ('d','e','f')} { "3"; continue } | |
{$_ -in ('g','h','i')} { "4"; continue } | |
{$_ -in ('j','k','l')} { "5"; continue } | |
{$_ -in ('m','n','o')} { "6"; continue } | |
{$_ -in ('p','q','r','s')} { "7"; continue } | |
{$_ -in ('t','u','v')} { "8"; continue } |
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 exp ($x) | |
{ | |
[double]$sum = 1 | |
foreach ($n in (1..100)) | |
{ | |
$sum += [Double]([math]::Pow($x, $n)/[double](Factorial $n)) | |
} | |
$sum | |
} |
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 Factorial ([bigint]$x) | |
{ | |
if ($x -ge 1) | |
{ | |
return $x * (Factorial ($x = $x - 1)) | |
} | |
elseif ($x -eq 0) | |
{ | |
return 1 | |
} |
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
$Computers = $env:COMPUTERNAME | |
$sccm = Foreach ($computer in $Computers) | |
{ | |
If (Test-Connection -ComputerName $Computer -count 1 -Quiet) | |
{ | |
Get-WmiObject -Class CCM_SoftwareUpdate -Filter ComplianceState=0 -Namespace root\CCM\ClientSDK -Computername $Computer | | |
Select-object @{N='Computername';E={$_.PSComputerName}},ArticleID,Name, URL | |
} | |
} |
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
$Measurement = get-childitem -Path C:\temp -Recurse -File | Measure-Object -Property Length -sum -Average | |
[pscustomobject]@{ | |
Count = $Measurement.Count | |
Average = $Measurement.Average | |
Sum = $Measurement.Sum | |
Date = Get-Date | |
ComputerName = $env:Computername | |
} |
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
$PublicIP = (Invoke-WebRequest -uri 'https://api.ipify.org?format=json' | convertfrom-json).ip | |
$GeoInfo = Invoke-WebRequest -Uri "http://www.geoplugin.net/json.gp?ip=$PublicIP" | ConvertFrom-Json | |
$location = "$($GeoInfo.geoplugin_latitude),$($GeoInfo.geoplugin_longitude)" | |
$TZ = [TimeZoneInfo]::Local.BaseUtcOffset.Hours | |
$Now = Get-date -Format M/dd/yyyy |
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
$Words = (invoke-webrequest -uri https://raw.githubusercontent.com/dwyl/english-words/master/words_alpha.txt).content -split ("`n") | |
<# Or If you have already downloaded the list | |
$Words = Get-Content -Path .\words_alpha.txt | |
#> | |
[regex]$NonLetters = "[gkmqvwxyz]" | |
$LongestWords = @() | |
foreach ($Word in $Words) | |
{ |
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
<# | |
.Synopsis | |
Gets all file metadata | |
.DESCRIPTION | |
Returns one or more objects containing all 290 metadata items available for windows files. | |
This function is based on work by Ed Wilson | |
https://gallery.technet.microsoft.com/scriptcenter/c3d0ea6c-64a1-4716-a262-bcd71c9925fc#content | |
https://blogs.technet.microsoft.com/heyscriptingguy/2009/12/29/hey-scripting-guy-how-can-i-list-all-the-properties-of-a-microsoft-word-document/ | |
.EXAMPLE | |
PS C:\> Get-FileMetaData -Path c:\Users\Me\Documents |
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
$vis = Connect-VIServer MyVcenter | |
$Servers = @("SomeServers") | |
foreach ($Server in $servers) | |
{ | |
if ( -not (Test-NetConnection -ComputerName $Server -CommonTCPPort SMB).TcpTestSucceeded ) | |
# Or maybe some other appropriate test or tests | |
{ | |
get-vm $Server | Restart-VM -Confirm:$false |
NewerOlder