Archive | Discovery RSS for this section

PowerShell: Improved .bat file

Discovery

I found a great article that describes a great .bat file for running a PowerShelll script!

Read More…

PowerShell: Check if credentials are valid

Discovery

When I was trying to configure a scheduled task to use a specific service account the task manager did not want to accept my service account credentials.
I wanted a quick way to find out if the credentials I was using where correct. Some quick browsing on the web lead me to this.
Read More…

PowerShell: Using .bat file

Discovery

The one thing I always loved about .bat files is that you can just double click them.
So I use them to run my scripts for actions I use often.

Read More…

Test GPO WMI filter using Powershell

Very useful when setting up new wmi filters.

Soyka's Blog

GPO WMI filters can get screwed up when edited. Quick way of testing a WMI filter is available using Powershell:

  1. Grab the GPO WMI filter from GPMC and put it into clipboard
  2. in Powershell console:
    gwmi -Query ‘Paste your WMI filter here’
    in words:
    write gwmi -Query ‘ (single qoute)
    paste in your wmi filter
    ‘ (single qoute) 

Result could look like this:
gwmi -Query ‘SELECT ProductType, CSName FROM Win32_OperatingSystem WHERE (ProductType = “1”) AND Not CSName = “CB002021”)

When any results are returned WMI filter evaluates to $true (GPO applies), else $false (GPO does not aplly)

Don’t forget that you get the luxury to test against multiple computer just by adding the -Computername parameter:

gwmi -Query ‘SELECT ProductType, CSName FROM Win32_OperatingSystem WHERE (ProductType = “1”) AND Not CSName = “CB002021”)‘ -Computername PC01,PC02

View original post

Windows CLI: SqlCmd

Discovery

While trying to run a Transaction SQL command on a Microsoft SQL Express database I had trouble connecting to it using my SQL Server Management Studio on my local machine. While browsing the world wide web and some help files I found this.

Read More…

PowerShell: Convert String to DateTime and vise versa

Discovery

For the hundredth time I Googled how to convert String to DateTime.
It’s time I put it in my memory extension.

Read More…

PowerShell: Replace special characters

Discovery

While browsing the interwebs I came across a neat little trick (on Martin Zugec blog):
[System.Text.RegularExpressions.Regex]::Replace($Text,"[^1-9a-zA-Z_]"," ")

Read More…