Skip to content

Instantly share code, notes, and snippets.

@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.
@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 / 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)
}
<Computer Vrt ="Physical" Name = "Server1">
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
@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
@weiyentan
weiyentan / job_launch_example.yml
Created July 7, 2019 00:54
Tower_job_launch example
- name: Launch Job Template to transfer archive files to management host
tower_job_launch:
job_template: " APFW - Helper playbook - Transfer archive to management host"
inventory: "{{ inventory }}"
credential: "{{ tower_jobcredential }}"
limit: "{{ limit }}"
tower_username: "{{ tower_username }}"
tower_password: "{{ tower_password }}"
tower_verify_ssl: no
extra_vars:
tower_job_launch:
job_template: "APFW - Helper playbook - Transfer archive to management host"
inventory: "{{ inventory }}"
credential: "{{ tower_jobcredential }}"
limit: "{{ management_server }}"
tower_username: "{{ tower_username }}"
tower_password: "{{ tower_password }}"
tower_verify_ssl: no
extra_vars:
- { management_server: "{{ management_server }}" , search_term: "{{ search_term }}" , destination_logpath: "{{ destination_logpath }}" }
tower_credential:
- name: test
organization: Prometheus
credential_type: 'create Custom SSH Cloud Credential'
description: test
state: present
---
tower_credential_types:
- name: SSH_Credential
description: Custom SSH Credential
inputs:
fields:
- secret: true
type: string
id: my_private_key
label: "Private Key"