This file contains hidden or 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-WinRMPCFailures | |
{ | |
# Ping a Server and if it responds test WINRM | |
$Log = 'C:\SCRIPTS\WinRM\PCs_WinRMFailed.log' | |
Remove-Item $Log | |
$PCs = (Get-ADComputer -Filter * -Properties Name,OperatingSystem,Enabled | Where {($_.Enabled -eq $true) -and ($_.OperatingSystem -notlike "Windows Server*") ` | |
-and ($_.OperatingSystem -like "Windows*")} | Sort Name).Name |
This file contains hidden or 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-GroupMemberAz | |
{ | |
[CmdletBinding()] | |
param( | |
[Parameter(Mandatory=$false)] | |
[string]$Group, | |
[bool]$IncludeAzureGroups = $true | |
) | |
This file contains hidden or 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 a DNS record wrapped in asterisks e.g. *FW* | |
.DESCRIPTION | |
'# WIP' Means it is still a Work In Progress | |
############################################ |
This file contains hidden or 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
# Get Users With A Duplicated Property e.g. Mobile Number | |
$Property = 'Mobile' | |
$A = Get-ADUser -Filter {($Property -like "*")} -Property $Property | Group $Property | Where-Object {$_.Count -ge 2} | Select-Object -ExpandProperty group | | |
Select-Object Enabled, Name, SamAccountName, $Property |
This file contains hidden or 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
# Query VMWare for the List of All servers With Only 1 CPU Shut Them Down and Add Another CPU | |
# Assumes You Need To Shut The Server Down Which May Not Be The Case | |
$Date = ((Get-Date -Format "yyyy-MM-dd_HHmm_K").Replace(":","-").Replace("+","-")).ToString() # _$($Date).csv" _$($Date).txt" # Date for use in Filenames with TZ | |
$Server = 'VC1' | |
$VMCli = (Get-Module VMware.PowerCLI -ListAvailable).Name | |
if($VMCli -ne 'VMware.PowerCLI'){ |
This file contains hidden or 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 Remove-LocalGroupMember | |
{ | |
[CmdletBinding(ConfirmImpact='High')] | |
Param | |
( | |
[Parameter(Mandatory=$true,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true,HelpMessage='Local Group To Remove Member From')] | |
[ValidateNotNullOrEmpty()] | |
[string]$Group = 'Backup Operators', | |
[Parameter(Mandatory=$true,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true,HelpMessage='Local User To Remove From Local Group')] |
This file contains hidden or 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-WhoRestarted{ | |
[CmdletBinding(ConfirmImpact='Low')] | |
Param | |
( | |
[Parameter(Mandatory=$false)] | |
[AllowNull()] | |
[String]$Computer = 'localhost' | |
This file contains hidden or 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 Remove-TempFiles{ | |
#requires -RunAsAdministrator | |
$ErrorActionPreference = 'STOP' | |
if(Test-Path C:\Temp){ | |
try{ | |
Set-Location C:\Temp -ErrorAction STOP | |
Get-ChildItem 'C:\Temp' -Recurse | Remove-Item -Recurse -Force -Confirm:$false -ErrorAction SilentlyContinue |
This file contains hidden or 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 Create-TeamsChannelMessage{ | |
# Synopsis of Last 7 Days of Script Creation Written to Teams Channel Webhook | |
#REF: https://www.scriptrunner.com/en/blog/teams-webhooks-via-powershell-part-1 | |
#REF: https://communary.net/2018/03/30/quick-tip-convertto-json-and-line-breaks-in-strings/ | |
$Days = (Get-Date).AddDays(-7) | |
$Data = Get-ChildItem C:\Scripts -Recurse -File -Include *.ps1,*.cmd | Select Name,FullName,CreationTime | Where {$_.CreationTime -gt $Days} | Sort Name |
This file contains hidden or 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-CodeSignScript{ | |
[CmdletBinding(ConfirmImpact='Medium')] | |
Param | |
( | |
[Parameter(Mandatory=$true,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true,HelpMessage='Script Full Path Name?')] | |
[ValidateNotNullOrEmpty()] | |
[String]$ScriptToSign, | |
[Parameter(Mandatory=$false,ValueFromPipelineByPropertyName=$true,HelpMessage="The CN of the Enterprise CA")] |