six demon bag
Wind, fire, all that kind of thing!
Sometimes a situation arises where an SQL Server instance comes back up with a database tagged as "suspect". Apparently there is a number of possible causes for this, like transaction log corruption, insufficient memory or disk space, or unexpected shutdowns due to hardware or power failure. In our case the reason was probably a hardware failure, since the database resides on an iSCSI volume, and we were making changes to our iSCSI network. And to make things a little bit more interesting, our
msdb database just had to be among the affected databases.
Posted 19:07 [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]
API documentation is nice, and being able to generate it from the code is even nicer. However, unlike Perl, Python, Java, or several other languages, VBScript doesn't have a feature or tool that supports this. Which kinda sucks.
I tried VBDOX, but didn't find usability or results too convincing. I also tried doxygen by adapting Basti Grembowietz' Visual Basic doxygen filter. However, doxygen does a lot of things I don't actually need, and I didn't manage to make it do some of the things I do need. Thus I ended up writing my own VBScript documentation generator.
Posted 19:18 [permalink]
Today I had a rather curious problem on my fileserver. I noticed that its system time was behind the clock, but when I tried to manually synchronize it with my timeserver,
ntpdate failed with the error message "Leap not in sync".
Posted 21:40 [permalink]
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 12:23 [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]
I finally got around to adding a style for mobile devices to this thing. Since I already do all the formatting via CSS, applying responsive design boiled down to adding a media query for devices with a given minimum screen width, and fine-tuning several values in the stylesheets. While doing that I ran into a weird problem, though.
Posted 16:59 [permalink]
VBScript arrays can be created with fixed or dynamic size. Fixed size arrays are rather straightforward. Define
Dim var(4) and you have an array variable
var with 5 elements (indexes 0 through 4). Unfortunately dynamic arrays aren't quite as simple.
Posted 18:26 [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]
SeaMonkey is my preferred web browser, because I'm quite comfortable with its user interface. However, some of my favorite extensions (namely text/plain and ReloadEvery) claim to be incompatible when trying to install them, although they actually work just fine with SeaMonkey. Here's how you can convince an extension that SeaMonkey is totally fine for installation.
Posted 19:58 [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]
Since I'm seeing lots of questions like "how can I do FOO in Excel/Word/... with VBScript" I thought I'd post some guidelines on how to approach this kind of task.
In general, VBA and VBScript are quite similar, so most of the time you're better off recording a VBA macro and translate that to VBScript than writing the whole thing in VBScript from the get go. There are some notable differences between the two languages, though, which you need to observe when translating VBA to VBScript.
Posted 15:26 [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]
Recently I encountered a rather weird problem with the cleanup of backups of some of our DB2 databases. The database backups are done via TSM by running the following command:
db2 "backup db DBNAME online use tsm"
Cleanup of obsolete backups is done by running the following commands via a scheduled task.
db2adutl delete full older than TIMESTAMP db DBNAME without prompting db2adutl delete logs between S0000000.LOG and S(xxxxxxx-1).LOG db DBNAME without prompting db2 "connect to DBNAME" db2 "prune history DATE and delete" db2 "prune logfile prior to Sxxxxxxx.LOG" db2 "connect reset"
Sxxxxxxx.LOG is the oldest log of the oldest backup to be kept, which is extracted from the output of
db2adutl query full db DBNAME.
S(xxxxxxx-1).LOG is that log number minus one.
Although this setup had been working for several years without problems and no changes were made to the system, the log cleanup step suddenly started to fail for some databases while it still worked fine for the others.
Posted 21:10 [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]
When setting up RedHat Enterprise Linux (RHEL) or CentOS systems I always find it handy to have a local repository with the RPMs from the install media. On hosts without Internet connection it saves me the trouble of having to shuffle install media around whenever I need to install an additional package after the system was initially set up. Even if the host is configured to use an online repository, keeping a local repository doesn't hurt except for a little extra disk space, which is cheap enough these days.
Posted 16:30 [permalink]