Skip to content

Instantly share code, notes, and snippets.

[cmdletbinding()]
Param(
$UnzipSearch = '(?s)(<([^>]+)>.*?</\2>)',
$UnzipReplace = "`n`$1`n",
$SnipSnipSearch = '(?m)(?<=^<.*)`n',
$SnipSnipReplace = '',
$RezipSearch = "`n",
$RezipReplace = ''
)
# 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:
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
}
}
$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) {
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:
class Computer{
[string] GetComputerName()
{
$raw_name = hostname
$name = $raw_name.trim("")
return $name.trim("")
}
[string] GetIPAddress()
{
$IpList = (Get-NetIPAddress).IPv4Address
for ($i = 0; $i -gt 5; $++)
{
if ((Get-Service -Computername $s -name Tomcat7).Status -eq "Running")
{
break
}
else
{
Start-Service -Computername $s -name Tomcat7
}