six demon bag
Wind, fire, all that kind of thing!
VSS writers are application-specific components for Microsoft's Volume Shadow Copy Service, which ensure the consistency of application data when a shadow copy is created. That's quite useful for creating consistent backups of a system. However, some of these writers go into error states more or less frequently. And Microsoft did not deem it necessary to document how to reset writers without rebooting the entire system (or at least I didn't manage to find that piece of information).
Posted 20:41 [permalink]
Posted here, since the Fedora people apparently can't be bothered to fix their documentation.
In January 2016 I came across this question on StackOverflow, asking about an OutOfMemory error when validating the SHA256 checksum of a Fedora ISO image. The Fedora documentation suggested reading the full file and then calculating the checksum from the bytes:
Why anyone would even want to read an entire ISO image into memory for a checksum calculation is beyond me. The recommended way of doing this is to open the file as a stream and calculate the checksum on that stream:
Posted 00:53 [permalink]
If you have a
DataTable object in PowerShell and you want to persist that object as a file (and restore it back to a
DataTable object sometime later) the naïve approach would be to export the (tabular) data to a (tabular) CSV:
$dt | Export-Csv -Path 'C:\path\to\table.csv' -NoType
However, the problem with this approach is that you lose the type information for the columns of the datatable (the only type information saved by the
Export-Csv cmdlet is about the type of the objects representing the rows). Also, there's no simple way to restore the CSV back to a datatable.
Posted 17:01 [permalink]
Even for DB2 10.5 the official documentation says to use the
db2cmd command for a Command Line Processor enabled environment on Windows:
On Windows operating systems, db2cmd command opens the CLP-enabled DB2® window, and initializes the DB2 command line environment.
However, being able to use PowerShell instead of
db2cmd would be much nicer, since the former is far more versatile in practically every respect (control structures, output processing, file handling, etc.).
Posted 01:38 [permalink]
A while ago I had to take a couple hundred subnets (don't ask) of an Active Directory site in one domain and re-create them in another domain. Doing that manually would've been a real pain. But if you export the subnets to a file the list can easily be transferred to the other domain and imported there.
Posted 17:42 [permalink]
For a little PowerShell GUI (using Windows Forms) the requirement to drag & drop files into a listbox came up. Some quick googling showed several articles (like this one) suggesting to set
AllowDrop = $true and add a handler for the
Posted 19:18 [permalink]
Normally when you add a member to an Active Directory group you'll simply use the
Add-GroupMember cmdlet from the
ActiveDirectory module. Except when you have to do it across domains/forests where the source domain is still running Windows Server 2008 (not R2). As in "no AD PowerShell cmdlets" and "no Active Directory Web Service (ADWS)". *sigh*
Posted 18:25 [permalink]
Microsoft Office applications can be controlled from PowerShell in the same way they can be controlled from VBScript. Most of what was said in the previous article about translating VBA to VBScript applies to PowerShell as well, but there are some additional things to take care of due to the syntactical differences between PowerShell and the VB dialects.
Posted 16:30 [permalink]
Sometimes when you try to change the PowerShell execution policy you'll get an error message that the setting was applied, but will be overridden by a setting in another scope:
Set-ExecutionPolicy : Windows PowerShell updated your execution policy successfully, but the setting is overridden by a policy defined at a more specific scope. Due to the override, your shell will retain its current effective execution policy of XXX. …
Execution policies can be defined in five different scopes, from
LocalMachine (least specific) to
MachinePolicy (most specific), where settings in more specific scopes take precedence over settings in less specific scopes. Use
Get-ExecutionPolicy -List to see which scope has which setting.
Posted 22:46 [permalink]
Recently I had the need to compare the ACLs of two Active
Directory objects. With file ACLs I could expand their
properties and compare the resulting lists with
Compare-Object. However, for
ACLs of Active Directory objects that didn't work, so I came up with
the following function.
Posted 18:50 [permalink]
At work we're connecting to customer systems through a jump station. This creates the problem that for domain password changes on the customer systems I can't open the Windows Security dialog/screen via either Ctrl+Alt+Del (shows the one on the local computer) or Ctrl+Alt+End (shows the one on the jump station).
Posted 23:14 [permalink]
We're using Microsoft Lync 2010 at work, and I find it quite annoying that the software keeps resetting my status to "available" when I don't want it to. So I started looking for a way to automate setting the status back to "busy".
Unfortunately the normal Lync installation doesn't seem to include a PowerShell module. There is, however, a .Net assembly included with the Lync SDK (this article describes the details). Having to install Visual Studio, SQL Server Express and the Silverlight 4 Tools seemed a little overkill to me, though.
Posted 21:46 [permalink]
Share migration is a common (if not integral) part of a file server migration. If you just move the shares from one host to another host the process is pretty straightforward as described in MSKB article 125996:
[HKLM\SYSTEM\CurrentControlSet\Services\LanmanServer\Shares]on the old file server to a file:
reg export HKLM\SYSTEM\CurrentControlSet\Services\LanmanServer\Shares shares.reg
Copy the file to the new file server and import it:
reg import shares.reg
net stop server && net start server
Posted 21:09 [permalink]
As a sysadmin I frequently have the need to get an overview of the utilization of particular system resources (disk space or memory for instance). Visualizing the numbers greatly helps with spotting bottlenecks.
One way to visualize data with PowerShell are
objects in Windows Forms, which are rather versatile, but not exactly what I
would consider straightforward. They also might be overkill for various tasks.
The current usage of a system resource for instance could easily be displayed
with a bar graph in a text console.
Posted 23:38 [permalink]
As a system administrator you're sometimes tasked with finding out who the last person logged into a particular computer was, or when a particular person was last logged in on some computer(s).
Windows records this information in the Security eventlog when you enable auditing account logon events.
Posted 16:03 [permalink]
List DFS replication groups:
dfsradmin rg list
List replicated folders in a replication group:
dfsradmin rf list /rgname:<REPL_GROUP>
Posted 15:16 [permalink]
Internet Explorer exposes a COM object that can be controlled programmatically e.g. from a VBScript. The usual way is to create a new Internet Explorer instance and work with that:
Set ie = CreateObject("InternetExplorer.Application")
However, sometimes you may want to use an already running instance instead of creating a new one.
Posted 20:59 [permalink]