Do you understand the difference between do loops and while loops? On the surface they appear very similar. £> do{$i++}while($i -lt 10) £> $i 10 £> $i=0 £> while($i -lt 10){$i++} £> $i 10 BUT there is a difference £> $i=11 £> do{$i++}while($i -lt 10) £> $i 12 £> $i=11 £> while($i -lt 10){$i++} £> […]
Archive for February, 2014
Automatically create folder for home drive
Posted by: richardsiddaway | February 28, 2014 | No Comment |In this post http://richardspowershellblog.wordpress.com/2013/10/28/setting-ad-attributes-from-a-csv-file/ I showed how to modify the user’s home folder setting in Active Directory. A comment was recently left asking about automatically creating the folder on the fileserver and creating the share that is associated with it. This isn’t a simple exercise – you will need a script to: You can create […]
This is a common type of use for Get-ChildItem: Get-ChildItem -Path c:\temp However, you could get files or folders returned. Very often you just want to see the files In PowerShell 1.0 & 2.0 you had to do this: Get-ChildItem -Path c:\temp | where {-not $_.PSIsContainer} If you want to see the subfolders only then […]
In PowerShell 1.0 you could do this: notepad $proc = Get-WmiObject -Class Win32_Process -Filter "Name=’notepad.exe’" $proc.Terminate() To access the methods of the WMI class you had to get a variable representing the instance and call the method. This technique still works in PowerShell 4.0 When the CIM cmdlets were introduced in PowerShell 3.0 people assumed […]
Learn AD Management in a Month of Lunches–ebook available
Posted by: richardsiddaway | February 27, 2014 | 2 Comments |The ebook – PDF format – for Learn AD Management in a Month of Lunches has been published – http://www.manning.com/siddaway3/ If you bought the ebook as part of your MEAP you should be able to down load it – you’ll get or have got an email with the link. The printed version is at the […]
PowerShell Summit NA 2014–reasons to attend
Posted by: richardsiddaway | February 27, 2014 | No Comment |The PowerShell Summit is happening in Bellevue (Seattle) – April 28 – 30th. You will be able to hear, meet and talk to some of the biggest names in PowerShell: – Jeffrey Snover – the inventor of PowerShell – PowerShell Team members – Don Jones – Jason Helmick – Jeff Hicks – Ed Wilson (The […]
Scanning through the Storage module there is a bunch of useful cmdlets – starting with the Get* cmdlets: Get-Command -Module Storage get* Get-Disk Get-DiskImage Get-FileIntegrity Get-FileStorageTier Get-InitiatorId Get-InitiatorPort Get-MaskingSet Get-OffloadDataTransferSetting Get-Partition Get-PartitionSupportedSize Get-PhysicalDisk Get-ResiliencySetting Get-StorageJob Get-StorageNode Get-StoragePool Get-StorageProvider Get-StorageReliabilityCounter Get-StorageSetting Get-StorageSubSystem Get-StorageTier Get-StorageTierSupportedSize Get-SupportedClusterSizes Get-SupportedFileSystems Get-TargetPort Get-TargetPortal Get-VirtualDisk Get-VirtualDiskSupportedSize Get-Volume Get-VolumeCorruptionCount Get-VolumeScrubPolicy £> Get-PhysicalDisk | […]
I was asked a question about deleting files from a folder based on age. The requirement was to delete all but the youngest N files. One solution is a classic PowerShell one-liner. It is actually one PowerShell pipeline though I’ve split it across multiple lines for ease of reading. Get-ChildItem -Path c:\temp -Filter *.tmp -File […]
You may have seen this at the top of scripts or modules #Requires –Version 3 This will stop the script running if the PowerShell version is 2.0 or below. Other options are available #Requires –PSSnapin can be used to force the loading of a snapin #Requires –Modules can be used to force […]
Some times you need to reboot a remote machine as part of your process. PowerShell provides the Restart-Computer cmdlet to perform that task: Restart-Computer -ComputerName server03 If you want you process to pause until the reboot has finished then you add the –Wait parameter: Restart-Computer -ComputerName server03 You final options when pausing are to wait […]
Categories
- .NET
- Active Directory
- Architecture
- Azure
- Bash
- BITS
- Books
- CDXML
- CIM
- Cloud
- COM
- Containers
- Deep Dive
- Desired State Configuration
- DevOps
- DHCP
- DNS
- DSC
- European Summit
- Events
- Exchange
- File System
- Firewall
- General
- General IT Matters
- Hyper-V
- IIS
- Infrastructure
- IT Community
- IT Security
- Learning PowerShell
- Linux
- Math
- Microsoft
- Modules
- Nano Server
- Networking
- Office 2010
- Office 2013
- Open Source
- Opinion
- Outlook
- Philosophy
- PowerShell
- PowerShell 7
- PowerShell and .NET
- PowerShell and Active Directory
- PowerShell and CIM
- PowerShell and Exchange 2007
- PowerShell and IIS
- PowerShell and SQL Server
- PowerShell and WMI
- PowerShell Basics
- PowerShell original
- PowerShell Summit
- PowerShell User Group
- PowerShell User Group 2
- PowerShell v2
- PowerShell V3
- PowerShell v4
- PowerShell v5
- PowerShell v6
- PowerShell.org
- PowerShellGet
- PowerShellV2
- PSAM
- Rant
- Registry
- Scripting
- Scripting Games
- Scripting Games 2104
- Security
- SQL Server
- Storage
- Strings
- Summit
- Technology
- Uncategorized
- Virtualization
- Windows 10
- Windows 2012 R2
- Windows 7
- Windows 8
- Windows 8 Server
- Windows 8.1
- Windows Server
- Windows server 1709
- Windows Server 2008
- Windows Server 2008 R2
- Windows Server 2012
- Windows Server 2012 R2
- Windows Server 2016
- Windows Server 2019
- WMFv5
- WPF
- WSUS