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
$Server = 'server' | |
$Shares = Get-Content -Path C:\temp\server-shares.txt | |
$output = foreach ($Share in $Shares) { | |
$Path = "\\$Server\$Share" | |
Get-ChildItem -Path $Path -Recurse | ` | |
where attributes -like *directory* | ` | |
Get-Acl | ` | |
Where-Object {$_.AreAccessRulesProtected -eq $True} | ` | |
Select-Object @{Label='Directory';Expression={$_.path.split(':')[-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 Get-PCBUptime { | |
<# | |
.SYNOPSIS | |
A simple tool for checking how long a system on the network has been running since last boot. | |
.DESCRIPTION | |
Get-PCBUptime is a quick WMI-based tool for determinging a remote system's uptime. It is useful for verifying | |
what a user says when asked if they've rebooted their machine recently. | |
Get-PCBUptime is written by and copyright of Christopher R. Lowery, aka The PowerShell Bear (poshcodebear.com; Twitter: @poshcodebear) | |
It is free for all to use, and free to distribute with attribution to the original author. |
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 = Get-ADComputer -SearchBase (Get-ADOrganizationalUnit -Filter {Name -eq 'Servers'} ) -Filter * | Select-Object -ExpandProperty Name | |
Measure-Command { | |
Get-WmiObject Win32_ComputerSystem -ComputerName $computers -ErrorAction ignore | |
} | |
Measure-Command { | |
Get-CimInstance Win32_ComputerSystem -ComputerName $computers -ErrorAction ignore | |
} |
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
# Get-WMIObject: | |
Days : 0 | |
Hours : 0 | |
Minutes : 7 | |
Seconds : 11 | |
Milliseconds : 568 | |
Ticks : 4315681996 | |
TotalDays : 0.00499500231018519 | |
TotalHours : 0.119880055444444 | |
TotalMinutes : 7.19280332666667 |
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
# Works with PowerShell v2, but only works with very simple JSON | |
function Get-SimpleJSON { | |
param( | |
[Parameter(Mandatory=$true, | |
ValueFromPipeline=$True)] | |
[Alias('Uri')] | |
[string]$JSONUri, | |
[Alias('CamelCase')] | |
[switch]$TitleCase |
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
(Add-Content -Value 'MACHINENAME,OSVERSION' -Path .\Output.csv -Encoding Ascii -PassThru) | Get-WmiObject Win32_OperatingSystem -ComputerName (Import-Csv -Path .\Input.csv).MACHINENAME -ErrorAction Ignore | foreach {Add-Content -Value "$($_.PSComputerName),$($_.Caption)" -Path .\Output.csv -Encoding Ascii} |
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
Get-ADOrganizationalUnit -Filter * -Properties ProtectedFromAccidentalDeletion | ` | |
where {$_.ProtectedFromAccidentalDeletion -eq $False} | ` | |
Set-ADOrganizationalUnit -ProtectedFromAccidentalDeletion $True |
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-PCBUptime { | |
<# | |
.SYNOPSIS | |
A simple tool for checking how long a system on the network has been running since last boot. | |
.DESCRIPTION | |
Get-PCBUptime is a quick WMI-based tool for determinging a remote system's uptime. It is useful for verifying | |
what a user says when asked if they've rebooted their machine recently, or to generate a report of server uptimes. | |
Get-PCBUptime is written by and copyright of Christopher R. Lowery, aka The PowerShell Bear (poshcodebear.com; Twitter: @poshcodebear) | |
It is free for all to use, and free to distribute with attribution to the original author. |
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
Get-ChildItem 'C:\temp\FileShare' -Recurse | foreach {if ($_.Name -match '[\p{IsLatin-1Supplement}-[\x80-\xbf\xd7\xf7]]+') {$_ | select Name, Directory, CreationTime, LastWriteTime, Length}} | Format-Table -AutoSize |
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
{ | |
"CanPauseAndContinue": false, | |
"CanShutdown": true, | |
"CanStop": true, | |
"DisplayName": "Windows Remote Management (WS-Management)", | |
"DependentServices": [ | |
], | |
"MachineName": ".", | |
"ServiceName": "winrm", |