-
PowerShell Tip – How to immediately access new disk after mount (Mount-VHD, Mount-DiskImage)
If you inside of a script mount a disk or do other operation that add another disk into system (unlock TrueCrypt protected volume) then you will not be able immediately access it. For example Get-ChildItem -Path X: will not work and you will get an error like you want to access a partition that does…
-
PowerShell advanced function (cmdlet) to create, format, mount and dismount VHD and VHDX files on local and remote computers
I often use Virtual Hard Disk (VHD or VHDX) files for different purposes then disks for virtual machines (VMs). A few examples: Container for temporary data It is possible to use it in home environment for file backups or for differential backups using Windows Server Backup. I like to use VHD as data disk (D:)…
-
PowerShell advanced function (cmdlet) to copy files and folders using Robocopy on a local or remote computer
I wrote Windows PowerShell Cmdlet (Advanced Function) to work with Robocopy. It is possible to use ComputerName (invoke all operations) or Session (use established session) to copy items on a remote computer. Results are not displayed as text but outputted as object. Some of the properties: Directories / Files / Bytes Total Directories / Files…
-
Simple PowerShell script to combine every item with every item
I needed a simple PowerShell code to generate hash tables with all possible pairs of a given array of strings. There are possibilities to use a similar method in .NET but I used only PowerShell functionality. This is my output: $inputItems = ‘aaa’, ‘bbb’, ‘ccc’ $pairItems = @() $i = 0 foreach ($pairItemFirst in $inputItems) {…
-
PowerShell advanced function (cmdlet) to get all Active Directory Sites and Subnets
I wrote a simple function to get all AD sites and subnets. Using this function it is possible to easily report all sites and for example find sites without subnets. If there is more then on subnet in a site then the output is multiple objects with the same site and different subnet. Every object…