Latest Posts
  • Power Tips: Converting UNIX Time to DateTime

    “Unix time” counts the seconds that have passed since 01/01/1970.

    For example, in Windows, you can read the installation date from the Windows Registry, and the returned value is “Unix time”:

    $values = Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion'…
  • Power Tips: Creating Dynamic Parameters

    Dynamic parameters are a special breed of parameters that can be shown or hidden based on runtime conditions. Your PowerShell functions could for example have just one parameter called -Action, and based on the action the user chooses, additional parameters would show. Or, you could have parameters show…

  • Power Tips: Turning Text into Individual Lines (Part 3)

    In the previous tip we split a chunk of multi-line text into individual lines and removed any empty lines.

    However, when a line isn’t really empty but contains whitespace (spaces or tabulators), it is still returned:

    # $data is a single string and contains blank lines
    $data = @'
  • Power Tips: Turning Text into Individual Lines (Part 2)

    Let’s assume your script gets text input data, and you need to split the text into individual lines. In the previous tip we suggested a number of regular expressions to do the job. But what if the input text contains blank lines?

    # $data is a single string and contains blank lines
    $data = @'…
  • Power Tips: Turning Text into Individual Lines (Part 1)

    Occasionally, you need to process multi-line text line by line. Here is an example of a multi-line string to start with:

    # working with 1-dimensional input
    # $data is a single string
    $data = @'

    An efficient way to split the text…

  • Power Tips: Taking Screenshot

    With types found in System.Windows.Forms, PowerShell can easily capture your screen and save the screenshot to a file. The code below captures your entire virtual screen, saves the screenshot to file, then opens the bitmap file in the associated program (if any):

    $Path = "$Env:temp\screenshot.b…
  • Power Tips: Disabling Local “Guest” Account

    Windows comes with the built-in account called “Guest”. Since this account is seldomly used, you may want to disable it. Else, its well-known name could serve as a vector for attackers.

    Since the account name is localized and can slightly vary from culture to culture, to identify the account…

  • Power Tips: Renaming Local Administrator Account

    For security reasons, you may want to consider renaming the built-in local Administrator account. This account is very powerful, and its name is easily guessable so it is a common vector for attackers. Before you rename this account, make sure you understand the consequences:

    • The account continues to…
  • Power Tips: Identifying Local Administrators Group

    Any member of the built-in Administrators group has access to extensive privileges, so checking the members of this group can be part of a security audit. While the “Administrators” group exists by default, its name can vary from culture to culture because it is localized. On German systems, for example…

  • Power Tips: Identifying Local Administrator Account

    There are a few default accounts on Windows machines such as the local “Administrator” account. While this account exists by default, its name can vary from culture to culture, and its name can also be renamed.

    To always identify the local Administrator account regardless of its name, search…