dinsdag 4 oktober 2016

Correct CSV Owner node

In my case not all CSV Lun’s had the right owners, I had 2 LUN’s with only 1 owner. In a cluster every Hyper-v node needs to be an owner of all CSV’s in the cluster, to check this run command below

Get-ClusterSharedVolume -Cluster clustername | Get-ClusterOwnerNode

Output:



To correct it run in a admin powershell:
Set-ClusterownerNode -Cluster "clustername" -Owners "Hyper-v01"," Hyper-v02"," Hyper-v03"," Hyper-v04” -Resource "Cluster Disk 2"


Check it again, et voila!

Performance counters server

Sometimes performance counters are not working.

You can fix this, do the following:
In a admin dos box:
C:\WINDOWS\System32\lodctr /r

To check  which counters are enabled:

lodctr /q

To enable a counter:

lodctr /e:Performance Counters



dinsdag 20 september 2016

Remove recovery type snapshot Hyper-V

Soms komt het voor dat een backup pakket een snapshot laat staan van een Hyper-v Machine, dit kan verschillende oorzaken hebben, als je deze weg wilt halen dan kan dit helaas niet via de GUI.
Je zult hiervoor met powershell aan de slag moeten, ga naar de Hyper-v node waar de VM op draait, en start een powershell CLI.
 
Vraag eerst de VM op en welke snapshot er nog staat: Get-VMSnapshot -VMName (naam vm)
 
 
Zoals je ziet staat er een recovery type snapshot, om deze weg te krijgen gebruik je het volgende commando:
 
Get-VMSnapshot -VMName (naam vm) | Remove-VMSnapshot
 
Je kunt nu binnen Hyper-v Manager zien dat er een merge in process is en check nadat deze klaar is of de disken netjes weer terug in 1 VHDX staan i.p.v. AVHDX.
 

 

donderdag 7 april 2016

Test-NetConnection

To check if a port is open without installing telnet ;-)
 
Test-NetConnection –Computername [computername] –Port [port]
 
 

GPO Back-up Script All

This Script makes a back-up of all GPO’s in your forest incl. child domains.
Make sure you have the folders in place and have enough admin rights! Als check the Environment settings for your own needs.
 
# --------------------------------------------------------------
# Script: Create_Backup_GPO_All_V2.ps1
# Author: Bart Michel
# Date: 06-04-2016
# This script makes a backup of all the GPO's in the domain
# --------------------------------------------------------------
 
#Environment settings
$Enddate = (Get-Date).tostring("ddMMyyyyHHmm")
$Destination = "C:\Scripts\Backup_GPO\GPO_Backup_$Enddate.zip"
$Source = "C:\Scripts\GPO"
$Backupfolder = "C:\Scripts\Backup_GPO\"
$BackupsToKeep = "10"
$CurrentDate = Get-Date
$DatetoDelete = $CurrentDate.AddDays(-$BackupsToKeep)
$Extension = "*.zip"
$AllDomains = Get-ADDomain
$TLD = Enter your top level domain
 
# Backup All GPO's in the Domain
Backup-GPO -All -Domain $TLD -Path $Source
foreach($domain in $AllDomains.ChildDomains)
{
    Backup-GPO -All -Domain $domain -Path $Source -ErrorAction SilentlyContinue
}
 
# Create Zip file of all GPO's
Add-Type -assembly "system.io.compression.filesystem"
[io.compression.zipfile]::CreateFromDirectory($Source, $Destination)
 
# Clean-up of Temp GPO folder and Backup dir
Get-ChildItem $Backupfolder -Include $Extension -recurse | Where-Object { $_.LastWriteTime -lt $DatetoDelete } | Remove-Item
Remove-Item C:\Scripts\GPO\* -recurse -Force
 

donderdag 14 januari 2016

Add DNS record with powershell

Add-DnsServerResourceRecordA -Name "TEST.TEST1.TEST1" -ZoneName "zone_name.local" -IPv4Address "10.0.0.1" -TimeToLive 00:15:00

This adds a A record in DNS under zone zone_name.local and the structure will be test.test1.test1.zone_name.local

Add-DnsServerResourceRecordCName -Name "TEST.TEST1.TEST1" -HostNameAlias "TEST.TEST1.TEST1" -ZoneName "zone_name" -TimeToLive 00:15:00

This adds a CNAME record in DNS under zone zone_name.local and the structure will be test.test1.test1.zone_name.local

Muliple Ip's on 1 interface register multiple DNS records

If you don’t want to register the extra ip addresses in DNS you simply can avoid this by adding the extra ip addresses with NETSH and the flag skipassource=true

netsh int ipv4 add address "Local Area Connection" address=10.0.0.1 mask=255.255.255.0 skipassource=true