Skip to content

Instantly share code, notes, and snippets.

for ($i = 0; $i -gt 5; $++)
{
if ((Get-Service -Computername $s -name Tomcat7).Status -eq "Running")
{
break
}
else
{
Start-Service -Computername $s -name Tomcat7
}
class Computer{
[string] GetComputerName()
{
$raw_name = hostname
$name = $raw_name.trim("")
return $name.trim("")
}
[string] GetIPAddress()
{
$IpList = (Get-NetIPAddress).IPv4Address
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:
$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) {
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
}
}
# 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:
[cmdletbinding()]
Param(
$UnzipSearch = '(?s)(<([^>]+)>.*?</\2>)',
$UnzipReplace = "`n`$1`n",
$SnipSnipSearch = '(?m)(?<=^<.*)`n',
$SnipSnipReplace = '',
$RezipSearch = "`n",
$RezipReplace = ''
)
@Szeraax
Szeraax / Update-ExcelHyperlinksAddress.ps1
Created August 10, 2018 20:30
A script to update href links in excel xlsx files when you move files
[cmdletbinding()]
Param(
[switch]$CopyToNew,
$SearchString = "\\OLDSERVER\OLDSHARE\FOLDERNAME",
$ReplaceString = "\\NEWSERVER\NEWSHARE\NEWFOLDER",
$FolderToSearch = "\\server\share\folder\",
$LogResultsLocation = $PSScriptRoot
)
$Excel = New-Object -ComObject "Excel.Application"
# 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),
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