Skip to content

Instantly share code, notes, and snippets.

View ChrisLynchHPE's full-sized avatar

Chris Lynch ChrisLynchHPE

View GitHub Profile
@ChrisLynchHPE
ChrisLynchHPE / Rename-Server-Profile.ps1
Created April 4, 2018 17:25
Change Server Profile Name
$ProfileToEdit = Get-HPOVServerProfile -Name "My Profile 1" -ErrorAction Stop
$ProfileToEdit.name = "My new name"
# Set-HPOVResource -InputObject $ProfileToEdit
# Or you can use Send-HPOVRequest natively:
# Send-HPOVRequest -Uri $ProfileToEdit.uri -Method PUT -Body $ProfileToEdit | Wait-HPOVTaskComplete
@ChrisLynchHPE
ChrisLynchHPE / Invoke-IPPoolCollector.ps1
Last active October 21, 2019 17:24
This script will invoke the IP Pool Collector service that will attempt to reclaim addresses that were not released during resource removal. Example resources that can consume IPv4 Addresses from pools are Logical Enclosures, OS Deployment Servers and Hypervisor Cluster Profiles.
# Replace the -NetworkID parameter with the right Subnet Pool ID to reclaim addresses
$subnet = Get-HPOVAddressPoolSubnet -NetworkId 10.41.87.0
ForEach ($range in $subnet.rangeUris)
{
$_Uri = $range + '/allocated-fragments?start=0&count=1'
$_AllocatedFragments = Send-HPOVRequest -uri $_Uri
# Ports we want to modify
$Ports = "1:0:0", "1:0:1", "2:0:0", "2:0:1"
# Set the portGroup name
$PortGroupName = "MyPortGroup1"
$StorageSystem = Get-HPOVStorageSystem -Name My3ParSystem
ForEach ($port in $Ports)
{
$ReleaseKey = Get-ChildItem 'HKLM:\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full\' | Get-ItemPropertyValue -Name Release
if ($ReleaseKey -ge 528040) {
return "4.8 or later";
}
if ($ReleaseKey -ge 461808) {
return "4.7.2";
}
$ServerName = "ReplaceMe"
$Server = Get-HPOVServer -Name $ServerName
$Credential = Get-Credential
$_InputObject = $Server.PSObject.Copy()
$_uri = $_InputObject.uri + "/refreshState"
$_body = @{

Keybase proof

I hereby claim:

  • I am chrislynchhpe on github.
  • I am chrislynchhpe (https://keybase.io/chrislynchhpe) on keybase.
  • I have a public key ASAie7DtPMQOFmbZbRISDgTvk5QOYACjadHUcEobpSGVoQo

To claim this, I am signing this object:

@ChrisLynchHPE
ChrisLynchHPE / Update-LocaliLOAdminCredentials.ps1
Last active January 17, 2020 17:10
This script updates the administrator account password using HPE OneView Server Profile Template, then updates the associated Server Profile resources.
# Prompt admin for updated password value
Do
{
# Prompt for new password
$Password = Read-Host "Password" -AsSecureString
# Ask for it again
$Password2 = Read-Host "Confirm password" -AsSecureString
# Get the SHT of the server hardware
$BL460cGen9SHT = Get-OVServerHardwareType -Name 'BL460c Gen9 1'
# Get the EG
$EnclosureGroup = Get-OVEnclosureGroup -Name $DCSDefaultEGName
# Create our profile Ethernet connections
$ServerProfileConnection1NetObject = Get-OVNetwork -Name $ServerProfileConnection1NetName -ErrorAction Stop
$ProfileConnection1 = New-OVServerProfileConnection -ConnectionID 1 -Name "$ServerProfileConnection1NetName Connection" -Network $ServerProfileConnection1NetObject
$ServerProfileConnection2NetObject = Get-OVNetwork -Name $ServerProfileConnection2NetName -ErrorAction Stop
$tasks = @()
# Get server profiles Apollo XL290 Gen9 server hardware type to then filter
$ServerProfiles = Get-OVServerProfile -InputObject (Get-OVServerHardwareType -Name "HPE ProLiant XL450 Gen9" -ErrorAction Stop)
ForEach ($serverProfile in $ServerProfiles)
{
# Change the profile Baseline property to "Managed Manually"
$serverProfile.firmware.manageFirmware = $false
Add-Type @"
namespace System.Security.Cryptography.X509Certificates {
public enum X509KeySpecFlags {
None = 0,
AT_KEYEXCHANGE = 1,
AT_SIGNATURE = 2
}
}
"@
function Convert-PemToPfx {