Basic Powershell commands

On this page some simple but useful Powershell commands are shown. These commands are the basics of the usage of Powershell.

To search all Powershell cmdlets for a keyword the ‘Get-Command’ command can be used. The ‘Get-Command’ can be abbreviated to ‘gcm’. To search for all commands that contain the word ‘network’ you can use the following commands.



It is also possible to serach within a specific module. To search in the NetTCPIP module the following command can be used:


If you need to know more about a specific cmdlets you can use the ‘Get-Help’ command followed by the command you want to have more information about.


If you want to know the details of an cmdlet the ‘Get-Member’ command can be used. If you for example want to know what information can be shown with the ‘Get-Process’ command the following command can be used:


Within an output you can search for a specific value. To search for specific values you can use the ‘Where-Oject’ command. In this example we search for all processes named MMC.


The first thing the code is doing is getting a list of processes on our computer and passing the output (using the | character) to our Where-Object cmdlet. The cmdlet takes a script block as a parameter. The script block instructs the Where-Object cmdlets to only select objects where their name parameter is equal to ‘mmc’. The result is a list of the MMC instances that are running.

To stop all the instances of MMC that are running you can pipe the output to a ‘Stop-Process’ command.


Delen via: Facebooktwittergoogle_pluspinterestlinkedinmail

Basic SQL commands

On this page some simple but useful SQL commands are shown.

Check all sysadmins on a SQL node:

Sometimes after a restore a login is not working, to fix use the following command:

Force take database offline:

ALTER DATABASE failed because a lock could not be placed on database error. If you get this error run the upper line and kill the SPID that is connected to the database.

Check open connections to databases

Check if full search is installed on SQL server

Delen via: Facebooktwittergoogle_pluspinterestlinkedinmail

Check Microsoft SQL Availailbity Group database failover status

With the following script databases in an Microsoft Availability Group cluster can be checked if they are failover ready. Run this script at all the SQL nodes that are past of the Availability Group. When the statys is displayed ‘1’ the database is ready for an failover.


Delen via: Facebooktwittergoogle_pluspinterestlinkedinmail

Memory usage per Microsoft SQL database

The following script can be used to determine the memory usage per database:



Delen via: Facebooktwittergoogle_pluspinterestlinkedinmail