header image

Archive for May, 2017

Get-PhysicalDisk options

Posted by: | May 31, 2017 Comments Off on Get-PhysicalDisk options |

These are the Get-PhysicalDisk options for identifying the disk you want -UniqueId <string> -ObjectId <string> -FriendlyName <string> -InputObject <CimInstance#MSFT_PhysicalDisk> -StorageSubsystem <CimInstance#MSFT_StorageSubsystem> -StorageEnclosure <CimInstance#MSFT_StorageEnclosure> -StorageNode <CimInstance#MSFT_StorageNode> -StoragePool <CimInstance#MSFT_StoragePool> -VirtualDisk <CimInstance#MSFT_VirtualDisk> When dealing with disks installed in the machine then the friendly names is the easiest to use PS> Get-PhysicalDisk | Format-List UniqueId, ObjectId, FriendlyName UniqueId     : […]

under: PowerShell, Storage

String casing

Posted by: | May 30, 2017 Comments Off on String casing |

There are times when you may want to change string casing. You have a couple of options. There are a couple of methods on the string class that you can use to modify the case of a string. PS> ‘aaa’.ToUpper() AAA PS> ‘AAA’.ToLower() aaa Alternatively you can use the culture information PS> (Get-Culture).TextInfo.ToLower(‘AAA’) aaa PS> […]

under: PowerShell

Build a better pull server

Posted by: | May 29, 2017 Comments Off on Build a better pull server |

DSC functions in 2 modes – push (most basic) and pull. Creating a pull server is a non-trivial task and the out-of-the-box pull server has some issues. Some of the folks at powershell.org have decided its time to build a better pull server. There’s a project on github that supplies the code for the open […]

under: DSC, PowerShell

Diskpart and PowerShell – part 6: Multiple partitions on a disk

Posted by: | May 26, 2017 Comments Off on Diskpart and PowerShell – part 6: Multiple partitions on a disk |

So far we’ve looked at creating a single partition on a disk. This time we’ll look at how you can create multiple partitions on a disk. The are good reasons not to do this but its something I’ve seen done on a frequent basis. Lets create a 20GB disk as an example and mount it […]

under: PowerShell, Storage

PowerShell in Azure Cloud Shell

Posted by: | May 23, 2017 Comments Off on PowerShell in Azure Cloud Shell |

if you are an Azure user see this post from the PowerShell team – https://blogs.msdn.microsoft.com/powershell/2017/05/23/coming-soon-powershell-in-azure-cloud-shell/

under: Azure, PowerShell

Diskpart and PowerShell – part4: Remove a partition

Posted by: | May 22, 2017 Comments Off on Diskpart and PowerShell – part4: Remove a partition |

So far you’ve seen how to create and modify partitions and volumes. Its now time to look at how you remove a partition. Mount the test VHD Get-VHD -Path C:\test\Test1.vhdx | Mount-VHD   You can’t remove a volume – you have to remove the partition. Identifying the CORRECT partition to remove is the challenge PS> […]

under: PowerShell, Storage

Diskpart and PowerShell–part 4: Expand a volume

Posted by: | May 21, 2017 Comments Off on Diskpart and PowerShell–part 4: Expand a volume |

Let’s create a new disk and mount it New-VHD -Path C:\test\Test1.vhdx -Dynamic -SizeBytes 20GB Get-VHD -Path C:\test\Test1.vhdx | Mount-VHD Initialize-Disk -Number 1   This time we’ll create a volume that only uses part of the disk New-Partition -DiskNumber 1 -DriveLetter F -Size 5GB   And now format the partition Get-Partition -DriveLetter F | Format-Volume -FileSystem […]

under: PowerShell, Storage

Table or List

Posted by: | May 18, 2017 Comments Off on Table or List |

A question on the forum asked why a object is displayed in a table if it has 4 or fewer properties and as  a list if it  has more than 4 properties: PS> [PSCustomObject]@{P1=1; P2=2; P3=3; P4=4} P1 P2 P3 P4 — — — — 1  2  3  4 PS> [PSCustomObject]@{P1=1; P2=2; P3=3; P4=4; P5=5} […]

under: PowerShell

PowerShell v6 beta

Posted by: | May 10, 2017 Comments Off on PowerShell v6 beta |

PowerShell v6 has reached a significant milestone – the release of the first PowerShell v6 beta version. There have been 18 releases of alpha code since August 2016 when the open source PowerShell v6 project started. There is no indication of how many beta releases there will be before PowerShell v6 is ready to ship. […]

under: PowerShell v6

Are your domain controllers real?

Posted by: | May 9, 2017 Comments Off on Are your domain controllers real? |

A question on the forum asked about discovering if domain controllers are physical or virtual machines. This will do the job foreach ($domain in (Get-ADForest).domains) { Get-ADDomainController -filter * -server $domain | sort hostname  | foreach { Get-CimInstance -ClassName Win32_ComputerSystem -ComputerName $psitem.Hostname | select PSComputerName, Manufacturer, Model } }   Get the domains in your […]

under: PowerShell and Active Directory, PowerShell and CIM

Older Posts »

Categories