Here’s another recent topic from the ScriptingAnswers.com forums which I thought I’d share. The forum members wanted to delete files if the drive utilization exceeded a certain threshold. Using Windows Management Instrumentation (WMI) with VBScript I came up with something like this…
Tag: scripting
"Live" Variables
In a recent PowerShell ScriptingAnswers.com post, a member was asking about variables and whether they were “live” or linked to an actual object.The answer is “Yes and No, depending…”
Fun with Debug Messages
In my script and function development, I often add the line $DebugPreference=”SilentlyContinue” to the beginning of my code. Throughout the script I add lines using Write-Debug that tell me what the script is doing or the value of a particular variable. This has been very helpful. When I want to see the debug messages, I set $DebugPreference to “Continue” and voila!. In PrimalScript all the messages are written to the debug panel. But I wanted more .
Export-PSCredential
Hal Rottenberg has put together a very nice set of functions for exporting and importing PSCredential to a file. The export function takes a PSCredential and serializes it to an XML file. The corresponding import function reconstitutes the PSCredential to an object that you can use. Now before you start freaking out about security, the xml file can only be used by the same user account that created it.
What I like about this is that I can now have multiple credentials easily stored for different computers. I’m no longer tied to using one credential.
Managing Active Directory Sample Chapter
We’ve posted a sample chapter for Managing Active Directory with Windows PowerShell: TFM. There is also a Table of Contents if you want to see what how I’ve been spending my time.
Clean Temp With PowerShell
You would think that by now Windows and Windows applications would be much better about cleaning up temporary files. But no. It is amazing how many files I still see in my %TEMP% directory. I’ve always operated under the assumption that any file in %TEMP% that was created or earlier than the time I last booted up is fair game for deletion. I finally got around to using PowerShell for this management task.
Analyze-Packet
If you’ve been trying out the Get-Packet script you’ve seen that there is a great deal of information. I wanted an easy way to analyze the data so I put together a script called Analyze-Packet that will slice and dice a saved network trace and produce a summary report.
Managing Active Directory with Windows PowerShell: TFM — Coming soon
I finally finished the last of the tech editing for my new book. The material is now off for copy editing, indexing and publication. Want to know what I’ve been working on?
Get-Packet
A few days ago I blogged about packet sniffer PowerShell script. Needless to say I was intrigued and spent some time dissecting to better understand it. Don’t worry, no PowerShell scripts were harmed during this operation. This is a nifty piece of PowerShell coding. Of course I’m never one to leave well enough alone so I had to add a few touches which I hope the original author doesn’t mind.
PowerShell and Schrödinger’s cat
Powershell does not require you to declare variables. For a shell, that makes perfect sense because that would create too much overhead for simple one-off tasks. However, as soon as you start to develop more complex scripts, it is very important to know what scope your dynamically created variables have. Consider the following VBScript: Function […]