Inside the PowerShell console, you can hold CTRL while pressing the arrow key to move the cursor word-by-word. This way, you can move the cursor...
database-tools
Change Service Start Mode the PowerShell Way
When you list services with Get-Service, you will find that a lot of properties may seem to be missing. You can still set such properties when you...
Change Service Startmode
You can use WMI like this if you want to change a service start mode: ([wmi]'Win32_Service.Name="Spooler"').ChangeStartMode('Automatic').ReturnValue...
Determining Service Start Modes
By using WMI, you can enumerate the start mode that you want your services to use. To get a list of all services, try this: Get-WMIObject...
Print All PDF Files in Folders
Try this one-liner if you need to print out all PDF documents you have stored in one folder: Dir c:\myfolder\*.pdf | Foreach-Object { Start-Process...
Store Pictures in Active Directory
When you need to store a picture into an AD account, the picture will have to be converted to byte values before it can be stored. Just make sure...
Per-database information in performance_schema, please!
This is a follow-up om my first Blog on performance_schema that appeared here: One particular request that we had frequently from our users is to...
FLUSH STATUS surprise?
What does FLUSH STATUS do? We all know that it will simply reset all status variables (except for 'uptime') to same values as immediately...
Finding IP and MAC address
When you query network adapters with WMI, it is not easy to find the active network card. To find the network card(s) that are currently connected...
Turning Multi-Value WMI Properties into Text
When you read multi-valued information from WMI or any other source, for example, network adapter IP addresses, this information is returned as a...
Finding Network Adapter Data Based On Connection Name
Sometimes it would be nice to be able to access network adapter configuration based on the name of that adapter as it appears in your network and...
Performance_schema considerations.
I have for the first time been spending some time trying to understand the performance_schema. It is not easy to understand everything unless you...
Creating Excel Reports from PowerShell Data
Provided you have Microsoft Excel installed, here is a clever function that you can use to convert PowerShell results into Excel spreadsheets:...
Outputting Text Reports without Truncating
If you want to capture PowerShell results in a text file, you can redirect the results or pipe them to Out-File. In any case, what you capture is...
Turning SIDs into Real Names
Sometimes, you'd like to turn security identifiers (SIDs) into real names. Here is a function that can do this for you: function SID2Name($sid){...
Converting User Names to SIDs
If you want to translate a valid user name to its security identifier (SID), here is a function to do that for you: function Name2SID($name,...
Changing Units
When you list folder contents, file sizes are in bytes. If you'd rather like to view them in MB or GB, you can use calculated properties, but by...
Closing Excel Gracefully
When you access Microsoft Excel from script, you may have noticed that it never gets removed from memory again, even if you call its Quit() method:...
Setting per-server thresholds in Monyog.
Please note that this blog was updated on April 5th 2012. We have added(at the buttom) how to use server TAGS for defining thresholds....
Formatting Currencies
Formatting numbers as currencies is straight-forward - as long as it is your own currency format: '{0:C}' -f 12.22 If you want to output...
Using Regular Expressions with Dir
When you use Dir (alias: Get-ChildItem) to list folder contents, you can use simple wildcards but they do not give you much control. A much more...
Permanently Changing User Environment Variables
To create or change an environment variable in the user context, use this low-level call: [environment]::SetEnvironmentVariable('Test',...
Using Wildcards with Environment Variables
You can use the env: PowerShell drive to list all Windows environment variables like this: PS> Dir env:*user* Name Value ---- ----- USERNAME...
Creating PowerShell Menus
PowerShell is console based, so its default menus are console based as well. To offer choices to your users, here is some sample code to create a...