A recent post on powershell.org – https://powershell.org/2017/06/22/taking-powershell-to-the-next-level/ – gave this path for learning PowerShell and becoming more proficient Books: Learn Powershell In A Month of Lunches Learn Powershell Toolmaking in a month of Lunches Windows Powershell In Action 3rd Edition Online: Advanced Tools And Scripting with Powershell 3.0 Jump Start Writing Powershell Powershell DSC Resources […]
Archive for June, 2017
Learning PowerShell
Posted by: richardsiddaway | June 30, 2017 Comments Off on Learning PowerShell |Finding a CIM class
Posted by: richardsiddaway | June 30, 2017 Comments Off on Finding a CIM class |One of the problems you might find is finding a CIM class. You know its name but you don’t know which namespace its in. The old WMI cmdlets allow you to search the namespaces recursively PS> Get-WmiObject -Class Win32_Process -Namespace root -Recurse -List NameSpace: ROOT\CIMV2 Name Methods Properties —- ——- ———- Win32_Process {Create, Terminat… […]
Joining and Testing folder paths
Posted by: richardsiddaway | June 29, 2017 Comments Off on Joining and Testing folder paths |Last time I showed how to split folder paths to just leave the path – no filenames or drive information. What about the opposite task – joining and testing folder paths. Here’s an example $basepath = ‘C:\Scripts’ $pathsTotest = ‘Containers’,’HyperV’, ‘NanoServer’, ‘NoSuchFolder’ $pathsToTest | foreach { $path = Join-Path -Path $basepath -ChildPath $psitem […]
Lets say you have a bunch of files in nested folders but you just want the folders not the file or drive Our files look like this C:\Scripts\HyperV\Setup C:\Scripts\HyperV\attachdisks.ps1 C:\Scripts\HyperV\get-mountedvhdDrive.ps1 C:\Scripts\HyperV\invoke-CIMshutdown.ps1 C:\Scripts\HyperV\set-loopbackswitch.ps1 C:\Scripts\HyperV\Set-NestedVirtualisation.ps1 C:\Scripts\HyperV\set-realswitch.ps1 C:\Scripts\HyperV\Start-AllWindowsVMs.ps1 C:\Scripts\HyperV\Stop-AllVMs.ps1 C:\Scripts\HyperV\Stop-Lab.ps1 C:\Scripts\HyperV\test-HotfixIpresence.ps1 C:\Scripts\HyperV\Setup\Copy-Updates.ps1 C:\Scripts\HyperV\Setup\Get-LicenseStatus.ps1 C:\Scripts\HyperV\Setup\Install-RollUp.ps1 C:\Scripts\HyperV\Setup\New-VirtualMachine.ps1 C:\Scripts\HyperV\Setup\SCsetup.ps1 C:\Scripts\HyperV\Setup\Set-VMconfig1.ps1 C:\Scripts\HyperV\Setup\Set-VMconfig2.ps1 C:\Scripts\HyperV\Setup\setup (2).ps1 C:\Scripts\HyperV\Setup\setup.ps1 C:\Scripts\HyperV\Setup\sysprep.txt You can strip out the file […]
Just recently I’ve found my self repeatedly working through a location, location pattern. cd C:\test\ .\hello.ps1 cd C:\Scripts\ The pattern consists of changing to another folder. Running some code and then changing back to the original folder – assuming you can remember it. I then remembered the location cmdlets PS> Get-Command *-Location | ft -a […]
A comment on yesterday’s post about passing parameters into a script block asked why I hadn’t mention $using $using allows you to access a local variable in a scriptblock BUT you need to be careful PS> $proc = “power*” Invoke-Command -ScriptBlock { Get-Process -Name $using:proc } A Using variable cannot be retrieved. A Using […]
PowerShell on Linux
Posted by: richardsiddaway | June 27, 2017 Comments Off on PowerShell on Linux |An introduction to PowerShell v6 on Windows, mac and Linux is available here https://blogs.msdn.microsoft.com/powershell/2017/06/09/getting-started-with-powershell-core-on-windows-mac-and-linux/ Well worth a read if you haven’t looked at PowerShell v6 yet
Passing parameters to a script block
Posted by: richardsiddaway | June 26, 2017 Comments Off on Passing parameters to a script block |Passing parameters to a scriptblock seems to be an issue at the moment. Consider a simple scriptblock Invoke-Command -ScriptBlock {Get-Process} How can you modify that to parameterise the processes that are returned. Its a two step process. Add a parameter block to your script block and secondly pass the correct values to the scriptblock Invoke-Command […]
Generating passwords
Posted by: richardsiddaway | June 26, 2017 Comments Off on Generating passwords |Generating new passwords can be a painful business. There are many ways of accomplishing password generation – depending on your needs. One suggestion for generating passwords is to use a GUID as the basis of the password PS> New-Guid Guid —- 269f328d-b80d-446a-a14c-6197ff1bcc40 You could then remove the hyphens and extract part of the guid PS> […]
Nano server changes
Posted by: richardsiddaway | June 25, 2017 Comments Off on Nano server changes |Nano server is the small, really small, footprint install version of Windows Server that was introduced with Server 2016. It has a limited number of roles available to to install – much like the original version of Server core. Recent announcements – https://blogs.technet.microsoft.com/hybridcloud/2017/06/15/delivering-continuous-innovation-with-windows-server/ https://docs.microsoft.com/en-us/windows-server/get-started/nano-in-semi-annual-channel indicates that Nano server is going to become even smaller (by […]
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