Skip to content

Instantly share code, notes, and snippets.

@BenNeise
BenNeise / RemoveAppSenseCCAGUID.ps1
Created February 24, 2014 10:14
Remove AppSense CCA GUID
# Remove AppSense CCA GUID
# "Removing values"
If (Get-ItemProperty -Path "HKLM:\Software\AppSense Technologies\Communications Agent" -name "machine id" -ErrorAction SilentlyContinue){
Remove-ItemProperty -Path "HKLM:\Software\AppSense Technologies\Communications Agent" -name "machine id"
}
If (Remove-ItemProperty -Path "HKLM:\Software\AppSense Technologies\Communications Agent" -name "group id" -ErrorAction SilentlyContinue){
Remove-ItemProperty -Path "HKLM:\Software\AppSense Technologies\Communications Agent" -name "group id"
}
# "Removing subkeys"
Get-Childitem "HKLM:\Software\AppSense\Environment Manager" | Remove-Item
@BenNeise
BenNeise / DisplayVMDiskInformation.ps1
Created February 18, 2014 11:59
Uses vSphere PowerCLI to display disk information. Most importantly, whether or not the disk is ThinProvisioned.
# Create an empty array for results
$arrResults = @()
# Get the .net view of the virtual machines
$objVMViews = Get-View -ViewType "VirtualMachine" | Where-Object {!$_.Config.Template}
# Loop through the .net view objects representing the machines
ForEach ($objVMView in $objVMViews){
# Loop through the .net view's devices
ForEach ($objDevice in $objVMView.Config.Hardware.Device) {
@BenNeise
BenNeise / Get-PCOIPStatsViaWMI.ps1
Created February 3, 2014 15:27
Powershell function to get PCOIP statistics gatherered via WMI from the target machine
Function Get-PCOIPStatsViaWMI {
<#
.Synopsis
Returns PCOIP statistics via WMI
.Description
This function displays PCOIP statistics gatherered via WMI from the
target machine
.Example
@BenNeise
BenNeise / SCSMOpenCallsReport.ps1
Last active January 2, 2016 02:19
Lists open calls in SCSM 2012 using only native CMDlets (no SMLets)
# Import the SCSM Native CMDLets
Import-Module "C:\Program Files\Microsoft System Center 2012\Service Manager\Powershell\System.Center.Service.Manager.psd1"
# Name of your SCSM Server
$strSCSMServer = "YourSCSMServer"
New-SCSMManagementGroupConnection -ComputerName $strSCSMServer
$objRelationshipAssignedToUser = Get-SCSMRelationship -Name "System.WorkItemAssignedToUser"
$objRelationshipAffectedUser = Get-SCSMRelationship -Name "System.WorkItemAffectedUser"
@BenNeise
BenNeise / Remove-StuckVDIMachineFromAdamDatabase.ps1
Last active December 29, 2015 13:39
Finds a computer object in View's ADAM database which represents a machine. Probably one stuck in a Deleting "(Missing)" state. Deletes it (with confirmation)
#Requires -PSSnapin Quest.ActiveRoles.ADManagement
Function Remove-StuckVDIMachineFromAdamDatabase {
<#
.Synopsis
Removes an object from View's ADAM database
.Description
Finds a computer object in View's ADAM database which represents a machine.
Probably one stuck in a Deleting "(Missing)" state. Deletes it (with confirmation)
@BenNeise
BenNeise / Invoke-SubversionScript.ps1
Created November 20, 2013 08:59
Given a valid PS1 file at a Subversion URL and credentials (Basic authentication) invokes the script on the local machine.
Function Invoke-SubversionScript {
<#
.Synopsis
Runs a script directly from Subversion.
.Description
Given a valid Subversion URL and credentials (Basic authentication) invokes the script on the local machine.
.Parameter Url
The URL of the script. Should be a valid URL, and end in PS1
# Script to deploy linked clones
# List of custom attributes which you're wanting to copy from the template or parent to the newly created machine
# (Machines deployed from templates no longer inherit CAs in vSphere 4.0)
# These help us track provenance, and provide information to the user
$arrStrAttributesToCopy = @(
"AD Object Location",
"Customisation",
"Infrastructure Consultant",
"Logon Administrator Name",
@BenNeise
BenNeise / getVCenterBuildNumbers.ps1
Created October 29, 2013 14:54
Script to connect to a list of vCenter Servers, and get their version numbers, as well as the version numbers of their hosts
# Script to connect to a list of vCenter Servers, and get their version numbers, as well as the version numbers of their hosts
# Ben Neise
# 02/10/09
# Array of vCenter Servers
$arrVCenterServers = @("server1","server2","server3")
# Create empty arrays for the results
$arrTableVCs = @()
$arrTableHosts = @()
@BenNeise
BenNeise / AddHashTableOfVirtualPortGroupsTovSphereHosts.ps1
Created October 29, 2013 14:52
Script to add a hash table full of virtual port groups to vSphere hosts
# Sets up virtual port groups on all hosts connected to a specific vCenter Server
# Name of vCenter Server
$strVCenterServer = "your.vCenter.Server"
# VLANs and associated VPGs
$ArrVLANs = @{
"123" = "vlanA";
"456" = "vlanB";
"789" = "vlanC";
# Get all templates
$objTemplates = Get-Template
# Loop through the templates
ForEach ($objTemplate in $objTemplates){
# Set the $StrInterimTemplateName variable to the template name, replacing the string "Tmpl" with an empty string
$StrInterimTemplateName = ($objTemplate.Name -replace("Tmpl",""))
# As the string we've just removed might be anywhere in the name, we need to replace double spaces with single
$StrInterimTemplateName = ($StrInterimTemplateName -replace(" "," "))
# And also remove trailing spaces from the start, or the end of the string