Windows Live Photo Gallery database location

%userprofile%\AppData\Local\Microsoft\Windows Live Photo Gallery

To clear the database, close the program and remove all files under here.

Posted in Windows | Comments Off on Windows Live Photo Gallery database location

Active Directory performance counters, Security System-Wide Statistics

Problem:
You cannot see the counterset “Security System-Wide Statistics” with powershell when you run the command Get-Counter -ListSet “Security System-Wide Statistics”

Or when you run the “Get-Counter “\Security System-Wide Statistics\Kerberos Authentications” you get “Internal performance counter API call failed. Error: c0000bb8”

Soloution:
Start powershell.exe with Run asAdministrator. The UAC prevents the ListSet from being displayed.

Posted in Active Directory, Performance | Comments Off on Active Directory performance counters, Security System-Wide Statistics

Autoenrollment is not working.

Problem:
Group Policy says that autoenrollment is switched on but the autoenrollment function is not working. None of your Root, Issuing or Machine certificates are enrolled.

If you try to trigger the autoenrollment process you get an error.
certutil -pulse
CertUtil: -pulse command FAILED: 0x80070002 (WIN32: 2)
CertUtil: The system cannot find the file specified.

Problem:
In som cases this is due to a folder missing. Check if the folder C:\Windows\System32\Logfiles\Scm exists. If not create it and restart the computer

 

Posted in PKI, Windows | Comments Off on Autoenrollment is not working.

Set proxy for machine account

netsh winhttp set proxy proxy.domain.com:8080 “*.domain.com;*.domain2.com”

Posted in Windows | Comments Off on Set proxy for machine account

Test network ports with Powershell

#Create socket object
$Socket = New-Object Net.Sockets.TcpClient
 
#Connect
$Socket.Connect("172.22.2.10", "8888")
 
#Check if connected
$Socket.Connected
 
#Close connection
$Socket.Dispose()
Posted in Network | Comments Off on Test network ports with Powershell

Base64 encoding with certutil

Encode
certutil -encode inputFileName encodedOutputFileName

Decode
certutil -decode encodedInputFileName OutputFileName

Posted in PKI | Comments Off on Base64 encoding with certutil

Smartcard – Force reading all certificates on smartcard

[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\SmartCardCredentialProvider]
“ForceReadingAllCertificates”=dword:00000001 

Posted in PKI, Windows | Comments Off on Smartcard – Force reading all certificates on smartcard

Powershell Hash and Arrays

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

#Alt1
$Array = New-Object System.Collections.ArrayList
#Foreach ()
{
	$Hash = New-Object -TypeName PSObject -Property @{
	    Status = "Ok"
	    DisplayName = "Test"
 
	}
$Array.Add($Hash) | Out-Null
Remove-Variable $Hash -ErrorAction SilentlyContinue
#} 
$Array | Out-GridView
 
 
#Alt2
$Array = New-Object System.Collections.ArrayList
$Hash = New-Object PSObject
#Foreach ()
#{
$Hash | Add-Member -NotePropertyName "Status" -NotePropertyValue "Ok"
$Hash | Add-Member -NotePropertyName "DisplayName" -NotePropertyValue "Test"
$Array.Add($Hash)
Remove-Variable Has -ErrorAction SilentlyContinue
#}
 
$Hash | Out-GridView
Posted in Powershell | Comments Off on Powershell Hash and Arrays

Powershell – Path and filename

[io.path]::GetFileNameWithoutExtension("c:\temp\myfile.txt")
[io.path]::GetDirectoryName("c:\temp\myfile.txt")
[io.path]::GetTempPath()
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.

$ThresholdWarning = "60"   #Set warning date  
$ThresholdError = "30"   #Set error date  
New-EventLog -Source PKI -LogName Application -ErrorAction:SilentlyContinue
$Certs = (Get-ChildItem Cert:\LocalMachine\My)
Foreach ($Cert in $Certs){  
	If ($($Cert.Subject) -notlike "*OU=Servrar, DC=domain, DC=se"){
		$Day = $($Cert.NotAfter - (Get-Date)).Days 
        $Message =  "$($cert.Subject)`n$($cert.Issuer)`n$($cert.NotAfter) `nExpires in $Day Days" 
		If ($Day -le $ThresholdError){
			Write-Eventlog -computername LocalHost -Logname 'Application' -source PKI -eventID 100 -EntryType Error -message $Message -Category 4
			#Write-Host "ERROR! `n$Message" #Debug only
			}
		ElseIf ($Day -le $ThresholdWarning){
			Write-Eventlog -computername LocalHost -Logname 'Application' -source PKI -eventID 100 -EntryType Warning -message $Message -Category 4
			#Write-Host "WARNING! `n$Message" #Debug only
			}
        }
	}
Posted in Powershell, Uncategorized | Comments Off on Check local certificate store for expired certificate