Category Archives: Powershell

Powershell Hash and Arrays

Two ways of making a table of hash tables and arrays.

Posted in Powershell | Comments Off on Powershell Hash and Arrays

Powershell – Path and filename

Some simple examples on how to get filename and folder out of a path with powershell and .Net

Posted in Powershell | Comments Off on Powershell – Path and filename

Check local certificate store for expired certificate

This script looks inside local machine certificate store for expired certificates. If found, it writes to the event log.

Posted in Powershell, Uncategorized | Comments Off on Check local certificate store for expired certificate

Search inside Powershell scripts

Posted in Powershell | Comments Off on Search inside Powershell scripts

Pass variables to Invoke-Command

Invoke-Command -ComputerName $Server -Credential $Creds -ArgumentList $Password -ScriptBlock {Param($Password) Write-Host $Password}

Posted in Powershell | Comments Off on Pass variables to Invoke-Command

Signera powershellscript

#Här väljer du om du vill hämta certet från Store eller från fil, kommentera bort det som du vill använda. #För att hämta ut certifikatets thumbprint körs enklast #Dir Cert:CurrentUser/My $Cert=(dir Cert:CurrentUser\My\673B9FB4FB236E5667AA17886B348DABD4C036) #$Cert = Get-PfxCertificate ‘C:\Temp\CodeSigningCertificate.pfx’ #Timestamp används för att … Continue reading

Posted in Powershell | Comments Off on Signera powershellscript

How to make a simple delayed start for a Powershell script

This is a simple script to make a delayed start for a Powershell script. $Start = “07:00” Write-Host “Waiting for the time to be $Start” Do { Start-Sleep -Seconds 60 $Time = Get-Date -UFormat %H:%M } Until ($Time -eq $Start) … Continue reading

Posted in Powershell | Tagged , | Comments Off on How to make a simple delayed start for a Powershell script

Run Powershell scripts as a Scheduled Task in Windows 2008R2

There is probobly thousands of ways you can do this and this is one of them. You must specify the Powershell script as an argument to Powershell.exe Se example In this case the executable is Powershell.exe and the arugment is … Continue reading

Posted in Powershell | Tagged , | Comments Off on Run Powershell scripts as a Scheduled Task in Windows 2008R2

Howto give a Domain User access to Domain Controller logs

If you try to get the Security Eventlog from a Domain Controller by using the Get-Eventlog in Powershell you get the error “Requested registry access is not allowed” In Windows 2008 and 2008 R2 there is a builtin groups called … Continue reading

Posted in Active Directory, Powershell | Comments Off on Howto give a Domain User access to Domain Controller logs

Import/Load modules in Powershell

There are a number of modules that ca be loaded into Powershell. List all available unloaded modules Get-Module -ListAvailable To load a module, use the Import-Module cmdlet Examples Active Directory Import-Module activedirectory Group Policy Objects Import-Module grouppolicy Quest Active Roles Add-Pssnapin … Continue reading

Posted in Powershell | Tagged , | Comments Off on Import/Load modules in Powershell