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 3.0 | |
$filter = {((name -notlike "*d") -and (name -notlike "*q")) -and ((name -notlike "dev*") -and (name -notlike "vdev*"))} | |
$SB = "OU=Servers,OU=Computers,OU=MyLocale,OU=MyDataCenterr,OU=NA,DC=foo,DC=local" | |
Get-ADComputer -filter $filter -SearchBase $SB -SearchScope Subtree | | |
where {(Test-Connection -ComputerName $_.name -Count 1 -Quiet)} | | |
% { Get-WmiObject -Class win32_operatingsystem -computername $_.name -Verbose} | | |
select csname, @{LABEL='LastBootUpTime';EXPRESSION={$_.ConverttoDateTime($_.lastbootuptime)}} | | |
#Sort-Object -Property LastBootUpTime | |
Out-GridView -Title "Production Servers" |
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 3.0 | |
<# Clear-ADGroupMember | |
.Synopsis | |
Removes all users from an AD group | |
.DESCRIPTION | |
Removes all users from an AD group provided to the script. | |
.EXAMPLE | |
“my-group” | Clear-ADGroupMember | |
#> |
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
{$_.Creationtime -lt (Get-Date).AddDays(-90)} | | |
ForEach-Object { | |
Move-Item -Force -Recurse -Path $_.FullName -Destination $($_.FullName.Replace("C:\Application\Log","\\NASServer\Archives")) | |
} |
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
$url = "https://eventloom.com/event/home/summit2017" | |
$page = Invoke-WebRequest -Uri $url | |
$outertext = $page.ParsedHtml.getElementsByTagName("div") | where Classname -eq "col-md-6" | Select -ExpandProperty OuterText | |
$AvailableText = ($outertext -split '[\r\n]').Where({$_ -like "*avail*"}) | |
$SeatsAvailable = $AvailableText.Split(' ')[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
Class PlayingCard { | |
[String] $Suit | |
[String] $FaceValue | |
hidden [int] $Value | |
PlayingCard (){} | |
PlayingCard ([String] $Suit, [String] $FaceValue){ | |
$this.Suit = $Suit | |
$this.FaceValue = $FaceValue |
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
@REM $Id: silentclient.cmd,v 1.24 2012/06/04 18:55:53 $ | |
@ECHO ----------------------- | |
@ECHO %COMPUTERNAME% | |
@DATE /T | |
@TIME /T | |
@ECHO ----------------------- | |
@ECHO OFF | |
REM ------------------------------------------------------------------------------------------- | |
SET CLIENT=%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
$Foo = Invoke-WebRequest -Uri 'https://www.eventbrite.com/e/powershell-devops-global-summit-2018-registration-32452427083' -UseBasicParsing | |
$null = $foo -match 'remaining":(\d{1,3})' | |
$Matches[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
function Compare-Things | |
{ | |
[CmdletBinding()] | |
[OutputType([bool])] | |
Param | |
( | |
# The singular thing that want to see if it matches | |
[Parameter(Mandatory=$true, | |
ValueFromPipelineByPropertyName=$true, | |
Position=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 Register-DNSVMGuest | |
{ | |
#Requires -modules VMware.VimAutomation.Core,DNSClient | |
[CmdletBinding()] | |
param ( | |
# Parameter help description | |
[Parameter(Mandatory = $true)] | |
[ValidateNotNullorEmpty] | |
[String] | |
$VIServer, |
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-AllWSMANServer | |
{ | |
[CmdletBinding()] | |
param ( | |
# Computername | |
[Parameter(ValueFromPipeline = $true)] | |
[String[]] | |
$ComputerName | |
) | |
OlderNewer