Skip to content

Instantly share code, notes, and snippets.

@weiyentan
weiyentan / configure_failovercluster.ps1
Last active June 11, 2019 18:22
Configure_failovercluster
#!powershell
# Description: Move Failover cluster from one node to the next.
#Requires -Module Ansible.ModuleUtils.Legacy
$ErrorActionPreference = 'Stop'
$results = @{
changed = $false #mandatory key value pair
msg = '' #optional keyvalue pair
if ($Clustertype -eq "Clustergroup")
{
$eval = testclusterelement -type clustergroup $name
if ($eval -eq $false)
{
Fail-Json -message "The cluster group $name does not exist. Cannot continue."
}
#test node ownership - whether or not relevant it is relevant to continue the task
<Computer Vrt ="Physical" Name = "Server1">
@weiyentan
weiyentan / copyproperty
Last active January 4, 2017 18:19
Example to copy object property to hashtable
$copyobjectdetails = $inputobject | Get-Member | Where-Object { $_.membertype -eq "Noteproperty" }
$hash = @{ }
$copyobjectdetails | ForEach-Object {
$name = $_.Name
$definition = $_.Definition
$definitionsplit = ($definition -split '=')[1]
$hash.Add($name, $definitionsplit)
}
@weiyentan
weiyentan / Parametspester.ps1
Created January 4, 2017 17:22
Example of Custom Pester function accepting parameters
function Invoke-CustomPestertest
{
[CmdletBinding()]
param
(
[string]$testpath,
[decimal]$version,
[string]$name
)
Invoke-Pester -Script @{ Path = '$testpath'; Parameters = @{ Name = $name; Version = $version } }
@weiyentan
weiyentan / New-ServerXML.ps1
Created June 5, 2016 10:55
Gets Windows Server information
<#
.SYNOPSIS
Creates a XML of a list of computer.
.DESCRIPTION
This script is to retrieve the system information in XML. Then we can merge that with another script to create a computer information document.
This is primarilydesigned for server audits. It uses CIM to gather certain information.
.PARAMETER computername
This is the computer to query.