2016-01-13

Print Screen button on a Surface Type Cover

I really missed the Print Screen button on my Surface Pro Type Cover for a long time. Just recently I found out that it was there all the time :-(

[Fn] + [Space]

It can also be combined with other keys like [Alt] + [Fn] + [Space]

I have no idea what took me so long to figure it out ...

2016-01-01

Checking for reboots

Sometime we schedule reboots on a machine and would like to know the next day if the reboots were successful or not.

The easiest approach for me is to look for event log entries that show that the Event Log service was started.

This can be done by filtering inside the Event Log console but I prefer this PowerShell one-liner that checks for these entries during the past 24 hours:

Get-EventLog -After $(Get-Date).AddHours(-24) -EntryType Information -Source EventLog -LogName System | Where {$_.EventID -eq "6005"}

2015-11-19

Quick glance at PowerShell environment

Logging in to a new system and need to know what my PowerShell capabilities are.

To have a quick overview of what I can do on that box I do this:


Write-Host "Installed PowerShell version: $($PSVersionTable.PSVersion.Major).$($PSVersionTable.PSVersion.Minor)"
Write-Host "Available PowerShell modules:"
Get-Module -ListAvailable | Select Name



2015-11-16

Rename Active Directory groups with PowerShell

I was struggling with this one because there are several different name attributes for AD objects, name, DisplayName, SamAccountName, cn, etc.

I finally ended up with this solution which seems to rename all name attributes:


Import-Module ActiveDirectory

$TargetGroups = Get-ADGroup -Filter {Name -like "XXXDescription*"}

ForEach($SingleGroup in $TargetGroups)
{
    Write-Host "Old name: $($SingleGroup.Name)"
    $NewGroupName = $($SingleGroup.Name).Replace('XXXDescription','YYYYZZZZDescription')
    Write-Host "New name: $($NewGroupName)"
    Get-ADGroup $SingleGroup | Set-ADGroup -DisplayName $NewGroupName -SamAccountName $NewGroupName
    Get-ADGroup $SingleGroup | Rename-ADObject -NewName $NewGroupName
}
If there is a nicer solution, please feel free to post it in the comments.

2015-09-24

Ping servers from a text file

This may look very simple ... but it took me some time to figure out :-(

I am on a Linux box and have a text file with server names / IPs that I want to ping.

How can I do that in a one-liner?

Here is what helped me:

cat [path to textfile] | xargs -n1 ping -c 2


Now I am still looking for a PowerShell one-liner to do something similar.

If you know one, please let me know in the comments.

2015-09-02

Collect disk space data from remote servers

A little PowerShell Script that collects disk space data from remote servers.

I found this practical to collect statistical data.

###############################################################
_#####################
# This script counts and calculated available and free disk
_ spare on remote servers
# # A WMI query is used to collect the data # # Target servers and disks are in a separate comma-delimited
_ text file
###############################################################
_#####################
# Input file location $InputFile = "ServersAndDisks.txt" # Loop through each line of the input file ForEach ($Line in $(Get-Content $InputFile)) { # Write line data into an array $Data = $Line.Split(",") # Get the server name (always first element of the array) $ServerName = $Data[0] write-host $ServerName # Loop through the remaining elements of the array to find
_ available disks
For ($Count = 1; $Count -le $Data.GetUpperBound(0); $Count++) { # Get the disk name $Disk = $Data[$Count] # Run the WMI query $DiskInfo = Get-WmiObject Win32_LogicalDisk -ComputerName
_$ServerName
-Filter "DeviceID='$Disk'" # Do some math on the data $DiskTotal = [math]::Round($DiskInfo.Size / 1GB, 1) $DiskFree = [math]::Round($DiskInfo.FreeSpace / 1GB, 1) $PercentageFree = [math]::Round($DiskInfo.FreeSpace /
_$DiskInfo
.Size * 100, 1) # Output the results Write-Host "$Disk - $DiskTotal GB Total / $DiskFree GB free
_ ($PercentageFree %)"
} }


The input file ServersAndDisks.txt is very simple - only a comma-delimited file with server name and the disks I want to check:
server001,C:,D:
server002,C:,D:
server003,D:

2015-08-26

Fixing Windows 10 to run Firefox & Chrome after OS upgrade

Just upgraded from Windows 7 Home to Windows 10.

Firefox & Chome would not connect to the network.

Here is what helped me:
  1. Started elevated cmd
  2. Executed netsh winsock reset
  3. Rebooted

PS: I had to do this for each (local) user account  on the box.