Work
Brocade Clone Config
by dwarfsoft on Jun.22, 2015, under Scripting, Storage, Uncategorized, Work
I was attempting to get a cloned configuration on Brocade switches as part of a PowerShell script that is adding Aliases and Zones to the Active Config. The original code that created the tasks to be run on the Brocade switch required 2 separate calls to PLINK in order to get all its information. The first was a call to cfgactvshow, and the second was a call to alishow. I knew there had to be a better way, so I developed the following one liner for cloning the active zone configuration based on our standard rules:
zoneobjectcopy "`cfg=\`cfgactvshow|grep "cfg:"\`;echo ${cfg:6}\", \"${cfg:6}_\`date +\"%Y%m%d%H%M%S\"\``" |
Windows Disk LUN WWID
by dwarfsoft on Aug.28, 2014, under Scripting, Storage, Tweet, Work
One of my main issues with attempting to identify storage on Windows Systems is that the Bus/LUN Id can be stored in multiple places, and trying to track that back to a Volume is pretty hard. So after doing some fairly deep investigation into DeviceIOControl calls to query Page 80 (Device information such as Vendor and type) and Page 83 (which returns the WWID object) I have managed to wrangle the C# into a Type usable from a PowerShell Script.
What is a WWID?
Start-iseTranscript
by dwarfsoft on Jul.15, 2014, under Scripting, Tweet, Work
I finally got around to fixing one of my biggest bugbears in PowerShell ISE 2.0, and when I did so I found on our new management server that it was broken for PowerShell ISE 4.0. I’m talking about Command Transcription. One of the most useful things I use in my day to day work is Start-Transcript for the standard PowerShell Shell. I have it automatically start in my PowerShell Profile so I can always go back and find how I achieved a particular goal.
I don’t use PowerShell ISE often, but when I do it’s usually because I am researching how to get something to work, or doing a colorized copy of the code for documentation purposes. For a long time I was happy enough with the suggested “Start-iseTranscript” provided by the Scripting Guy Blog.
Network Interface Removal and Renaming
by dwarfsoft on Dec.09, 2012, under Drivers, Scripting, Tweet, Work
So we had some Blade Chassis and implemented some Firmware upgrades. Surely this should not impact the blades themselves, or the OS on which they run? You’ve got to be kidding right. As soon as the Blade Chassis firmware has been upgraded we lost all four Broadcom NICs, and we had four new Broadcom NICs added in their place. This means that any IP Configuration has been lost and so has, in our case, Team configuration. Due to the four original NICs being removed, their Connection Names have also become unusable, because there are hidden devices that are still using those names.
Firstly, how do we remove devices via PowerShell. The Answer can be found on any Windows 7 workstation in the C:\Windows\Diagnostics\System\Device\CL_Utility.ps1. There is a function there called RemoveDevice.
Word.Application Trolling in PowerShell
by dwarfsoft on Nov.21, 2012, under Scripting, Work
I’ve been doing a little bit of investigation into OneNote and Word in PowerShell. So after this I got around to thinking of some of the mischievous things that could be achieved with some of the things I’ve learned… Like enumerating all documents, and in those documents enumerating all sentences, and then providing a 1% opportunity to replace its Font with Wingdings.
The following script demonstrates managing multiple threads, and managing the closure of those threads/jobs once they are complete. I’ve tested this on my C:\Temp folder with a number of documents in it, and the results are as expected. It provides some amusing opportunities for trolling.
PowerCLI – Virtual Machine Disk Usage Report
by dwarfsoft on Oct.25, 2012, under Scripting, Work
So, this is one of my largest PowerCLI/PowerShell scripts. This maps for each Virtual Machine, every Disk that is attached and trace back to what the LUN ID is that the disk is stored on, be it a VMDK, Thick/Thin provisioned disk, Physical/Virtual mode RDM, etc.
For the moment I will just paste the script as it stands, but I hope to return and explain some of the components.
NIC Bind Order for Microsoft Failover Cluster Virtual Adapter
by dwarfsoft on Oct.24, 2012, under Scripting, Work
I’ve been busy working on a project that is implementing a SQL Geo-Cluster. One of the requirements was to modify the NIC bind order such that the order of preference is Production,Heartbeat,…,Microsoft Failover Cluster Virtual Adapter. Most of this can be achieved through the Network Adapter Advanced Configuration window (Start->run->ncpa.cpl->Advanced Menu->Advanced Settings…) but the Microsoft Failover Cluster Virtual Adapter is a Hidden adapter and needs to be handled separately.
The original Suggestion from the Design document is to run “wmic nicconfig get description,settingid”. This list is used to get the SettingId of the NIC where the description is “Microsoft Failover Cluster Virtual Adapter”. The SettingId is then checked and moved in HKLM\SYSTEM\CurrentControlSet\services\tcpip\Linkage\Bind. The line in the Multi String that equals “\Device\” needs to be moved to the last line.
PowerShell Profile and Global Functions
by dwarfsoft on Jul.16, 2012, under Scripting, Work
So I came across an interesting problem today while trying to dynamically load Functions using a Load-Lib function. The issue was that Loading a Script within a function means that the functions defined within that File are only defined within the Scope of the loading function. The two ways around this are to Define every Function like:
Function Global:Load-Lib { ... |
Personally, I wanted my script to be the same whether I was loading it as a Global Module, or locally within a Function. In order to get the behaviour I wanted I had to redefine the functions as Global dynamically. This idea would also resolve the other issue I had: Redefining functions did not seem to always overwrite or replace the existing function code.
SEP11 Scan Logs
by dwarfsoft on Mar.03, 2011, under Scripting, Tweet, Work
I will start out by simply stating how much I HATE SEP11, and how it handles client scan logs. For some reason there is NO way of getting a client scan log out of the Central Management Console. The whole point of Central Management is being able to … manage CENTRALLY.
Anyway, enough rant. I wrote a batch file to pull the latest (or specified) log file from a list of servers (in a file called Servers.txt). More Source: (continue reading…)
SYSTEM Account Permissions
by dwarfsoft on May.25, 2010, under Novell, Scripting, Tweet, Work
Recently I have been working on some rather complicated projects preparing our SOE to move from Novell eDirectory to an Active Directory environment. One of the packages I built was required to run periodically and so I set up a Scheduled Task to accomplish this. Rather than introduce a security risk by creating a new Administrator Account I just created the scheduled task to run as the local SYSTEM account. It turns out that the SYSTEM account does not have as much access as I required, especially when managing user registry hives.
After quite some time looking in to how to achieve my goal I came up with a rather simple, yet ultimately hacky, solution. Give the SYSTEM Account Administrative Privileges.