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
for ($i = 0; $i -gt 5; $++) | |
{ | |
if ((Get-Service -Computername $s -name Tomcat7).Status -eq "Running") | |
{ | |
break | |
} | |
else | |
{ | |
Start-Service -Computername $s -name Tomcat7 | |
} |
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
class Computer{ | |
[string] GetComputerName() | |
{ | |
$raw_name = hostname | |
$name = $raw_name.trim("") | |
return $name.trim("") | |
} | |
[string] GetIPAddress() | |
{ | |
$IpList = (Get-NetIPAddress).IPv4Address |
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
mkdir 1; mkdir 2; | |
new-item 1\FILENAME.txt; new-item 2\FILENAME.txt; | |
ls *\FILENAME.txt | Select -Exp Fullname ; | |
ls *\FILENAME.txt | sort -desc Fullname | Select -Exp Fullname ; | |
ls *\FILENAME.txt | sort -desc fullname | Sort Name | Select -Exp Fullname | |
# You can do this without the Select -Exp Fullname, but this is easier to see what its doing. | |
Another test: |
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
$filesperfolder = 55 | |
$sourcePath = "C:\Source\SPLITFILELOCATION\" | |
$destPath = "C:\Source\Test Sample\" | |
$i = 0; | |
$FolderName = "Dr. Bob" | |
$folderNum = 1; | |
$CurrentFolderSize = 0 | |
New-Item -Path ($destPath + $FolderName + $folderNum) -Type Directory -Force | |
Get-ChildItem "$sourcePath\*.pdf " | % { | |
if (($CurrentFolderSize + $_.Length) -gt 800MB) { |
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 Enable-RDPAccess ($TargetComputer) | |
{ | |
Invoke-Command -ComputerName $TargetComputer { | |
set-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Control\Terminal Server'-name "fDenyTSConnections" -Value 0 | |
set-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp' -name "UserAuthentication" -Value 1 | |
} | |
} |
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
# Usage: | |
# Edit default OU path if you aren't going to specify it on the command line (you normally won't). | |
# (If pasted into a script file, dot source it to bring functions into current scope) | |
# Connect to your EXO instance: | |
# & "C:\Program Files\Internet Explorer\iexplore.exe" https://cmdletpswmodule.blob.core.windows.net/exopsmodule/Microsoft.Online.CSE.PSModule.Client.application | |
# To list eligible groups: | |
# Get-AadMigrationEligibleDistributionGroups | |
# To Select some group\groups: |
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
[cmdletbinding()] | |
Param( | |
$UnzipSearch = '(?s)(<([^>]+)>.*?</\2>)', | |
$UnzipReplace = "`n`$1`n", | |
$SnipSnipSearch = '(?m)(?<=^<.*)`n', | |
$SnipSnipReplace = '', | |
$RezipSearch = "`n", | |
$RezipReplace = '' | |
) |
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
[cmdletbinding()] | |
Param( | |
[switch]$CopyToNew, | |
$SearchString = "\\OLDSERVER\OLDSHARE\FOLDERNAME", | |
$ReplaceString = "\\NEWSERVER\NEWSHARE\NEWFOLDER", | |
$FolderToSearch = "\\server\share\folder\", | |
$LogResultsLocation = $PSScriptRoot | |
) | |
$Excel = New-Object -ComObject "Excel.Application" |
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
# The "i'm up late and shouldn't be writing code" method. | |
# License: Public Domain - use however you desire, no strings attached. | |
# Strings attached: There are none, but you can attribute me in your source code comment if you want to | |
function Test-PrivateIP { | |
param( | |
$IPAddress | |
) | |
$PrivateSubnetAddressList = | |
(([ipaddress]"10.0.0.0").address -band ([ipaddress]"255.0.0.0").address), |
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 Invoke-SumSize { | |
# I don't wanna type out the full name every time... Add an alias for me. | |
[alias("iss")] | |
param ( | |
[parameter( | |
ValueFromPipeline | |
)] | |
[Alias('Length')] | |
[ValidateNotNullorEmpty()] | |
# Removed type enforcement on the input object because there are several possible types they send in on |
OlderNewer