Posts Tagged ‘pipeline’


 

Writing VBScript that really runs in PowerShell

Tuesday, September 15th, 2009 by SAPIEN Technologies
It's quite possible to run traditional WSH script from the PowerShell console, and people have even directly hosted VBScript in PowerShell since 2004 using the Microsoft Script Control. However, you can go farther than just loading VBScript into an object in a PowerShell session and calling its methods. You can use VBScript – or any other Active Scripting language, for that matter – as a scripting language for PowerShell.   More »

PowerShell Functions: Return vs Write

Tuesday, June 2nd, 2009 by Jeffery Hicks
The other day I was involved in a short Twitter debate about the relative merits of using RETURN vs Write-Object (or its alias Write) in PowerShell functions. Here's my take.   More »

Out-CSV Revised

Friday, May 15th, 2009 by Jeffery Hicks
A while ago I published a short function to create CSV strings. While working on another task I came across $OFS, which is something I know about but never really think about. $OFS is an intrinsic PowerShell variable that controls the output field separator for arrays. You can modify this variable which made me realize there was a better way to handle my Out-CSV function. Here's the revised function.   More »

Get ServiceAccount Name with ADSI

Tuesday, March 31st, 2009 by Jeffery Hicks
One drawback to the service objects returned from Get-Service is that you can't see what account the service is running under, often referred to as the service account. This will be something like LocalService or perhaps even a special user account like Mydomain\svcAccount123. You can retrieve this information by querying Windows Management Instrumentation (WMI) and the Win32_Service class. But did you know you can also use ADSI?   More »

PowerShell Tree

Wednesday, March 25th, 2009 by Jeffery Hicks
Of course since I've posted a VBScript version of the Tree command, I had to do it in PowerShell. On one hand, this would have been pretty straightforward since PowerShell can use COM objects and I could have simply reused the FileSystemObject. But that didn't feel right. So I came up with a version that uses cmdlets and PowerShell features like the -f formatting operator. So here is TREE.PS1.   More »

Show-CSpace

Monday, March 16th, 2009 by Jeffery Hicks
My latest Prof. PowerShell column has a function that takes a computername as pipelined input. It then returns a custom object showing free space on drive C:\. The point of the column was to demonstrate how to make a function behave like a cmdlet and take pipelined input so it's not necessarily the most glamorous function I've ever written. Anyway, the function got mangled in formatting for the web. This is what it should be...   More »