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
#https://www.reddit.com/r/PowerShell/comments/3hdjyt/need_help_with_if_statement/ | |
$ServerList = "C:\lazywinadmin\servers.txt" | |
$Output = "C:\LazyWinAdmin\RAMReport.txt" | |
$PercentUsageLimit = 5 | |
Get-Content $ServerList | ForEach-Object -Process { | |
# Test the connection | |
IF (Test-Connection $_ -Count 1 -Quiet) | |
{ |
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
#Source http://blogs.technet.com/b/pstips/archive/2015/02/04/don-t-use-aliases-in-your-scripts.aspx | |
function Expand-Aliases { | |
$ast = [System.Management.Automation.PSParser]::Tokenize( | |
$psISE.CurrentFile.Editor.Text, [ref]$null) | |
$commands = $ast | Where-Object { | |
$_.Type -eq [System.Management.Automation.PSTokenType]::Command } | |
$after = $psISE.CurrentFile.Editor.Text -split [System.Environment]::NewLine |
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
$signature = @' | |
[DllImport("user32.dll")] | |
public static extern bool SetWindowPos( | |
IntPtr hWnd, | |
IntPtr hWndInsertAfter, | |
int X, | |
int Y, | |
int cx, | |
int cy, | |
uint uFlags); |
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 = "die Nacht, die Nächte".split() | |
$text2 = (Get-Content file.txt).split() | |
function Remove-StringLatinCharacters | |
{ | |
PARAM ([string[]]$String) | |
foreach ($text in $string) | |
{ | |
[Text.Encoding]::ASCII.GetString([Text.Encoding]::GetEncoding("Cyrillic").GetBytes($text)) | |
} |
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
# https://msdn.microsoft.com/en-us/library/aa746475%28v=vs.85%29.aspx?f=255&MSPPError=-2147217396 | |
# ADS_GROUP_TYPE_SECURITY_ENABLED | |
get-adgroup -LDAPFilter "(&(objectCategory=group)(groupType:1.2.840.113556.1.4.803:=2147483648))" |
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-ADGroup -LDAPFilter ("(member:1.2.840.113556.1.4.1941:={0})" -f $((Get-Aduser <SamAccount>).distinguishedname)) |
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
[string]::IsNullOrEmpty("") | |
True | |
[string]::IsNullOrEmpty("Hello World") | |
False |
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 Remove-StringLatinCharacters | |
{ | |
PARAM([string]$String) | |
[Text.Encoding]::ASCII.GetString([Text.Encoding]::GetEncoding("Cyrillic").GetBytes($String)) | |
} |
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-date -for "yyyy-MM-dd HH:mm:ss.fffffff" | |
2015-05-30 17:07:25.2352256 |
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
# This need to be run on the destination server | |
# Drivers must be installed already | |
# Get the printers from the source server | |
$printers = Get-Printer -ComputerName <SERVERSOURCE> | Select-Object -property * | |
#foreach printer in the file: | |
foreach ($printer in $printers) { | |
# Create the Printer Port | |
Add-PrinterPort -Name $printer.Name -PrinterHostAddress $printer.PortName |