PowerShell Date Time

To play with Date and Time with PowerShell, the main Cmdlet to use is Get-Date. TechNet: https://technet.microsoft.com/en-us/library/hh849887.aspx The Get-Date cmdlet gets a DateTime object that represents the current date or a date that you specify. It can format the date and time in several Windows and UNIX formats. You can use Get-Date to generate a … Read more

Remove “Users” Group from ACL

This script allows to remove the “Users” Group from the Access Control List (ACL) of a file or folder. First, the NTFS rights inheritance is removed, then the “Users” group is removed from ACL. To play with ACL, the Cmdlet to use is the following: Get-Acl TechNet: https://technet.microsoft.com/fr-fr/library/hh849802.aspx The Get-Acl cmdlet gets objects that represent … Read more

Check Hotfix with PowerShell

This script allows to check if a KB (Hotfix) is installed on a machine. The Cmdlet to use is Get-Hotfix. The Get-Hotfix cmdlet gets hotfixes (also called updates) that have been installed on either the local computer (or on specified remote computers) by Windows Update, Microsoft Update, or Windows Server Update Services; the cmdlet also … Read more

PowerShell Usual Commands

Here is a memento of several useful commands in PowerShell (check files, folders and registry, create or delete files and folders, run executables with or without arguments, displaying MsgBox…). Here is the TechNet listing the standard CmdLets: https://technet.microsoft.com/en-us/library/hh848794.aspx There are only few commands for the time being, but this article will be updated progressively. . Check … Read more

Send Variable to SCCM Task Sequence

In this example, we launch the command cctk.exe –tpm If the result is equal to “tpm=on”, $TPMvalue variable is set to “on”, else $TPMvalue variable is set to “off” tpm variable is send to the task sequence with the value of $TPMvalue To retrieve the information in the Task Sequence, use the variable “tpm” (value … Read more

PowerShell and Strings

Here is a memento of several ways to play with strings in PowerShell. Insert Double Quote and ASCII codes Return a specified number of characters   Insert Double Quotes and ASCII Codes To insert double quotes in a string, the following ASCII code can be used: [char]34 ASCII codes can be inserted like follow: $([char]34) … Read more

PADT – Registry

PowerShell Application Deployment Toolkit is a tool very powerful to manage the registry: Adding, modifying, deleting registry keys and registry values Adding HKEY CURRENT USER registry entries for all existing user profiles + default user, to avoid Active Setup Modifying the value of environment variables (for example the PATH environment variable)   1. Import REG … Read more

PADT – System Commands

PowerShell Application Deployment Toolkit is a tool very powerful to manage systems: Silent install commands Start or stop services Kill processes Wait a process not existing anymore before continuing Manage scheduled tasks Environment variables There are many possibilities, not forgetting that all old batch commands are compatible with PowerShell too. Here is a memento of … Read more

PADT – MSIEXEC

PowerShell Application Deployment Toolkit is a tool very powerful to use MSIEXEC: Installing using MSI Installing using MSI with MST Patching using MSP Uninstalling… Log files are created in the same folder as the log file of the main script.The log folder is defined in the file AppDeployToolkit\AppDeployToolkitConfig.xml. For example: <Toolkit_LogPath>$envSystemDrive\Logs</Toolkit_LogPath>   MSI MSI must be … Read more