Mastering the (steppable) pipeline
PowerShell Community
by Ronald Bode
1d ago
Mastering the (steppable) pipeline Before stepping into the steppable pipeline, it is essential that you have a good understanding of how and when exactly items are processed by a cmdlet in the pipeline. The PowerShell pipeline might just look like syntactical sugar but it is a lot more than that. In fact, it really acts like a pipeline where each item flows through and is handled by each cmdlet one-at-a-time. In comparison to the pipes in CMD, PowerShell streams objects through the pipeline rather than plain text. One-at-a-time process The following explanation describes the one-at-a-time pro ..read more
Visit website
On Preferences and Scopes
PowerShell Community
by James O'Neill
11M ago
Progress in PowerShell: a tale of Verbosity and other preferences with lessons in Scopes and Proxies thrown in It started, as these things often do, with someone complaining. In PowerShell Version 7.2 the output of Invoke-WebRequest -Verbose and Invoke-RestMethod -Verbose look like this: VERBOSE: GET with 0-byte payload In all the earlier versions they look like the version below, which is more helpful when you’re trying to debug code that builds URIs: VERBOSE: GET https://google.com/ with 0-byte payload A proxy function will fix that. If two commands have the same name an alias beats a fu ..read more
Visit website
How to Preview PowerShell Scripts In PowerShell
PowerShell Community
by @DoctorDNS
1y ago
Q: When I use Windows Explorer and select a PowerShell script file – I do not see the script in the preview window. Can I fix that? A: You can make a few simple registry updates and do just what you want! At some time in the deep and distant past, Windows Explorer gained the preview pane feature. The idea is simple: you select a file in Explorer and Windows shows you a preview of the file in a separate pane. I love this feature, although when clicking on a Word document, it could take a few moments before I could view. And if you are viewing a file, it was “open” and you could not delete it in ..read more
Visit website
How to Use $PSDefaultParameterValues
PowerShell Community
by @DoctorDNS
1y ago
Q: When I use cmdlets like Receive-Job and Format-Table, how do I change default values of the Keep and Wrap parameters? A: Use the $PSDefaultValues automatic variable. When I first discovered PowerShell’s background jobs feature, I would use Receive-Job to view job output – only to discover it’s no longer there. And almost too often to count, I pipe objects to Format-Table cmdlet only to get truncated output because I forgot to use -Wrap. I’m sure you all have parameters whose default value you would gladly change – at least for your environment. I’m sure you have seen this (and know how to u ..read more
Visit website
How to Use $FormatEnumerationLimit
PowerShell Community
by @DoctorDNS
1y ago
Q: When I format an object where a property contains more than 4 objects, I never see the extra property values. How can I fix that? A: Use the $FormatEnumerationLimit variable. This query is one I hear in many PowerShell support forums, and I have encountered this issue a lot over the years. What happens is that you issue a command to return objects, for example Get-Process. The Get-* cmdlets return objects which can contain properties that are arrays of values, not just a single value. When you pipe those objects to Format-Table, by default, PowerShell only shows you the first four. Let me i ..read more
Visit website
How to use the Secret modules
PowerShell Community
by @DoctorDNS
1y ago
Q: I have a bunch of scripts we use in production that make use of Windows credentials. In some cases, these scripts have an actual password in plain text, while others read the password from an XML file. Is there a better way? A: Scripts with high-privilege account passwords in plain text is not a good idea. There are several methods you can use to improve the security of credentials handling. One great way is to use the SecretManagement and SecretStore modules from the PowerShell Gallery. What are Secrets? Secrets are, in general, passwords you need to access some resource. It might be the p ..read more
Visit website
A closer look at the Crescendo configuration
PowerShell Community
by Sean Wheeler
1y ago
In my previous post, I looked at the details of a Crescendo output handler from my VssAdmin module. In this post, I explain the details of a cmdlet definition in the Crescendo JSON configuration file. The purpose of the configuration The structure for the interface of a cmdlet is a reasonably predictable thing. The cmdlet uses a standard Verb-Noun format The cmdlets take input using sets of parameters Cmdlets that make changes to the system support -Confirm and -WhatIf parameters The pattern of the script code to support these fits a template. The more difficult part of the cmdlet is in the ..read more
Visit website
A closer look at the parsing code of a Crescendo output handler
PowerShell Community
by Sean Wheeler
1y ago
In my previous post, I showed you how to parse the output from the netstat command. The output of netstat is not very complex. The goal of the post was to introduce some parsing strategies that you can use to create a full Crescendo module. In this post, I explain the details of a more complex parsing function that I created for my VssAdmin module. Examining the parser for Get-VssShadowStorage The following screenshot shows the ParseShadowStorage function that is called by the Get-VssShadowStorage cmdlet to handle the output from vssadmin.exe. The parsing process is broken into four areas: Co ..read more
Visit website
Converting string output to objects
PowerShell Community
by Sean Wheeler
1y ago
In my previous post, I talked about using Crescendo to create a PowerShell module for the vssadmin.exe command in Windows. As I explained, you have to write Output Handler code that parses the output of the command you are using. But if you never written a parser like this, where do you start? In this post I show you how to parse the output from the netstat command. The output of netstat is not very complex and it is basically the same on Windows and Linux systems. The goal here is to talk about parsing strategies that you can use to create a full Crescendo module. Step 1 – Capture the output ..read more
Visit website
Understanding Get-ACL and AD Drive Output
PowerShell Community
by Faris Malaeb
1y ago
Understanding Active Directory ACL using PowerShell can be a bit tricky. There are no out-of-the-box cmdlets with ActiveDirectory PowerShell module to help in settings the permission quickly. While there are no cmdlets, you can nevertheless manage AD permissions using the AD PowerShell drive. In this post, I will try to simplify Active Directory ACL and how to read the result easily, so let’s start. Prerequisites To follow along with this article, you need the following: PowerShell 7. x or Windows PowerShell 5.1 A user account that is member of Domain Admin AD Group. Windows Server 2012, 2016 ..read more
Visit website

Follow PowerShell Community on Feedspot

Continue with Google
OR