Powershell

CMD and PowerShell misc stuff.

Back to CS

Get a sum in GBs of all ISO files under the Data folder.

$(Get-ChildItem -path C:\Data -Recurse -Include *.ISO|Measure-Object -Property length -Sum).sum/1GB
4.7607421875

Open a Port with TcpListener.

$Listener = [System.Net.Sockets.TcpListener]8080;
$Listener.Start();
#wait, try connect from another PC etc.
$Listener.Stop();

Install .NET Framework 3.5 on Windows Server 2012 R2 from DVD.

dism /online /enable-feature /featurename:NetFX3 /all /Source:D:\sources\sxs /LimitAccess

Install a Telnet client:

dism /online /enable-feature /featurename:TelnetClient

Finding out when a domain user password will expire.

net user %USERNAME% /domain

Print files older than 14 days:

forfiles /P "D:\Temp" /S /M *.* /D -14 /C "cmd /c echo @path

Delete files older than 14 days:

forfiles /P "D:\Temp" /S /M *.* /D -14 /C "cmd /c del @path

How to create a large dummy file on Windows.

echo "This is just a sample line to create a file of 64 bytes... " >dummy.txt

Create a 1GB file:

for /L %i in (1,1,24) do type dummy.txt >>dummy.txt

Create a 4GB file:

for /L %i in (1,1,26) do type dummy.txt >>dummy.txt

Back to CS