From 512848bbee77cb22855e40e18d71fd2ba27e0e95 Mon Sep 17 00:00:00 2001 From: Chris Lynch Date: Tue, 24 Sep 2024 08:28:44 -0700 Subject: [PATCH] Fixing branch contents Signed-off-by: Chris Lynch --- .gitattributes | 20 + .gitignore | 232 + Appliance.format.ps1xml | 5261 + Cluster.format.ps1xml | 75 + HPEOneView.900.psd1 | 191 + HPEOneView.900.psm1 | 149083 +++++++++++++++ ...6-37bd-4c1a-bbe9-596baa795520_HelpInfo.xml | 10 + ...37bd-4c1a-bbe9-596baa795520_ModuleInfo.xml | 5 + Networking.format.ps1xml | 3508 + PSScriptAnalyzerSettings.psd1 | 46 + Samples/AddServers_Monitored_Sample.ps1 | 118 + Samples/AddStorageSystem_Sample.ps1 | 224 + Samples/Alerts_Sample.ps1 | 168 + Samples/ApplianceConfig_Sample.ps1 | 599 + Samples/Appliance_Backup_Sample.ps1 | 103 + Samples/ComposerApplianceConfig_Sample.ps1 | 477 + Samples/ConfigureRemoteSupport_Sample.ps1 | 194 + ...nfigure_IIS_WebDav_ExternalRepo_Sample.ps1 | 300 + Samples/CreateEnclosureGroup_Sample.ps1 | 78 + ...eLogicalInterconnectGroup_AA_VC_Sample.ps1 | 64 + .../DefineLogicalInterconnectGroup_Sample.ps1 | 73 + Samples/DefineNetworks_AA_VC_Sample.ps1 | 80 + Samples/DefineNetworks_Sample.ps1 | 84 + .../Server_Multiconnection_AA_VC_Sample.ps1 | 167 + ...ver_Multiconnection_SAN_Storage_Sample.ps1 | 182 + Samples/Server_Multiconnection_Sample.ps1 | 171 + ...rofile_Template_Multiconnection_Sample.ps1 | 116 + ...er_Profile_Template_Rack_Server_Sample.ps1 | 101 + Samples/Wipe_Appliance.ps1 | 257 + Server.format.ps1xml | 2080 + Storage.format.ps1xml | 2290 + en-US/HPEOneView.900.psm1-help.xml | 110266 +++++++++++ ..._Appliance_Connection_Permissions.help.txt | 120 + en-US/about_Appliance_Connections.help.txt | 162 + en-US/about_HPEOneView.900.help.txt | 90 + .../about_Two_Factor_Authentication.help.txt | 180 + 36 files changed, 277175 insertions(+) create mode 100644 .gitattributes create mode 100644 .gitignore create mode 100644 Appliance.format.ps1xml create mode 100644 Cluster.format.ps1xml create mode 100644 HPEOneView.900.psd1 create mode 100644 HPEOneView.900.psm1 create mode 100644 HPEOneView.900_93487b26-37bd-4c1a-bbe9-596baa795520_HelpInfo.xml create mode 100644 HPEOneView.900_93487b26-37bd-4c1a-bbe9-596baa795520_ModuleInfo.xml create mode 100644 Networking.format.ps1xml create mode 100644 PSScriptAnalyzerSettings.psd1 create mode 100644 Samples/AddServers_Monitored_Sample.ps1 create mode 100644 Samples/AddStorageSystem_Sample.ps1 create mode 100644 Samples/Alerts_Sample.ps1 create mode 100644 Samples/ApplianceConfig_Sample.ps1 create mode 100644 Samples/Appliance_Backup_Sample.ps1 create mode 100644 Samples/ComposerApplianceConfig_Sample.ps1 create mode 100644 Samples/ConfigureRemoteSupport_Sample.ps1 create mode 100644 Samples/Configure_IIS_WebDav_ExternalRepo_Sample.ps1 create mode 100644 Samples/CreateEnclosureGroup_Sample.ps1 create mode 100644 Samples/DefineLogicalInterconnectGroup_AA_VC_Sample.ps1 create mode 100644 Samples/DefineLogicalInterconnectGroup_Sample.ps1 create mode 100644 Samples/DefineNetworks_AA_VC_Sample.ps1 create mode 100644 Samples/DefineNetworks_Sample.ps1 create mode 100644 Samples/Server_Multiconnection_AA_VC_Sample.ps1 create mode 100644 Samples/Server_Multiconnection_SAN_Storage_Sample.ps1 create mode 100644 Samples/Server_Multiconnection_Sample.ps1 create mode 100644 Samples/Server_Profile_Template_Multiconnection_Sample.ps1 create mode 100644 Samples/Server_Profile_Template_Rack_Server_Sample.ps1 create mode 100644 Samples/Wipe_Appliance.ps1 create mode 100644 Server.format.ps1xml create mode 100644 Storage.format.ps1xml create mode 100644 en-US/HPEOneView.900.psm1-help.xml create mode 100644 en-US/about_Appliance_Connection_Permissions.help.txt create mode 100644 en-US/about_Appliance_Connections.help.txt create mode 100644 en-US/about_HPEOneView.900.help.txt create mode 100644 en-US/about_Two_Factor_Authentication.help.txt diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..9876da9 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,20 @@ +# Auto detect text files and perform LF normalization +* text=auto + +# Custom for Visual Studio +*.cs diff=csharp + +# Standard to msysgit +*.doc diff=astextplain +*.DOC diff=astextplain +*.docx diff=astextplain +*.DOCX diff=astextplain +*.dot diff=astextplain +*.DOT diff=astextplain +*.pdf diff=astextplain +*.PDF diff=astextplain +*.rtf diff=astextplain +*.RTF diff=astextplain +*.PMS1 diff=astextplain +*.PSD1 diff=astextplain +*.PS1 diff=astextplain diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b36c0f8 --- /dev/null +++ b/.gitignore @@ -0,0 +1,232 @@ +################### +## Project Specific +################### +"Build Scripts/MamlOneViewHelpFiles/**" +"/Build Scripts/GitHub Documentation/**" +*.md +*.zip +.vscode +signed/ +.vs/ +*- Copy* +*ORIGINAL.* + +################# +## Eclipse +################# + +*.pydevproject +.project +.metadata +bin/ +tmp/ +*.tmp +*.bak +*.swp +*~.nib +local.properties +.classpath +.settings/ +.loadpath + +# External tool builders +.externalToolBuilders/ + +# Locally stored "Eclipse launch configurations" +*.launch + +# CDT-specific +.cproject + +# PDT-specific +.buildpath + + +################# +## Visual Studio +################# + +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. + +# User-specific files +*.suo +*.user +*.sln.docstates +*.psproj.user + +# Build results + +[Dd]ebug/ +[Rr]elease/ +x64/ +# build/ +[Bb]in/ +[Oo]bj/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +*_i.c +*_p.c +*.ilk +*.meta +*.obj +*.pch +*.pdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.log +*.scc + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opensdf +*.sdf +*.cachefile + +# Visual Studio profiler +*.psess +*.vsp +*.vspx + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# NCrunch +*.ncrunch* +.*crunch*.local.xml + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.Publish.xml +*.pubxml +*.publishproj + +# NuGet Packages Directory +## TODO: If you have NuGet Package Restore enabled, uncomment the next line +#packages/ + +# Windows Azure Build Output +csx +*.build.csdef + +# Windows Store app package directory +AppPackages/ + +# Others +sql/ +*.Cache +ClientBin/ +[Ss]tyle[Cc]op.* +~$* +*~ +*.dbmdl +*.[Pp]ublish.xml +*.pfx +*.publishsettings + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file to a newer +# Visual Studio version. Backup files are not needed, because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm + +# SQL Server files +App_Data/*.mdf +App_Data/*.ldf + +############# +## Windows detritus +############# + +# Windows image file caches +Thumbs.db +ehthumbs.db + +# Folder config file +Desktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Mac crap +.DS_Store + + +############# +## Python +############# + +*.py[cod] + +# Packages +*.egg +*.egg-info +dist/ +# build/ +eggs/ +parts/ +var/ +sdist/ +develop-eggs/ +.installed.cfg + +# Installer logs +pip-log.txt + +# Unit test / coverage reports +.coverage +.tox + +#Translations +*.mo + +#Mr Developer +.mr.developer.cfg +sh.exe.stackdump +/SimCertHPOneView.300.psm1 diff --git a/Appliance.format.ps1xml b/Appliance.format.ps1xml new file mode 100644 index 0000000..1dd5419 --- /dev/null +++ b/Appliance.format.ps1xml @@ -0,0 +1,5261 @@ + + + + + + ApplianceTrustedCertificateTypes + + HPEOneView.Appliance.TrustedCertificate + HPEOneView.Appliance.TrustedCertificateAuthority + + + + + ApplianceSnmpTrapDestinationTypes + + HPEOneView.Appliance.SnmpV1TrapDestination + HPEOneView.Appliance.SnmpV3TrapDestination + + + + + PowerDeliveryDeviceTypes + + HPEOneView.PowerDeliveryDevice + HPEOneView.PowerDeliveryDevice.PduAcModule + HPEOneView.PowerDeliveryDevice.LoadSegment + HPEOneView.PowerDeliveryDevice.OutletBar + HPEOneView.PowerDeliveryDevice.Outlet + + + + + + + ApplianceTrustedCertificateTypes-GroupingFormat + + + + + + 4 + + Type: + + + Switch ($_.GetType().Name) { + 'TrustedCertificateAuthority' { 'TrustedCertificateAuthority' } + 'TrustedCertificate' { 'TrustedCertificate' } + } + + + + + + + + + + + + + ApplianceSnmpTrapDestinationTypes-GroupingFormat + + + + + + 4 + + Type: + + + $_.Type + + + + + + + + + + + + + PowerDeliveryDevice-GroupingFormat + + + + + + 4 + + DeviceType: + + + $_.deviceType + + + + + + + + + + + + + ApplianceSecurityProtocolMode-GroupingFormat + + + + + + 4 + + Mode: + + + $_.Mode + + + + + + + + + + + + + + + ApplianceAvailableUpdates + + HPEOneView.Appliance.ApplianceAvailableUpdates + + + + + + + + name + + + + version + + + + releaseDate + + + + updateType + + + + description + + + + Supplements + + + + + + + + + HPEOneView.Appliance.ApplianceUpdateSchedule + + HPEOneView.Appliance.ApplianceUpdateSchedule + + + + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + + + + + State + + + ScheduleFrequency + + + Day + + + "{0:00}:{1:00}UTC" -f $_.Time.Hours, $_.Time.Minutes + + + LastSuccessfulCheck + + + + + + + + + HPEOneView.Appliance.ComposerNetworkInterface + + HPEOneView.Appliance.ComposerNetworkInterface + + + + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + + + + + Interface + + + ComposerRole + + + IPv4Address + + + IPv4Type + + + IPv4MaintenanceAddress + + + IPv4SubnetMask + + + IPv6Address + + + IPv6Type + + + IPv6MaintenanceAddress + + + + + + + + + HPEOneView.Appliance.NetworkInterface + + HPEOneView.Appliance.NetworkInterface + + + + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + + + + + Interface + + + IPv4Address + + + IPv4Type + + + IPv4SubnetMask + + + IPv6Address + + + IPv6Type + + + Hostname + + + + + + + + + StaticRoute + + HPEOneView.Appliance.StaticRoute + + + + + + + Left + + + + Left + + + + Left + + + + Left + + + + + + + + Destination + + + Gateway + + + Metric + + + Interface + + + + + + + + + ScopeCollection + + HPEOneView.Appliance.ScopeCollection + + + + + + + Left + + + + Left + + + + Left + + + + Left + + + + + + + + ApplianceConnection + + + Name + + + Description + + + Members + + + + + + + + + ScopeCollectionMemberEntry + + HPEOneView.Appliance.ScopeCollectionMemberEntry + + + + + + + Left + + + + Left + + + + + + + + Name + + + Type + + + + + + + + + ComposerNode + + HPEOneView.ComposerNode + + + + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + + + + + ApplianceConnection + + + name + + + state + + + status + + + modelNumber + + + version + + + role + + + + + + + + + ComposerNode + + HPEOneView.ComposerNode + + + + + + + + ApplianceConnection + + + + name + + + + state + + + + status + + + + modelNumber + + + + version + + + + role + + + + + + + + + RemoteSyslog + + HPEOneView.RemoteSyslog + + + + + + + Left + + + + Left + + + + Left + + + + Left + + + + + + + + ApplianceConnection + + + remoteSyslogDestination + + + remoteSyslogPort + + + enabled + + + + + + + + + RemoteSyslog + + HPEOneView.RemoteSyslog + + + + + + + + ApplianceConnection + + + + remoteSyslogDestination + + + + remoteSyslogPort + + + + enabled + + + + + + + + + LoginMessage + + HPEOneView.Appliance.LoginMessage + + + + + + + + ApplianceConnection + + + + Message + + + + Acknowledgment + + + + + + + + + LoginMessage + + HPEOneView.Appliance.LoginMessage + + + + + + + Left + + + + Left + 25 + + + + Right + + + + + + + + ApplianceConnection + + + Message + + + Acknowledgment + + + + + + + + + ApplianceConnection + + HPEOneView.Appliance.Connection + + + + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + + + + ConnectionID + + + Name + + + UserName + + + AuthLoginDomain + + + Default + + + + + + + + + ApplianceConnection + + HPEOneView.Appliance.Connection + + + + + + + + ConnectionID + + + + Name + + + + UserName + + + + AuthLoginDomain + + + + Default + + + + + + + + + ActiveUserSession + + HPEOneView.Appliance.ActiveUserSession + + + + + + + Left + + + + Left + + + + Left + + + + Left + + + + + + + UserName + + + LoginDomain + + + ClientHost + + + LoginTime + + + + + + + + + ActiveUserSession + + HPEOneView.Appliance.ActiveUserSession + + + + + + + + UserName + + + + LoginDomain + + + + ClientHost + + + + LoginTime + + + + ApplianceConnection + + + + + + + + + RemoteSupportConfig + + HPEOneView.Appliance.RemoteSupportConfig + + + + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + + + + ApplianceConnection + + + enableRemoteSupport + + + companyName + + + autoEnableDevices + + + marketingOptIn + + + + + + + + + RemoteSupportConfig + + HPEOneView.Appliance.RemoteSupportConfig + + + + + + + + ApplianceConnection + + + + enableRemoteSupport + + + + companyName + + + + autoEnableDevices + + + + marketingOptIn + + + + + + + + + RemoteSupportContact + + HPEOneView.Appliance.RemoteSupport.Contact + + + + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + + + + ApplianceConnection + + + '{0} {1}' -f $_.firstName, $_.lastName + + + email + + + primaryPhone + + + default + + + + + + + + + RemoteSupportPartner + + HPEOneView.Appliance.RemoteSupport.Partner + + + + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + + + + ApplianceConnection + + + name + + + partnerType + + + city + + + country + + + default + + + + + + + + + ApplianceTrustedCertificate + + HPEOneView.Appliance.TrustedCertificate + + + $_.GetType().Name + ApplianceTrustedCertificateTypes-GroupingFormat + + + + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + + + + Name + + + AliasName + + + CertificateStatus + + + [DateTime]$_.Certificate.NotBefore + + + [DateTime]$_.Certificate.NotAfter + + + + + + + + + ApplianceTrustedCertificate + + HPEOneView.Appliance.TrustedCertificateAuthority + + + $_.GetType().Name + ApplianceTrustedCertificateTypes-GroupingFormat + + + + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + + + + Name + + + Status + + + CRLInfo + + + [DateTime]$_.Certificate.NotBefore + + + [DateTime]$_.Certificate.NotAfter + + + + + + + + + RemoteSupportSchedule + + HPEOneView.Appliance.RemoteSupport.Schedule + + + + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + + + + ScheduleName + + + RepeatOption + + + HourOfDay + + + Minute + + + DayOfMonth + + + DayOfWeek + + + + + + + + + RemoteSupportDefaultSite + + HPEOneView.Appliance.RemoteSupport.DefaultSite + + + + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + + + + ApplianceConnection + + + streetAddress1 + + + streetAddress2 + + + provinceState + + + postalCode + + + countryCode + + + timeZone + + + + + + + + + SmtpConfigurationObject + + HPEOneView.Appliance.SmtpConfiguration + + + + + + + + alertEmailDisabled + + + + senderEmailAddress + + + + smtpServer + + + + smtpPort + + + + alertEmailDisabled + + + + + + + + + SnmpReadCommunity + + HPEOneView.Appliance.SnmpReadCommunity + + + + + + + Left + + + + Left + + + + + + + ApplianceConnection + + + CommunityString + + + + + + + + + GlobalSetting + + HPEOneView.Appliance.GlobalSetting + + + + + + + Left + + + + Left + + + + Left + + + + + + + ApplianceConnection + + + name + + + value + + + + + + + + + TaskResource + + HPEOneView.Appliance.TaskResource + + + + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + + + + ApplianceConnection + + + name + + + owner + + + Get-Date $_.created + + + "{0:hh\:mm\:ss}" -f ((Get-Date $_.modified) - (Get-Date $_.created)) + + + taskState + + + percentComplete + + + + + + + + + TaskResource + + HPEOneView.Appliance.TaskResource + + + + + + + + ApplianceConnection + + + + name + + + + owner + + + + created + + + + "{0:hh\:mm\:ss}" -f ((Get-Date $_.modified) - (Get-Date $_.created)) + + + + taskState + + + + percentComplete + + + + progressUpdates + + + + taskErrors + + + + parentTaskUri + + + + + + + + + License + + HPEOneView.Appliance.License + + + + + + + + Product + + + + Type + + + + Capacity + + + + Allocated + + + + Available + + + + Nodes + + + + + + + + + UserRole + + HPEOneView.Appliance.UserRole + + + + + + + Left + + + + + + + roleName + + + + + + + + + User + + HPEOneView.Appliance.User + + + + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + + + + userName + + + enabled + + + $_.permissions.roleName + + + emailAddress + + + officePhone + + + mobilePhone + + + + + + + + + ConnectionPermission + + HPEOneView.Appliance.ConnectionPermission + + + + + + + Left + + + + Left + + + + Left + + + + + + + RoleName + + + ScopeName + + + Active + + + + + + + + + AuthGlobalDirectoryConfiguration + + HPEOneView.Appliance.AuthGlobalDirectoryConfiguration + + + + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + + + + ApplianceConnection + + + allowLocalLogin + + + "{0}" -f $_.defaultLoginDomain.name + + + ($_.configuredLoginDomains | Sort-Object -property name) | ForEach { $_.name } + + + if ($_.loginMessage.acknowledgment) { 'Enabled' } else { 'Disabled' } + + + + + + + + + AuthDirectory + + HPEOneView.Appliance.AuthDirectory + + + + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + + + + ApplianceConnection + + + name + + + authProtocol + + + baseDn + + + ($_.directoryServers | Sort-Object -property name) | ForEach { "{0}:{1}" -f $_.directoryServerIpAddress,$_.directoryServerSSLPortNumber } + + + + + + + + + AuthDirectory + + HPEOneView.Appliance.AuthDirectory + + + + + + + + ApplianceConnection + + + + name + + + + authProtocol + + + + baseDn + + + + ($_.directoryServers | Sort-Object -property name) | ForEach { "{0}:{1}" -f $_.directoryServerIpAddress,$_.directoryServerSSLPortNumber } + + + + + + + + + AuthDirectoryServer + + HPEOneView.Appliance.AuthDirectoryServer + + + + + + + Left + + + + Left + + + + Left + + + + Left + + + + + + + directoryServerIpAddress + + + directoryServerSSLPortNumber + + + validUntil + + + directoryServerCertificateBase64Data + + + + + + + + + AuthDirectoryServer + + HPEOneView.Appliance.AuthDirectoryServer + + + + + + + + ApplianceConnection + + + + name + + + + authProtocol + + + + baseDn + + + + ($_.directoryServers | Sort-Object -property name) | ForEach { "{0}:{1}" -f $_.directoryServerIpAddress,$_.directoryServerSSLPortNumber } + + + + + + + + + LdapDirectoryGroup + + HPEOneView.Appliance.LdapDirectoryGroup + + + + + + + Left + + + + Left + + + + + + + Name + + + Directory + + + + + + + + + AuthDirectoryGroupRoleMapping + + HPEOneView.Appliance.AuthDirectoryGroupRoleMapping + + + + + + + Left + + + + Left + + + + Left + + + + Left + + + + + + + ApplianceConnection + + + egroup + + + loginDomain + + + '{0}' -f [String]::Join(', ', $_.permissions.roleName) + + + + + + + + + ApplianceGlobalSetting + + HPEOneView.Appliance.GlobalSetting + + + + + + + + Left + + + + + Left + + + + + + + name + + + value + + + + + + + + + AuditLogEntry + + HPEOneView.Appliance.AuditLogEntry + + + + + + + + ApplianceConnection + + + + dateTimeStamp + + + + objectType + + + + action + + + + result + + + + severity + + + + msg + + + + sourceIp + + + + + + + + + ApplianceAlert + + HPEOneView.Alert + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + severity + + + $_.associatedResource.resourceName + + + $_.created | Get-Date -UFormat %c + + + $_.modified | Get-Date -UFormat %c + + + alertState + + + assignedToUser + + + description + + + + + + + + + ApplianceAlert + + HPEOneView.Alert + + + + + + + + severity + + + + description + + + + $_.associatedResource.resourceName + + + + $_.created | Get-Date -UFormat %c + + + + $_.modified | Get-Date -UFormat %c + + + + alertState + + + + assignedToUser + + + + $_.changeLog | % { "[{0}] {1}" -f (Get-Date $_.created),$_.notes } + + + + + + + + + Baseline + + HPEOneView.Appliance.Baseline + + + + + + + + Name + + + + State + + + + Status + + + + Version + + + + IsoFileName + + + + XmlKeyName + + + + [HPEOneView.Utilities.Library]::IntToStorageString($_.BundleSize) + + + + Locations + + + + + + + + + BaselineRepository + + HPEOneView.Appliance.BaselineRepository + + + + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + + + + ApplianceConnection + + + name + + + repositoryType + + + status + + + '{0:N2}GB' -f ($_.availableSpace / 1MB) + + + '{0:N2}GB' -f ($_.totalSpace / 1MB) + + + + + + + + + ApplianceSslCertificateStatus + + HPEOneView.Appliance.ApplianceSslCertificateStatus + + + + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + + + + commonName + + + issuer + + + "{0:r}" -f (Get-Date $_.validFrom) + + + "{0:r}" -f (Get-Date $_.validUntil) + + + "{0} days" -f $_.expiresInDays + + + + + + + + + XAPIVersion + + HPEOneView.Appliance.XAPIVersion + + + + + + + + currentVersion + + + + minimumVersion + + + + + + + + + VersionBase + + HPEOneView.Appliance.Version.Base + + + + + + + + OneViewPowerShellLibrary + + + + libraryLoadedPath + + + + + + + + + VersionExtended + + HPEOneView.Appliance.Version.Extended + + + + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + + + + applianceName + + + major + + + minor + + + softwareVersion + + + xapiVersion + + + modelNumber + + + + + + + + + VersionExtended + + HPEOneView.Appliance.Version.Extended + + + + + + + + applianceName + + + + major + + + + minor + + + + softwareVersion + + + + xapiVersion + + + + modelNumber + + + + + + + + + UpdatePending + + HPEOneView.Appliance.Update.Pending + + + + + + + + version + + + + if ($_.rebootRequired) { "Yes" } else { "No" } + + + + estimatedUpgradeTime + + + + fileName + + + + + + + + + AddressPool + + HPEOneView.Appliance.AddressPool + + + + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + + + + name + + + poolType + + + enabled + + + totalCount + + + allocatedCount + + + freeCount + + + + + + + + + AddressPool + + HPEOneView.Appliance.AddressPool + + + + + + + + name + + + + poolType + + + + enabled + + + + totalCount + + + + allocatedCount + + + + freeCount + + + + + + + + + IPAddressSubnet + + HPEOneView.Appliance.IPAddressSubnet + + + + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + + + + ApplianceConnection + + + networkId + + + + if ($null -ne $_.subnetMask) { $_.subnetMask } + else { $_.prefixLength} + + + + gateway + + + dnsServers + + + domain + + + + $ac = $_.ApplianceConnection.Name + $_.rangeUris | % { (Send-OVRequest $_ -Hostname $ac).name } + + + + + + + + + + IPAddressSubnet + + HPEOneView.Appliance.IPAddressSubnet + + + + + + + + ApplianceConnection + + + + networkId + + + + + if ($null -ne $_.subnetMask) { $_.subnetMask } + else { $_.prefixLength} + + + + + gateway + + + + dnsServers + + + + domain + + + + + $ac = $_.ApplianceConnection.Name + $_.rangeUris | % { (Send-OVRequest $_ -Hostname $ac).name } + + + + + + + + + + AddressPoolRange + + HPEOneView.Appliance.AddressPoolRange + + + + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + + + + ApplianceConnection + + + name + + + enabled + + + rangeCategory + + + totalCount + + + allocatedIdCount + + + freeIdCount + + + reservedIdCount + + + startAddress + + + endAddress + + + + + + + + + AddressPoolRange + + HPEOneView.Appliance.AddressPoolRange + + + + + + + + ApplianceConnection + + + + name + + + + enabled + + + + rangeCategory + + + + totalCount + + + + allocatedIdCount + + + + freeIdCount + + + + reservedIdCount + + + + startAddress + + + + endAddress + + + + + + + + + HealthStatus + + HPEOneView.Appliance.HealthStatus + + + + + + + Left + + + + Left + + + + Left + + + + Left + + + + + + + resourceType + + + available + + + capacity + + + + + if ($_.statusMessage -match "insufficient") { + + "Critical" + + } + if ($_.statusMessage -match "sufficient") { + + "Good" + + } + + + + + + + + + + + HealthStatus + + HPEOneView.Appliance.HealthStatus + + + + + + + + resourceType + + + + available + + + + capacity + + + + + + if ($_.statusMessage -match "insufficient") { + + "Critical" + + } + if ($_.statusMessage -match "sufficient") { + + "Good" + + } + + + + + + + + + + + ApplianceServerConfiguration + + HPEOneView.Appliance.ApplianceServerConfiguration + + + + + + Left + + + + Left + + + + + + + + applianceNetworks + + + serverCertificate + + + + + + + + + ApplianceServerConfiguration + + HPEOneView.Appliance.ApplianceServerConfiguration + + + + + + + + applianceNetworks + + + + serverCertificate + + + + + + + + + ApplianceServerDateTime + + HPEOneView.Appliance.ApplianceServerDateTime + + + + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + + + + + ApplianceConnection + + + '{0}' -f (Get-Date $_.dateTime) + + + locale + + + timezone + + + ntpServers + + + pollingInterval + + + + + + + + + ApplianceServerDateTime + + HPEOneView.Appliance.ApplianceServerDateTime + + + + + + + + ApplianceConnection + + + + '{0}' -f (Get-Date $_.dateTime) + + + + locale + + + + timezone + + + + ntpServers + + + + pollingInterval + + + + + + + + + ApplianceServerConfiguration.ApplianceNetworks + + HPEOneView.Appliance.ApplianceServerConfiguration.ApplianceNetworks + + + + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + + + + + hostname + + + ipv4Type + + + + "{0}\{1}" -f $_.app1Ipv4Addr,(((([Net.IPAddress]$_.ipv4Subnet).GetAddressBytes() | ForEach-Object { [Convert]::ToString($_, 2) } ) -join "`n" -replace '[\s0]').length) + + + + ipv4NameServers + + + ipv6Type + + + app1Ipv6Addr + + + ipv6NameServers + + + + + + + + + ApplianceServerConfiguration.ApplianceNetworks + + HPEOneView.Appliance.ApplianceServerConfiguration.ApplianceNetworks + + + + + + + + hostname + + + + ipv4Type + + + + app1Ipv4Addr + + + + ipv4Subnet + + + + ipv4Gateway + + + + ipv4NameServers + + + + ipv6Type + + + + app1Ipv6Addr + + + + ipv6Subnet + + + + ipv6Gateway + + + + ipv6NameServers + + + + + + + + + AutomaticBackupConfig + + HPEOneView.Appliance.AutomaticBackupConfig + + + + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + + + + + ApplianceConnection + + + enabled + + + remoteServerName + + + protocol + + + remoteServerDir + + + scheduleInterval + + + scheduleDays + + + scheduleTime + + + + + + + + + AutomaticBackupConfig + + HPEOneView.Appliance.AutomaticBackupConfig + + + + + + + + hostname + + + + ipv4Type + + + + app1Ipv4Addr + + + + ipv4Subnet + + + + ipv4Gateway + + + + ipv4NameServers + + + + ipv6Type + + + + app1Ipv6Addr + + + + ipv6Subnet + + + + ipv6Gateway + + + + ipv6NameServers + + + + + + + + + ImageStreamerAppliance + + HPEOneView.Appliance.ImageStreamerAppliance + + + + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + + + + + ApplianceConnection + + + name + + + status + + + applianceSerialNumber + + + imageStreamerVersion + + + + + + + + + OsDeploymentServer + + HPEOneView.Appliance.OsDeploymentServer + + + + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + + + + + ApplianceConnection + + + name + + + status + + + state + + + primaryIPV4 + + + + + + + + + OsDeploymentServer + + HPEOneView.Appliance.OsDeploymentServer + + + + + + + + ApplianceConnection + + + + name + + + + status + + + + state + + + + primaryIPv4 + + + + primaryClusterName + + + + + + + + + OsDeploymentPlan + + HPEOneView.Appliance.OsDeploymentPlan + + + + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + + + + + ApplianceConnection + + + name + + + status + + + state + + + osdpSize + + + + + + + + + OsDeploymentPlan + + HPEOneView.Appliance.OsDeploymentPlan + + + + + + + + ApplianceConnection + + + + name + + + + status + + + + state + + + + osdpSize + + + + + + + + + DataCenter + + HPEOneView.Facilities.DataCenter + + + + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + + + + + ApplianceConnection + + + name + + + width + + + depth + + + deratingType + + + deratingPercentage + + + defaultPowerLineVoltage + + + RemoteSupportLocation + + + + + + + + + DataCenter + + HPEOneView.Facilities.DataCenter + + + + + + + + ApplianceConnection + + + + name + + + + width + + + + depth + + + + deratingType + + + + deratingPercentage + + + + defaultPowerLineVoltage + + + + RemoteSupportLocation + + + + + + + + + RemoteSupportLocation + + HPEOneView.Facilities.RemoteSupportLocation + + + + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + + + + + + $Contact = Send-OVRequest -Uri $_.primaryContactUri -Hostname $_.ApplianceConnection.Name + '{0} {1}' -f $Contact.firstName, $Contact.lastName + + + + + $Contact = Send-OVRequest -Uri $_.secondaryContactUri -Hostname $_.ApplianceConnection.Name + '{0} {1}' -f $Contact.firstName, $Contact.lastName + + + + streetAddress1 + + + streetAddress2 + + + city + + + provinceState + + + postalCode + + + countryCode + + + timeZone + + + + + + + + + RemoteSupportLocation + + HPEOneView.Facilities.RemoteSupportLocation + + + + + + + + + $Contact = Send-OVRequest -Uri $_.primaryContactUri -Hostname $_.ApplianceConnection.Name + '{0} {1}' -f $Contact.firstName, $Contact.lastName + + + + + + $Contact = Send-OVRequest -Uri $_.secondaryContactUri -Hostname $_.ApplianceConnection.Name + '{0} {1}' -f $Contact.firstName, $Contact.lastName + + + + + streetAddress1 + + + + streetAddress2 + + + + city + + + + provinceState + + + + postalCode + + + + countryCode + + + + timeZone + + + + + + + + + RackMember + + HPEOneView.Facilities.RackMember + + + + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + + + + + Name + + + Model + + + UHeight + + + ULocation + + + RackName + + + + + + + + + RackMember + + HPEOneView.Facilities.RackMember + + + + + + + + Name + + + + Model + + + + UHeight + + + + ULocation + + + + RackName + + + + ApplianceConnection + + + + + + + + + Label + + HPEOneView.Appliance.Label + + + + + + + Left + + + + + + + + Name + + + + + + + + + Label + + HPEOneView.Appliance.Label + + + + + + + + Name + + + + ApplianceConnection + + + + + + + + + SnmpV3User + + HPEOneView.Appliance.SnmpV3User + + + + + + + Left + + + + Left + + + + Left + + + + Left + + + + + + + + Username + + + SecurityLevel + + + AuthenticationProtocol + + + PrivacyProtocol + + + + + + + + + SnmpV3User + + HPEOneView.Appliance.SnmpV3User + + + + + + + + userName + + + + securityLevel + + + + authenticationProtocol + + + + privacyProtocol + + + + + + + + + SnmpV3EngineId + + HPEOneView.Appliance.SnmpV3EngineId + + + + + + + Left + + + + + + + + EngineID + + + + + + + + + SnmpV3EngineId + + HPEOneView.Appliance.SnmpV3EngineId + + + + + + + + EngineID + + + + + + + + + SnmpV1TrapDestination + + HPEOneView.Appliance.SnmpV1TrapDestination + + + type + ApplianceSnmpTrapDestinationTypes-GroupingFormat + + + + + + + Left + + + + Left + + + + Left + + + + + + + + DestinationAddress + + + Port + + + CommunityString + + + + + + + + + SnmpV1TrapDestination + + HPEOneView.Appliance.SnmpV1TrapDestination + + + type + ApplianceSnmpTrapDestinationTypes-GroupingFormat + + + + + + + + destinationAddress + + + + Port + + + + CommunityString + + + + + + + + + SnmpV3TrapDestination + + HPEOneView.Appliance.SnmpV3TrapDestination + + + type + ApplianceSnmpTrapDestinationTypes-GroupingFormat + + + + + + + Left + + + + Left + + + + Left + + + + + + + + DestinationAddress + + + Port + + + SnmpV3User + + + + + + + + + SnmpV3TrapDestination + + HPEOneView.Appliance.SnmpV3TrapDestination + + + type + ApplianceSnmpTrapDestinationTypes-GroupingFormat + + + + + + + + destinationAddress + + + + Port + + + + SnmpV3User + + + + + + + + + ProxyServer + + HPEOneView.Appliance.ProxyServer + + + + + + + Left + + + + Left + + + + Left + + + + + + + + Server + + + Port + + + Username + + + + + + + + + ProxyServer + + HPEOneView.Appliance.ProxyServer + + + + + + + + Server + + + + Port + + + + Username + + + + + + + + + ApplianceLocaleDateTime + + HPEOneView.Appliance.ApplianceLocaleDateTime + + + + + + + Left + + + + Left + + + + Left + + + + Left + + + + + + + + DateTime + + + TimeZone + + + SyncWithHost + + + NtpServers + + + + + + + + + PowerDeliveryDevice + + + PowerDeliveryDeviceTypes + + + deviceType + PowerDeliveryDevice-GroupingFormat + + + + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + + + + + Name + + + Model + + + LineVoltage + + + PhaseType + + + feedIdentifier + + + + + + + + + PowerDeliveryDeviceLoadSegment + + + PowerDeliveryDeviceTypes + + + deviceType + PowerDeliveryDevice-GroupingFormat + + + + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + + + + + Name + + + Model + + + LineVoltage + + + PhaseType + + + feedIdentifier + + + + + + + + + PowerDeliveryDevicePduAcModule + + + PowerDeliveryDeviceTypes + + + deviceType + PowerDeliveryDevice-GroupingFormat + + + + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + + + + + Name + + + Model + + + LineVoltage + + + PhaseType + + + feedIdentifier + + + + + + + + + PowerDeliveryDeviceOutlet + + + PowerDeliveryDeviceTypes + + + deviceType + PowerDeliveryDevice-GroupingFormat + + + + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + + + + + Name + + + Model + + + Power + + + LineVoltage + + + PhaseType + + + feedIdentifier + + + + + + + + + PowerDeliveryDeviceOutletBar + + + PowerDeliveryDeviceTypes + + + deviceType + PowerDeliveryDevice-GroupingFormat + + + + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + + + + + Name + + + Model + + + LineVoltage + + + PhaseType + + + feedIdentifier + + + + + + + + + ServiceAlert + + HPEOneView.Appliance.ServiceAlert + + + + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + + + + + CaseID + + + ResourceName + + + SerialNumber + + + State + + + Created + + + Description + + + + + + + + + ProxyServer + + HPEOneView.Appliance.ServiceAlert + + + + + + + + CaseID + + + + ResourceName + + + + SerialNumber + + + + State + + + + Created + + + + Modified + + + + Description + + + + + + + + + SecurityProtocol + + HPEOneView.Appliance.SecurityProtocol + + + Mode + ApplianceSecurityProtocolMode-GroupingFormat + + + + + + + Left + + + + Left + + + + Left + + + + Left + + + + + + + + Name + + + Enabled + + + ModeIsEnabled + + + CipherSuites + + + + + + + + + AlertEmailFilter + + HPEOneView.Appliance.AlertEmailFilter + + + + + + + Left + + + + Left + + + + Left + + + + Left + + + + + + + filterName + + + disabled + + + displayFilter + + + emails + + + + + + + + + + ApplianceStatus + + HPEOneView.Appliance.ApplianceStatus + + + + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + + + + ApplianceConnection + + + "{0:#.##} GHz" -f $_.CPUSpeed + + + [HPEOneView.Utilities.Library]::IntToStorageString($_.Memory) + + + [HPEOneView.Utilities.Library]::BandwidthAsFormattedString($_.LinkSpeed) + + + "{0} Days, {1} Hours, {2} Minutes" -f $_.Uptime.Days, $_.Uptime.Hours, $_.Uptime.Minutes + + + + + + + + + + RotateMPPasswordPolicy + + HPEOneView.Appliance.RotateMPPasswordPolicy + + + + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + + + + ApplianceConnection + + + State + + + RotationInterval + + + + "{0:00}:{1:00}" -f $_.RotationTime.Hours, $_.RotationTime.Minutes + + + + LastRotatedOn + + + + + + + + + + RotateMPPasswordPolicyReport + + HPEOneView.Appliance.RotateMPPasswordPolicyReport + + + + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + + + + ApplianceConnection + + + DateRan + + + State + + + CompletedOn + + + Servers + + + + + + + + + + RotateMPPasswordPolicyReport+Server + + HPEOneView.Appliance.RotateMPPasswordPolicyReport+Server + + + + + + + Left + + + + Left + + + + Left + + + + + + + Name + + + Result + + + Message + + + + + + + + + + PortalConnectionToken + + HPEOneView.Appliance.RemoteSupport.PortalConnectionToken + + + + + + + Left + + + + Left + + + + Left + + + + Left + + + + + + + State + + + Token + + + "{0}:{1}" -f $_.ExpirationTimeLeft.Hours, $_.ExpirationTimeLeft.Minutes + + + ValidToken + + + + + + + + + + \ No newline at end of file diff --git a/Cluster.format.ps1xml b/Cluster.format.ps1xml new file mode 100644 index 0000000..e4b38ce --- /dev/null +++ b/Cluster.format.ps1xml @@ -0,0 +1,75 @@ + + + + + + + + HypervisorManager + + HPEOneView.Cluster.HypervisorManager + + + + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + + + + + Name + + + Port + + + Version + + + State + + + StateReason + + + Status + + + Username + + + + + + + + \ No newline at end of file diff --git a/HPEOneView.900.psd1 b/HPEOneView.900.psd1 new file mode 100644 index 0000000..ebb6c53 --- /dev/null +++ b/HPEOneView.900.psd1 @@ -0,0 +1,191 @@ +# +# Module manifest for module 'HPEOneView.900' +# +# Generated by: Hewlett-Packard Enterprise +# +# Generated on: 9/20/2024 +# + +@{ + +# Script module or binary module file associated with this manifest. +RootModule = 'HPEOneView.900.psm1' + +# Version number of this module. +ModuleVersion = '9.0.4010.1835' + +# Supported PSEditions +# CompatiblePSEditions = @() + +# ID used to uniquely identify this module +GUID = '93487b26-37bd-4c1a-bbe9-596baa795520' + +# Author of this module +Author = 'Hewlett-Packard Enterprise' + +# Company or vendor of this module +CompanyName = 'Hewlett-Packard Enterprise' + +# Copyright statement for this module +Copyright = ' (C) Copyright 2013-2024 Hewlett Packard Enterprise Development LP + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE.' + +# Description of the functionality provided by this module +Description = 'HPE OneView PowerShell Library' + +# Minimum version of the PowerShell engine required by this module +PowerShellVersion = '7.0' + +# Name of the PowerShell host required by this module +# PowerShellHostName = '' + +# Minimum version of the PowerShell host required by this module +# PowerShellHostVersion = '' + +# Minimum version of Microsoft .NET Framework required by this module. This prerequisite is valid for the PowerShell Desktop edition only. +DotNetFrameworkVersion = '4.7.2' + +# Minimum version of the common language runtime (CLR) required by this module. This prerequisite is valid for the PowerShell Desktop edition only. +ClrVersion = '4.0.30319.42000' + +# Processor architecture (None, X86, Amd64) required by this module +# ProcessorArchitecture = '' + +# Modules that must be imported into the global environment prior to importing this module +# RequiredModules = @() + +# Assemblies that must be loaded prior to importing this module +RequiredAssemblies = 'lib\HPEOneView_Classes.dll' + +# Script files (.ps1) that are run in the caller's environment prior to importing this module. +# ScriptsToProcess = @() + +# Type files (.ps1xml) to be loaded when importing this module +# TypesToProcess = @() + +# Format files (.ps1xml) to be loaded when importing this module +FormatsToProcess = 'Appliance.format.ps1xml', 'Cluster.format.ps1xml', + 'Networking.format.ps1xml', 'Server.format.ps1xml', + 'Storage.format.ps1xml' + +# Modules to import as nested modules of the module specified in RootModule/ModuleToProcess +# NestedModules = @() + +# Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export. +# FunctionsToExport = '*' + +# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export. +# CmdletsToExport = '*' + +# Variables to export from this module +# VariablesToExport = '*' + +# Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export. +# AliasesToExport = '*' + +# DSC resources to export from this module +# DscResourcesToExport = @() + +# List of all modules packaged with this module +# ModuleList = @() + +# List of all files packaged with this module +FileList = 'HPEOneView.900.psd1', 'HPEOneView.900.psm1', + 'Appliance.format.ps1xml', 'Cluster.format.ps1xml', + 'Networking.format.ps1xml', 'Server.format.ps1xml', + 'Storage.format.ps1xml', + 'HPEOneView.900_93487b26-37bd-4c1a-bbe9-596baa795520_HelpInfo.xml', + 'HPEOneView.900_93487b26-37bd-4c1a-bbe9-596baa795520_ModuleInfo.xml', + 'en-US\about_Appliance_Connections.help.txt', + 'en-US\about_Appliance_Connection_Permissions.help.txt', + 'en-US\about_Two_Factor_Authentication.help.txt', + 'en-US\about_HPEOneView.900.help.txt', + 'en-US\HPEOneView.900.psm1-help.xml', 'lib\HPEOneView_Classes.dll', + 'Samples\AddServers_Monitored_Sample.ps1', + 'Samples\AddStorageSystem_Sample.ps1', 'Samples\Alerts_Sample.ps1', + 'Samples\Appliance_Backup_Sample.ps1', + 'Samples\ApplianceConfig_Sample.ps1', + 'Samples\ComposerApplianceConfig_Sample.ps1', + 'Samples\Configure_IIS_WebDav_ExternalRepo_Sample.ps1', + 'Samples\ConfigureRemoteSupport_Sample.ps1', + 'Samples\CreateEnclosureGroup_Sample.ps1', + 'Samples\DefineLogicalInterconnectGroup_AA_VC_Sample.ps1', + 'Samples\DefineLogicalInterconnectGroup_Sample.ps1', + 'Samples\DefineNetworks_AA_VC_Sample.ps1', + 'Samples\DefineNetworks_Sample.ps1', + 'Samples\Server_Multiconnection_AA_VC_Sample.ps1', + 'Samples\Server_Multiconnection_Sample.ps1', + 'Samples\Server_Multiconnection_SAN_Storage_Sample.ps1', + 'Samples\Server_Profile_Template_Multiconnection_Sample.ps1', + 'Samples\Server_Profile_Template_Rack_Server_Sample.ps1', + 'Samples\Wipe_Appliance.ps1' + +# Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell. +PrivateData = @{ + + PSData = @{ + + # Tags applied to this module. These help with module discovery in online galleries. + Tags = 'Hewlett', 'Packard', 'Enterprise', 'HPE', 'HPOneView', 'HPEOneView', + 'HPESynergy' + + # A URL to the license for this module. + LicenseUri = 'https://github.com/HewlettPackard/POSH-HPEOneView/blob/master/LICENSE' + + # A URL to the main website for this project. + ProjectUri = 'http://hewlettpackard.github.io/POSH-HPEOneView' + + # A URL to an icon representing this module. + # IconUri = '' + + # ReleaseNotes of this module + ReleaseNotes = 'Release 9.00.4010.1835 + + + - Initial HPE OneView 9.00 library release. + - Added Get-OVRotateMPPasswordPolicy and Set-OVRotateMPPasswordPolicy cmdlets that will rotate the priviledged user account OneView deploys to a servers embedded management processor (i.e. iLO). + - Added Firmware Bundle Updates to New-OVServerProfileTemplate and New-OVServerProfile Cmdlets. + - Added server profile support to Update-OVServerFirmware Cmdlet. This will modify the server profile resource directly, and not invoke the process with the server hardware resource. + - Added Get-OVRemoteSupportPortalConnection, Register-OVRemoteSupportPortalConnection, Unregister-OVRemoteSupportPortalConnection Cmdlets to manage registering the appliance with the HPE Support Center for enhanced support case vibility. + - Fixed New-OVRemoteSupportContact returning the correct object type. + - Remove-OVRemoteSupportPartner API returns an Async task.' + + # Prerelease string of this module + # Prerelease = '' + + # Flag to indicate whether the module requires explicit user acceptance for install/update/save + # RequireLicenseAcceptance = $false + + # External dependent modules of this module + # ExternalModuleDependencies = @() + + } # End of PSData hashtable + +} # End of PrivateData hashtable + +# HelpInfo URI of this module +HelpInfoURI = 'http://hewlettpackard.github.io/POSH-HPEOneView/UpdateHelp' + +# Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix. +# DefaultCommandPrefix = '' + +} + + diff --git a/HPEOneView.900.psm1 b/HPEOneView.900.psm1 new file mode 100644 index 0000000..ddcf773 --- /dev/null +++ b/HPEOneView.900.psm1 @@ -0,0 +1,149083 @@ +############################################################################## +# HPE OneView PowerShell Library +############################################################################## +############################################################################## +## (C) Copyright 2013-2024 Hewlett Packard Enterprise Development LP +############################################################################## +<# + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + +#> + +# Set HPEOneView POSH Library Version +[Version]$ModuleVersion = '9.00.4010.1835' +New-Variable -Name PSLibraryVersion -Scope Global -Value ([HPEOneView.Library.Version]::new($ModuleVersion)) -Option Constant -ErrorAction SilentlyContinue +$Global:CallStack = Get-PSCallStack +$script:ModuleVerbose = [Bool]($Global:CallStack | Where-Object { $_.Command -eq "" }).position.text -match "-verbose" +[void][Reflection.Assembly]::LoadWithPartialName("System.Web") + +# Need to add a check here for .NetFramework for Windows PowerShell 5.1 only +if ($PSVersionTable.PSVersion.Major -eq '5' -and $PSVersionTable.Platform -eq 'Win32NT') +{ + + $ReleaseKey = Get-Item 'HKLM:\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full\' | Get-ItemPropertyValue -Name Release + + if ($ReleaseKey -lt 461808) + { + + [System.String]$Exception = 'InvalidOperationException' + [System.String]$ErrorId = 'UnableToLoadModuleMissingDependancy' + [System.Object]$TargetObject = 'Import-Module HPEOneView.{0}{1:D2}' -f $ModuleVersion.Major, $ModulaVersion.Minor + [System.Management.Automation.ErrorCategory]$ErrorCategory = 'ResourceUnavailable' + [System.String]$Message = 'The library is unable to load due to this sytem missing the required .NetFramework 4.7.2 client. Please visit https://go.microsoft.com/fwlink/?LinkId=863265 to download the .NetFramework 4.7.2 Offline Installer.' + + throw [Management.Automation.ErrorRecord]::new((New-Object $Exception $Message), $ErrorID, $ErrorCategory, $TargetObject) + + } + +} + +# Check to see if another module is loaded in the console, but allow Import-Module to Process normally if user specifies the same module name +if (Get-Module -Name HPEOneView.* | Where-Object Name -ne "HPEOneView.830") +{ + + write-Host "CRITICAL: Another HPE OneView module is already loaded: " -ForegroundColor Yellow -BackgroundColor Black + Write-Host " |" -ForegroundColor Yellow -BackgroundColor Black + get-module -name HPEOneView.* | ForEach-Object { write-host " |--> $($_.name) ($($_.Version))" -ForegroundColor Yellow -BackgroundColor Black } + write-host "" + + [System.String]$Exception = 'InvalidOperationException' + [System.String]$ErrorId = 'CannotLoadMultipleLibraries' + [System.Object]$TargetObject = 'Import-Module HPEOneView.{0}{1:##}' -f $ModuleVersion.Major, $ModulaVersion.Minor + [System.Management.Automation.ErrorCategory]$ErrorCategory = 'ResourceExists' + [System.String]$Message = 'Another HPE OneView module is already loaded. The HPE OneView PowerShell library does not support loading multiple versions of libraries within the same console.' + + throw [Management.Automation.ErrorRecord]::new((New-Object $Exception $Message), $ErrorID, $ErrorCategory, $TargetObject) + +} + +# Region URIs and Enums +${Global:ConnectedSessions} = [HPEOneView.Library.ConnectedSessionsList]::new() +${Global:ResponseErrorObject} = [System.Collections.ArrayList]::new() +New-Variable -Name DefaultTimeout -Value (New-Timespan -Minutes 20) -Option Constant +$script:FSOpenMode = [System.IO.FileMode]::Open +$script:FSRead = [System.IO.FileAccess]::Read +$RegExInsensitiveFlag = [System.Text.RegularExpressions.RegexOptions]::IgnoreCase +[MidpointRounding]$MathMode = 'AwayFromZero' +[String]$MinXAPIVersion = "6600" +[String]$MaxXAPIVersion = "6600" +[String]$Repository = "https://api.github.com/repos/HewlettPackard/POSH-HPEOneView/releases" + +if ($Global:IgnoreCertPolicy) +{ + + [HPEOneView.PKI.SslValidation]::IgnoreCertErrors = $true + +} + +# Global Enum +$ResourceCategoryEnum = @{ + Alert = "alerts"; + Baseline = "firmware-drivers"; + ClusterNode = "hypervisor-host-profiles"; + ClusterProfile = "hypervisor-cluster-profiles"; + Datacenter = "datacenters"; + Drive = "drives"; + DriveEnclosure = "drive-enclosures"; + Enclosure = "enclosures"; + EnclosureGroup = "enclosure-groups"; + EthernetNetwork = "ethernet-networks"; + FabricManager = "fabric-managers"; + FabricManagerTenant = "tenants"; + FCoENetwork = "fcoe-networks"; + FibreChannelNetwork = "fc-networks"; + HypervisorCluster = "hypervisor-cluster-profiles"; + HypervisorManager = "hypervisor-managers"; + ImageStreamer = "image-streamer"; + Interconnect = "interconnects"; + IPv4Range = "id-range-IPv4"; + IPv4Subnet = "id-range-IPv4-subnet"; + IPv6Range = "id-range-IPv6"; + IPv6Subnet = "id-range-IPv6-subnet"; + LogicalEnclosure = "logical-enclosures"; + LogicalInterconnect = "logical-interconnects"; + LogicalInterconnectGroup = "logical-interconnect-groups"; + LogicalJBOD = "sas-logical-jbods"; + LogicalSwitch = "logical-switches"; + LogicalSwitchGroup = "logical-switch-groups"; + ManagedSAN = "fc-sans"; + NetworkSet = "network-sets"; + OSDeploymentPlan = "os-deployment-plans"; + Rack = "racks"; + RackManager = "rack-managers"; + RepositoryManager = "repository-manager"; + RoCENetwork = "roce-networks"; + SasInterconnect = "sas-interconnects"; + SasLogicalInterconnect = "sas-logical-interconnects"; + SasLogicalInterconnectGroup = "sas-logical-interconnect-groups"; + ServerHardware = "server-hardware"; + ServerHardwareType = "server-hardware-types"; + ServerProfile = "server-profiles"; + ServerProfileTemplate = "server-profile-templates"; + StoragePool = "storage-pools"; + StorageSystem = "storage-systems"; + StorageVolume = "storage-volumes"; + StorageVolumeSet = "storage-volume-sets"; + StorageVolumeTemplate = "storage-volume-templates"; + Task = "tasks"; + UplinkSet = "uplink-sets"; + Updates = "updates"; + User = "users" +} + +# Global RegEx +[RegEx]$EmbeddedVariableNameRegEx = "{(?'variable'\w*)}" + +#------------------------------------ +# Appliance Configuration +#------------------------------------ + [Int]$ApplianceStartupTimeout = 900 + [String]$ApplianceStartProgressUri = '/rest/appliance/progress' + [String]$ApplianceVersionUri = '/rest/appliance/nodeinfo/version' + [String]$ApplianceEulaStatusUri = '/rest/appliance/eula/status' + [String]$ApplianceEulaSaveUri = '/rest/appliance/eula/save' + [String]$ApplianceNetworkConfigUri = '/rest/appliance/network-interfaces' + [String]$ApplianceNetworkStatusUri = '/rest/appliance/network-interfaces/status' + [String]$ApplianceNetworkMacAddrUri = '/rest/appliance/network-interfaces/mac-addresses' + [String]$ApplinaceStaticRoutesUri = '/rest/appliance/static-routes' + [String]$ApplianceDateTimeUri = '/rest/appliance/configuration/time-locale' + [String]$ApplianceGlobalSettingsUri = '/rest/global-settings' + [String]$ApplianceBaselineRepoUri = '/rest/firmware-drivers' + [String]$ApplianceRepositoriesUri = '/rest/repositories' + [String]$ApplianceBaselineRepositoriesUri = '/rest/firmware-repositories/defaultOneViewRepo' + [Hashtable]$RepositoryType = @{ + External = 'FirmwareExternalRepo'; + Internal = 'FirmwareInternalRepo' + } + [String]$DuplicateFWBaselineTermsRegEx = "\'(?([a-zA-Z0-9_-]*\s?)+)\'" + [regex]$NFSPathRegEx = '^([a-zA-Z0-9.\-]+):(\/[a-zA-Z0-9_-]+)+$' + [String]$ApplianceXApiVersionUri = '/rest/version' + [String]$ApplianceStatusInfoUri = '/rest/appliance/nodeinfo/status' + [String]$ApplianceHANodesUri = '/rest/appliance/ha-nodes' + [String]$ApplianceBackupUri = '/rest/backups' + [String]$ApplianceRestoreRepoUri = '/rest/backups/archive' + [String]$ApplianceAutoBackupConfUri = '/rest/backups/config' + [String]$ApplianceAutoBackupHostKeyUri = '/rest/backups/hostkey' + [String]$ApplianceRestoreUri = '/rest/restores' + [String]$ApplianceProxyConfigUri = '/rest/appliance/proxy-config' + [Hashtable]$ApplianceUpdateProgressStepEnum = @{ + + COMPLETED = "Restore Completed"; + FAILED = "Restore Failed"; + PREPARING_TO_RESTORE = "Preparing to Restore"; + RESTORING_DB = "Restoring Database"; + RESTORING_FILES = "Restoring Files"; + STARTING_SERVICES = "Starting Services"; + UNKNOWN = "The restore step is unknown" + + } + [Hashtable]$ApplianceLocaleSetEnum = @{ + + 'en-US' = 'en_US.UTF-8'; + 'en_US' = 'en_US.UTF-8'; + 'zh_CN' = 'zh_CN.UTF-8'; + 'zh-CN' = 'zh_CN.UTF-8'; + 'ja_JP' = 'ja_JP.UTF-8'; + 'ja-JP' = 'ja_JP.UTF-8'; + + } + [Hashtable]$ApplianceLocaleEnum = @{ + + 'en_US.UTF-8' = 'English (United States)'; + 'zh_CN.UTF-8' = 'Chinese (China)'; + 'ja_JP.UTF-8' = 'Japanese (Japan)'; + + } + [Hashtable]$DayOfWeekEnum = @{ + + Sunday = 'SU'; + SU = 'SU'; + SUN = 'SU'; + Monday = 'MO'; + MO = 'MO'; + MON = 'MO'; + Tuesday = 'TU'; + TU = 'TU'; + TUE = 'TU'; + TUES = 'TU'; + WE = 'WE'; + WED = 'WE'; + Thursday = 'TH'; + Thur = 'TH'; + Thurs = 'TH'; + TH = 'TH'; + Friday = 'FR'; + Fri = 'FR'; + FR = 'FR'; + Saturday = 'SA'; + Sat = 'SA'; + SA = 'SA'; + + } + [Hashtable]$AppliancePlatformType = @{ + + hardware = 'Composer'; + vm = 'VMA' + + } + [Hashtable]$NTPSourceEnum = @{ + + ServerDefault = "Appliance"; + ICMDefault = "ExternalNtpServers"; + Appliance = "Appliance"; + External = "ExternalNtpServers" + + } + [String]$ApplianceSupportDumpUri = "/rest/appliance/support-dumps" + [String]$ApplianceHealthStatusUri = "/rest/appliance/health-status" + [String]$ApplianceUpdateImageUri = "/rest/appliance/firmware/image" + [String]$ApplianceUpdatePendingUri = "/rest/appliance/firmware/pending" + [String]$ApplianceUpdateNotificationUri = "/rest/appliance/firmware/notification" + [String]$ApplianceUpdateMonitorUri = "/cgi-bin/status/update-status.cgi" + [String]$ApplianceSnmpReadCommunityUri = "/rest/appliance/device-read-community-string" + [String]$script:applianceRebootUri = '/rest/appliance/shutdown?type=REBOOT' + [String]$script:applianceShutDownUri = '/rest/appliance/shutdown?type=HALT' + [String]$script:applianceCsr = '/rest/certificates/https/certificaterequest' + [String]$script:applianceSslCert = '/rest/certificates/https' + [String]$ApplianceCertPFXUploadUri = '{0}/pkcs12' -f $applianceSslCert + [String]$Script:appliancePingTestUri = '/rest/appliance/reachable' + [String]$script:applianceDebugLogSetting = '/logs/rest/debug/' + [String]$script:RemoteSyslogUri = '/rest/remote-syslog' + [String]$script:IPSubnetAddressPattern = '^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.' + + '(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.' + + '(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.' + + '(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)' + + '(/0*([1-9]|[12][0-9]|3[0-2]))?$' + [String]$LabelsUri = '/rest/labels' + [String]$LabelsResourcesBaseUri = '/rest/labels/resources' + [String]$ApplianceSnmpV3TrapDestUri = '/rest/appliance/snmpv3-trap-forwarding/destinations' + [String]$ApplianceSnmpV3UsersUri = '/rest/appliance/snmpv3-trap-forwarding/users' + [String]$ApplianceSnmpV1TrapDestUri = '/rest/appliance/trap-destinations' + [String]$ApplianceSnmpV1TrapDestValidationUri = '/rest/appliance/trap-destinations/validation' + [String]$ApplianceSnmpV3TrapDestUri = '/rest/appliance/snmpv3-trap-forwarding/destinations' + [String]$ApplianceSnmpV3TrapDestValidationUri = '/rest/appliance/snmpv3-trap-forwarding/destinations/validation' + [String]$ApplianceSnmpV3EngineIdUri = '/rest/global-settings/appliance/global/applianceSNMPv3EngineId' + [Regex]$ApplianceSnmpV3EngineIdValidationPattern = '^[A-Za-z0-9]{16}$' + [String]$ApplianceFixmeLogsDownloadUri = '/rest/fixme-logs/download' + [String]$ApplianceComposerConfigUri = '/rest/hw-appliances' + [String]$ApplianceStaticRoutesUri = '/rest/appliance/static-routes' + [String]$ApplianceUpdateScheduleUri = '/rest/update-settings/schedule' + [Hashtable]$ApplianceUpdateScheduleStateEnum = @{ + Enabled = "Enabled"; + Disabled = "Disabled"; + CheckForUpdates = "CheckForUpdates" + } + [Hashtable]$ApplianceUpdateScheduleDayEnum = @{ + Monday = "Monday"; + Tuesday = "Tuesday"; + Thursday = "Thursday"; + Friday = "Friday"; + Saturday = "Saturday"; + Sunday = "Sunday" + } + [Hashtable]$ApplianceUpdateScheduleIntervalEnum = @{ + Manual = "Manual"; + Weekly = "Weekly" + } + [String]$ApplianceAvailableUpdatesUri = '/rest/updates' + [String]$ApplianceGlobalSecuritySettingsUri = '/rest/security/global-settings' + [String]$ApplianceComputeOpsManagementUri = '/rest/appliance/cloud' + +#------------------------------------ +# Remote Support +#------------------------------------ + [String]$RemoteSupportUri = '/rest/support' + [String]$RemoteSupportEventsUri = '/rest/support/events' + [String]$RemoteSupportConfigUri = '/rest/support/configuration' + [String]$RemoteSupportRegistrationUri = '/rest/support/registration' + [String]$RemoteSupportPortalConnectionUri = '/rest/support/portal-connection' + [String]$RemoteSupportPortalRegistrationCodeUri = '/rest/support/portal-connection/registration-code' + [String]$RemoteSupportContactsUri = '/rest/support/contacts' + [String]$RemoteSupportSitesUri = '/rest/support/sites' + [String]$RemoteSupportDefaultSitesUri = '/rest/support/sites/default' + [String]$ServerHardwareRemoteSupportSettingsUri = '/rest/support/server-hardware' + [String]$EnclosureRemoteSupportSettingsUri = '/rest/support/server-hardware' + [String]$RemoteSupportDataCollectionsUri = '/rest/support/data-collections' + [String]$RemoteSupportDataCollectionsDownloadUri = '/rest/support/data-collections/download' + [String]$RemoteSupportChannelPartnersUri = '/rest/support/channel-partners' + [String]$RemoteSupportChannelPartnersValidatorUri = '/rest/support/channel-partners/validator' + [String]$RemoteSupportDataCollectionScheduleUri = '/rest/support/schedules' + [String]$RemoteSupportComputeSettingsUri = '/rest/support/server-hardware' + $RemoteSupportRefreshAllDeviceEntitlementUri = '/rest/support/entitlements/refreshEntitlementAllDevices' + [String]$RemoteSupportRackManagerSettingsUri = '/rest/support/rack-managers' + [String]$RemoteSupportEnclosureSettingsUri = '/rest/support/enclosures' + [String]$RemoteSupportInterconnectSettingsUri = '/rest/support/interconnects' + [String]$RemoteSupportSasInterconnectSettingsUri = '/rest/support/sas-interconnects' + [HashTable]$RemoteSupportResourceSettingEnum = @{ + 'salesChannelPartnerUri' = 'SalesChannelPartner'; + 'supportChannelPartnerUri' = 'SupportChannelPartner'; + 'primaryContactUri' = 'PrimaryContact'; + 'secondaryContactUri' = 'SecondaryContact' + } + [Hashtable]$RemoteSupportCollectionEnum = @{ + 'AHS' = 'AHS'; + 'Basic' = 'Basic' + } + [Hashtable]$RemoteSupportPortalRegistrationStateEnum = @{ + Expired = "EXPIRED"; + Received = "RECEIVED"; + Registred = "REGISTERED"; + RegistrationInProgress = "REGISTRATION_IN_PROGRESS"; + Requested = "REQUESTED"; + Generating = 'GENERATING'; + Generated = 'GENERATED' + } + [Array]$RemoteSupportUris = @( + $RemoteSupportUri, + $RemoteSupportConfigUri, + $RemoteSupportRegistrationUri, + $RemoteSupportContactsUri, + $RemoteSupportSitesUri, + $RemoteSupportDefaultSitesUri + ) +#------------------------------------ +# Remote Technician +#------------------------------------ + [String]$RemoteTechnicianUri = '/rest/appliance/rda-cas' + [String]$RemoteTechnicianAclUri = '{0}/access-control' -f $RemoteTechnicianUri + [String]$RemoteTechnicianActiveTechniciaConnectionsUri = '{0}/connections' -f $RemoteTechnicianUri + [String]$RemoteTechnicianActiveApplianceConnectivityStatusUri = '{0}/connectivity' -f $RemoteTechnicianUri + [String]$RemoteTechnicianAgentInfoUri = '{0}/info' -f $RemoteTechnicianUri + [String]$RemoteTechnicianConnectivitySessionsUri = '{0}/sessions' -f $RemoteTechnicianUri + [String]$RemoteTechnicianTunnelSessionsUri = '{0}/tunnel' -f $RemoteTechnicianUri +#------------------------------------ +# Server Resource Management +#------------------------------------ + [String]$SynergyEnclosureTypeUri = "/rest/enclosure-types/SY12000" + [String]$ServerHardwareUri = "/rest/server-hardware" + [String]$ServerMigrationUri = '/rest/migrate' + [String]$MigratableServersUri = '/rest/migrate/migratable-server-hardware' + [String]$ServerHardwareFirmwareComplianceUri = '{0}/firmware-compliance' -f $ServerHardwareUri + [String]$ServerHardwareTypesUri = "/rest/server-hardware-types" + [String]$EnclosuresUri = "/rest/enclosures" + [String]$LogicalEnclosuresUri = '/rest/logical-enclosures' + [String]$EnclosureGroupsUri = "/rest/enclosure-groups" + [String]$EnclosureGroupType = 'EnclosureGroupV8' + [String]$ApplianceFwBundlesUri = "/rest/firmware-bundles" + [String]$ApplianceFwCompSigUri = "/rest/firmware-bundles/addCompsig?uploadfilename={0}" + [String]$ApplianceFwDriversUri = "/rest/firmware-drivers" + [String]$RackManagerUri = '/rest/rack-managers' + [String]$PowerDevicesUri = "/rest/power-devices" + [String]$PowerDevicesDiscoveryUri = "/rest/power-devices/discover" + [String]$PowerDevicePotentialConnections = "/rest/power-devices/potentialConnections?providerUri=" + [String]$UnmanagedDevicesUri = "/rest/unmanaged-devices?sort=name:asc" + [PSCustomObject]$MpModelTable = @{ + ilo2 = "RI7"; + ilo3 = "RI9"; + ilo4 = "RI10" + iLO5 = "RI11" + } + [HashTable]$Script:ServerPowerControlEnum = @{ + + PressAndHold = 'PressAndHold'; + MomentaryPress = 'MomentaryPress'; + ColdBoot = 'ColdBoot'; + Reset = 'Reset' + + } + [String]$SyngergyEnclosureTypeUri = '/rest/enclosure-types/SY12000' + [Hashtable]$EnclosureGroupIpAddressModeEnum = @{ + + DHCP = 'DHCP'; + External = 'External'; + AddressPool = 'IpPool' + IpPool = 'AddressPool' + + } + [Hashtable]$FramePowerModeEnum = @{ + + RedundantPowerSupply = 'RedundantPowerSupply'; + RedundantPowerFeed = 'RedundantPowerFeed' + + } + [Hashtable]$FrameAmbientTemperatureEnum = @{ + + 'ASHRAE_A3' = 'ASHRAE_A3'; + 'ASHRAE_A4' = 'ASHRAE_A4'; + 'Standard' = 'Standard'; + 'Telco' = 'Telco' + } + [Hashtable]$LogicalEnclosureFirmwareUpdateMethodEnum = @{ + EnclosureOnly = 'EnclosureOnly'; + SharedInfrastructureOnly = 'SharedInfrastructureOnly'; + SharedInfrastructureAndServerProfiles = 'SharedInfrastructureAndServerProfiles' + } + [Hashtable]$LogicalInterconnectUpdateModeEnum = @{ + Orchestrated = 'Orchestrated'; + Parallel = 'Parallel' + } + [Hashtable]$ServerHardwareOneTimeBootEnum = @{ + Normal = 'Normal'; + CD = 'CDROM'; + USB = 'USB'; + HardDisk = 'HDD'; + PXE = 'NETWORK'; + CDROM = 'CD'; + HDD = 'HardDisk'; + NETWORK = 'PXE' + } + [String]$FQDNRegex = "^(?=.{1,254}$)((?=[a-z0-9-]{1,63}\.)(xn--+)?[a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{1,63}$" + + Enum LogicalEnclosureEbipaAddresTypeEnum { + IPv4; + IPv6 + } + + Enum FirmwarePolicyGenerationSupportEnum { + Gen10; + Gen10Plus; + Gen10Plusv2; + Gen11 + } + + Enum LogicalDiskControllerEnum { + + Embedded; + Mezz1; + Mezz2; + Mezz3; + Slot1; + Slot2; + Slot3; + Slot4; + Slot5; + Slot6; + Slot7; + Slot8; + Slot9; + Slot10; + Slot11; + Slot12; + Slot13; + Slot14; + Slot15; + Slot16; + + } + + $LogicalDiskControllerEnumDict = @{ + Embedded = "Embedded"; + Mezz1 = "Mezz 1"; + Mezz2 = "Mezz 2"; + Mezz3 = "Mezz 3"; + Slot1 = "Slot 1"; + Slot2 = "Slot 2"; + Slot3 = "Slot 3"; + Slot4 = "Slot 4"; + Slot5 = "Slot 5"; + Slot6 = "Slot 6"; + Slot7 = "Slot 7"; + Slot8 = "Slot 8"; + Slot9 = "Slot 9"; + Slot10 = "Slot 10"; + Slot11 = "Slot 11"; + Slot12 = "Slot 12"; + Slot13 = "Slot 13"; + Slot14 = "Slot 14"; + Slot15 = "Slot 15"; + Slot16 = "Slot 16"; + + } + + enum ServerProfileControllerFamilyEnum { + + MegaRAID; + SmartRAID + + } + [Hashtable]$ServerProfileControllerFamilyEnumDict = @{ + + MegaRAID = "MegaRAID"; + SmartRAID = "SmarRAID" + } +#------------------------------------ +# Storage Resource Management +#------------------------------------ + [String]$SasLogicalInterconnectType = 'sas-logical-interconnectV2' + [String]$SasLogicalInterconnectGroupType = 'sas-logical-interconnect-groupV2' + [String]$DriveEnclosureUri = '/rest/drive-enclosures' + [Array]$DriveCollectionSortExpression = @{Expression = {$_.attributes.driveEnclosureUri}; Ascending = $true}, @{Expression = {$_.Name}; Ascending = $true} + [String]$DriveType = 'DriveV2' + [String]$SasLogicalJBODUri = '/rest/sas-logical-jbods' + [String]$SasLogicalJBODType = 'sas-logical-jbodV4' + [String]$SasInterconnectTypeUri = '/rest/sas-interconnect-types' + [String]$SasInterconnectsUri = '/rest/sas-interconnects' + [String]$SasLogicalInterconnectsUri = '/rest/sas-logical-interconnects' + [String]$SasLogicalInterconnectGroupsUri = '/rest/sas-logical-interconnect-groups' + [String]$StorageSystemsUri = "/rest/storage-systems" + [String]$StorageVolumesUri = "/rest/storage-volumes" + [String]$StorageVolumeFromSnapshotUri = '/rest/storage-volumes/from-snapshot' + [String]$StoragePoolsUri = "/rest/storage-pools" + [String]$ReachableStoragePoolsUri = '/rest/storage-pools/reachable-storage-pools' + [String]$AttachableStorageVolumesUri = '/rest/storage-volumes/attachable-volumes' + [String]$StorageVolumeTemplateUri = "/rest/storage-volume-templates" + [String]$ApplStorageVolumeTemplateRequiredPolicy = '/rest/global-settings/appliance/global/StorageVolumeTemplateRequired' + [String]$fcSanManagerProvidersUri = "/rest/fc-sans/providers" # List available SAN Manager plugins, and create SAN Manager + [Hashtable]$StorageVolumeProvisioningTypeEnum = @{ + 'Thin' = 'Thin'; + 'Full' = 'Full'; + 'ThinDeduplication' = 'Thin Deduplication' + } + [Hashtable]$SnmpAuthLevelEnum = @{ + None = "noauthnopriv"; + AuthOnly = "authnopriv"; + AuthAndPriv = "authpriv" + } + [Hashtable]$Snmpv3UserAuthLevelEnum = @{ + None = "None"; + AuthOnly = "Authentication"; + AuthAndPriv = "Authentication and privacy" + } + [Hashtable]$SnmpAuthProtocolEnum = @{ + + 'none' = 'none'; + 'md5' = 'MD5'; + 'SHA' = 'SHA'; + 'sha1' = 'SHA1'; + 'sha2' = 'SHA2'; + 'sha256' = 'SHA256'; + 'sha384' = 'SHA384'; + 'sha512' = 'SHA512' + + } + [Hashtable]$SnmpPrivProtocolEnum = @{ + 'none' = 'none'; + 'aes' = "AES128"; + 'aes-128' = "AES128"; + 'aes-192' = "AES192"; + 'aes-256' = "AES256"; + 'aes128' = "AES128"; + 'aes192' = "AES192"; + 'aes256' = "AES256"; + 'des56' = "DES56"; + '3des' = "3DES"; + 'tdea' = 'TDEA' + } + [Hashtable]$ApplianceSnmpV3PrivProtocolEnum = @{ + 'none' = 'none'; + "des56" = 'DES'; + '3des' = '3DES'; + 'aes128' = 'AES-128'; + 'aes192' = 'AES-192'; + 'aes256' = 'AES-256' + } + [String]$script:FcSanManagersUri = "/rest/fc-sans/device-managers" # Created SAN Managers + [String]$script:FcManagedSansUri = "/rest/fc-sans/managed-sans" # Discovered managed SAN(s) that the added SAN Manager will manage + [String]$script:FcZonesUri = '/rest/fc-sans/zones' + [String]$Script:SanEndpoints = '/rest/fc-sans/Endpoints' + [RegEx]$Script:iQNPattern = '^(?:iqn\.[0-9]{4}-[0-9]{2}(?:\.[A-Za-z](?:[A-Za-z0-9\-]*[A-Za-z0-9])?)+(?::.*)?|eui\.[0-9A-Fa-f]{16})' + [RegEx]$StoreServeTargetPortIDPattern = '\d:\d:\d' + [Hashtable]$StorageVolShareableEnum = @{ + + Private = $false; + Shared = $true + + } + [Hashtable]$StorageSystemFamilyTypeEnum = @{ + StoreVirtual = 'StoreVirtual'; + StoreServ = 'StoreServ'; + Nimble = 'Nimble'; + Primera = 'Primera'; + Alletra5000 = 'Alletra5000'; + Alletra6000 = 'Alletra6000'; + Alletra9000 = 'Alletra9000' + } + Enum NimbleBasedStorageSystemsEnum { + Alletra5000; + Alletra6000; + Nimble; + } + Enum ThreeParBasedStorageSystemsEnum { + ThreePar; + StoreServ; + Primera; + Alletra9000; + } + [Hashtable]$Global:StorageSystemPortModeEnum = @{ + + AutoSelectExpectedSan = 'Auto'; + Ignore = 'Ignore'; + Managed = 'Managed' + + } + [Hashtable]$StorageVolumeProvisioningTypeEnum = @{ + Full = 'Full'; + Thin = 'Thin'; + TPDD = 'Thin' + } + [Hashtable]$AuthenticDriveEnum = @{ + + yes = $true; + no = $false + + } +#------------------------------------ +# Network Resource Management +#------------------------------------ + [String]$LogicalInterconnectGroupType = 'logical-interconnect-groupV8' + [String]$LogicalInterconnectEthernetSettingsType = "EthernetInterconnectSettingsV7" + [String]$LogicalInterconnectGroupCategory = 'logical-interconnect-groups' + [String]$InterconnectLinkTopologies = '/rest/interconnect-link-topologies' + [String]$NetworkSetsUri = "/rest/network-sets" + [String]$NetworkSetType = 'network-setV5' + [String]$EthernetNetworksUri = "/rest/ethernet-networks" + [String]$EthernetNetworkType = "ethernet-networkV4" + [String]$EthernetNetworkBulkType = "bulk-ethernet-networkV2" + [String]$FCNetworksUri = "/rest/fc-networks" + [String]$FCNetworkType = "fc-networkV4" + [String]$FCoENetworksUri = "/rest/fcoe-networks" + [String]$FCoENetworkType = "fcoe-networkV4" + [String]$RoCENetworksUri = "/rest/roce-networks" + [String]$RoCENetworkType = "roce-network" + [String]$ConnectionTemplatesUri = "/rest/connection-templates" + [String]$LogicalInterconnectGroupsUri = "/rest/logical-interconnect-groups" + [String]$LogicalInterconnectsUri = "/rest/logical-interconnects" + [String]$InterconnectsUri = "/rest/interconnects" + [String]$InterconnectTypesUri = '/rest/interconnect-types' + [String]$UplinkSetsUri = "/rest/uplink-sets" + [String]$UplinkSetType = "uplink-setV7" + [String]$LogicalDownlinksUri = "/rest/logical-downlinks" + [String]$SwitchTypesUri = '/rest/switch-types' + [String]$LogicalSwitchGroupsUri = '/rest/logical-switch-groups' + [String]$LogicalSwitchesUri = '/rest/logical-switches' + [String]$SwitchesUri = '/rest/switches' + [String]$FabricManagersUri = '/rest/fabric-managers' + [String]$FabricManagerType = "FabricManagerV2" + [String]$DomainFabrics = '/rest/fabrics' + [Hashtable]$LogicalSwitchManagementLevelEnum = @{ + Managed = 'BASIC_MANAGED'; + Monitored = 'MONITORED'; + ManagedSnmpV3 = 'BASIC_MANAGED'; + MonitoredSnmpV3 = 'MONITORED' + } + [String]$ApplianceVmacPoolsUri = '/rest/id-pools/vmac' + [String]$ApplianceVmacPoolRangesUri = '/rest/id-pools/vmac/ranges' + [String]$ApplianceVwwnPoolsUri = '/rest/id-pools/vwwn' + [String]$ApplianceVwwnPoolRangesUri = '/rest/id-pools/vwwn/ranges' + [String]$ApplianceVsnPoolsUri = '/rest/id-pools/vsn' + [String]$ApplianceVsnPoolRangesUri = '/rest/id-pools/vsn/ranges' + [String]$ApplianceIPv4PoolsUri = '/rest/id-pools/ipv4' + [String]$ApplianceIPv4SubnetsUri = '/rest/id-pools/ipv4/subnets' + [String]$ApplianceIPv4PoolRangesUri = '/rest/id-pools/ipv4/ranges' + [String]$ApplianceIPv6PoolsUri = '/rest/id-pools/ipv6' + [String]$ApplianceIPv6SubnetsUri = '/rest/id-pools/ipv6/subnets' + [String]$ApplianceIPv6PoolRangesUri = '/rest/id-pools/ipv6/ranges' + [String]$ApplianceVmacGenerateUri = '/rest/id-pools/vmac/generate' + [String]$ApplianceVwwnGenerateUri = '/rest/id-pools/vwwn/generate' + [String]$ApplianceVsnPoolGenerateUri = '/rest/id-pools/vsn/generate' + [Regex]$MacAddressPattern = '^(?:[A-Fa-f0-9]{2}[:-]){5}(?:[A-Fa-f0-9]{2})$' + [Regex]$WwnAddressPattern = '^([0-9a-fA-F]{2}:){7}([0-9a-fA-F]{2})$' + [Regex]$WwnLongAddressPattern = '^([0-9a-fA-F]{2}:){15}([0-9a-fA-F]{2})$' + [RegEx]$IPv4AddressPattern = "^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$" + [RegEx]$SnmpV3EngineIdPattern = "^10x([A-Fa-f0-9]{2}){5,32}" + [RegEx]$UplinkPortParameterRegExPattern = "^(?'Enclosure'[E|e]nclosure\d)?\:?(?'Bay'[B|b]ay\d)\:(?'FaceplatePort'[X|x|Q|q]?\d*\.?\d+)\:?(?'Subport'\d+)?" + [HashTable]$Global:FCNetworkFabricTypeEnum = @{ + + FA = 'FabricAttach'; + FabricAttach = 'FabricAttach'; + DA = 'DirectAttach'; + DirectAttach = 'DirectAttach' + + } + [Hashtable]$global:GetUplinkSetPortSpeeds = @{ + Speed0M = "0"; + Speed100M = "100Mb"; + Speed10G = "10Gb"; + Speed10M = "10Mb"; + Speed1G = "1Gb"; + Speed1M = "1Mb"; + Speed20G = "20Gb"; + Speed2G = "2Gb"; + Speed2_5G = "2.5Gb"; + Speed40G = "40Gb"; + Speed4G = "4Gb"; + Speed8G = "8Gb"; + Auto = "Auto" + } + [Hashtable]$global:SetUplinkSetPortSpeeds = @{ + '0' = "Speed0M"; + '100M' = "Speed100M"; + '100' = "Speed100M"; + '10G' = "Speed10G"; + '10' = "Speed10G"; + '10M' = "Speed10M"; + '120G' = "Speed120G"; + '120' = "Speed120G"; + '1G' = "Speed1G"; + '1' = "Speed1G"; + '1M' = "Speed1M"; + '20G' = "Speed20G"; + '20' = "Speed20G"; + '25G' = "Speed25G"; + '25' = "Speed25G"; + '2G' = "Speed2G"; + '2' = "Speed2G"; + '2.5G' = "Speed2_5G"; + '40G' = "Speed40G"; + '50G' = "Speed50G"; + '50' = "Speed50G"; + '4G' = "Speed4G"; + '8G' = "Speed8G"; + '4' = "Speed4G"; + '8' = "Speed8G"; + '16' = "Speed16G"; + '16G' = 'Speed16G'; + '32' = "Speed32G"; + '32G' = "Speed32G"; + '100G' = "Speed100G"; + '300G' = 'Speed300G'; + '300' = 'Speed300G'; + 'Auto' = "Auto" + } + [Hashtable]$NitroDownlinkSpeedEnum = @{ + "25GbSpeed" = "SPEED_25GB"; + "25" = "SPEED_25GB"; + "50GbSpeed" = "SPEED_50GB"; + "50" = "SPEED_50GB" + } + [Hashtable]$UplinkPortFecModeEnum = @{ + "Auto" = "Auto"; + "Cl74" = "Cl74"; + "Cl91" = "Cl91"; + "Cl108" = "Cl108"; + "None" = "None" + } + [Array]$UplinkSubPortAllowedFecModesEnum = @( + $UplinkPortFecModeEnum.Auto, + $UplinkPortFecModeEnum.Cl74, + $UplinkPortFecModeEnum.Cl108, + $UplinkPortFecModeEnum.None + ) + [Array]$UplinkPortAllowedFecModesEnum = @( + $UplinkPortFecModeEnum.Auto, + $UplinkPortFecModeEnum.Cl74, + $UplinkPortFecModeEnum.Cl91, + $UplinkPortFecModeEnum.None + ) + [Array]$FecCapableICMPartnumberEnum = @( + '867793-B21', + '867796-B21' + ) + [Hashtable]$global:LogicalInterconnectConsistencyStatusEnum = @{ + + 'CONSISTENT' = "Consistent" ; + 'NOT_CONSISTENT' = "Inconsistent with group" + + } + [Array]$IngressDscpClassMappingEnum = @('DSCP 18, AF21','DSCP 20, AF22','DSCP 22, AF23','DSCP 26, AF31','DSCP 28, AF32','DSCP 30, AF33','DSCP 34, AF41','DSCP 36, AF42','DSCP 38, AF43','DSCP 16, CS2','DSCP 24, CS3','DSCP 32, CS4','DSCP 10, AF11','DSCP 12, AF12','DSCP 14, AF13','DSCP 8, CS1','DSCP 0, CS0','DSCP 46, EF','DSCP 40, CS5','DSCP 48, CS6','DSCP 56, CS7') + [Hashtable]$Global:UplinkSetNetworkTypeEnum = @{ + + Ethernet = 'Ethernet'; + FibreChannel = 'FibreChannel'; + Untagged = 'Ethernet'; + Tunnel = 'Ethernet'; + ImageStreamer = 'Ethernet' + + } + [Hashtable]$Global:UplinkSetEthNetworkTypeEnum = @{ + + Ethernet = 'Tagged' + Untagged = 'Untagged' + Tunnel = 'Tunnel' + ImageStreamer = 'ImageStreamer' + + } + [Hashtable]$Global:LogicalInterconnectGroupRedundancyEnum = @{ + + HighlyAvailable = 'HighlyAvailable'; + ASide = 'NonRedundantASide'; + BSide = 'NonRedundantBSide'; + Redundant = 'Redundant' + + } + [Array]$Script:SnmpEneTrapCategoryEnums = @('Other', 'PortStatus', 'PortThresholds') + [Array]$Script:SnmpFcTrapCategoryEnums = @('Other', 'PortStatus') + [Array]$Script:SnmpVcmTrapCategoryEnums = @('Legacy') + [Array]$Script:SnmpTrapSeverityEnums = @('Critical', 'Info', 'Major', 'Minor', 'Normal', 'Unknown', 'Warning') + [Net.IPAddress]$Script:ExcludedIPSubnetID = '172.30.254.0' # Synergy Specific + [Net.IPAddress]$Script:ExcludedIPSubnetEnd = '172.30.254.254' # Synergy Specific + [Hashtable]$EthernetNetworkPurposeEnum = @{ + + General = "General"; + Management = "Management"; + VMMigration = "VMMigration"; + FaultTolerance = "FaultTolerance"; + ISCSI = 'ISCSI' + + } + [String]$FabricManagersUri = '/rest/fabric-managers' + [Array]$FCTrunkCapablePartnumbers = @( + + '751465-B21', + '779227-B21', + '876259-B21', + 'P08477-B21' + + ) + [Array]$SynergyVCEthModulePartNumbers = @( + + '794502-B23', + '867796-B21' + + ) + [Hashtable]$LIGConsistencyCheckingEnum = @{ + + Exact = 'ExactMatch'; + None = 'NotChecked' + + } + $LogicalInterconnectActivationTypeEnum = @{ + Orchestrated = 'PairProtect'; + OddEven = 'OddEven'; + Parallel = 'Parallel'; + Serial = 'Serial'; + Manual = 'ManualOrchestration' + } + $SynergyValidationTypeEnum = @{ + Update = 'ValidateFailFast'; + Activate = 'ValidateFailFast'; + Stage = 'ValidateOnly'; + Preview = 'ValidateOnly' + } + Enum InterconnectModuleFamilyTypeEnum + { + + FlexFabric; + FibreChannel; + SAS; + Unsupported + + } + Enum VMADisallowedNetworkTypesEnum + { + FCoE; + RoCE + } +#------------------------------------ +# Profile Management +#------------------------------------ + + [String]$ServerProfileType = "ServerProfileV12" + [String]$ServerProfilesCategory = $ResourceCategoryEnum.ServerProfile + [String]$ServerProfileTemplateType = "ServerProfileTemplateV8" + [String]$ServerProfileTemplatesCategory = 'server-profile-templates' + [String]$ServerProfilesUri = "/rest/{0}" -f $ServerProfilesCategory + [String]$ServerProfileTemplatesUri = '/rest/{0}?sort=name:asc' -f $ServerProfileTemplatesCategory + [String]$ServerProfileIndexListUri = "/rest/index/resources?sort=name:asc&category={0}" -f $ServerProfilesCategory + [String]$ServerProfileAvailStorageSystemsUri = '/rest/{0}/available-storage-systems' -f $ServerProfilesCategory + [String]$ServerProfilesAvailableNetworksUri = '/rest/{0}/available-networks' -f $ServerProfilesCategory + [String]$ConvertProfileToTemplateUri = "/rest/server-profile-templates/from-server-profile" + [String]$AvailableServerHardwareStorageControllersUri = '/rest/server-profiles/available-controllers?serverHardwareUri={0}' + [Hashtable]$ServerProfileConnectionBootPriorityEnum = @{ + none = 'NotBootable'; + NotBootable = 'NotBootable'; + Primary = 'Primary'; + Secondary = 'Secondary'; + IscsiPrimary = 'Primary'; + IscsiSecondary = 'Secondary'; + LoadBalanced = 'LoadBalanced' + } + [Hashtable]$ServerProfileSanManageOSType = @{ + CitrixXen = "Citrix Xen Server 5.x/6.x"; + CitrisXen7 = "Citrix Xen Server 7.x"; + AIX = "AIX"; + IBMVIO = "IBM VIO Server"; + RHEL4 = "RHE Linux (Pre RHEL 5)"; + RHEL3 = "RHE Linux (Pre RHEL 5)"; + RHEL = "RHE Linux (5.x, 6.x, 7.x)"; + RHEV = "RHE Virtualization (5.x, 6.x)"; + RHEV7 = "RHE Virtualization 7.x"; + VMware = "VMware (ESXi)"; + Win2k3 = "Windows 2003"; + Win2k8 = "Windows 2008/2008 R2"; + Win2k12 = "Windows 2012 / WS2012 R2"; + Win2k16 = "Windows Server 2016"; + Win2k19 = "Windows Server 2019"; + OpenVMS = "OpenVMS"; + Egenera = "Egenera"; + Exanet = "Exanet"; + Solaris9 = "Solaris 9/10"; + Solaris10 = "Solaris 9/10"; + Solaris11 = "Solaris 11"; + ONTAP = "NetApp/ONTAP"; + OEL = "OE Linux UEK (5.x, 6.x)"; + OEL7 = "OE Linux UEK 7.x"; + HPUX11iv1 = "HP-UX (11i v1, 11i v2)" + HPUX11iv2 = "HP-UX (11i v1, 11i v2)"; + HPUX11iv3 = "HP-UX (11i v3)"; + SUSE = "SuSE (10.x, 11.x, 12.x)"; + SUSE9 = "SuSE Linux (Pre SLES 10)"; + Inform = "InForm"; + Ubuntu = "Ubuntu" + } + [Hashtable]$ServerProfileConnectionTypeEnum = @{ + + 'ethernet-networks' = 'Ethernet'; + 'network-sets' = 'Ethernet'; + 'fcoe-networks' = 'FibreChannel'; + 'fc-networks' = 'FibreChannel'; + 'FC' = 'FibreChannel'; + 'FibreChannel' = 'FibreChannel'; + 'FCoE' = 'FibreChannel'; + 'Eth' = 'Ethernet'; + 'Ethernet' = 'Ethernet'; + 'iSCSI' = 'iSCSI' + + } + [Hashtable]$LogicalDiskTypeEnum = @{ + + 'Sas' = 'SasHdd'; + 'SASHDD' = 'SasHdd'; + 'Sata' = 'SataHdd'; + 'SATAHDD' = 'SataHdd'; + 'Sasssd' = 'SasSsd'; + 'Satassd' = 'SataSsd'; + 'Auto' = $Null + + } + [Hashtable]$LogicalDriveMediaEnum = @{ + 'SAS' = 'HDD'; + 'SATA' = 'HDD'; + 'SASSSD' = 'SSD'; + 'SATASSD' = 'SSD'; + } + [Hashtable]$LogicalDriveInterfaceEnum = @{ + SAS = 'SAS'; + SATA = 'SATA'; + SASSSD = 'SAS'; + SATASSD = 'SATA' + + } + [Hashtable]$ServerProfileFirmwareControlModeEnum = @{ + + FirmwareOnly = 'FirmwareOnly'; + FirmwareAndSoftware = 'FirmwareAndOSDrivers'; + FirmwareOffline = 'FirmwareOnlyOfflineMode'; + FirmwareAndOSDrivers = 'FirmwareAndOSDrivers'; + FirmwareOnlyOfflineMode = 'FirmwareOnlyOfflineMode' + + } + [Hashtable]$ServerProfileFirmareActivationModeEnum = @{ + Immediate = 'Immediate'; + NotScheduled = 'NotScheduled'; + Scheduled = 'Scheduled' + } + [Hashtable]$IscsiInitiatorNameAssignmetEnum = @{ + Virtual = 'AutoGenerated'; + UserDefined = 'UserDefined' + } + [Hashtable]$ConsistencyCheckingEnum = @{ + + Exact = 'Checked'; + None = 'Unchecked'; + Minimum = 'CheckedMinimum' + + } + [Hashtable]$IloProfileSettingTypeEnum = @{ + + AdministratorAccount = 'AdministratorAccount'; + LocalAccounts = 'LocalAccounts'; + Directory = 'Directory'; + DirectoryGroups = 'DirectoryGroups'; + KeyManager = 'KeyManager'; + Hostname = 'Hostname' + SecurityDashboard = 'SecurityDashboard' + + } + [Hashtable]$IloAuthDirectorySchemaEnum = @{ + + DirectoryDefault = 'defaultSchema'; + HPEExtended = 'extendedSchema'; + Disabled = 'disabledSchema'; + defaultSchema = 'DirectoryDefault'; + extendedSchema = 'HPEExtended'; + disabledSchema = 'Disabled' + + } +#------------------------------------ +# Cluster Profile Management +#------------------------------------ + [String]$ClusterProfileType = 'HypervisorClusterProfileV3' + [String]$ClusterProfileHostType = 'HypervisorHostProfileV2' + [String]$ClusterProfileHostCategory = 'hypervisor-host-profiles' + [String]$ClusterProfilesUri = '/rest/hypervisor-cluster-profiles' + [Hashtable]$ClusterProfileHostPowerStateEnum = @{ + On = 'On'; + Off = 'Off'; + InMaintenanceMode = 'InMaintenance'; + ExitMaintenaneMode = 'ExitMaintenance' + } + [String]$ClusterHostProfilesUri = '/rest/hypervisor-host-profiles' + [String]$ClusterProfileCompliancePreviewUri = '/rest/hypervisor-cluster-profiles/{0}/compliance-preview' + [String]$HypervisorManagersUri = '/rest/hypervisor-managers' + [String]$HypervisorClustersUri = '/rest/hypervisor-clusters' + [String]$GenerateClusterProfileNetworkingLayoutUri = '/rest/hypervisor-cluster-profiles/virtualswitch-layout' + [Hashtable]$ClusterProfileDistributedSwitchTypeEnum = @{ + Distributed = 'Distributed'; + Standard = 'Standard' + } + $ClusterProfileComplianceStateEnum = [PSCustomObject]@{ + ClusterConfigInconsistent = [PSCustomObject] @{ + State = 'ClusterConfigInconsistent'; + Message = 'Hypervisor cluster is inconsistent hypervisor cluster profile. ' + }; + ClusterTemplateError = [PSCustomObject] @{ + State = 'ClusterTemplateError'; + Message = 'Hypervisor cluster profile is out of sync with server profile template connections and volumes.' + }; + ClusterTemplateStorageVolError = [PSCustomObject] @{ + State = 'ClusterTemplateStorageVolError'; + Message = 'Hypervisor cluster profile is out of sync with server profile template volumes.' + }; + ClusterTemplateVSwitchError = [PSCustomObject]@{ + State = 'ClusterTemplateVSwitchError'; + Message = 'Hypervisor cluster profile is out of sync with server profile template connections.' + }; + Consistent = [PSCustomObject]@{ + State = 'Consistent'; + Message = 'Cluster or Hypervisor profile is consistent with its template.' + }; + HostProfileInconsistent = [PSCustomObject]@{ + State = 'HostProfileInconsistent'; + Message = 'Hypervisor profile is inconsistent with host profile template.' + }; + Inconsistent = [PSCustomObject]@{ + State = 'Inconsistent'; + Message = 'Hypervisor Profile is inconsistent with its template. Remediate Indicates cluster of hypervisor profile should be made consistent with its template.' + }; + ServerProfileInconsistent = [PSCustomObject]@{ + State = 'ServerProfileInconsistent'; + Message = 'Server profile is inconsistent with server profile template.' + }; + Unknown = [PSCustomObject]@{ + State = 'Unknown'; + Message = 'Unable to determine compliance state of profile.' + } + } +#------------------------------------ +# Datacenter/Facilities +#------------------------------------ + [String]$DataCentersUri = '/rest/datacenters' + [String]$DataCenterRacksUri = '/rest/racks' +#------------------------------------ +# Index Search +#------------------------------------ + [String]$IndexUri = "/rest/index/resources" + [String]$AssociationsUri = "/rest/index/associations" + [String]$IndexAssociatedResourcesUri = '{0}/resources' -f $AssociationsUri + [String]$AssociationTreesUri = "/rest/index/trees" +#------------------------------------ +# Tasks +#------------------------------------ + [String]$AllNonHiddenTaskUri = "/rest/tasks?filter=hidden=$false" + [String]$TasksUri = "/rest/tasks" + [Array]$TaskFinishedStatesEnum = @( + + "Error", + "Warning", + "Completed", + "Terminated", + "Killed" + + ) +#------------------------------------ +# Alerts and Events +#------------------------------------ + $AlertsUri = "/rest/alerts" + $script:eventsUri = "/rest/events" + [String]$SmtpConfigUri = "/rest/appliance/notifications/email-config" + [String]$TestNotificationUri = "/rest/appliance/notifications/send-email" + [String]$HtmlPattern = "\s]+))?)+\s*|\s*)/?>" + [Hashtable]$SmtpConnectionSecurityEnum = @{ + + None = 'PLAINTEXT'; + Tls = 'TLS'; + StartTls = 'STARTTLS' + + } + Enum AlertHealthCategoryEnum { + Appliance; + DeviceBay; + Enclosure; + Fan; + Firmware; + Host; + Instance; + InterconnectBay; + LogicalSwitch; + Logs; + ManagementProcessor; + Memory; + Network; + Operational; + Power; + Processor; + RemoteSupport; + Storage; + Thermal; + Security; + Unknown + } +#------------------------------------ +# Licenses +#------------------------------------ + $ApplianceLicensePoolUri = "/rest/licenses" + $OneViewFIOLicenseSKUs = @( + "E5Y41A", + "E5Y43A", + "F6Q89A", + "P8B31A" + ) +#------------------------------------ +# Security +#------------------------------------ + [String]$ApplianceEncryptionKeyUri = '/rest/appliance-encryption-key' + [String]$ApplianceDataAtRestEncryptionKeyGenUri = '/rest/encryption-key-generator' + [String]$ApplianceDataAtRestConfigUri = '/rest/secure-data-at-rest' + [String]$ApplianceSecurityModesUri = '/rest/security-standards/modes' + [String]$ApplianceCurrentSecurityModeUri = '/rest/security-standards/modes/current-mode' + [String]$ApplianceSecurityModeCompatibiltyReportUri = '/rest/security-standards/compatibility-report' + [String]$ApplianceSecurityProtocolsUri = '/rest/security-standards/protocols' + [String]$UserLoginSessionUri = '/rest/sessions' + [String]$ApplianceLoginSessionsUri = '/rest/login-sessions' + [Regex]$DetectLoginDomainInUsernameRegex = [System.Text.RegularExpressions.Regex]::new('^(?[a-zA-Z][a-zA-Z0-9\-\.]{0,61}[a-zA-Z])\\(?\w[\w\.\- ]+)$', [System.Text.RegularExpressions.RegexOptions]::IgnoreCase) + [Regex]$DetectUPNInUsernameRegex = [System.Text.RegularExpressions.Regex]::new('^(?\b[A-Z0-9._%+-]+)@(?[A-Z0-9.-]+[\.A-Z]?\b)$', [System.Text.RegularExpressions.RegexOptions]::IgnoreCase) + [String]$ApplianceLoginSessionsSmartCardAuthUri = '/rest/login-sessions/smartcards' + [String]$UpdateApplianceSessionAuthUri = '/rest/login-sessions/auth-token' + [String]$ActiveUserSessionsUri = '/rest/active-user-sessions' + [String]$ApplianceUserAccountsUri = '/rest/users' + [String]$ApplianceUserAccountRoleUri = "/rest/users/role" + [String]$ApplianceTrustedCertStoreUri = '/rest/certificates' + [String]$ApplianceCertificateValidatorUri = '/rest/certificates/validator-configuration' + [String]$ApplianceCertificateAuthorityUri = '/rest/certificates/ca' + [String]$ApplianceInternalCertificateAuthority = '/rest/certificates/ca?filter=certType:INTERNAL' + [String]$ApplianceTrustedCAValidatorUri = '/rest/certificates/ca/validator' + [String]$ApplianceTrustedSslHostStoreUri = '/rest/certificates/servers' + [String]$ApplianceScmbRabbitmqUri = "/rest/certificates/client/rabbitmq" + [String]$ApplianceRabbitMQKeyPairUri = "/rest/certificates/client/rabbitmq/keypair/default" + [String]$ApplianceRabbitMQKeyPairCertUri = '/rest/certificates/ca/rabbitmq_readonly' + [String]$RetrieveHttpsCertRemoteUri = "/rest/certificates/https/remote/" + [String]$AuthnProvidersUri = '/rest/logindomains' + [String]$Authn2FALoginCertificateConfigUri = '/rest/logindomains/logincertificates' + [String]$AuthnAllowLocalLoginUri = '/rest/logindomains/global-settings/allow-local-login' + [String]$AuthnDefaultLoginDomainUri = '/rest/logindomains/global-settings/default-login-domain' + [String]$AuthnProviderValidatorUri = "/rest/logindomains/validator" + [String]$AuthnSettingsUri = "/rest/logindomains/global-settings" + [String]$AuthnLocalLoginsAllowedUri = "{0}/allow-local-login" -f $AuthnSettingsUri + [String]$AuthnDirectoryGroupsUri = "/rest/logindomains/groups" + [String]$AuthnDirectorySearchContextUri = '/rest/logindomains/contexts' + [String]$AuthnEgroupRoleMappingUri = "/rest/logindomains/grouptorolemapping" + [String]$ApplAuditLogsUri = "/rest/audit-logs" + [String]$ApplAuditLogDownloadUri = "/rest/audit-logs/download" + [String]$ApplianceAuditLogForwardingUri = '/rest/audit-logs/settings' + [String]$ApplianceTestAuditLogForwardingUri = '/rest/audit-logs/test-forwarding' + [String]$ApplianceRolesUri = '/rest/roles' + [String]$ApplianceLoginDomainDetailsUri = '/rest/logindetails' + [String]$ScopesUri = '/rest/scopes' + [String]$ApplianceServiceAccessUri = '/rest/appliance/settings/serviceaccess' + [String]$ApplianceEnableServiceAccessUri = '/rest/appliance/settings/enableServiceAccess' + [String]$ApplianceSshAccessUri = '/rest/appliance/ssh-access' + [String]$ManagedDevicePasswordRotationUri = '/rest/global-settings/appliance/security' + [Hashtable]$ScopeCategoryEnum = @{ + + 'enclosures' = 'Enclosure'; + 'enclosure-groups' = 'EnclosureGroup'; + 'logical-enclosures' = 'LogicalEnclosure'; + 'server-hardware' = 'ServerHardware'; + 'network-sets' = 'NetworkSet'; + 'interconnects' = 'Interconnect'; + 'sas-interconnects' = 'SasInterconnect'; + 'logical-interconnects' = 'LogicalInterconnect'; + 'sas-logical-interconnects' = 'SasLogicalInterconnect'; + 'logical-interconnect-groups' = 'LogicalInterconnectGroup'; + 'ethernet-networks' = 'EthernetNetwork'; + 'fc-networks' = 'FCNetwork'; + 'fcoe-networks' = 'FCoENetwork'; + 'roce-networks' = 'RoCENetwork'; + 'logical-switches' = 'LogicalSwitch'; + 'logical-switch-groups' = 'LogicalSwitchGroup'; + 'switches' = 'Switch'; + 'server-profiles' = 'ServerProfile'; + 'server-profile-templates' = 'ServerProfileTemplate'; + 'firmware-drivers' = 'FirmwareBundle'; + 'os-deployment-plans' = 'OSDeploymentPlan'; + 'storage-pools' = 'StoragePool'; + 'storage-volumes' = 'StorageVolume'; + 'storage-volume-templates' = 'StorageVolumeTemplate'; + 'scopes' = 'Scope'; + 'hypervisor-managers' = 'HypervisorManagers' + 'hypervisor-cluster-profiles' = 'ClusterProfile'; + 'hypervisor-hosts' = 'ClusterNode'; + 'drive-enclosures' = 'DriveEnclosure' + + } + [Hashtable]$LdapDirectoryAccountBindTypeEnum = @{ + USERACCOUNT = 'USER_ACCOUNT'; + SERVICEACCOUNT = 'SERVICE_ACCOUNT'; + USER_ACCOUNT = 'USER_ACCOUNT'; + SERVICE_ACCOUNT = 'SERVICE_ACCOUNT' + } + [Hashtable]$EmergencyLocalLoginTypeEnum = @{ + NONE = 'NONE'; + APPLIANCECONSOLEONLY = 'APPLIANCE_CONSOLE_ONLY'; + APPLIANCE_CONSOLE_ONLY = 'APPLIANCECONSOLEONLY'; + NETWORK_AND_APPLIANCE_CONSOLE = 'NETWORKANDAPPLIANCECONSOLE'; + NETWORKANDAPPLIANCECONSOLE = 'NETWORK_AND_APPLIANCE_CONSOLE' + } + $Script:OrganizationalUnitPattern = '^(?:(?:CN|OU|DC)\=[\w\s]+,)*(?:CN|OU|DC)\=[\w\s]+$' + $CommonNamePattern = '^CN=(.+?),(?:CN|OU)=.+' + $JsonPasswordRegEx = '(\"[p|P]ass[word|phrase]+\"\:)[\s]*?\"((?=.*[a-z])(?=.*\W)(?!.* ).{2,})\"' + +# Endregion + +$UnAuthenticatedAllowedURIs = @( + + $ApplianceLoginSessionsUri, + $ApplianceLoginSessionsSmartCardAuthUri, + $ApplianceUpdateMonitorUri, + $ApplianceXApiVersionUri, + "/ui-js/pages/", + $ApplianceEulaStatusUri, + $ApplianceEulaSaveUri, + ($ApplianceUserAccountsUri + "/changePassword"), + "/startstop/rest/component?fields=status", + $ApplianceStartProgressUri, + $ApplianceLoginDomainDetailsUri + +) + +$ExtendedTimeoutUris = @( + $ApplianceSupportDumpUri, + $ApplianceBackupUri, + "$LogicalInterconnectsUri/*/support-dumps", + $ApplianceScmbRabbitmqUri, + $ApplianceRabbitMQKeyPairUri, + $ApplianceRabbitMQKeyPairCertUri, + $RemoteSupportUri, + $applianceSslCert, + $ApplianceCertificateValidatorUri +) + +####################################################### +# Resource Objects +# + +class ServerProfileTemplateUnmanagedFCConnection +{ + + $id = 1; + $name = $null; + $functionType = 'FibreChannel'; + $portId = $null; + $networkUri = $null; + + ServerProfileTemplateUnmanagedFCConnection ([Object]$Object) + { + + $this.id = $Object.id + $this.name = $Object.name + $this.networkUri = $Object.networkUri + + } + +} + +class ServerProfileUnmanagedFCConnection +{ + + $id = 1; + $name = $null; + $functionType = 'FibreChannel'; + $portId = $null; + $networkUri = $null; + $requestedMbps = $null; + $boot = $null; + $wwpn = $null; + $managed = $false; + + ServerProfileUnmanagedFCConnection ([Object]$Object) + { + + $this.id = $Object.id + $this.name = $Object.name + $this.networkUri = $Object.networkUri + + if (-not [String]::IsNullOrEmpty($Object.wwpn)) + { + + $this.managed = $null + $this.wwpn = $Object.wwpn + + } + + } + +} + +class ObsoleteMessage +{ + + static [hashtable] $DeprecatedCmdlets = @{ + VMA = @( + "Add-OVEnclosure", + "Disable-OVLogicalInterconnectPortMonitoring", + "Enable-OVLogicalInterconnectPortMonitoring", + "Get-OVAddressPool", + "Get-OVAddressPoolRange", + "Get-OVAddressPoolSubnet", + "Get-OVEnclosure", + "Get-OVEnclosureGroup", + "Get-OVInterconnect", + "Get-OVInterconnectNTPConfiguration", + "Get-OVInterconnectType", + "Get-OVLogicalEnclosure", + "Get-OVLogicalInterconnect", + "Get-OVLogicalInterconnectGroup", + "Get-OVLogicalInterconnectPortMonitoring", + "Get-OVLogicalSwitch", + "Get-OVLogicalSwitchGroup", + "Get-OVUplinkSet", + "Install-OVLogicalInterconnectFirmware", + "New-OVAddressPoolRange", + "New-OVAddressPoolSubnet", + "New-OVAddressRange", + "New-OVEnclosure", + "New-OVEnclosureGroup", + "New-OVLogicalEnclosure", + "New-OVLogicalInterconnectGroup", + "New-OVUplinkSet", + "Remove-OVAddressPoolRange", + "Remove-OVAddressPoolSubnet", + "Remove-OVEnclosure", + "Remove-OVEnclosureGroup", + "Remove-OVLogicalEnclosure", + "Remove-OVLogicalInterconnectGroup", + "Reset-OVEnclosureDevice", + "Set-OVAddressPoolSubnet", + "Set-OVEnclosure", + "Set-OVEnclosureGroup", + "Set-OVLogicalEnclosure", + "Set-OVUplinkSet", + "Show-OVPortStatistics", + "Update-OVEnclosure", + "Update-OVLogicalEnclosure", + "Update-OVLogicalEnclosureFirmware", + "Update-OVLogicalInterconnect", + "Test-ObsoleteMessage" + ); + Composer = @( + "ConvertTo-OVImageStreamerConfiguration", + "Get-OVImageStreamerAppliance", + "Get-OVOSDeploymentPlan", + "Get-OVOSDeploymentPlanAttribute", + "Get-OVOSDeploymentServer", + "New-OVOSDeploymentServer", + "Remove-OVOSDeploymentServer" + ) + + } + + static [void] WriteMessage ([HPEOneView.Appliance.Connection]$_Appliance, [String]$Caller) + { + + "[DEBUG] Processing [ObsoleteMessage]::WriteMessage() method." | Microsoft.PowerShell.Utility\Write-Debug + "[DEBUG] Caller: {0}" -f $Caller | Microsoft.PowerShell.Utility\Write-Debug + "[DEBUG] Appliance type: {0}" -f $_Appliance.ApplianceType | Microsoft.PowerShell.Utility\Write-Debug + "[DEBUG] Caller Cmdlet is in Deprecated {0} list: {1}" -f $_Appliance.ApplianceType, ([ObsoleteMessage]::DeprecatedCmdlets.$($_Appliance.ApplianceType).Contains($Caller)) | Microsoft.PowerShell.Utility\Write-Debug + + if ([ObsoleteMessage]::DeprecatedCmdlets.$($_Appliance.ApplianceType).Contains($Caller)) + { + + $Message = $null + + if ($_Appliance.ApplianceType -eq 'VMA') + { + + # This should now throw an exception message it is no longer supported and should not be used. + [System.String]$Message = "The command '{0}' is no longer supported with HPE OneView and HPE BladeSystem c-Class resources." -f $Caller + + } + + elseif ($_Appliance.ApplianceType -eq 'Composer') + { + + # This should now throw an exception message it is no longer supported and should not be used. + [System.String]$Message = "The command '{0}' is no longer be supported with HPE OneView and HPE Synergy." -f $Caller + + } + + $ExceptionMessage = [HPEOneView.Library.UnsupportedOperationException]::new($Message) + + [System.String]$ErrorId = 'UnsupportedCommand' + [System.Object]$TargetObject = $Caller + $ErrorCategory = [System.Management.Automation.ErrorCategory]::InvalidOperation + + throw [Management.Automation.ErrorRecord]::new($ExceptionMessage, $ErrorID, $ErrorCategory, $TargetObject) + + } + + } + + static [void] Write ([HPEOneView.Library.ApplianceConnection]$Appliance) + { + + $Caller = (Get-PSCallStack)[1].Command + + # Get the full connection object, which is where the ApplianceType property exists + $_Appliance = $GLOBAL:ConnectedSessions | ? Name -eq $Appliance.Name + + [ObsoleteMessage]::WriteMessage($_Appliance, $Caller) + + } + + static [void] Write ([HPEOneView.Appliance.Connection]$Appliance) + { + + $Caller = (Get-PSCallStack)[1].Command + + [ObsoleteMessage]::WriteMessage($Appliance, $Caller) + + } + + static [void] Write ([String]$ApplianceName) + { + + $Caller = (Get-PSCallStack)[1].Command + + #Get the full connection object, which is where the ApplianceType property exists + $_Appliance = $GLOBAL:ConnectedSessions | ? Name -eq $ApplianceName + + [ObsoleteMessage]::WriteMessage($_Appliance, $Caller) + + } + +} + +# Class used for server migration features, Get-OVMigratableServer +class ServerMigrationConnectApplianceCredentials +{ + + [ValidateNotNullOrEmpty()] [string]$ipAddress; + [ValidateNotNullOrEmpty()] [string]$username; + [ValidateNotNullOrEmpty()] [string]$password; + + ServerMigrationConnectApplianceCredentials ([String]$Hostname, [PSCredential]$Credential) + { + + $this.ipAddress = $Hostname; + $this.username = $Credential.Username; + $this.password = [Runtime.InteropServices.Marshal]::PtrToStringBSTR([Runtime.InteropServices.Marshal]::SecureStringToBSTR($Credential.Password)) + + } + +} + +# Used for server migration features, Invoke-OVMigrateServer +class ServerMigration : ServerMigrationConnectApplianceCredentials +{ + + [ValidateNotNullOrEmpty()] [string]$uri; + + ServerMigration ([String]$ServerHardwareUri, [String]$Hostname, [PSCredential]$Credential) : base ($Hostname, $Credential) + { + + $this.uri = $ServerHardwareUri; + + } + +} + +# POST and use class when the key is retreived from GLCP +class ApplianceComputeOpsManagementConfig +{ + + [ValidateNotNullOrEmpty()] [string]$activationKey; + + ApplianceComputeOpsManagementConfig([String]$Key) + { + + $this.activationKey = $Key; + + } + +} +function NewObject +{ + + [CmdletBinding ()] + Param + ( + + [Object]$InputObject, + [Switch]$FabricManagerClusterNodeInfo, + [Switch]$AddFabricManager, + [Switch]$AddStorageVolume, + [Switch]$AddRackManager, + [Switch]$AlertFilter, + [Switch]$AllApiResponse, + [Switch]$ApplianceCSR, + [Switch]$ApplianceDebug, + [Switch]$ApplianceGlobalCertificateValidationConfig, + [Switch]$ApplianceProxy, + [Switch]$ApplianceSslCertificate, + [Switch]$ApplianceSecurityProtocols, + [Switch]$ApplianceStaticRoute, + [Switch]$ApplianceTimeLocale, + [Switch]$ApplianceTrustedCertAuthority, + [Switch]$ApplianceTrustedSslCertificate, + [Switch]$ApplianceVersion, + [Switch]$AuthDirectory, + [Switch]$AuthDirectoryServer, + [Switch]$AuthLoginCredential, + [Switch]$AutoBackupConfig, + [Switch]$BaseTrafficClass, + [Switch]$BulkEthernetNetworks, + [Switch]$CertificateToImport, + [Switch]$CertificateDetails, + [Switch]$ClusterProfile, + [Switch]$ClusterProfileManager, + [Switch]$ClusterProfileSharedStorageVolume, + [Switch]$ClusterVirtualSwitchConfig, + [Switch]$ClusterProfileOverrideMgmtIPSettings, + [Switch]$ClusterNetworkingSettings, + [Switch]$ClusterNetworkingLayout, + [Switch]$ClusterNetworkingConfigPolicy, + [Switch]$ClusterProfileVirtualSwitchUplink, + [Switch]$ClusterProfileVirtualSwitchPortGroup, + [Switch]$ClusterProfileVirtualSwitchPort, + [Switch]$ComposerIloConfig, + [Switch]$ComposerIloAddress, + [Switch]$ConvertSnapshotToVol, + [Switch]$CustomBaselineRestore, + [Switch]$DataCenter, + [Switch]$DataCenterItem, + [Switch]$DCBXOverride, + [Switch]$DefaultBestEffortTrafficClass, + [Switch]$DefaultFCoELosslessQosTrafficClassifiers, + [Switch]$DefaultNoFCoELosslessQosTrafficClassifiers, + [Switch]$DeploymentModeSettings, + [Switch]$DirectoryGroup, + [Switch]$DirectoryGroupPermissions, + [Switch]$DirectoryGroupCredentials, + [Switch]$DownloadFileStatus, + [Switch]$EnclosureGroup, + [Switch]$SynergyEnclosureGroup, + [Switch]$EnclosureGroupPreview, + [Switch]$EnclosureGroupI3SDeploymentSettings, + [Switch]$EnclosureImport, + [Switch]$EnclosureRefresh, + [Switch]$EnclosureRefreshForceOptions, + [Switch]$EphemeralStorageVolume, + [Switch]$EthernetNetwork, + [Switch]$EulaStatus, + [Switch]$ExternalRepository, + [Switch]$FCNetwork, + [Switch]$FCoELossLessTrafficClass, + [Switch]$FCoENetwork, + [Switch]$FCAlias, + [Switch]$FCZone, + [Switch]$FromServerProfile, + [Switch]$GlobalSetting, + [Switch]$IPIDPoolRange, + [Switch]$IDPoolStartStopFragment, + [Switch]$IDPoolRange, + [Switch]$I3SAdd, + [Switch]$IloRestSession, + [Switch]$IloProfileSettings, + [Switch]$IloProfileTemplateSettings, + [Switch]$IloLocalAdministrator, + [Switch]$IloLocalAccount, + [Switch]$IloDirectoryGroup, + [Switch]$IloBasePriviledges, + [Switch]$Ilo5Priviledges, + [Switch]$IloDirectoryGroupPriviledges, + [Switch]$IloAuthDirectoryConfig, + [Switch]$IloAuthDirectoryKerberosConfig, + [Switch]$IloKeyManagerConfig, + [Switch]$IloSetting, + [Switch]$IloSecurityDashboard, + [Switch]$IloSecurityDashboardSettings, + [Switch]$InstallServerFirmware, + [Switch]$IPv4Subnet, + [Switch]$IPv6Subnet, + [Switch]$InterconnectBayMapping, + [Switch]$InterconnectMapEntryTemplate, + # [Switch]$InsightOnlineRegistration, + [Switch]$IscsiBootEntry, + [Switch]$IscsiIPv4Configuration, + [Switch]$LogicalInterconnectBaseline, + [Switch]$SasLogicalInterconnectBaseline, + [Switch]$C7kLIG, + [Switch]$SELIG, + [Switch]$SESASLIG, + [Switch]$LiUplinkSetObject, + [Switch]$LigUplinkSetObject, + [Switch]$LicenseKey, + [Switch]$LocationEntry, + [Switch]$LogicalEnclosure, + [Switch]$LogicalEnclosureEbipaAddress, + [Switch]$LogicalEnclosureEnclosureBaySettings, + [Switch]$LogicalEnclosureEbipaSetting, + [Switch]$LogicalEnclosureFirmareUpdate, + [Switch]$LogicalSwitchGroup, + [Switch]$LogicalSwitch, + [Switch]$LogicalSwitchCredentials, + [Switch]$LogicalSwitchSnmpV3Config, + [Switch]$LogialSwitchConnectionProperties, + [Switch]$LogicalSwitchConnectionProperty, + [Switch]$LogicalSasJbod, + [Switch]$LogicalSASJbodSpecificDrives, + [Switch]$LoginMessageObject, + [Switch]$MacTableAddressEntry, + [Switch]$NetworkSet, + [Switch]$NimbleEphemeralVolumeProperties, + [Switch]$OSDeploymentSettings, + [Switch]$OSDeploymentPlanSetting, + [Switch]$PatchOperation, + [Switch]$Ping, + [Switch]$PowerDeliveryDeviceAdd, + [Switch]$Rack, + [Switch]$RackItem, + [Switch]$RabbitmqCertReq, + [Switch]$RemoteSupportConfig, + [Switch]$RemoteSupportContact, + [Switch]$RemoteSupportPartner, + [Switch]$RemoteSupportSchedule, + [Switch]$RemoteSupportSite, + [Switch]$RemoteSupportTestEvent, + [Switch]$RemoteSyslog, + [Switch]$ReservedVlanRange, + [Switch]$RoCENetwork, + [Switch]$QosConfiguration, + [Switch]$SanManager, + [Switch]$SanManagerConnectInfo, + [Switch]$ScopeCollection, + [Switch]$ScopeMemberUpdate, + [Switch]$SecureDataAtRestEncryption, + [Switch]$SecurityModeCompatabilityReport, + [Switch]$SelfSignedCert, + [Switch]$ServerImport, + [Switch]$ServerFirmwareBundleCompliance, + [Switch]$ServerProfile, + [Switch]$ServerProfileBootMode, + [Switch]$ServerProfileBootModeLegacyBios, + [Switch]$ServerProfileEthernetConnection, + [Switch]$ServerProfileIscsiConnection, + [Switch]$ServerProfileFCConnection, + [Switch]$ServerProfileUnmanagedFCConnection, + [Switch]$ServerProfileEthBootableConnection, + [Switch]$ServerProfileEthBootableConnectionWithTargets, + [Switch]$ServerProfileIscsiBootableConnectionWithTargets, + [Switch]$ServerProfileFcBootableConnection, + [Switch]$ServerProfileConnectionFcBootTarget, + [Switch]$ServerProfileLocalStorageController, + [Switch]$ServerProfileLocalStorageLogicalDrive, + [Switch]$ServerProfileSanStorage, + [Switch]$ServerProfileTemplateSanStorage, + [Switch]$ServerProfileSasLogicalJBOD, + [Switch]$ServerProfileStorageVolume, + [Switch]$ServerProfileTemplate, + [Switch]$ServerProfileTemplateLocalStorage, + [Switch]$SPTOSDeploymentSettings, + [Switch]$SmtpConfig, + [Switch]$SnmpConfig, + [Switch]$SnmpTrapDestination, + [Switch]$StoragePath, + [Switch]$StorageSystemCredentials, + [Switch]$StorageSystemManagedPort, + [Switch]$StorageVolume, + [Switch]$StorageVolumeTemplate, + [Switch]$StoreVirtualEphemeralVolumeProperties, + [Switch]$StoreServeEphemeralVolumeProperties, + [Switch]$SwitchLogicalLocation, + [Switch]$TemporaryConnection, + [Switch]$TestSmtpConfig, + [Switch]$UpdateAlert, + [Switch]$UplinkSetLocation, + [Switch]$UplinkSetLocationEntry, + [Switch]$UplinkSetLogicalLocation, + [Switch]$UplinkSetLogicalLocationEntry, + [Switch]$UnmanagedDevice, + [Switch]$UserAccount, + [Switch]$UpdateUserPassword, + [Switch]$UpdateToActivePermissions, + [Switch]$VcMigration, + [Switch]$VCMigratorReport, + [Switch]$VolSnapshot + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + } + + Process + { + + switch($PSBoundParameters.Keys) + { + + 'ServerFirmwareBundleCompliance' + { + + return [PSCustomObject] @{ + serverUUID = $null; + firmwareBaselineId = $null; + installationPolicy = "LowerThanBaseline" + } + + } + + 'InstallServerFirmware' + { + + return [PSCustomObject] @{ + baselineUri = $null; + forceApplyFirmware = $true; + firmwareInstallType = "FirmwareOnlyOfflineMode"; + installationPolicy = "LowerThanBaseline" + } + + } + + 'ApplianceStaticRoute' + { + + return [PSCustomObject]@{ + destination = $null; + gateway = $null; + interface = $null; + metric = "0" + } + + } + + 'MacTableAddressEntry' + { + + return [PSCustomObject]@{ + Enclosure = $null; + Interconnect = $null; + Interface = $null; + Address = $null; + Type = $null; + Network = $null; + VLAN = $null + } + + } + + 'RemoteSupportTestEvent' + { + + Return [PSCustomObject]@{ + type = "EventType"; + eventType = "Test"; + createCase = $false + } + + } + + 'ComposerIloConfig' + { + + Return [PSCustomObject]@{ + iloUsername = $null; + iloPassword = $null; + iloHostName = $null; + ipv4Config = $null; + ipv6Config = $null + } + + } + + 'ComposerIloAddress' + { + + Return [PSCustomObject]@{ + address = $null; + gateway = $null; + preferredDNS = $null; + secondaryDNS = $null; + subnet = $null + } + + } + + 'FromServerProfile' + { + + Return [PSCustomObject]@{ + name = $null; + serverProfileUri = $null; + description = $null; + initialScopeUris = [System.Collections.ArrayList]::new() + + } + + } + + 'SecureDataAtRestEncryption' + { + + Return [PSCustomObject]@{ + type = "SecureDataAtRestV1"; + secureDataAtRest = $false + applianceEncryptionKey = $null; + keyId = $null + } + + } + + 'LogicalSasJbod' + { + + return [PSCustomObject]@{ + + type = $SasLogicalJBODType; + numPhysicalDrives = 1 + name = $null; + description = $null; + minSizeGB = 200; + maxSizeGB = 600; + eraseData = $false; + driveTechnology = @{ + + deviceInterface = "SAS"; + driveMedia = "HDD" + + }; + driveEnclosureUris = [System.Collections.ArrayList]::new(); + initialScopeUris = [System.Collections.ArrayList]::new() + + } + + } + + 'LogicalSASJbodSpecificDrives' + { + + return [PSCustomObject]@{ + + type = $SasLogicalJBODType; + name = $null; + description = $null; + eraseData = $false; + driveBayUris = [System.Collections.ArrayList]::new() + initialScopeUris = [System.Collections.ArrayList]::new() + + } + + } + + 'ServerProfileSanStorage' + { + + Return [PSCustomObject]@{ + + hostOSType = $null; + manageSanStorage = $false; + volumeAttachments = [System.Collections.ArrayList]::new() + + } + + } + + 'ServerProfileTemplateSanStorage' + { + + $_Object = NewObject -ServerProfileSanStorage + $_Object | Add-Member -NotePropertyName complianceControl -NotePropertyValue $ConsistencyCheckingEnum.Exact + Return $_Object + + } + + 'ReservedVlanRange' + { + + Return [PSCustomObject]@{ + start = 0; + length = 0; + type = "vlan-pool" + } + + } + + 'AddRackManager' + { + + return @{ + hostname = $null; + username = $null; + password = $null; + force = $false + } + + } + + 'ApplianceSecurityProtocols' + { + + Return @( + @{ + type = "ProtocolV1"; + protocolName = "TLSv1"; + enabled = $false + }, + @{ + type = "ProtocolV1"; + protocolName = "TLSv1.1"; + enabled = $false + }, + @{ + type = "ProtocolV1"; + protocolName = "TLSv1.2"; + enabled = $false + } + ) + } + + 'SecurityModeCompatabilityReport' + { + + return [PSCustomObject]@{ + + currentMode = $null + targetMode = $null + + } + + } + + 'LogicalEnclosureFirmareUpdate' + { + Return [PSCustomObject]@{ + + firmwareBaselineUri = $null; + firmwareUpdateOn = "SharedInfrastructureAndServerProfiles"; + forceInstallFirmware = $false; + validateIfLIFirmwareUpdateIsNonDisruptive = $false; + logicalInterconnectUpdateMode = "Orchestrated" + + } + + } + + 'AddFabricManager' + { + + Return [PSCustomObject]@{ + name = $null; + fabricManagerType = "Cisco ACI"; + userName = $null; + password = $null; + fabricManagerClusterNodeInfo = [System.Collections.Generic.List[PSCustomObject]]::new(); + automaticRemediation = $false; + type = $FabricManagerType + } + + } + + 'FabricManagerClusterNodeInfo' + { + + Return [PSCustomObject]@{ + + oobMgmtAddr = $null + + } + + } + + 'ClusterProfile' + { + + Return [PSCustomObject]@{ + type = "HypervisorClusterProfileV3"; + name = $null; + hypervisorManagerUri = $null; + path = $null; + initialScopeUris = [System.Collections.Generic.List[String]]::new(); + description = ""; + hypervisorType = "Vmware"; + hypervisorClusterSettings = [PSCustomObject]@{ + type = "Vmware"; + drsEnabled = $true; + haEnabled = $false; + multiNicVMotion = $false; + virtualSwitchType = "Standard"; + distributedSwitchUsage = $null; + distributedSwitchVersion = $null + }; + hypervisorHostProfileTemplate = [PSCustomObject]@{ + serverProfileTemplateUri = $null; + deploymentPlan = [PSCustomObject]@{ + serverPassword = $null + deploymentCustomArgs = [System.Collections.Generic.List[PSCustomObject]]::new(); + }; + hostprefix = $null; + virtualSwitches = [System.Collections.Generic.List[PSCustomObject]]::new(); + hostConfigPolicy = [PSCustomObject]@{ + leaveHostInMaintenance = $false; + useHostPrefixAsHostname = $false; + useHostnameToRegister = $false + }; + virtualSwitchConfigPolicy = [PSCustomObject]@{ + manageVirtualSwitches = $true; + configurePortGroups = $true + } + + }; + addHostRequests = [System.Collections.Generic.List[HPEOneView.Cluster.AddHostRequest]]::new; + sharedStorageVolumes = [System.Collections.Generic.List[PSCustomObject]]::new(); + + } + + } + + 'ClusterProfileOverrideMgmtIPSettings' + { + + Return [PSCustomObject]@{ + + netmask = $null; + gateway = $null; + dnsDomain = $null; + primaryDns = $null; + secondaryDns = $null; + tertiaryDNS = $null + + } + + } + + 'ClusterProfileSharedStorageVolume' + { + + Return [PSCustomObject]@{ + + storageVolumeUri = $null; + volumeFileSystemType = $null + + } + + } + + 'ClusterVirtualSwitchConfig' + { + + Return [PSCustomObject]@{ + name = $null; + virtualSwitchType = "Standard"; + version = $null; + virtualSwitchPortGroups = [System.Collections.Generic.List[PSCustomObject]]::new(); + virtualSwitchUplinks = [System.Collections.Generic.List[PSCustomObject]]::new(); + action = "NONE"; + networkUris = [System.Collections.Generic.List[String]]::new(); + } + + } + + 'ClusterProfileVirtualSwitchUplink' + { + + Return [PSCustomObject]@{ + name = $null; + mac = $null; + vmnic = $null; + action = "NONE"; + active = $false + } + + } + + 'ClusterProfileVirtualSwitchPortGroup' + { + + Return [PSCustomObject]@{ + name = $null; + networkUris = [System.Collections.Generic.List[String]]::new(); + vlan = "0"; + virtualSwitchPorts = @( + + ); + action = "NONE" + } + + } + + 'ClusterProfileVirtualSwitchPort' + { + + Return [PSCustomObject]@{ + virtualPortPurpose = [System.Collection.Generic.List[String]]::new(); + ipAddress = $null; + subnetMask = $null; + dhcp = $true; + action = "NONE" + } + + } + + 'ClusterNetworkingLayout' + { + Return [PSCustomObject] @{ + + serverHardwareUri = $null; + serverProfileTemplateUri = $null; + hypervisorClusterSettings = NewObject -ClusterNetworkingSettings; + virtualSwitchConfigPolicy = NewObject -ClusterNetworkingConfigPolicy + + } + + } + + 'ClusterNetworkingSettings' + { + + Return [PSCustomObject] @{ + + multiNicVMotion = $false; + virtualSwitchType = "Standard"; + distributedSwitchUsage = $null; + distributedSwitchVersion = $null; + type = "Vmware" + + } + + } + + 'ClusterNetworkingConfigPolicy' + { + + Return [PSCustomObject]@{ + + configurePortGroups = $true; + customVirtualSwitches = $false; + manageVirtualSwitches = $true + + } + + } + + 'ServerProfileBootMode' + { + + return [PSCustomObject]@{ + + manageMode = $false; + mode = $null; + secureBoot = "Unmanaged"; + pxeBootPolicy = "Auto" + + } + + } + + 'ServerProfileBootModeLegacyBios' + { + + return [PSCustomObject]@{ + + manageMode = $false; + mode = $null; + secureBoot = "Unmanaged" + + } + + } + + 'ClusterProfileManager' + { + + return [PSCustomObject]@{ + + displayName = $null; + name = $null; + username = $null + password = $null; + port = "443" + initialScopeUris = [System.Collections.ArrayList]::new(); + type = "HypervisorManagerV2" + + } + + } + + 'CertificateToImport' + { + + Return [PSCustomObject]@{ + + type = 'CertificateInfoV2'; + certificateDetails = @(NewObject -CertificateDetails) + + } + + } + + 'CertificateDetails' + { + + Return [PSCustomObject]@{ + + base64Data = $null; + aliasName = $null; + type = "CertificateDetailV2" + + } + + } + + 'UpdateToActivePermissions' + { + + Return [PSCustomObject]@{ + + sessionID = $null; + permissionsToActivate = [System.Collections.ArrayList]::new() + + } + + } + + 'ApplianceGlobalCertificateValidationConfig' + { + + Return [PSCustomObject]@{ + type = "CertValidationConfig"; + okToReboot = $False; + certValidationConfig = @{ + + 'global.validateCertificate' = $false; + 'global.enableExpiryCheckForSelfSignedLeafAtConnect' = $false; + 'global.checkCertificateRevocation' = $true; + 'global.allow.noCRL' = $true; + 'global.allow.invalidCRL' = $true + + } + + } + + } + + 'ApplianceTrustedCertAuthority' + { + + Return [PSCustomObject]@{ + + certificateDetails = [PSCustomObject]@{ + aliasName = $null; + base64Data = $null; + type = "CertificateDetailV2" + }; + + type = "CertificateAuthorityInfo" + + } + + } + + 'IloRestSession' + { + + Return [PSCustomObject]@{ + + RootUri = $null; + "X-Auth-Token" = $null; + Location = $null + + } + + } + + 'IloProfileSettings' + { + + Return [PSCustomObject]@{ + manageMp = $true; + mpSettings = [System.Collections.ArrayList]::new() + } + + } + + 'IloProfileTemplateSettings' + { + + $Base = NewObject -IloProfileSettings + + $Base | Add-Member -NotePropertyName complianceControl -NotePropertyValue $ConsistencyCheckingEnum.Exact + + Return $Base + + } + + 'IloAuthDirectoryConfig' + { + + Return [PSCustomObject]@{ + + directoryAuthentication = $null; + directoryGenericLDAP = $false; + directoryServerAddress = $null; + directoryServerPort = 636; + directoryUserContext = [System.Collections.ArrayList]::new() + kerberosAuthentication = $false; + + } + + } + + 'IloAuthDirectoryKerberosConfig' + { + + Return [PSCustomObject]@{ + + kerberosRealm = $null; + kerberosKDCServerAddress = $null; + kerberosKDCServerPort = 88; + kerberosKeytab = $null; + + } + + } + + 'IloLocalAdministrator' + { + + Return [PSCustomObject]@{ + + deleteAdministratorAccount = $False + + } + + } + + 'IloLocalAccount' + { + + Return [PSCustomObject]@{ + + userName = $null; + displayName = $null; + password = $null; + + } + + } + + 'IloDirectoryGroup' + { + + Return [PSCustomObject]@{ + + groupDN = $null; + groupSID = $null; + + } + + } + + 'IloBasePriviledges' + { + + Return [PSCustomObject]@{ + + userConfigPriv = $false; + virtualMediaPriv = $false; + remoteConsolePriv = $false; + virtualPowerAndResetPriv = $false; + iLOConfigPriv = $false + + } + + } + + 'Ilo5Priviledges' + { + + Return [PSCustomObject]@{ + + loginPriv = $false; + hostBIOSConfigPriv = $false; + hostNICConfigPriv = $false; + hostStorageConfigPriv = $false + + } + + } + + 'IloKeyManagerConfig' + { + + Return [PSCustomObject]@{ + + primaryServerAddress = $null; + primaryServerPort = 9000; + secondaryServerAddress = $null; + secondaryServerPort = 9000; + redundancyRequired = $false; + groupName = $null; + certificateName = $null; + loginName = $null; + password = $null + + } + + } + + 'IloSetting' + { + + Return [PSCustomObject]@{ + + settingType = $null; + args = $null + + } + + } + + 'IloSecurityDashboard' + { + + Return [PSCustomObject]@{ + + securityDashboardSettings = [System.Collections.ArrayList]::new() + + } + + } + + 'IloSecurityDashboardSettings' + { + + Return [PSCustomObject]@{ + + securityParam = $null; + securityParamSetting = $true + + } + + } + + 'SPTOSDeploymentSettings' + { + + Return [PSCustomObject]@{ + + osCustomAttributes = $null; + osDeploymentPlanUri = $null + + } + + } + + 'ApplianceSslCertificate' + { + + Return [PSCustomObject]@{ + + type = "CertificateDataV2"; + base64Data = $null + + } + + } + + 'ApplianceTrustedSslCertificate' + { + + Return [PSCustomObject]@{ + + aliasName = $null; + base64Data = $null; + type = "CertificateDetailV2" + + } + + } + + 'ExternalRepository' + { + + Return [PSCustomObject]@{ + + repositoryName = $null; + userName = $null; + password = $null; + repositoryURI = $null; + nfsFolderPath = $null; + repositoryType = "FirmwareExternalRepo"; + base64Data = $null + + } + + } + + 'OSDeploymentPlanSetting' + { + + Return [PSCustomObject]@{ + + name = $null; + value = $null + + } + + } + + 'OSDeploymentSettings' + { + + Return [PSCustomObject]@{ + + osDeploymentPlanUri = $null; + osCustomAttributes = [System.Collections.ArrayList]::new() + + } + + } + + 'DataCenter' + { + + Return [PSCustomObject]@{ + + name = $null; + coolingCapacity = 5; + costPerKilowattHour = 1.5; + currency = 'USD'; + deratingType = 'NaJp'; + deratingPercentage = 20.0; + defaultPowerLineVoltage = 220; + coolingMultiplier = 1.5; + width = 0; + depth = 0; + contents = [System.Collections.ArrayList]::new() + + } + + } + + 'Rack' + { + + Return [PSCustomObject]@{ + + name = $null; + thermalLimit = $null; + serialNumber = $null; + partNumber = $null; + model = $null; + uHeight = 42; + depth = 1000; + height = 2001; + width = 600; + rackMounts = [System.Collections.ArrayList]::new() + + } + + } + + 'DataCenterItem' + { + + Return [PSCustomObject]@{ + + resourceUri = $null; + rotation = 0; + x = 0; + y = 0 + + } + + } + + 'RackItem' + { + + Return [PSCustomObject]@{ + + mountUri = $null; + location = 'CenterFront'; + relativeOrder = -1; + topUSlot = 0; + uHeight = 0 + + } + + } + + 'RemoteSupportSchedule' + { + + Return [PSCustomObject]@{ + + type = "Schedule"; + taskType = $null; + hourOfDay = $null; + taskKey = $null; + scheduleName = $null; + repeatOption = $null; + factory = $true; + viewable = $true; + serviceName = $null; + minute = $null; + dayOfMonth = $null; + dayOfWeek = $null; + enabled = $true; + priority = $null + + } + + } + + 'RemoteSupportPartner' + { + + Return [PSCustomObject]@{ + + type = "ChannelPartner"; + id = $null; + default = $false; + partnerType = "RESELLER" + + } + + } + + 'ApplianceProxy' + { + + Return [PSCustomObject] @{ + + type = "ProxyServerV2"; + server = $null; + port = $null; + username = $null; + password = $null; + credUri = $null; + communicationProtocol = 'HTTP' + + } + + } + + # 'InsightOnlineRegistration' + # { + + # Return [PSCustomObject]@{ + + # type = "PortalRegistration"; + # userName = "username"; + # password = "password" + + # } + + # } + + 'RemoteSyslog' + { + + Return [PSCustomObject]@{ + + type = "RemoteSyslog"; + sendTestLog = $false; + remoteSyslogPort = "514"; + remoteSyslogDestination = $null; + enabled = $true + + } + + } + + 'I3SAdd' + { + + Return [PSCustomObject]@{ + + name = $null; + description = $null; + deplManagersType = 'Image Streamer' + imageStreamerData = @{ + mgmtNetworkUri = $null; + applianceUri = $null + }; + } + + } + + 'LogicalSwitch' + { + Return [PSCustomObject]@{ + + logicalSwitch = [PSCustomObject]@{ + type = 'logical-switchV4'; + name = $null; + managementLevel = $null + logicalSwitchGroupUri = $null; + switchCredentialConfiguration = [System.Collections.ArrayList]::new() + + }; + logicalSwitchCredentials = [System.Collections.ArrayList]::new() + + } + + } + + 'LogicalSwitchCredentials' + { + + Return [PSCustomObject]@{ + + snmpV1Configuration = [PSCustomObject] @{communityString = $null}; + snmpV3Configuration = NewObject -LogicalSwitchSnmpV3Config; + logicalSwitchManagementHost = $null; + snmpVersion = "SNMPv1"; + snmpPort = 161 + + } + + } + + 'LogicalSwitchSnmpV3Config' + { + + Return [PSCustomObject]@{ + + authorizationProtocol = $null; + privacyProtocol = $null; + securityLevel = $null + + } + + } + + 'LogialSwitchConnectionProperties' + { + + Return [PSCustomObject] @{ connectionProperties = [System.Collections.ArrayList]::new() } + + } + + 'LogicalSwitchConnectionProperty' + { + + Return [PSCustomObject]@{ + + propertyName = $null; + value = $null; + valueFormat = 'Unknown'; + valueType = $null; + + } + + } + + 'LogicalSwitchGroup' + { + + Return [PSCustomObject]@{ + + type = "logical-switch-groupV4"; + name = $null; + state = "Active" + switchMapTemplate = [PSCustomObject]@{ + + switchMapEntryTemplates = [System.Collections.ArrayList]::new() + + } + + } + + } + + 'SwitchLogicalLocation' + { + + Return [PSCustomObject]@{ + + logicalLocation = [PSCustomObject]@{ + + locationEntries = [System.Collections.ArrayList]::new() + + }; + permittedSwitchTypeUri = $null + } + + } + + 'ScopeMemberUpdate' + { + + Return [PSCustomObject]@{ + + type = "ScopeV2"; + addedResourceUris = [System.Collections.ArrayList]::new(); + removedResourceUris = [System.Collections.ArrayList]::new() + + } + + } + + 'EulaStatus' + { + + Return [PSCustomObject]@{ + + EulaAccepted = $false; + SupportAccessEnabled = $false + + } + + } + + 'EnclosureGroupPreview' + { + + Return [PSCustomObject]@{ + + hostname = $null; + username = $null; + password = $null; + logicalInterconnectGroupNeeded = $true; + ligPrefix = $null + + } + + } + + 'FCZone' + { + + Return [PSCustomObject]@{ + + Name = $null; + State = $null; + Status = $null; + ManagedSan = $null; + Members = [System.Collections.ArrayList]::new(); + Created = $null; + Modified = $null; + ApplianceConnection = $null + + } + + } + + 'FCAlias' + { + + Return [PSCustomObject]@{ + + Name = $null; + WWN = $null; + + } + + } + + 'UpdateUserPassword' + { + + Return [PSCustomObject]@{ + + type = 'UserAndPermissions'; + currentPassword = $null; + password = $null; + userName = $Null + } + + } + + 'VCMigratorReport' + { + + Return [PSCustomObject]@{ + + apiVcMigrationReport = @{}; + issueCount = [Int]$null; + migrationState = [String]$Null; + VcemManaged = [Bool]$False; + outReport = [System.Collections.ArrayList]::new() + + } + + } + + 'EnclosureRefresh' + { + + Return [PSCustomObject]@{ + + refreshState = "RefreshPending"; + refreshForceOptions = $null + } + + } + + 'EnclosureRefreshForceOptions' + { + + Return [PSCustomObject]@{ + + address = $null; + username = $null; + password = $null + + } + + } + + 'AutoBackupConfig' + { + + Return [PSCustomObject]@{ + + remoteServerName = $null; + port = 22; + remoteServerDir = ''; + remoteServerPublicKey = $null; + userName = $null; + password = $null; + enabled = $true; + protocol = 'SCP'; + scheduleInterval = 'NONE'; + scheduleDays = [System.Collections.ArrayList]::new() + scheduleTime = $null; + eTag = $null + + } + + } + + 'DirectoryGroupCredentials' + { + + Return [PSCustomObject]@{ + + userName = $null; + password = $null + + } + + } + + 'ApplianceTimeLocale' + { + + Return [PSCustomObject]@{ + + type = 'TimeAndLocale'; + locale = $null; + timezone = 'UTC'; + ntpServers = [System.Collections.ArrayList]::new() + pollingInterval = $null; + + } + + } + + 'RemoteSupportConfig' + { + + Return [PSCustomObject]@{ + + type = 'Configuration'; + eTag = $null; + enableRemoteSupport = $false; + companyName = $null; + marketingOptIn = $false + + } + + } + + 'RemoteSupportContact' + { + + Return [PSCustomObject]@{ + + type = 'Contact'; + default = $false; + defaultSecondary = $false; + alternatePhone = $null; + email = $null; + firstName = $null; + lastName = $null; + language = $null; + notes = $null; + primaryPhone = $null + + } + + } + + 'RemoteSupportSite' + { + + Return [PSCustomObject]@{ + + type = 'Site'; + name = 'DEFAULT SITE' + default = $true; + city = $null; + postalCode = $null; + provinceState = $null; + streetAddress1 = $null; + streetAddress2 = $null; + countryCode = $null; + timeZone = $null + + } + + } + + 'SnmpConfig' + { + + Return [PSCustomObject]@{ + + type = 'snmp-configuration' + readCommunity = 'public'; + enabled = $true; + systemContact = $null; + v3Enabled = $false; + snmpUsers = [System.Collections.ArrayList]::new(); + snmpAccess = [System.Collections.ArrayList]::new(); + trapDestinations = [System.Collections.ArrayList]::new() + + } + + } + + 'SnmpTrapDestination' + { + + Return [PSCustomObject]@{ + + trapDestination = $null; + communityString = $null; + trapFormat = $null; + trapSeverities = [System.Collections.ArrayList]::new(); + vcmTrapCategories = [System.Collections.ArrayList]::new(); + enetTrapCategories = [System.Collections.ArrayList]::new(); + fcTrapCategories = [System.Collections.ArrayList]::new(); + userName = $null; + inform = $true; + port = '162' + + } + + } + + 'PatchOperation' + { + + Return [PSCustomObject]@{ + + op = $null; + path = $null; + value = $null + + } + + } + + 'IPv4Subnet' + { + + Return [PSCustomObject]@{ + + type = 'Subnet'; + category = $ResourceCategoryEnum.IPv4Subnet; + name = $null; + networkId = $null; + subnetmask = $null; + gateway = $null; + domain = $null; + dnsServers = [System.Collections.ArrayList]::new(); + + } + + } + + 'IPv6Subnet' + { + + Return [PSCustomObject]@{ + + type = "SubnetIPv6"; + networkId = $null; + prefixLength = $null; + gateway = $null; + domain = $null; + dnsServers = [System.Collections.ArrayList]::new() + + } + + } + + 'LogicalEnclosure' + { + + Return [PSCustomObject] @{ + + name = $null; + enclosureBaySettings = [System.Collections.ArrayList]::new(); + enclosureUris = [System.Collections.ArrayList]::new(); + enclosureGroupUri = $null; + firmwareBaselineUri = $null; + forceInstallFirmware = $false; + initialScopeUris = [System.Collections.ArrayList]::new() + + } + + } + + 'LogicalEnclosureEnclosureBaySettings' + { + + $EnclosureObjectToReturn = [PSCustomObject]@{ + + interconnectBays = [System.Collections.ArrayList]::new(); + deviceBays = [System.Collections.ArrayList]::new() + + } + + Return $EnclosureObjectToReturn + + } + + 'LogicalEnclosureEbipaAddress' + { + + Return [PSCustomObject]@{ + + type = $null; + ipAddress = $null + + } + + } + + 'LogicalEnclosureEbipaSetting' + { + + Return [PSCustomObject]@{ + + bayNumber = $null; + manualAddresses = [System.Collections.ArrayList]::new() + + } + + } + + 'InterconnectMapEntryTemplate' + { + + Return [PSCustomObject] @{ + + # LogicalDownlinkUri = $null; + permittedInterconnectTypeUri = $null; + enclosureIndex = $null; + logicalLocation = [PSCustomObject]@{ + + locationEntries = [System.Collections.ArrayList]::new() + + } + + } + + } + + 'InterconnectMapEntryTemplate' + { + + Return [PSCustomObject] @{ + + logicalDownlinkUri = $null; + permittedInterconnectTypeUri = $null; + enclosureIndex = $null; + logicalLocation = [PSCustomObject]@{ + + locationEntries = [System.Collections.ArrayList]::new() + + } + + } + + } + + 'LocationEntry' + { + + Return [PSCustomObject]@{ + + relativeValue = 1; + type = $Null + + } + + } + + 'LoginMessageObject' + { + + Return [PSCustomObject]@{ + + Message = $null; + Acknowledgment = $null; + ApplianceConnection = $null + + } + + } + + 'ConvertSnapshotToVol' + { + + Return [PSCustomObject]@{ + + properties = [PSCustomObject] @{ + + name = $null; + description = $null; + provisioningType = 'Thin'; + storagePool = $null; + snapshotPool = $null; + isShareable = $false + + }; + snapshotUri = $null; + templateUri = $null; + # isPermanent = $true; + + } + + } + + 'VolSnapshot' + { + + Return [PSCustomObject]@{ + + name = '{volumeName}_{timestamp}'; + description = $null + + } + + } + + 'LogicalInterconnectBaseline' + { + + Return [PsCustomObject]@{ + + command = 'Update'; + ethernetActivationType = 'OddEven'; + ethernetActivationDelay = 5; + fcActivationType = 'OddEven'; + fcActivationDelay = 5; + sppUri = $null; + force = $false; + validationType = $null + + } + + } + + 'SasLogicalInterconnectBaseline' + { + + Return [PsCustomObject]@{ + + command = 'Update'; + fwBaseline = $null; + force = $false; + sppUri = $null; + validationType = $null + + } + + } + + 'StoragePath' + { + + Return [PSCustomObject]@{ + + targetSelector = "Auto"; + targets = [System.Collections.ArrayList]::new(); + connectionId = 1; + isEnabled = $true + + } + + } + + 'LicenseKey' + { + + Return [PsCustomObject] @{ + + type = "LicenseV500"; + key = $null + + } + + } + + 'UnmanagedDevice' + { + + Return [PSCustomObject]@{ + + name = [String]$null; + model = [String]$null; + height = [Int]1; + mac = [String]$null; + ipv4Address = [String]$null; + ipv6Address = [String]$null; + maxPwrConsumed = [Int]100 + + } + + } + + 'RabbitmqCertReq' + { + + Return [PSCustomObject] @{ + + commonName = 'default'; + type = 'RabbitMqClientCertV2' + + } + + } + + 'AuthLoginCredential' + { + + Return [PSCustomObject] @{ + + userName = $null; + password = $null; + authLoginDomain = $null + + } + + } + + 'DownloadFileStatus' + { + + Return [PSCustomObject]@{ + + status = $null; + file = $null; + ApplianceConnection = $null + + } + + } + + 'GlobalSetting' + { + + Return [PSCustomObject]@{ + + type = "SettingV2"; + name = $null; + value = $null + + } + + } + + 'StorageVolumeTemplate' + { + + Return [PSCustomObject]@{ + + name = $null; + description = $null; + rootTemplateUri = $null; + initialScopeUris = [System.Collections.ArrayList]::new(); + properties = @{} + + } + + } + + 'CustomBaselineRestore' + { + + Return [PSCustomObject]@{ + + baselineUri = $null; + hotfixUris = [System.Collections.ArrayList]::new(); + customBaselineName = $null + + } + + } + + 'SmtpConfig' + { + + Return [PSCustomObject]@{ + + type = "EmailNotificationV4"; + senderEmailAddress = $null; + password = $null; + smtpServer = $null; + smtpPort = 25; + smtpProtocol = 'TLS'; + alertEmailDisabled = $false; + alertEmailFilters = [System.Collections.ArrayList]::new() + + } + + } + + 'TestSmtpConfig' + { + + Return [PSCustomObject]@{ + + type = "Email"; + subject = $null; + htmlMessageBody = $null; + textMessageBody = $null; + toAddress = [System.Collections.ArrayList]::new() + + } + + } + + 'UpdateAlert' + { + + Return [PSCustomObject] @{ + + alertState = $null; + assignedToUser = $null; + notes = $null; + eTag = $null + + } + + } + + 'SelfSignedCert' + { + + Return [PSCustomObject]@{ + + type = "CertificateDtoV3"; + country = $null; + state = $null; + locality = $null; + organization = $null; + commonName = $null; + organizationalUnit = $null; + alternativeName = $null; + contactPerson = $null; + email = $null; + surname = $null; + givenName = $null; + initials = $null; + dnQualifier = $null + + } + + } + + 'ApplianceCSR' + { + + Return [PSCustomObject]@{ + + type = "CertificateSigningRequestV2"; + country = $null; + state = $null; + locality = $null; + organization = $null; + commonName = $null; + organizationalUnit = $null; + alternativeName = $null; + contactPerson = $null; + email = $null; + surname = $null; + givenName = $null; + initials = $null; + dnQualifier = $null; + unstructuredName = $null; + challengePassword = $null; + cnsaCertRequested = $false + + } + + } + + 'AuthDirectory' + { + + Return [PSCustomObject]@{ + + type = 'LoginDomainConfigV600'; + directoryBindingType = $LdapDirectoryAccountBindTypeEnum['USERACCOUNT']; + authnType = "CREDENTIAL"; + authProtocol = 'AD'; + baseDN = $null; + orgUnits = [System.Collections.ArrayList]::new() + userNamingAttribute = 'UID'; + name = $null; + credential = [PSCustomObject]@{ + + userName = $null; + password = $null + + }; + directoryServers = [System.Collections.ArrayList]::new(); + + } + + } + + 'DirectoryGroup' + { + + Return [PSCustomObject]@{ + + type = 'LoginDomainGroupCredentials'; + group2PermissionPerGroup = [PSCustomObject]@{ + + type = 'LoginDomainGroupPermission'; + loginDomain = $null; + egroup = $null; + permissions = [System.Collections.ArrayList]::new(); + + } + credentials = NewObject -DirectoryGroupCredentials + + } + + } + + 'DirectoryGroupPermissions' + { + + Return [PSCustomObject]@{ + + roleName = $null; + scopeUri = $null + + } + + } + + 'AuthDirectoryServer' + { + + Return [PSCustomObject]@{ + + type = 'LoginDomainDirectoryServerInfoDto' + directoryServerCertificateStatus = ""; + directoryServerCertificateBase64Data = ""; + serverStatus = ""; + directoryServerIpAddress = $null; + directoryServerSSLPortNumber = "636"; + + } + + } + + 'IPIDPoolRange' + { + + Return [PsCustomObject]@{ + + type = 'Range'; + rangeCategory = 'Custom'; + name = $null; + enabled = $true; + startStopFragments = [System.Collections.ArrayList]::new() + subnetUri = $null + + } + + } + + 'IDPoolStartStopFragment' + { + + Return @{ + + startAddress = $null; + endAddress = $null + + } + + } + + 'IDPoolRange' + { + + Return [PsCustomObject]@{ + + type = 'Range'; + rangeCategory = 'Custom'; + name = $null; + enabled = $true; + startAddress = $null; + endAddress = $null + + } + + } + + 'UserAccount' + { + + Return [PsCustomObject]@{ + + type = "UserAndPermissions"; + userName = $null; + fullName = $null; + password = $null; + emailAddress = $emailAddress; + officePhone = $null; + mobilePhone = $null; + enabled = $True; + permissions = [System.Collections.ArrayList]::new() + + } + + } + + 'PowerDeliveryDeviceAdd' + { + + Return [PSCustomObject]@{ + + hostname = $null; + username = $null; + password = $null; + force = $null + + } + + } + + 'ApplianceDebug' + { + + Return [PSCustomObject]@{ + + scope = $null; + loggerName = $null; + level = $null + + } + + } + + 'AlertFilter' + { + + Return [PSCustomObject]@{ + + filterName = $null; + disabled = $False; + filter = $null; + displayFilter = $null; + userQueryFilter = $null; + emails = [System.Collections.ArrayList]::new(); + scopeQuery = $null; + customEmailSenderEnabled = $false; + customSenderEmailAddress = $null; + customSenderPassword = $null + + } + + } + + 'ServerProfile' + { + + Return [PSCustomObject]@{ + + type = $ServerProfileType; + name = $null; + description = $null; + affinity = $null; + hideUnusedFlexNics = $true; + initialScopeUris = [System.Collections.ArrayList]::new(); + bios = [PSCustomObject]@{ + + manageBios = $false; + overriddenSettings = $null + + }; + firmware = [PSCustomObject]@{ + + manageFirmware = $false; + firmwareBaselineUri = $null; + forceInstallFirmware = $false; + installationPolicy = "LowerThanBaseline"; + firmwareInstallType = 'FirmwareAndOSDrivers'; + firmwareActivationType = 'Immediate'; + firmwareScheduleDateTime = $null + + }; + boot = [PSCustomObject]@{ + + manageBoot = $false; + order = [System.Collections.ArrayList]::new() + + }; + bootMode = $null; + localStorage = [PSCustomObject]@{ + + sasLogicalJBODs = [System.Collections.ArrayList]::new(); + controllers = [System.Collections.ArrayList]::new() + + } + serialNumberType = 'Virtual'; + macType = 'Virtual'; + wwnType = 'Virtual'; + connectionSettings = [PSCustomObject]@{ + connections = [System.Collections.ArrayList]::new(); + } + serialNumber = $null; + iscsiInitiatorNameType = 'AutoGenerated' + serverHardwareUri = $null; + serverHardwareTypeUri = $null; + serverProfileTemplateUri = $null; + enclosureBay = $null; + enclosureGroupUri = $null; + enclosureUri = $null; + sanStorage = $null; + uuid = $null; + managementProcessor = [PSCustomObject]@{ + + manageMp = $false; + mpSettings = [System.Collections.ArrayList]::new() + + } + + } + + } + + 'ServerProfileTemplate' + { + + Return [PSCustomObject]@{ + + type = $ServerProfileTemplateType; + serverProfileDescription = $null; + serverHardwareTypeUri = $null; + enclosureGroupUri = $null; + serialNumberType = 'Virtual'; + macType = 'Virtual'; + wwnType = 'Virtual'; + name = $null; + description = $null; + affinity = $null; + initialScopeUris = [System.Collections.ArrayList]::new(); + connectionSettings = @{ + + connections = [System.Collections.ArrayList]::new(); + manageConnections = $true + + } + + boot = [PSCustomObject]@{ + + complianceControl = $ConsistencyCheckingEnum.Exact; + manageBoot = $true; + order = [System.Collections.ArrayList]::new() + + }; + bootMode = $null; + firmware = [PSCustomObject]@{ + + complianceControl = $ConsistencyCheckingEnum.Exact; + manageFirmware = $false; + firmwareBaselineUri = $null; + forceInstallFirmware = $false; + installationPolicy = "LowerThanBaseline"; + firmwareInstallType = 'FirmwareAndOSDrivers'; + firmwareActivationType = 'Immediate' + + }; + bios = [PSCustomObject]@{ + + complianceControl = $ConsistencyCheckingEnum.Exact; + manageBios = $false; + overriddenSettings = [System.Collections.ArrayList]::new() + + }; + hideUnusedFlexNics = $true; + iscsiInitiatorNameType = "AutoGenerated"; + localStorage = [PSCustomObject]@{ + + complianceControl = $ConsistencyCheckingEnum.Exact; + sasLogicalJBODs = [System.Collections.ArrayList]::new(); + controllers = [System.Collections.ArrayList]::new() + + } + sanStorage = $null; + managementProcessor = [PSCustomObject]@{ + + complianceControl = $ConsistencyCheckingEnum.None; + manageMp = $false; + mpSettings = [System.Collections.ArrayList]::new() + + } + + } + + } + + 'ServerProfileTemplateLocalStorage' + { + + Return [PSCustomObject]@{ + + slotNumber = '0'; + managed = $true; + mode = 'RAID' + initialize = $false; + logicalDrives = [System.Collections.ArrayList]::new() + + } + + } + + 'ServerProfileLocalStorageController' + { + + Return [PSCustomObject]@{ + + deviceSlot = 'Embedded'; + importConfiguration = $false; + family = [ServerProfileControllerFamilyEnum]::SmartRAID.ToString(); + mode = 'RAID' + initialize = $false; + driveWriteCache = "Unmanaged"; + logicalDrives = [System.Collections.ArrayList]::new() + + } + + } + + 'ServerProfileLocalStorageLogicalDrive' + { + + Return [PSCustomObject]@{ + + name = $null; + bootable = $false; + raidLevel = $null; + numPhysicalDrives = $null; + driveTechnology = $null; + sasLogicalJBODId = $null; + accelerator = "Unmanaged"; + readCachePolicy = "Unmanaged"; + writeCachePolicy = "Unmanaged"; + + } + + } + + 'ServerProfileSasLogicalJBOD' + { + + Return [PSCustomObject]@{ + + id = 1; + deviceSlot = $null; + name = $null + numPhysicalDrives = 1; + driveMinSizeGB = 0; + driveMaxSizeGB = 0; + driveTechnology = $null; + eraseData = $false; + persistent = $true + + } + + } + + 'EnclosureImport' + { + + Return [PSCustomObject]@{ + + hostname = $null; + username = $null; + password = $null; + licensingIntent = 'OneView'; + force = $false; + enclosureGroupUri = $null; + firmwareBaselineUri = $null; + forceInstallFirmware = $false; + updateFirmwareOn = $null; + state = $null; + initialScopeUris = [System.Collections.ArrayList]::new() + + } + + } + + 'ServerImport' + { + + Return [PSCustomObject]@{ + + hostname = $null; + username = $null; + password = $null; + force = $false; + licensingIntent = 'OneView'; + configurationState = $null; + initialScopeUris = [System.Collections.ArrayList]::new() + + } + + } + + 'StorageSystemCredentials' + { + + Return [PSCustomObject]@{ + + hostname = $null; + username = $null; + password = $null; + family = $null + + } + + } + + 'StorageSystemManagedPort' + { + + Return [PSCustomObject]@{ + + type = "StorageTargetPortV4"; + portName = $null; + name = $null; + expectedNetworkUri = $null; + expectedNetworkName = $null; + actualNetworkUri = $null; + actualNetworkSanUri = $null; + portWwn = $null; + groupName = 'Auto'; + label = $null; + protocolType = 'FC' + + } + + } + + 'StorageVolume' + { + + Return [PSCustomObject]@{ + + properties = @{}; + templateUri = $null; + # isPermanent = $true; + initialScopeUris = [System.Collections.ArrayList]::new() + + } + + } + + 'StoreVirtualStorageVolume' + { + + Return [PSCustomObject]@{ + + properties = @{ + name = $null; + description = $null; + storagePool = $null; + size = 107374182400; + provisioningType = "Thin"; + isShareable = $false; + dataProtectionLevel = $null + isAdaptiveOptimizationEnabled = $false + }; + templateUri = $null; + # isPermanent = $true; + initialScopeUris = [System.Collections.ArrayList]::new() + + } + + } + + 'ServerProfileStorageVolume' + { + + Return [PsCustomObject]@{ + + id = $null; + lun = $null; + volumeUri = $null; + volumeStoragePoolUri = $null; + volumeStorageSystemUri = $null; + lunType = 'Auto'; + isPermanent = $true; + storagePaths = [System.Collections.ArrayList]::new(); + bootVolumePriority = 'NotBootable'; + ApplianceConnection = $null; + + } + + } + + 'AddStorageVolume' + { + + Return [PSCustomObject]@{ + + description = $null; + deviceVolumeName = $null; + isShareable = $false; + name = $null; + storageSystemUri = $null; + initialScopeUris = [System.Collections.ArrayList]::new() + + } + + } + + 'EphemeralStorageVolume' + { + + Return [PsCustomObject]@{ + + id = 1 + volumeUri = $null; + volumeStorageSystemUri = $null; + volume = [PSCustomObject]@{ + properties = @{} + templateUri = $null; + initialScopeUris = $null + }; + bootVolumePriority = 'NotBootable'; + lunType = 'Auto'; + lun = $null; + ApplianceConnection = $null; + storagePaths = [System.Collections.ArrayList]::new(); + isPermanent = $true + + } + + } + + 'StoreVirtualEphemeralVolumeProperties' + { + + Return [PSCustomObject]@{ + name = $null; + description = $null; + storagePool = $null; + templateVersion = "1.0"; + provisioningType = 'Thin'; + size = '10737418240'; + isShareable = $false; + dataProtectionLevel = $null; + isAdaptiveOptimizationEnabled = $false + } + + } + + 'StoreServeEphemeralVolumeProperties' + { + + Return [PSCustomObject]@{ + name = $null; + description = $null; + storagePool = $null; + templateVersion = "1.0"; + provisioningType = 'Thin'; + size = '10737418240'; + isShareable = $false; + snapshotPool = $null + } + + } + + 'NimbleEphemeralVolumeProperties' + { + + Return [PSCustomObject]@{ + name = $null; + description = $null; + storagePool = $null; + provisioningType = 'Thin'; + size = '10737418240'; + isShareable = $false; + templateVersion = "1.0"; + isDeduplicated = $false; + performancePolicy = $null; + folder = $null; + volumeSet = $null; + isEncrypted = $false; + isPinned = $false; + iopsLimit = $null; + dataTransferLimit = $null + } + + } + + 'ServerProfileEthernetConnection' + { + + Return [PSCustomObject]@{ + + id = 1; + functionType = 'Ethernet'; + name = $null; + portId = $null; + networkUri = $null; + requestedMbps = 2000; + boot = $null; + macType = 'Virtual'; + mac = $null; + requestedVFs = '0'; + lagName = $null; + ApplianceConnection = $null + + } + + } + + 'ServerProfileIscsiConnection' + { + + Return [PSCustomObject]@{ + + id = 1; + functionType = 'Ethernet'; + name = $null; + portId = $null; + networkUri = $null; + requestedMbps = 2000; + boot = $null; + macType = 'Virtual'; + mac = $null; + ipv4 = $null; + lagName = $null; + ApplianceConnection = $null + + } + + } + + 'ServerProfileFCConnection' + { + + Return [PSCustomObject]@{ + + id = 1; + functionType = 'FibreChannel'; + name = $null; + portId = $null; + networkUri = $null; + requestedMbps = 2000; + boot = $null; + macType = 'Virtual'; + mac = $null; + wwpnType = 'Virtual'; + wwnn = $null; + wwpn = $null; + ApplianceConnection = $null + + } + + } + + 'ServerProfileUnmanagedFCConnection' + { + + Return [PSCustomObject]@{ + + id = 1; + name = $null; + functionType = 'FibreChannel'; + portId = $null; + networkUri = $null; + requestedMbps = $null; + boot = $null; + wwpn = $null; + managed = $false; + ApplianceConnection = $null + + } + + } + + 'ServerProfileEthBootableConnection' + { + + Return [PSCustomObject]@{ + + priority = 'NotBootable'; + ethernetBootType = "PXE"; + iscsi = $null + + } + + } + + 'ServerProfileEthBootableConnectionWithTargets' + { + + Return [PSCustomObject]@{ + + priority = 'NotBootable'; + targets = [System.Collections.ArrayList]::new(); + bootVolumeSource = 'AdapterBIOS'; + ethernetBootType = "PXE"; + iscsi = $null + + } + + } + + 'ServerProfileIscsiBootableConnectionWithTargets' + { + + Return [PSCustomObject]@{ + + priority = 'NotBootable'; + targets = [System.Collections.ArrayList]::new(); + bootVolumeSource = 'AdapterBIOS'; + iscsi = $null + + } + + } + + 'ServerProfileFcBootableConnection' + { + + Return [PSCustomObject]@{ + + priority = 'NotBootable'; + targets = [System.Collections.ArrayList]::new(); + bootVolumeSource = 'AdapterBIOS' + + } + + } + + 'ServerProfileConnectionFcBootTarget' + { + + Return [PSCustomObject]@{ + + arrayWwpn = $null; + lun = $null + + } + + } + + 'IscsiBootEntry' + { + + Return [PSCustomObject]@{ + + initiatorNameSource = "ProfileInitiatorName"; + firstBootTargetIp = $null; + firstBootTargetPort = $null; + secondBootTargetIp = $null; + secondBootTargetPort = $null; + chapLevel = $null; + initiatorName = $null; + bootTargetName = $null; + bootTargetLun = $null; + chapName = $null; + chapSecret = $null; + mutualChapName = $null; + mutualChapSecret = $null + + } + + } + + 'IscsiIPv4Configuration' + { + + Return [PSCustomObject]@{ + + ipAddress = $null; + subnetMask = $null; + gateway = $null; + ipAddressSource = 'UserDefined' + + } + + } + + 'SanManager' + { + + Return [PSCustomObject]@{ + + "connectionInfo" = [System.Collections.ArrayList]::new() + + } + + } + + 'SanManagerConnectInfo' + { + + Return [PSCustomObject]@{ + + name = $null; + Value = $null + + } + + } + + 'EthernetNetwork' + { + + Return [pscustomobject]@{ + + type = $EthernetNetworkType; + vlanId = 1; + ethernetNetworkType = 'Tagged'; + purpose = 'General'; + name = $null; + smartLink = $false; + privateNetwork = $false; + subnetUri = $null; + ipv6SubnetUri = $null; + initialScopeUris = [System.Collections.ArrayList]::new() + + } + + } + + 'BulkEthernetNetworks' + { + + Return [pscustomobject]@{ + + type = $EthernetNetworkBulkType; + vlanIdRange = $null; + purpose = 'General'; + namePrefix = $null; + smartLink = $false; + privateNetwork = $false; + bandwidth = [PSCustomObject]@{ + + typicalBandwidth = 2500; + maximumBandwidth = 20000 + + }; + networkSetUris = [System.Collections.ArrayList]::new(); + initialScopeUris = [System.Collections.ArrayList]::new() + + } + + } + + 'FCNetwork' + { + + [pscustomobject]@{ + + type = $FCNetworkType; + name = $Name; + linkStabilityTime = 30; + autoLoginRedistribution = $true; + fabricType = 'FabricAttach'; + connectionTemplateUri = $null; + managedSanUri = $null; + initialScopeUris = [System.Collections.ArrayList]::new() + + } + + } + + 'FCoENetwork' + { + + Return [pscustomobject]@{ + + type = $FCoENetworkType; + name = $null; + vlanId = 1; + connectionTemplateUri = $null; + managedSanUri = $null; + initialScopeUris = [System.Collections.ArrayList]::new() + + } + + } + + 'RoCENetwork' + { + + Return [pscustomobject]@{ + + type = $RoCENetworkType; + ethernetNetworkType = "Tagged"; + name = $null; + vlanId = 1; + connectionTemplateUri = $null; + privateNetwork = $null; + initialScopeUris = [System.Collections.ArrayList]::new() + + } + + } + + 'NetworkSet' + { + + Return [PSCustomObject] @{ + + type = $NetworkSetType; + name = $null; + networkUris = [System.Collections.ArrayList]::new(); + nativeNetworkUri = $null; + networkSetType = 'Regular'; + initialScopeUris = [System.Collections.ArrayList]::new() + + } + + } + + 'SynergyEnclosureGroup' + { + + Return [PSCustomObject]@{ + + name = $null; + interconnectBayMappings = [System.Collections.ArrayList]::new(); + configurationScript = $null; + powerMode = 'RedundantPowerFeed'; + ipAddressingMode = $null; + ipRangeUris = [System.Collections.ArrayList]::new(); + ipv6AddressingMode = $null; + ipv6RangeUris = [System.Collections.ArrayList]::new(); + enclosureCount = 1; + osDeploymentSettings = $null; + initialScopeUris = [System.Collections.ArrayList]::new(); + + } + + } + + 'EnclosureGroup' + { + + Return [PSCustomObject]@{ + + name = $null; + interconnectBayMappings = [System.Collections.ArrayList]::new(); + configurationScript = $null; + powerMode = 'RedundantPowerFeed'; + enclosureCount = 1; + initialScopeUris = [System.Collections.ArrayList]::new(); + ambientTemperatureMode = 'Standard' + + } + + } + + 'DeploymentModeSettings' + { + + Return [PSCustomObject]@{ + + deploymentModeSettings = $null; + manageOSDeployment = $false + + } + + } + + 'EnclosureGroupI3SDeploymentSettings' + { + + Return [PSCustomObject]@{ + + deploymentMode = 'None'; + deploymentNetworkUri = $null + + } + + } + + 'InterconnectBayMapping' + { + + Return [PSCustomObject]@{ + + enclosureIndex = 1; + interconnectBay = 1; + logicalInterconnectGroupUri = $null + + } + + } + + 'ApplianceVersion' + { + + Return [PSCustomObject]@{ + + applianceName = $null; + softwareVersion = $null; + major = $null; + minor = $null; + xapiVersion = $null; + modelNumber = $null + + } + + } + + 'AllApiResponse' + { + + Return [PSCustomObject]@{ + + type = [String]$null; + nextPageUri = [String]$null; + start = [Int]0; + prevPageUri = [String]$null; + total = [Int]0; + count = [Int]0; + members = [System.Collections.ArrayList]::new(); + eTag = [String]$null; + created = [String]$null; + modified = [String]$null; + category = [String]$null; + uri = [String]$null + + } + + } + + # Default LIG Object + "C7KLIG" + { + + Return [PSCustomObject]@{ + name = $Null; + uplinkSets = [System.Collections.ArrayList]::new(); + interconnectMapTemplate = [PSCustomObject]@{ + + interconnectMapEntryTemplates = [System.Collections.ArrayList]::new()}; + + internalNetworkUris = [System.Collections.ArrayList]::new(); + consistencyCheckingForInternalNetworks = $LIGConsistencyCheckingEnum.Exact; + ethernetSettings = [PSCustomObject]@{ + + type = $LogicalInterconnectEthernetSettingsType; + enableFastMacCacheFailover = $true; + macRefreshInterval = 5; + enableNetworkLoopProtection = $false; + enablePauseFloodProtection = $true; + enableRichTLV = $false; + enableTaggedLldp = $false; + consistencyChecking = $LIGConsistencyCheckingEnum.Exact + + }; + igmpSettings = [PSCustomObject]@{ + type = 'IgmpSettings'; + consistencyChecking = $LIGConsistencyCheckingEnum.Exact; + enableIgmpSnooping = $false; + igmpIdleTimeoutInterval = 260; + } + snmpConfiguration = $Null; + qosConfiguration = [PSCustomObject]@{ + + type = "qos-aggregated-configuration"; + activeQosConfig = $Null; + inactiveFCoEQosConfig = $null; + inactiveNonFCoEQosConfig = $null; + consistencyChecking = $LIGConsistencyCheckingEnum.Exact + + + }; + stackingMode = "Enclosure"; + enclosureType = "C7000"; + type = $LogicalInterconnectGroupType; + category = 'logical-interconnect-groups'; + initialScopeUris = [System.Collections.ArrayList]::new() + + } + + } + + "SELIG" + { + + Return [PSCustomObject]@{ + type = $LogicalInterconnectGroupType; + category = 'logical-interconnect-groups'; + name = $Null; + uplinkSets = [System.Collections.ArrayList]::new(); + interconnectMapTemplate = [PSCustomObject]@{ + interconnectMapEntryTemplates = [System.Collections.ArrayList]::new() + }; + internalNetworkUris = [System.Collections.ArrayList]::new(); + consistencyCheckingForInternalNetworks = $LIGConsistencyCheckingEnum.Exact; + ethernetSettings = [PSCustomObject]@{ + + type = $LogicalInterconnectEthernetSettingsType; + enableFastMacCacheFailover = $true; + macRefreshInterval = 5; + enableNetworkLoopProtection = $false; + enablePauseFloodProtection = $true; + enableRichTLV = $false; + enableTaggedLldp = $false; + enableStormControl = $false; + stormControlThreshold = 1; + stormControlPollingInterval = 10; + enableCutThrough = $false; + enableDdns = $false; + domainName = ""; + consistencyChecking = $LIGConsistencyCheckingEnum.Exact + + }; + igmpSettings = [PSCustomObject]@{ + type = 'IgmpSettings'; + consistencyChecking = $LIGConsistencyCheckingEnum.Exact; + enableIgmpSnooping = $false; + igmpSnoopingVlanIds = $null; + igmpIdleTimeoutInterval = 260; + enablePreventFlooding = $false; + enableProxyReporting = $true; + + } + snmpConfiguration = $Null; + qosConfiguration = [PSCustomObject]@{ + + type = "qos-aggregated-configuration"; + activeQosConfig = $Null; + inactiveFCoEQosConfig = $null; + inactiveNonFCoEQosConfig = $null; + consistencyChecking = $LIGConsistencyCheckingEnum.Exact + + }; + enclosureType = 'SY12000'; + enclosureIndexes = [System.Collections.ArrayList]::new(); + interconnectBaySet = 1; + redundancyType = 'Redundant'; + downlinkSpeedMode = $NitroDownlinkSpeed."25GbSpeed" + initialScopeUris = [System.Collections.ArrayList]::new() + + } + + } + + "SESASLIG" + { + + Return [PSCustomObject]@{ + type = "sas-logical-interconnect-groupV2" + name = $Null; + interconnectMapTemplate = [PSCustomObject]@{ + + interconnectMapEntryTemplates = [System.Collections.ArrayList]::new()}; + + enclosureType = 'SY12000'; + enclosureIndexes = @(1); + interconnectBaySet = 1; + initialScopeUris = [System.Collections.ArrayList]::new() + + } + + } + + # Default qosConfiguration Object for LIG + "QosConfiguration" + { + + Return [PSCustomObject]@{ + + type = "QosConfiguration"; + configType = "Passthrough"; + qosTrafficClassifiers = [System.Collections.ArrayList]@() + uplinkClassificationType = $Null; # Leave Null to support default 'Passthrough' + downlinkClassificationType = $Null; # Leave Null to support default 'Passthrough' + + } + + } + + 'QosIngressClassMapping' + { + + Return [PSCustomObject]@{ + + dot1pClassMapping = [System.Collections.ArrayList]::new(); + dscpClassMapping = [System.Collections.ArrayList]::new() + + } + + } + + # Default With FCoE Lossless Traffic Classifiers Object + "DefaultFCoELosslessQosTrafficClassifiers" + { + + Return @( + + #1 + [PSCustomObject]@{ + qosTrafficClass = [PSCustomObject]@{ + + maxBandwidth = 100; + bandwidthShare = "65"; + egressDot1pValue = 0; + realTime = $false; + className = "Best effort"; + enabled = $true; + + }; + + qosClassificationMapping = [PSCustomObject]@{ + + dot1pClassMapping = [System.Collections.ArrayList]@(1,0); + dscpClassMapping = [System.Collections.ArrayList]@( + + "DSCP 10, AF11", + "DSCP 12, AF12", + "DSCP 14, AF13", + "DSCP 8, CS1", + "DSCP 0, CS0" + + ) + + } + + }, + + #2 + [PSCustomObject]@{ + qosTrafficClass = [PSCustomObject]@{ + + maxBandwidth = 100; + bandwidthShare = "0"; + egressDot1pValue = 0; + realTime = $false; + className = "Class1"; + enabled = $false; + + }; + + qosClassificationMapping = $null + + }, + + #3 + [PSCustomObject]@{ + qosTrafficClass = [PSCustomObject]@{ + + maxBandwidth = 100; + bandwidthShare = "0"; + egressDot1pValue = 0; + realTime = $false; + className = "Class2"; + enabled = $false; + + }; + + qosClassificationMapping = $null + + }, + + #4 + [PSCustomObject]@{ + qosTrafficClass = [PSCustomObject]@{ + + maxBandwidth = 100; + bandwidthShare = "0"; + egressDot1pValue = 0; + realTime = $false; + className = "Class3"; + enabled = $false; + + }; + + qosClassificationMapping = $null + + }, + + #5 + [PSCustomObject]@{ + qosTrafficClass = [PSCustomObject]@{ + + maxBandwidth = 100; + bandwidthShare = "0"; + egressDot1pValue = 0; + realTime = $false; + className = "Class4"; + enabled = $false; + + }; + + qosClassificationMapping = $null + + }, + + #6 + [PSCustomObject]@{ + qosTrafficClass = [PSCustomObject]@{ + + maxBandwidth = 100; + bandwidthShare = "fcoe"; + egressDot1pValue = 3; + realTime = $false; + className = "FCoE lossless"; + enabled = $true; + + }; + + qosClassificationMapping = [PSCustomObject]@{ + + dot1pClassMapping = [System.Collections.ArrayList]@(3); + dscpClassMapping = [System.Collections.ArrayList]@() + + } + + }, + + #7 + [PSCustomObject]@{ + qosTrafficClass = [PSCustomObject]@{ + + maxBandwidth = 100; + bandwidthShare = "25"; + egressDot1pValue = 2; + realTime = $false; + className = "Medium"; + enabled = $true; + + }; + + qosClassificationMapping = [PSCustomObject]@{ + + dot1pClassMapping = [System.Collections.ArrayList]@(4,3,2); + dscpClassMapping = [System.Collections.ArrayList]@( + + "DSCP 18, AF21", + "DSCP 20, AF22", + "DSCP 22, AF23", + "DSCP 26, AF31", + "DSCP 28, AF32", + "DSCP 30, AF33", + "DSCP 34, AF41", + "DSCP 36, AF42", + "DSCP 38, AF43", + "DSCP 16, CS2", + "DSCP 24, CS3", + "DSCP 32, CS4" + + ) + + } + + }, + + #8 + [PSCustomObject]@{ + qosTrafficClass = [PSCustomObject]@{ + + maxBandwidth = 10; + bandwidthShare = "10"; + egressDot1pValue = 5; + realTime = $true; + className = "Real time"; + enabled = $true; + + }; + + qosClassificationMapping = [PSCustomObject]@{ + + dot1pClassMapping = [System.Collections.ArrayList]@(5,6,7); + dscpClassMapping = [System.Collections.ArrayList]@( + + "DSCP 46, EF", + "DSCP 40, CS5", + "DSCP 48, CS6", + "DSCP 56, CS7" + + ) + + } + + } + + ) + + } + + # Default With No FCoE Lossless Traffic Classifiers Object + "DefaultNoFCoELosslessQosTrafficClassifiers" + { + + Return @( + + #1 + [PSCustomObject]@{ + qosTrafficClass = [PSCustomObject]@{ + + maxBandwidth = 100; + bandwidthShare = "65"; + egressDot1pValue = 0; + realTime = $false; + className = "Best effort"; + enabled = $true; + + }; + + qosClassificationMapping = [PSCustomObject]@{ + + dot1pClassMapping = [System.Collections.ArrayList]@(1,0); + dscpClassMapping = [System.Collections.ArrayList]@( + + "DSCP 10, AF11", + "DSCP 12, AF12", + "DSCP 14, AF13", + "DSCP 8, CS1", + "DSCP 0, CS0" + + ) + + } + + }, + + #2 + [PSCustomObject]@{ + qosTrafficClass = [PSCustomObject]@{ + + maxBandwidth = 100; + bandwidthShare = "0"; + egressDot1pValue = 0; + realTime = $false; + className = "Class1"; + enabled = $false; + + }; + + qosClassificationMapping = $null + + }, + + #3 + [PSCustomObject]@{ + qosTrafficClass = [PSCustomObject]@{ + + maxBandwidth = 100; + bandwidthShare = "0"; + egressDot1pValue = 0; + realTime = $false; + className = "Class2"; + enabled = $false; + + }; + + qosClassificationMapping = $null + + }, + + #4 + [PSCustomObject]@{ + qosTrafficClass = [PSCustomObject]@{ + + maxBandwidth = 100; + bandwidthShare = "0"; + egressDot1pValue = 0; + realTime = $false; + className = "Class3"; + enabled = $false; + + }; + + qosClassificationMapping = $null + + }, + + #5 + [PSCustomObject]@{ + qosTrafficClass = [PSCustomObject]@{ + + maxBandwidth = 100; + bandwidthShare = "0"; + egressDot1pValue = 0; + realTime = $false; + className = "Class4"; + enabled = $false; + + }; + + qosClassificationMapping = $null + + }, + + #6 + [PSCustomObject]@{ + qosTrafficClass = [PSCustomObject]@{ + + maxBandwidth = 100; + bandwidthShare = "0"; + egressDot1pValue = 0; + realTime = $false; + className = "Class5"; + enabled = $false; + + }; + + qosClassificationMapping = $null + + }, + + #7 + [PSCustomObject]@{ + qosTrafficClass = [PSCustomObject]@{ + + maxBandwidth = 100; + bandwidthShare = "25"; + egressDot1pValue = 2; + realTime = $false; + className = "Medium"; + enabled = $true; + + }; + + qosClassificationMapping = [PSCustomObject]@{ + + dot1pClassMapping = [System.Collections.ArrayList]@(4,3,2); + dscpClassMapping = [System.Collections.ArrayList]@( + + "DSCP 18, AF21", + "DSCP 20, AF22", + "DSCP 22, AF23", + "DSCP 26, AF31", + "DSCP 28, AF32", + "DSCP 30, AF33", + "DSCP 34, AF41", + "DSCP 36, AF42", + "DSCP 38, AF43", + "DSCP 16, CS2", + "DSCP 24, CS3", + "DSCP 32, CS4" + + ) + + } + + }, + + #8 + [PSCustomObject]@{ + qosTrafficClass = [PSCustomObject]@{ + + maxBandwidth = 10; + bandwidthShare = "10"; + egressDot1pValue = 5; + realTime = $true; + className = "Real time"; + enabled = $true; + + }; + + qosClassificationMapping = [PSCustomObject]@{ + + dot1pClassMapping = [System.Collections.ArrayList]@(5,6,7); + dscpClassMapping = [System.Collections.ArrayList]@( + + "DSCP 46, EF", + "DSCP 40, CS5", + "DSCP 48, CS6", + "DSCP 56, CS7" + + ) + + } + + } + + ) + + } + + # Default BestEffort Traffic Class + "DefaultBestEffortTrafficClass" + { + + Return [PSCustomObject]@{ + + qosTrafficClass = [PSCustomObject]@{ + + maxBandwidth = 100; + bandwidthShare = "65"; + egressDot1pValue = 0; + realTime = $false; + className = "Best effort"; + enabled = $true; + + }; + + qosClassificationMapping = [PSCustomObject]@{ + + dot1pClassMapping = [System.Collections.ArrayList]@(1,0); + dscpClassMapping = [System.Collections.ArrayList]@( + + "DSCP 10, AF11", + "DSCP 12, AF12", + "DSCP 14, AF13", + "DSCP 8, CS1", + "DSCP 0, CS0" + + ) + + } + + } + + } + + # FCoE Lossless Traffic Class + "FCoELossLessTrafficClass" + { + + Return [PSCustomObject]@{ + + qosTrafficClass = [PSCustomObject]@{ + + maxBandwidth = 100; + bandwidthShare = "fcoe"; + egressDot1pValue = 3; + realTime = $false; + className = "FCoE lossless"; + enabled = $true; + + }; + + qosClassificationMapping = [PSCustomObject]@{ + + dot1pClassMapping = [System.Collections.ArrayList]@(3); + dscpClassMapping = [System.Collections.ArrayList]::new() + + } + + } + + } + + #Basic, not enabled Traffic Class + "BaseTrafficClass" + { + + Return [PSCustomObject]@{ + + qosTrafficClass = [PSCustomObject]@{ + + maxBandwidth = 100; + bandwidthShare = "0"; + egressDot1pValue = 0; + realTime = $false; + className = "Class"; + enabled = $false; + + }; + + qosClassificationMapping = [PSCustomObject]@{ + + dot1pClassMapping = [System.Collections.ArrayList]::new(); + dscpClassMapping = [System.Collections.ArrayList]::new() + + } + + } + + } + + "Ping" + { + + Return [PSCustomObject]@{ + + type = "PingDto"; + address = "example.com"; + noOfPackets = 5 + + } + + } + + "DCBXOverride" + { + + Return [PSCustomObject]@{ + + enabled = $false; + rocev1 = $false; + rocev2 = $false + + } + + } + + "liUplinkSetObject" + { + + Return [PSCustomObject]@{ + + type = $UplinkSetType; + name = $Name; + networkType = $null; + networkUris = [System.Collections.ArrayList]::new(); + portConfigInfos = [System.Collections.ArrayList]::new(); + fcNetworkUris = [System.Collections.ArrayList]::new(); + fcoeNetworkUris = [System.Collections.ArrayList]::new(); + roceNetworkUris = [System.Collections.ArrayList]::new(); + networkSetUris = [System.Collections.ArrayList]::new(); + privateVlanDomains = [System.Collections.ArrayList]::new(); + primaryPortLocation = $null; + connectionMode = 'Auto'; + ethernetNetworkType = $null; + lacpTimer = 'Short'; + logicalInterconnectUri = $null; + manualLoginRedistributionState = 'NotSupported'; + loadBalancingMode = 'SourceAndDestinationMac'; + fcMode = 'NA' + + } + + } + + 'ligUplinkSetObject' + { + + Return [PSCustomObject]@{ + + name = $null; + networkType = $null; + networkUris = [System.Collections.ArrayList]::new(); + nativeNetworkUri = $null; + networkSetUris = [System.Collections.ArrayList]::new(); + privateVlanDomains = [System.Collections.ArrayList]::new(); + logicalPortConfigInfos = [System.Collections.ArrayList]::new(); + ethernetNetworkType = "NotApplicable"; + mode = 'Auto'; + lacpTimer = 'Short'; + primaryPort = $null; + loadBalancingMode = 'SourceAndDestinationMac'; + consistencyChecking = $LIGConsistencyCheckingEnum.Exact; + fcMode = 'NA' + + } + + } + + 'UplinkSetLogicalLocation' + { + + Return [PSCustomObject]@{ + + desiredSpeed = "Auto"; + desiredFecMode = "None"; + logicalLocation = [PSCustomObject]@{ + + locationEntries = [System.Collections.ArrayList]::new() + + } + + } + + } + + 'UplinkSetLocation' + { + + Return [PSCustomObject]@{ + + desiredSpeed = "Auto"; + desiredFecMode = "None"; + location = [PSCustomObject]@{ + + locationEntries = [System.Collections.ArrayList]::new() + + } + + } + + } + + 'UplinkSetLogicalLocationEntry' + { + + Return [PSCustomObject]@{ + + type = $Null; + relativeValue = 1 + + } + + } + + 'UplinkSetLocationEntry' + { + + Return [PSCustomObject]@{ + + type = $Null; + value = 1 + + } + + } + + 'VcMigration' + { + + Return [PSCustomObject]@{ + + enclosureGroupUri = $Null; + iloLicenseType = $Null; + credentials = [PSCustomObject]@{ + + oaIpAddress = $Null; + oaUsername = $Null; + oaPassword = $Null; + vcmUsername = $Null; + vcmPassword = $Null; + type = "EnclosureCredentials" + + }; + category = "migratable-vc-domains"; + type = "MigratableVcDomainV300" + + } + + } + + } + + } + +} + +Function JoinObject +{ + + [CmdletBinding ()] + Param + ( + + [Parameter (Mandatory)] + [ValidateNotNullOrEmpty()] + [PSCustomObject]$Object1, + + [Parameter (Mandatory)] + [ValidateNotNullOrEmpty()] + [PSCustomObject]$Object2 + + ) + + $arguments = [PSCustomObject]@{} + + foreach ( $Property in $Object1.psobject.Properties){ + $arguments | Add-Member -NotePropertyName $Property.Name -NotePropertyValue $Property.value + + } + + foreach ( $Property in $Object2.psobject.Properties){ + $arguments | Add-Member -NotePropertyName $Property.Name -NotePropertyValue $Property.value + + } + + return [PSCustomObject]$arguments + +} + + +####################################################### +# Basic Support functions +# + +function Update-OVUserScript +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding ()] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline)] + [ValidateNotNullOrEmpty()] + [System.IO.FileInfo]$Path, + + [Parameter (Mandatory = $false)] + [Switch]$Replace + + ) + + Process + { + + $CmdletSearchExpression = [System.Text.RegularExpressions.Regex]::new("(?'CmdletVerb'add|copy|get|new|remove|set|show|wait|clear|connect|convert|convertto|disable|disconnect|enable|enter|exit|import|install|invoke|join|ping|pop|push|reset|restart|restore|save|search|send|start|stop|test|update)-(?'VendorPrefix'hpov)(?'CmdletNoun'[a-z]+)", [System.Text.RegularExpressions.RegexOptions]::IgnoreCase) + $OtherBrandStyleSearchExp = [System.Text.RegularExpressions.Regex]::new("(?'Libraryname'HPEOneView\.)", [System.Text.RegularExpressions.RegexOptions]::IgnoreCase) + $StringBuilder = [System.Text.StringBuilder]::new() + $File = [System.IO.StreamReader]::new((Resolve-Path $Path)) + $ReplacementString = '${CmdletVerb}-OV${CmdletNoun}' + $LibraryReplacementString = 'HPEOneView.' + + While (-not ($file.EndOfStream)) + { + $line = $file.ReadLine() + + $UpdatedLine = $CmdletSearchExpression.Replace($line, $ReplacementString) + $UpdatedLine = $OtherBrandStyleSearchExp.Replace($UpdatedLine, $LibraryReplacementString) + + [void]$StringBuilder.Append(($UpdatedLine + "`n")) + + } + + $file.Close() + + if ($PSBoundParameters.Keys -Contains 'Replace') + { + + [System.IO.File]::WriteAllLines((Resolve-Path $Path), $StringBuilder.ToString()) + + } + + else + { + + $StringBuilder + + } + + } + +} + +function Wait-Reboot +{ + + [CmdletBinding ()] + Param + ( + + [Parameter (Mandatory, Position = 0)] + [Int]$Time = 600 + + ) + + $_Time = $Time + + foreach ($i in (1..$_Time)) + { + + $_Percentage = $i / $_Time + + $_Remaining = New-TimeSpan -Seconds ($_Time - $i) + + $_Message = "Remaining time {0}" -f $_Remaining + + Write-Progress -Activity $_Message -PercentComplete ($_Percentage * 100) + + Start-Sleep 1 + + } + + Write-Progress -Activity $_Message -Completed + +} + +function Join-Scope +{ + + [CmdletBinding ()] + Param + ( + + [Parameter (Mandatory, Position = 0)] + [Object]$Scope + + ) + + Begin + { + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Debug + + } + + Process + { + + $_ScopeQueryStringBuilder = [System.Collections.Generic.List[System.String]]::new() + + ForEach ($_scope in $Scope) + { + + if ($_scope -isnot [HPEOneView.Appliance.ScopeCollection] -and $_scope -isnot [HPEOneView.Appliance.ConnectionPermission]) + { + + "[{0}] Scope {1} is not a valid HPEOneview.Appliance.ScopeCollection resource." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_scope | Write-Verbose + + $ExceptionMessage = "Scope {0} is not a valid HPEOneview.Appliance.ScopeCollection resource." -f $_scope + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.ScopeResourceException ScopeResourceNotFound ObjectNotFound -TargetObject 'Name' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($_scope -is [HPEOneView.Appliance.ScopeCollection]) + { + + $_ScopeName = $_scope.Name + + } + + else + { + + $_ScopeName = $_scope.ScopeName + + } + + if (-not ($_ScopeQueryStringBuilder | Where-Object { $_ -match $_ScopeName }) -and $_ScopeName -ne 'AllResources') + { + + "[{0}] Adding Scope {1} to collection." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_ScopeName | Write-Verbose + + [void]$_ScopeQueryStringBuilder.add(("scope:'{0}'" -f $_ScopeName)) + + } + + } + + Return [String]::Join(' OR ', $_ScopeQueryStringBuilder.ToArray()) + + } + +} + +function Get-InitialScopeUris +{ + + [CmdletBinding ()] + Param + ( + + [Parameter (Mandatory = $false, Position = 0)] + [HPEOneView.Appliance.ScopeCollection[]]$Scopes, + + [Parameter (Mandatory, Position = 1)] + [ValidateSet ('Server', 'Networking', 'Storage')] + [String]$ResourceType, + + [Parameter (Mandatory, Position = 2)] + [Object]$Appliance + + ) + + Begin + { + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Debug + + } + + Process + { + + $_ScopeUriCol = [System.Collections.ArrayList]::new() + + if (-not $Scopes) + { + + $ScopePermissions = ($ConnectedSessions | Where-Object Name -eq $Appliance.Name).ActivePermissions | Where-Object RoleName -match $ResourceType + + ForEach ($_scopePermission in ($ScopePermissions | Where-Object ScopeName -ne 'AllResources')) + { + + Try + { + + $_scope = Get-OVScope -Name $_scopePermission.ScopeName + [void]$_ScopeUriCol.Add($_scope.Uri) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + ForEach ($_scope in $Scopes) + { + + [void]$_ScopeUriCol.Add($_scope.Uri) + + } + + } + + return $_ScopeUriCol + + } + + +} + +function ConvertFromEmbeddedJsonString +{ + + [CmdletBinding ()] + + Param + ( + + [String]$String + + ) + + $_pos1 = $String.IndexOf("{") + $_pos2 = $String.IndexOf("}") + + if ($_pos1 -ne -1) + { + + $_SubstringToReplace = $String.Substring($_pos1).SubString(0, ($_pos2 - $_pos1 + 1)) + + $_EmbeddedJson = $String.Substring($_pos1).SubString(0, ($_pos2 - $_pos1 + 1)).Replace('\', $null) | ConvertFrom-Json + + Return $String.Replace($_SubstringToReplace, ('"{0}"' -f $_EmbeddedJson.name)) + + } + + else + { + + Return $String + + } + +} + +function New-ErrorRecord +{ + + <# + .Synopsis + Creates an custom ErrorRecord that can be used to report a terminating or non-terminating error. + + .Description + Creates an custom ErrorRecord that can be used to report a terminating or non-terminating error. + + .Parameter Exception + The Exception that will be associated with the ErrorRecord. + + .Parameter ErrorID + A scripter-defined identifier of the error. This identifier must be a non-localized string for a specific error type. + + .Parameter ErrorCategory + An ErrorCategory enumeration that defines the category of the error. The supported Category Members are (from: http://msdn.microsoft.com/en-us/library/system.management.automation.errorcategory(v=vs.85).aspx) : + + * AuthenticationError - An error that occurs when the user cannot be authenticated by the service. This could mean that the credentials are invalid or that the authentication system is not functioning properly. + * CloseError - An error that occurs during closing. + * ConnectionError - An error that occurs when a network connection that the operation depEnds on cannot be established or maintained. + * DeadlockDetected - An error that occurs when a deadlock is detected. + * DeviceError - An error that occurs when a device reports an error. + * FromStdErr - An error that occurs when a non-Windows PowerShell command reports an error to its STDERR pipe. + * InvalidArgument - An error that occurs when an argument that is not valid is specified. + * InvalidData - An error that occurs when data that is not valid is specified. + * InvalidOperation - An error that occurs when an operation that is not valid is requested. + * InvalidResult - An error that occurs when a result that is not valid is returned. + * InvalidType - An error that occurs when a .NET Framework type that is not valid is specified. + * LimitsExceeded - An error that occurs when internal limits prevent the operation from being executed. + * MetadataError - An error that occurs when metadata contains an error. + * NotEnabled - An error that occurs when the operation attempts to use functionality that is currently disabled. + * NotImplemented - An error that occurs when a referenced application programming interface (API) is not implemented. + * NotInstalled - An error that occurs when an item is not installed. + * NotSpecified - An unspecified error. Use only when not enough is known about the error to assign it to another error category. Avoid using this category if you have any information about the error, even if that information is incomplete. + * ObjectNotFound - An error that occurs when an object cannot be found. + * OpenError - An error that occurs during opening. + * OperationStopped - An error that occurs when an operation has stopped. For example, the user interrupts the operation. + * OperationTimeout - An error that occurs when an operation has exceeded its timeout limit. + * ParserError - An error that occurs when a parser encounters an error. + * PermissionDenied - An error that occurs when an operation is not permitted. + * ProtocolError An error that occurs when the contract of a protocol is not being followed. This error should not happen with well-behaved components. + * QuotaExceeded An error that occurs when controls on the use of traffic or resources prevent the operation from being executed. + * ReadError An error that occurs during reading. + * ResourceBusy An error that occurs when a resource is busy. + * ResourceExists An error that occurs when a resource already exists. + * ResourceUnavailable An error that occurs when a resource is unavailable. + * SecurityError An error that occurs when a security violation occurs. This field is introduced in Windows PowerShell 2.0. + * SyntaxError An error that occurs when a command is syntactically incorrect. + * WriteError An error that occurs during writing. + + .Parameter TargetObject + The object that was being Processed when the error took place. + + .Parameter Message + Describes the Exception to the user. + + .Parameter InnerException + The Exception instance that caused the Exception association with the ErrorRecord. + .Parameter TargetType + To customize the TargetType value, specify the appropriate Target object type. Values can be "Array", "PSObject", "HashTable", etc. Can be provided by ${ParameterName}.GetType().Name. + + .Example + #> + + [CmdletBinding ()] + Param + ( + + [Parameter (Mandatory, Position = 0)] + [System.String]$Exception, + + [Parameter (Mandatory, Position = 1)] + [Alias ('ID')] + [System.String]$ErrorId, + + [Parameter (Mandatory, Position = 2)] + [Alias ('Category')] + [ValidateSet ('AuthenticationError','ConnectionError','NotSpecified', 'OpenError', 'CloseError', 'DeviceError', + 'DeadlockDetected', 'InvalidArgument', 'InvalidData', 'InvalidOperation', + 'InvalidResult', 'InvalidType', 'MetadataError', 'NotImplemented', + 'NotInstalled', 'ObjectNotFound', 'OperationStopped', 'OperationTimeout', + 'SyntaxError', 'ParserError', 'PermissionDenied', 'ResourceBusy', + 'ResourceExists', 'ResourceUnavailable', 'ReadError', 'WriteError', + 'FromStdErr', 'SecurityError')] + [System.Management.Automation.ErrorCategory]$ErrorCategory, + + [Parameter (Mandatory, Position = 3)] + [System.Object]$TargetObject, + + [Parameter (Mandatory)] + [System.String]$Message, + + [Parameter (Mandatory = $false)] + [System.Exception]$InnerException, + + [Parameter (Mandatory = $false)] + [System.String]$TargetType = "String" + + ) + + Process + { + + # ...build and save the new Exception depending on present arguments, if it... + $_exception = if ($Message -and $InnerException) { + # ...includes a custom message and an inner exception + New-Object $Exception $Message, $InnerException + } elseif ($Message) { + # ...includes a custom message only + New-Object $Exception $Message + } else { + # ...is just the exception full name + New-Object $Exception + } + + # now build and output the new ErrorRecord + "[{0}] Building ErrorRecord object" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $record = [Management.Automation.ErrorRecord]::new($_exception, $ErrorID, $ErrorCategory, $TargetObject) + + $record.CategoryInfo.TargetType = $TargetType + + Return $record + } + +} + +function Enable-OVMSDSC +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding ()] + + Param () + + Begin { } + + Process + { + + $RegKey = "HKCU:\Software\Hewlett-Packard\HPEOneView" + + if (-not(Test-Path $RegKey)) { New-Item -Path $RegKey -force | Write-Verbose } + + $UseMSDSC = [Bool](Get-ItemProperty -LiteralPath $RegKey -ea silentlycontinue).'UseMSDSC' + + if (-not($UseMSDSC)) { New-ItemProperty -Path $RegKey -Name UseMSDSC -Value 1 -Type DWORD | Write-Verbose } + + else { Set-ItemProperty -Path $RegKey -Name UseMSDSC -Value 1 -Type DWORD | Write-Verbose } + + } + + End { } + +} + +function Disable-OVMSDSC +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding ()] + + Param () + + Begin { } + + Process + { + + $RegKey = "HKCU:\Software\Hewlett-Packard\HPEOneView" + + if (-not(Test-Path $RegKey)) { New-Item -Path $RegKey -force | Write-Verbose } + + $UseMSDSC = [Bool](Get-ItemProperty -LiteralPath $RegKey -ea silentlycontinue).'UseMSDSC' + + if (-not($UseMSDSC)) { New-ItemProperty -Path $RegKey -Name UseMSDSC -Value 0 -Type DWORD | Write-Verbose } + + else { Set-ItemProperty -Path $RegKey -Name UseMSDSC -Value 0 -Type DWORD | Write-Verbose } + + } + + End { } + +} + +function RestClient +{ + + <# + + .SYNOPSIS + Internal Private Class for building a RestClient using [System.Net.WebRequest] + + .DESCRIPTION + This is a private, internal class/function to create a new [System.Net.WebRequest] object with pre-defined properties of the HttpWebReqeuest connection. This class will set the following attributes, which the caller can overload the values with their own after the resource has been created: + + Timeout = 20000 + ContentType = "application/json" + Accept = "application/json" + Headers.Item("X-API-Version") = $MaxXAPIVersion + Headers.Item("accept-language") = "en_US" + Headers.Item("accept-encoding") = "gzip, deflate" + Headers.Item("auth") = ${Global:ConnectedSessions}.sessionID NOTE: Only if the sessionID exists. + AutomaticDecompression = "GZip,Deflate,None" + + The URI of the WebRequest object will automatically include the connected (or requested if the first call is Connect-OVMgmt) appliance address or name ${Global:ConnectedSessions}. This value can be overloaded, but the Auth token that may be included as an HTTP header item could be invalid. + + .INPUTS + None. + + .OUTPUTS + New [System.Net.WebRequest] object. + + .Parameter URI + The URI of the request. Do not include the appaliance hostname or IP Address, only the cononical URI value (i.e. /rest/server-hardware). + + .Parameter Method + Optional. Provide the HTTP method for the request. The default value is 'GET'. Only the following values are allowed: + + GET + PUT + POST + DELETE + PATCH + + .Parameter Appliance + Provide the appliance hostname or FQDN. + + #> + + [CmdletBinding ()] + Param + ( + + [Parameter (Mandatory = $False, Position = 0)] + [ValidateScript({if ("GET","POST","DELETE","PATCH","PUT" -match $_) {$true} else { Throw "'$_' is not a valid Method. Only GET, POST, DELETE, PATCH, or PUT are allowed." }})] + [String]$method = "GET", + + [Parameter (Mandatory, Position = 1)] + [ValidateScript({if ($_.startswith('/')) {$true} else {throw "-URI must being with a '/' (eg. /rest/server-hardware) in its value. Please correct the value and try again."}})] + [String]$uri, + + [Parameter (Mandatory, Position = 2)] + [ValidateNotNullorEmpty()] + [String]$Appliance = $Null + + ) + + Begin + { + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Debug + + $url = 'https://{0}{1}' -f $Appliance, $uri + + "[{0}] Building new [System.Net.HttpWebRequest] object for {1} {2}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $method, $url | Write-Verbose + + } + + Process + { + + $RestClient = ([HPEOneView.Utilities.Net]::new()).RestClient($url, $Method, $MaxXAPIVersion) + + if ($ApplianceUpdateScheduleUri, $ApplianceAvailableUpdatesUri -contains $uri -and $Method -eq "PATCH") + { + + $RestClient.ContentType = "application/json" + + } + + } + + End + { + + Return $RestClient + + } + +} + +function RedactPassword +{ + + [CmdletBinding ()] + Param + ( + + [Hashtable]$BoundParameters + + ) + + $PropToRedact = @('password','passphrase','oldPassword','newPassword','currentPassword','newPassword','confirmPassword','passwords') + + $Caller = (Get-PSCallStack)[1].Command + + '[{0}] Redacting users Password from Verbose Output' -f $Caller | Write-Verbose + + $_Params = [hashtable]@{} + + ForEach ($Item in $BoundParameters.GetEnumerator()) + { + + if ($BoundParameters.($Item.Key) -is [PSCustomObject]) + { + + $_Params.Add($Item.Key,$BoundParameters.($Item.Key).PSObject.Copy()) + + } + + elseif ($BoundParameters.($Item.Key) -is [String] -or + $BoundParameters.($Item.Key) -is [Hashtable]) + { + + $_Params.Add($Item.Key,$Item.Value.Clone()) + + } + + else + { + + $_Params.Add($Item.Key,$Item.Value) + + } + + # Handle Level 1 + if (($_Params.psobject.properties | ? { $PropToRedact -contains $_.Name } ) -and $_Params.password -isnot [System.Security.SecureString]) + { + + $_Params.password = '[*****REDACTED******]' + + } + + # Handle Level 2 + if (($_Params[$Item.Key].psobject.properties | ? { $PropToRedact -contains $_.Name } ) -and $_Params[$Item.Key].password -isnot [System.Security.SecureString]) + { + + $_Params[$Item.Key].password = '[*****REDACTED******]' + + } + + + } + + Return "[{0}] Bound PS Parameters: {1}" -f $Caller, ($_Params | out-string) + +} + +function RedactJsonPassword +{ + + [CmdletBinding ()] + Param + ( + + [String]$String + + ) + + $Caller = (Get-PSCallStack)[1].Command + + '[{0}] Redacting users Password from Verbose Output' -f $Caller | Write-Verbose + + $ReplaceWithRedactedPassword = '"[*****REDACTED******]"' + + Return [RegEx]::Replace($String, $JsonPasswordRegEx, '$1 ' + $ReplaceWithRedactedPassword) + +} + +function Send-OVRequest +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding ()] + Param + ( + + [Parameter (Position = 0, Mandatory)] + [ValidateScript ({if ($_.StartsWith('/')) {$true} else {throw "-URI must being with a '/' (eg. /rest/server-hardware) in its value. Please correct the value and try again."}})] + [String]$uri, + + [Parameter (Position = 1, Mandatory = $false)] + [ValidateScript ({if ("GET","POST","DELETE","PATCH","PUT" -match $_) {$true} else { Throw "'$_' is not a valid Method. Only GET, POST, DELETE, PATCH, or PUT are allowed." }})] + [String]$method = "GET", + + [Parameter (Position = 2, Mandatory = $false)] + [ValidateNotNullorEmpty()] + [object]$body, + + [Parameter (Position = 3, Mandatory = $false)] + [ValidateNotNullorEmpty()] + [Int]$start = 0, + + [Parameter (Position = 4, Mandatory = $false)] + [ValidateNotNullorEmpty()] + [Int]$count = 0, + + [Parameter (Position = 5, Mandatory = $false)] + [ValidateNotNullorEmpty()] + [hashtable]$AddHeader, + + [Parameter (Position = 6, Mandatory = $false)] + [ValidateNotNullorEmpty()] + [String]$OverrideContentType, + + [Parameter (Position = 7, Mandatory = $false)] + [ValidateNotNullorEmpty()] + [Int]$OverrideTimeout, + + [Parameter (Mandatory = $false)] + [ValidateNotNullorEmpty()] + [Alias ('Appliance','ApplianceConnection')] + [Object]$Hostname = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + "[{0}] BEGIN" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Bound PS Parameters: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), ($PSBoundParameters | out-string) | Write-Verbose + + # Support getting the Appliance Connection Name from the object being passed within the body Param + if ($PSBoundParameters['body'] -and $body.ApplianceConnection -and (-not($Hostname)) -and ($body -isnot [System.Collections.IEnumerable])) + { + + "[{0}] Getting the Appliance Connection Name from the object being passed within the body Param" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $Hostname = $body.ApplianceConnection.Name + + } + + # Collection to return all responses from all specified appliance connections + $AllResponses = [System.Collections.ArrayList]::new() + + } + + Process + { + + $c = 1 + + if (-not($PSboundParameters['Hostname']) -and (-not([Bool]($Hostname | Measure-Object).count))) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoAuthSession ObjectNotFound 'Hostname' -Message "No appliance Hostname Parameter provided and no valid appliance session(s) found." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + ForEach ($ApplianceHost in $Hostname) + { + + "[{0}] Process" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + "[{0}] Hostname value: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), ($ApplianceHost | Out-String) | Write-Verbose + + # Clear last error response for the connection we are going to make. + if (${Global:ResponseErrorObject} | Where-Object Name -eq $ApplianceHost.Name) + { + + "[{0}] Prior Global Response Error Object for '{1}' found. Clearing." -f $MyInvocation.InvocationName.ToString().ToUpper(), $ApplianceHost.Name | Write-Verbose + + $_ResponseObject = (${Global:ResponseErrorObject} | Where-Object Name -eq $ApplianceHost.Name) + + [void]${Global:ResponseErrorObject}.Remove($_ResponseObject) + + } + + # If the value is String, we assume this is the Appliance Hostname, so look up the Connection details in ${Global:ConnectedSessions} + if ($ApplianceHost -is [String] -and (${Global:ConnectedSessions} | Where-Object Name -eq $ApplianceHost )) + { + + "[{0}] Filtering for Connection Object via String: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $ApplianceHost | Write-Verbose + + $ApplianceHost = ${Global:ConnectedSessions} | Where-Object Name -eq $ApplianceHost + + } + + elseif ($ApplianceHost -isnot [HPEOneView.Appliance.Connection] -and $ApplianceHost.Name) + { + + "[{0}] Filtering for Connection Object via PSObject: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), ($ApplianceHost | Out-String) | Write-Verbose + + if (${Global:ConnectedSessions} | Where-Object Name -eq $ApplianceHost.Name) + { + + $ApplianceHost = ${Global:ConnectedSessions} | Where-Object Name -eq $ApplianceHost.Name + + } + + } + + "[{0}] Processing '{1}' appliance connection request. {2} of {3}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $ApplianceHost.Name,$c,$Hostname.count | Write-Verbose + + # Need to check for authenticated session when the URI passed is not value of $UnAuthenticatedAllowedURIs + "[{0}] Requested URI '{1}' to '{2}'" -f $MyInvocation.InvocationName.ToString().ToUpper(), $uri, ($ApplianceHost.Name -join ',') | Write-Verbose + + if ($UnAuthenticatedAllowedURIs -contains $uri) + { + + "[{0}] We have reached the URI Whitelist condition block. Unauth request allowed for '{1}'." -f $MyInvocation.InvocationName.ToString().ToUpper(), $uri | Write-Verbose + + } + + # Else, require authentication + elseif (-not($ApplianceHost.SessionID)) + { + + $ExceptionMessage = "No valid session ID found for '{0}'. The call to '{1}' requires authentication. Please use Connect-OVMgmt to connect and authenticate to an appliance." -f $ApplianceHost.Name, $uri + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoAuthSession AuthenticationError 'Send-OVRequest' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + # Pagination handling: + $AllMembers = [System.Collections.ArrayList]::new() + + # See if the caller specified a count, either in the URI or as a Param + # (if so, we will let them handle pagination manually) + [Bool]$manualPaging = $false + + if ($uri.ToLower().Contains("count=") -or $uri.ToLower().Contains("count =")) + { + + $manualPaging = $true + + } + + elseif ($count -gt 0) + { + + $manualPaging = $true + + # Add start & count params to the URI + if (-not ($uri -contains "?")) + { + + $uri += "?" + + } + + $uri += ("start=" + $start + "&") + + $uri += ("count=" + $count) + + } + + elseif ($start -gt 0) + { + + # Start specified, but no count -- just set the start Param & auto-page from there on: + $manualPaging = $false + + if (-not ($uri -contains "?")) + { + + $uri += "?" + + } + + $uri += ("start=" + $start) + + } + + do + { + + $_TelemetryStopWatch = [system.diagnostics.stopwatch]::startNew() + + # Used to keep track of async task response + $taskReceived = $False + + $url = 'https://{0}{1}' -f $ApplianceHost.Name, $uri + + [System.Net.WebRequest]$req = ([HPEOneView.Utilities.Net]::new()).RestClient($url, $Method, $MaxXAPIVersion) + + if ($PSBoundParameters['OverrideContentType']) + { + + $req.ContentType = $PSBoundParameters['OverrideContentType'] + + } + + if ($PSBoundParameters['OverrideTimeout']) + { + + $req.Timeout = $OverrideTimeout + + } + + "[{0}] Restclient timeout setting: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $req.Timeout | Write-Verbose + + # Add Auth Session token if it exists + if ($ApplianceHost.SessionID -and $ApplianceHost.SessionID -ne 'TemporaryConnection') + { + + $req.Headers.Item("auth") = $ApplianceHost.SessionID + + } + + # Handle additional headers being passed in for updated API (storage volume removal) + # Variable defined as a hashtable in case other API pass more than one additional header + if($PSBoundParameters['AddHeader']) + { + + ForEach ($_header in $AddHeader.GetEnumerator()) + { + + # "[{0}] Overloading '{1}' in HttpWebRequest object to: {2}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_header.Key, $_header.Value | Write-Verbose + + if ($_header.Key -eq 'If-Match') + { + + [void]$req.Headers.Add("If-Match", "*") + + $DateTimeRef = [DateTime]::Now + + if ([DateTime]::TryParse($_header.Value, [ref]$DateTimeRef) -and $_header.Value -is [DateTime]) + { + + $_CorrectedEtag = $_header.Value.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ss.fffZ") + + $req.Headers.Item($_header.Key) = $_CorrectedEtag + + "[{0}] (DELETE) ETag was converted to [DateTime] object by PowerShell. Changing back to string value: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_CorrectedEtag | Write-Verbose + + } + + } + + else + { + + if ("Password", "Pasphrase" -contains $_header.Key) + { + + "[{0}] Overloading '{1}' in HttpWebRequest object to: {2}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_header.Key, "******REDACTED******" | Write-Verbose + + } + + else + { + + "[{0}] Overloading '{1}' in HttpWebRequest object to: {2}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_header.Key, $_header.Value | Write-Verbose + + } + + $req.Headers.Item($_header.Key) = [String]$_header.Value + + } + + } + + } + + # Adding due to X-API-Version 500 requirement to pass If-Match header for DELETE requests. + if ($Method -eq 'DELETE' -and -not $req.Headers.Item('If-Match') -and $Uri -ne $ApplianceLoginSessionsUri) + { + + Throw ([Exception]::new("The Method requested was DELETE but the required 'If-Match' HTTP header is not found.")) + + } + + # Remove If-Match for removing users and groups + if ($Method -eq 'DELETE' -and ($ApplianceUserAccountsUri, $AuthnEgroupRoleMappingUri | % { $Uri.contains($_)}) -contains $True) + { + + $req.Headers.Remove('If-Match') + + } + + # $Body will contain the certificate object + if ($Uri -contains $ApplianceLoginSessionsSmartCardAuthUri -and $Method -eq 'POST') + { + + "[{0}] Initiating SmartCard auth. Adding client certificate to request object." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + [void]$req.ClientCertificates.Add($Body[0]) + $req.UseDefaultCredentials = $true + + } + + # Send the request with a messege + elseif ($body) + { + + "[{0}] Body object found. Converting to JSON." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (('PUT','PATCH' -contains $method) -and $null -eq $req.Headers.Item('If-Match') -and $null -ne $Body.eTag) + { + + $_ETag = $body.eTag + + if ($_ETag -is [DateTime]) + { + + "[{0}] (BODY1) ETag was converted to [DateTime] object by PowerShell. Changing back to string value." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $DateTimeRef = [DateTime]::Now + + if ([DateTime]::TryParse($_ETag, [ref]$DateTimeRef) -and $_ETag -is [DateTime]) + { + + $req.Headers.Item("If-match") = $_ETag.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ss.fffZ") + + "[{0}] (BODY2) ETag was converted to [DateTime] object by PowerShell. Changing back to string value: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $req.Headers.Item($_header.Key) | Write-Verbose + + } + + } + + else + { + + $req.Headers.Item("If-match") = $_Etag + + + } + + "[{0}] HTTP Method is {1} and eTag value found {2}. Setting 'If-Match' HTTP Header." -f $MyInvocation.InvocationName.ToString().ToUpper(), $Method, $_Etag | Write-Verbose + + } + + # Remove any found ApplianceConnection property(ies) to not generate REST API Error + if ('PUT', 'PATCH', 'POST' -contains $method -and $body -isnot [System.String]) + { + + "[{0}] HTTP Method is $method. Removing 'ApplianceConnection' NoteProperty from object(s)." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $body = Remove-ApplianceConnection $body + + } + + if ($method -eq "PATCH" -and ($body -isnot [Array])) + { + + "[{0}] Patch Request and body is not an Array." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + [Array]$body = @($body) + + } + + # Create a new stream writer to write the json to the request stream. + if ($body -isnot [String]) + { + + $js = ConvertTo-Json $body -Depth 99 -Compress + + } + + else + { + + $js = $body + + } + + # Needed to remove \r character that ConvertTo-JSON adds which /rest/logindirectories does not support for the directory server SSL certificate + if ([RegEx]::Match($body.type, "LoginDomainConfig*Dto", $RegExInsensitiveFlag).Success) + { + + $js = $js -replace "\\r",$null + + } + + $RedactedString = RedactJsonPassword -String $js + + # Need to redact passwords here + "[{0}] Request Body: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $RedactedString | Write-Verbose + + # Send the messege + try + { + + $stream = [IO.StreamWriter]::new($req.GetRequestStream()) + + $stream.AutoFlush = $True + $stream.WriteLine($js) + [void]$stream.Flush() + + } + + catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + finally + { + + $stream.Close() + + if ($stream -is [System.IDisposable]) + { + + $stream.Dispose() + + } + + } + + } + + "[{0}] Request: {1} https://{2}{3}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $req.Method, $ApplianceHost.Name, $Uri | Write-Verbose + + # Write Verbose the headers if needed + $i = 0 + + foreach ($h in $req.Headers) + { + + # Remove Auth Token info from Headers + if ($h -eq 'auth') + { + + "[{0}] Request Header {1}: {2} = [*****REDACTED******]" -f $MyInvocation.InvocationName.ToString().ToUpper(), ($i+1), $h | Write-Verbose + + } + + else + { + + "[{0}] Request Header {1}: {2} = {3}" -f $MyInvocation.InvocationName.ToString().ToUpper(), ($i+1), $h, $req.Headers[$i] | Write-Verbose + + } + + $i++ + + } + + try + { + + # Get response from appliance + [System.Net.WebResponse]$LastWebResponse = $req.GetResponse() + + $_TelemetryStopWatch.Stop() + + "[{0}] Response time: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_TelemetryStopWatch.Elapsed.ToString() | Write-Verbose + + # Display the response status if verbose output is requested + "[{0}] Response Status: {1} ({2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), [Int]$LastWebResponse.StatusCode, [String]$LastWebResponse.StatusDescription | Write-Verbose + + $i = 0 + + foreach ($h in $LastWebResponse.Headers) + { + + "[{0}] Response Header {1}: {2} = {3}" -f $MyInvocation.InvocationName.ToString().ToUpper(), ($i+1), $h, $LastWebResponse.Headers[$i] | Write-Verbose + + $i++ + + } + + # Read the response + $reader = [IO.StreamReader]::new($LastWebResponse.GetResponseStream()) + + $FinalResponse = $reader.ReadToEnd() + + $reader.close() + + "[{0}] FinalResponse: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $FinalResponse | Write-Verbose + + $DuplicateFound = $true + + While ($DuplicateFound) + { + + try + { + + $resp = ConvertFrom-JSON -InputObject $FinalResponse + + # If a duplicate was NOT found causing an exception, then this flag would be set to false, and woudl then allow us to exit the While loop + $DuplicateFound = $False + + } + + catch + { + + "[{0}] ConvertToJson exception caught." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $FoundMatches = $null + + if ($_.FullyQualifiedErrorId -match "KeysWithDifferentCasingInJsonString" -or $_.FullyQualifiedErrorId -match "DuplicateKeysInJsonString") + { + + "[{0}] DuplciateKey exception was thrown." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $FoundMatches = [RegEx]::Matches($_.Exception.Message, $DuplicateFWBaselineTermsRegEx) + + if ($FoundMatches.Success) + { + + $c = 1 + + ForEach ($match in $FoundMatches) + { + + "[{0}] DuplciateKey '{1}' replaced with '{2}'." -f $MyInvocation.InvocationName.ToString().ToUpper(), $match.Groups["term"].Value, ($match.Groups["term"].Value + "-$c") | Write-Verbose + + $FinalResponse = [RegEx]::Replace($FinalResponse, $match.Groups["term"].Value, ("${term}-" + $c)) + + $c++ + + } + + } + + else + { + + "[{0}] Unable to identify DuplciateKey within exception. Original exception will be thrown." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + else + { + + # Other ConvertFromJson exception is generated. Throwing original exception back to caller. + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + if ($resp -is [String]) + { + + "[{0}] Response: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $resp | Write-Verbose + + } + + elseif ($resp -is [Boolean]) + { + + "[{0}] Bool Response: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), [Bool]$resp | Write-Verbose + + } + + else + { + + if ($resp -is [PSCustomObject]) + { + + if ([RegEx]::Match($resp.PSobject.Properties.name, "sessionId", $RegExInsensitiveFlag).Success) + { + + $_resp = $resp.PSObject.Copy() + + $_resp.sessionId = '[*****REDACTED******]' + + "[{0}] Response: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), ($_resp | Format-List * -force | out-string) | Write-Verbose + + } + + } + + else + { + + "[{0}] Response: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), ($resp | Format-List * -force | out-string) | Write-Verbose + + } + + } + + "[{0}] Manual Pagination: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $ManualPaging | Write-Verbose + + # If Asyncronous (HTTP status=202), make sure we return a Task object: + if ([Int]$LastWebResponse.StatusCode -eq 202 -and ($LastWebResponse.Headers.Item('X-Task-URI') -or $LastWebResponse.Headers.Item('Location'))) + { + + "[{0}] Async Task (HTTP 202) received"-f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + # Asynchronous operation -- in some cases we get the Task object returned in the body. + # In other cases, we only get the Task URI in the Location header. + # In either case, return a Task object with as much information as we know + if ($LastWebResponse.Headers.Item('X-Task-URI')) + { + + [String]$TaskUri = $LastWebResponse.Headers.Item('X-Task-URI') + + } + + elseif ($LastWebResponse.Headers.Item('Location')) + { + + [String]$TaskUri = $LastWebResponse.Headers.Item('Location') + + } + + if ($TaskUri) + { + + "[{0}] Async Task URI: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $TaskUri | Write-Verbose + + # First, make sure the task URI is relative: + $pos = $TaskUri.IndexOf($TasksUri) + + if ($pos -gt 0) + { + + $TaskUri = $taskUri.SubString($pos) + + } + + Try + { + + $resp = Send-OVRequest -uri $TaskUri -method GET -appliance $ApplianceHost.Name + + "[{0}] Adding 'HPEOneview.Appliance.TaskResource' to PSObject TypeNames for task object" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $resp | ForEach-Object { $_.PSObject.TypeNames.Insert(0,'HPEOneview.Appliance.TaskResource') } + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + elseif ([Int]$LastWebResponse.StatusCode -eq 202) + { + + "[{0}] Return is not an Async task, but HTTP 202 was returned. Labels?" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if ($Method -eq 'DELETE' -and $null -eq $resp) + { + + "[{0}] Returning custom delete successful message." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $resp = [PSCustomObject]@{StatusCode = [Int]$LastWebResponse.StatusCode; Message = "Resource deleted successfully." } + + } + + } + + # Handle Task Objects that have been directly accessed via task URI and not created async tasks (HTTP 202) + if (([Int]$LastWebResponse.StatusCode -eq 200 -or [Int]$LastWebResponse.StatusCode -eq 202) -and ($resp.category -eq $ResourceCategoryEnum.Task) -and (-not([RegEx]::Match($resp.PSObject.TypeNames, "HPEOneview.Appliance.TaskResource", $RegExInsensitiveFlag).Success))) + { + + $resp | ForEach-Object { $_.PSObject.TypeNames.Insert(0,'HPEOneview.Appliance.TaskResource') } + + } + + # User Logoff success message + if (([Int]$LastWebResponse.StatusCode -eq 204) -and ($uri -eq $ApplianceLoginSessionsUri)) + { + + $resp = [PSCustomObject]@{ Message = "User logoff successful." } + + } + + elseif (([Int]$LastWebResponse.StatusCode -eq 204 -or [Int]$LastWebResponse.StatusCode -eq 200) -and $method -eq "DELETE") + { + + $resp = [PSCustomObject]@{StatusCode = [Int]$LastWebResponse.StatusCode; Message = "Resource deleted successfully." } + + } + + # Handle multi-page result sets + if ([Bool]($resp | Get-Member -Name members -ErrorAction SilentlyContinue) -and (-not($manualPaging))) + { + + "[{0}] Response members and automatic pagination" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $resp.members | ForEach-Object { + + Add-Member -InputObject $_ -NotePropertyName ApplianceConnection -NotePropertyValue ([HPEOneView.Library.ApplianceConnection]::new($ApplianceHost.Name, $ApplianceHost.ConnectionId)) -Force + + [void]$AllMembers.Add($_) + + } + + "[{0}] total stored '$($AllMembers.count)'" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + "[{0}] nextPageURI: '$($resp.nextPageUri)'" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if ($resp.nextPageUri) + { + + "[{0}] Pagination has occurred. Received $($resp.count) resources of $($resp.total)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $uri = $resp.nextPageUri + + } + + else + { + + "[{0}] Reached End of pagination. Building AllResults" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_AllResults = [PsCustomObject]@{ + + members = $AllMembers; + count = $AllMembers.Count; + total = $AllMembers.Count; + category = $resp.category; + eTag = $resp.eTag; + nextPageUri = $resp.nextPageUri; + start = $resp.start; + prevPageUri = $resp.prevPageUri; + created = $resp.created; + modified = $resp.modified; + uri = $resp.uri + + } + + [void]$AllResponses.Add($_AllResults) + + } + + } + + elseif ($resp.members -and $manualPaging ) + { + + "[{0}] Response members and manual paging" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $resp.members | ForEach-Object { + + Add-Member -InputObject $_ -NotePropertyName ApplianceConnection -NotePropertyValue ([HPEOneView.Library.ApplianceConnection]::new($ApplianceHost.Name, $ApplianceHost.ConnectionId)) -Force + + } + + [void]$AllResponses.Add($resp) + + } + + elseif ($resp) + { + + "[{0}] Response object, no paging needed." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Add-Member -InputObject $resp -NotePropertyName ApplianceConnection -NotePropertyValue ([HPEOneView.Library.ApplianceConnection]::new($ApplianceHost.Name, $ApplianceHost.ConnectionId)) -Force + + [void]$AllResponses.Add($resp) + + } + + } + + catch [System.Net.WebException] + { + + "[{0}] Net.WebException Error caught" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + "[{0}] Exception Object: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), ($_ | Format-List * -force | Out-String) | Write-Verbose + + "[{0}] Exception Message: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_.Exception.Message | Write-Verbose + + "[{0}] InnerException FullyQualifiedErrorId: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_.Exception.InnerException.FullyQualifiedErrorId | Write-Verbose + + "[{0}] InnerException Message: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_.Exception.InnerException.Message | Write-Verbose + + # Set Global Response Error Object + if (-not(${Global:ResponseErrorObject} | Where-Object Name -eq $ApplianceHost.Name)) + { + + $_NewResponseErrorObject = [PSCustomObject]@{ + + Name = $ApplianceHost.Name + Exception = $_ + LastWebResponse = $LastWebResponse + ErrorResponse = $ErrorResponse + + } + + [void]${Global:ResponseErrorObject}.Add($_NewResponseErrorObject) + + } + + else + { + + (${Global:ResponseErrorObject} | Where-Object Name -eq $ApplianceHost.Name).LastWebResponse = $LastWebResponse + (${Global:ResponseErrorObject} | Where-Object Name -eq $ApplianceHost.Name).ErrorResponse = $ErrorResponse + (${Global:ResponseErrorObject} | Where-Object Name -eq $ApplianceHost.Name).Exception = $_ + + } + + if ($_.Exception.InnerException.InnerException.FullyQualifiedErrorId -eq "ApplianceTransportException") + { + + "[{0}] Caught ApplianceTransportException exception." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if ([regex]::Match($_.Exception.InnerException.InnerException.Message, "The certificate is not trusted due to these X509CertChain flags").Success) + { + + Write-Host "CertChain message caught." + $ExceptionMessage = "Unable to connect to '{0}' appliance. {1}" -f $ApplianceHost.Name, $_.Exception.InnerException.InnerException.Message + + } + + else + { + + $ExceptionMessage = "Unable to connect to '{0}' appliance. {1}" -f $ApplianceHost.Name, $_.Exception.InnerException.Message + + } + + $ErrorRecord = New-ErrorRecord HPEOneView.Library.ApplianceTransportException HostnameAndCertDoNotMatch ResourceUnavailable 'Hostname' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ([RegEx]::Match($_.Exception.InnerException, "System.Net.WebException: Unable to connect to the remote server", $RegExInsensitiveFlag).Success) + { + + $ExceptionMessage = "Unable to connect to '{0}' due to timeout." -f $ApplianceHost.Name + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.NetworkConnectionException ApplianceNotResponding ResourceUnavailable 'Hostname' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ([RegEx]::Match($_.Exception.Message, 'The remote name could not be resolved', $RegExInsensitiveFlag).Success) + { + + $ExceptionMessage = "Unable to connect to the appliance. {0}" -f $_.Exception.Message + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.NetworkConnectionException RemoteNameLookupFailure ObjectNotFound 'Hostname' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + if ($_.Exception.InnerException) + { + + if ($_.Exception.InnerException.Response) + { + + "[{0}] InnerException" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $LastWebResponse = $_.Exception.InnerException.Response + + } + + else + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + else + { + + if ($_.Exception.Response) + { + + "[{0}] Exception" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $LastWebResponse = $_.Exception.Response + + } + + else + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + if ($LastWebResponse) + { + + Try + { + + "[{0}] Getting Error Response" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $reader = [IO.StreamReader]::new($LastWebResponse.GetResponseStream()) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $_JsonErrorResponse = $reader.ReadToEnd() + + "[{0}] ERROR RESPONSE: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_JsonErrorResponse | Write-Verbose + + $ErrorResponse = ConvertFrom-JSON -InputObject $_JsonErrorResponse + + $reader.Close() + + # "[{0}] ERROR RESPONSE: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_JsonErrorResponse | Write-Verbose + + # Set Global Response Error Object + if (-not(${Global:ResponseErrorObject} | Where-Object Name -eq $ApplianceHost.Name)) + { + + $_NewResponseErrorObject = [PSCustomObject]@{ + + Name = $ApplianceHost.Name + LastWebResponse = $LastWebResponse + ErrorResponse = $ErrorResponse + + } + + [void]${Global:ResponseErrorObject}.Add($_NewResponseErrorObject) + + } + + else + { + + (${Global:ResponseErrorObject} | Where-Object Name -eq $ApplianceHost.Name).LastWebResponse = $LastWebResponse + (${Global:ResponseErrorObject} | Where-Object Name -eq $ApplianceHost.Name).ErrorResponse = $ErrorResponse + + } + + "[{0}] Response Status: HTTP $([Int](${Global:ResponseErrorObject} | ? Name -eq $ApplianceHost.Name).LastWebResponse.StatusCode) [$((${Global:ResponseErrorObject} | ? Name -eq $ApplianceHost.Name).LastWebResponse.StatusDescription)]" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + foreach ($h in (${Global:ResponseErrorObject} | Where-Object Name -eq $ApplianceHost.Name).LastWebResponse.Headers) + { + + "[{0}] Response Header: $($h) = $((${Global:ResponseErrorObject} | ? Name -eq $ApplianceHost.Name).LastWebResponse.Headers[$i])" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $i++ + + } + + switch ([Int](${Global:ResponseErrorObject} | Where-Object Name -eq $ApplianceHost.Name).LastWebResponse.StatusCode) + { + + # HTTP 400 errors + 400 + { + + "[{0}] HTTP 400 error caught." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if ([System.String]::IsNullOrWhiteSpace(($Global:ResponseErrorObject | Where-Object Name -eq $ApplianceHost.Name).ErrorResponse.details)) + { + + $_Message = "{0} {1} " -f ($Global:ResponseErrorObject | Where-Object Name -eq $ApplianceHost.Name).ErrorResponse.message, ([String]::Join(' ',($global:ResponseErrorObject | Where-Object Name -eq $ApplianceHost.Name).ErrorResponse.recommendedActions)).trim() + + } + + else + { + + $_Message = "{0} {1} " -f ($Global:ResponseErrorObject | Where-Object Name -eq $ApplianceHost.Name).ErrorResponse.details, ([String]::Join(' ',($global:ResponseErrorObject | Where-Object Name -eq $ApplianceHost.Name).ErrorResponse.recommendedActions)).trim() + + } + + switch ((${Global:ResponseErrorObject} | Where-Object Name -eq $ApplianceHost.Name).ErrorResponse.errorCode) + { + + 'DEVICE_NOT_ELIGIBLE' + { + + $ExceptionMessage = "The device is not eligible." + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.RemoteSupportResourceException DeviceNotEligible InvalidOperation "Server" -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + # Hande initial authentication errors + {"AUTHN_AUTH_DIR_FAIL","AUTHN_AUTH_FAIL" -contains $_} + { + + "[{0}] Authentication Directory failure. Likely bad username and/or password from auth dir." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $ConnectedSessions.RemoveConnection($ApplianceHost) + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException InvalidUsernameOrPassword AuthenticationError "Appliance:$($ApplianceHost.Name)" -Message $_Message + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + # Handle invalid user session + "AUTHN_LOGOUT_FAILED" + { + + "[{0}] User session no longer valid, likely due to session timeout. Clearing library runtime global and script variables." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $ConnectedSessions.RemoveConnection($ApplianceHost) + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException InvalidUserSession AuthenticationError "Appliance:$($ApplianceHost.Name)" -Message $_Message + Throw $ErrorRecord + + } + + # Handle user not acknowledging login message + "AUTHN_LOGIN_MESSAGE_ACKNOWLEDGMENT_REQUIRED" + { + + "[{0}] User needed to accept the Login Message." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException LoginMessageAcknowledgementRequired AuthenticationError "Appliance:$($ApplianceHost.Name)" -Message $_Message + Throw $ErrorRecord + + } + + # Valid user, but does not belong to a group that has an assigned role + 'AUTHN_AUTH_FAIL_NO_ROLES' + { + + $ConnectedSessions.RemoveConnection($ApplianceHost) + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoDirectoryRoleMapping AuthenticationError "Appliance:$($ApplianceHost.Name)" -Message $_Message + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + # Valid User, but no directory group have been added + 'AUTHN_LOGINDOMAIN_NO_MEMBER_GROUPS_FOUND' + { + + $ConnectedSessions.RemoveConnection($ApplianceHost) + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoDirectoryRoleMapping AuthenticationError "Appliance:$($ApplianceHost.Name)" -Message $_Message + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + default + { + + if ((${Global:ResponseErrorObject} | Where-Object Name -eq $ApplianceHost.Name).ErrorResponse.errorSource) + { + + $source = (${Global:ResponseErrorObject} | Where-Object Name -eq $ApplianceHost.Name).ErrorResponse.errorSource + + } + + else + { + + $source = 'Send-OVRequest' + + } + + $ErrorRecord = New-ErrorRecord InvalidOperationException (${Global:ResponseErrorObject} | Where-Object Name -eq $ApplianceHost.Name).ErrorResponse.errorCode InvalidOperation $source -Message $_Message + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + } + + # User is unauthorized + 401 + { + + "[{0}] HTTP 401 error caught." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if ((${Global:ResponseErrorObject} | Where-Object Name -eq $ApplianceHost.Name).ErrorResponse.details -cmatch "User not authorized for this operation" -or (${Global:ResponseErrorObject} | Where-Object Name -eq $ApplianceHost.Name).ErrorResponse.message -cmatch "insufficient privilege for operation") + { + + "[{0}] $((${Global:ResponseErrorObject} | ? Name -eq $ApplianceHost.Name).ErrorResponse.message) Request was '$method' at '$uri'." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthPrivilegeException InsufficientPrivilege AuthenticationError 'Send-OVRequest' -Message ("[Send-OVRequest]: {0}. Request was '{1}' at '{2}'. " -f (${Global:ResponseErrorObject} | Where-Object Name -eq $ApplianceHost.Name).ErrorResponse.message, $method, $uri ) + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ((${Global:ResponseErrorObject} | Where-Object Name -eq $ApplianceHost.Name).ErrorResponse.errorCode -eq "INSUFFICIENT_PRIVILEGES") + { + + "[{0}] $((${Global:ResponseErrorObject} | ? Name -eq $ApplianceHost.Name).ErrorResponse.message) Request was '$method' at '$uri'." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthPrivilegeException InsufficientPrivilege AuthenticationError 'Send-OVRequest' -Message ("[Send-OVRequest]: {0}. Request was '{1}' at '{2}'. " -f (${Global:ResponseErrorObject} | Where-Object Name -eq $ApplianceHost.Name).ErrorResponse.message, $method, $uri ) + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ((${Global:ResponseErrorObject} | Where-Object Name -eq $ApplianceHost.Name).ErrorResponse.errorCode -eq "INVALID_REPOSITORY_CREDENTIALS") + { + + "[{0}] $((${Global:ResponseErrorObject} | ? Name -eq $ApplianceHost.Name).ErrorResponse.message) Request was '$method' at '$uri'." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthPrivilegeException ExternalRepositoryCredentials AuthenticationError $Caller -Message ("{0}" -f (${Global:ResponseErrorObject} | Where-Object Name -eq $ApplianceHost.Name).ErrorResponse.message) + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ((${Global:ResponseErrorObject} | Where-Object Name -eq $ApplianceHost.Name).ErrorResponse.errorCode -eq "AlertAuthorizationException") + { + + "[{0}] $((${Global:ResponseErrorObject} | ? Name -eq $ApplianceHost.Name).ErrorResponse.message) Request was '$method' at '$uri'." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthPrivilegeException AlertAuthorizationException AuthenticationError 'Send-OVRequest' -Message ("[Send-OVRequest]: {0}. Request was '{1}' at '{2}'. " -f (${Global:ResponseErrorObject} | Where-Object Name -eq $ApplianceHost.Name).ErrorResponse.message, $method, $uri ) + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + else + { + + $ConnectedSessions.RemoveConnection($ApplianceHost) + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException InvalidOrTimedoutSession AuthenticationError 'Send-OVRequest' -Message "[Send-OVRequest]: Your session has timed out or is not valid. Please use Connect-OVMgmt to authenticate to your appliance." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + 403 + { + + $resp = $Null + + if ((${Global:ResponseErrorObject} | Where-Object Name -eq $ApplianceHost.Name).ErrorResponse.errorCode -eq "PASSWORD_CHANGE_REQUIRED") + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.PasswordChangeRequired PasswordExpired PermissionDenied "URI" -Message ((${Global:ResponseErrorObject} | Where-Object Name -eq $ApplianceHost.Name).ErrorResponse.message + " " + (${Global:ResponseErrorObject} | Where-Object Name -eq $ApplianceHost.Name).ErrorResponse.recommendedActions) + + } + + else + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.ResourcePrivledgeException ResourcePrivledge PermissionDenied "URI" -Message ((${Global:ResponseErrorObject} | Where-Object Name -eq $ApplianceHost.Name).ErrorResponse.message + " " + (${Global:ResponseErrorObject} | Where-Object Name -eq $ApplianceHost.Name).ErrorResponse.recommendedActions) + + } + + Throw $ErrorRecord + + } + + 404 + { + + if ((${Global:ResponseErrorObject} | Where-Object Name -eq $ApplianceHost.Name).ErrorResponse.errorCode -eq 'CHANNEL_PARTNER_VALIDATION_FAILED') + { + + $_ExceptionMessage = (${Global:ResponseErrorObject} | Where-Object Name -eq $ApplianceHost.Name).ErrorResponse.message + $ErrorRecord = New-ErrorRecord HPEOneView.ResourceNotFoundException ChannelPartnerNotFound ObjectNotFound 'ID' -Message $_ExceptionMessage + + } + + else + { + + $ErrorRecord = New-ErrorRecord HPEOneView.ResourceNotFoundException ResourceNotFound ObjectNotFound "URI" -Message ("The requested resource '$uri' could not be found. " + (${Global:ResponseErrorObject} | Where-Object Name -eq $ApplianceHost.Name).ErrorResponse.recommendedActions) + + } + + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + 405 + { + + $ExceptionMessage = "{0} {1}" -f (${Global:ResponseErrorObject} | Where-Object Name -eq $ApplianceHost.Name).ErrorResponse.message, [String]::Join(" ", (${Global:ResponseErrorObject} | Where-Object Name -eq $ApplianceHost.Name).ErrorResponse.recommendedActions) + $ExceptionErrorID = (${Global:ResponseErrorObject} | Where-Object Name -eq $ApplianceHost.Name).ErrorResponse.errorCode + $ErrorRecord = New-ErrorRecord InvalidOperationException $ExceptionErrorID InvalidOperation "$($Method):$($uri)" -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + { @(409, 412) -contains $_ } + { + + if ((${Global:ResponseErrorObject} | Where-Object Name -eq $ApplianceHost.Name).ErrorResponse.errorCode -eq 'AUTHN_LOGIN_TWO_FACTOR_AUTHENTICATION_DISABLED') + { + + $_ExceptionMessage = 'Two-factor authentication is disabled on this appliance. Enable two-factor authentication using the Set-OVApplianceTwoFactorAuthentication Cmdlet, or in the security settings page (settings->security->edit).' + $ErrorRecord = New-ErrorRecord HPEOneView.Library.UnsupportedArgumentException Invalid2FactorAuthenticationStatus ObjectNotFound 'Certificate' -Message $_ExceptionMessage + + } + + else + { + + $ErrorRecord = New-ErrorRecord InvalidOperationException $(${Global:ResponseErrorObject} | Where-Object Name -eq $ApplianceHost.Name).ErrorResponse.errorCode InvalidOperation 'Send-OVRequest' -Message ("[Send-OVRequest]: $((${Global:ResponseErrorObject} | ? Name -eq $ApplianceHost.Name).ErrorResponse.message) $((${Global:ResponseErrorObject} | ? Name -eq $ApplianceHost.Name).ErrorResponse.recommendedActions)") + + } + + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + 500 + { + + if ((${Global:ResponseErrorObject} | Where-Object Name -eq $ApplianceHost.Name).ErrorResponse.details) + { + + $message = (${Global:ResponseErrorObject} | Where-Object Name -eq $ApplianceHost.Name).ErrorResponse.details + + } + + else + { + + $message = (${Global:ResponseErrorObject} | Where-Object Name -eq $ApplianceHost.Name).ErrorResponse.message + + } + + if (-not($message.SubString($message.length - 1) -eq ".")) { $message += "." } + + $ErrorRecord = New-ErrorRecord InvalidOperationException $(${Global:ResponseErrorObject} | Where-Object Name -eq $ApplianceHost.Name).ErrorResponse.errorCode InvalidOperation 'Send-OVRequest' -Message ("[Send-OVRequest]: $message $((${Global:ResponseErrorObject} | ? Name -eq $ApplianceHost.Name).ErrorResponse.recommendedActions)") #-InnerException $global:ResponseErrorObject + Throw $ErrorRecord + + } + + # Wait for appliance startup here by calling Wait-OVApplianceStart + { @(503, 0) -contains $_ } + { + + "[{0}] HTTP $([Int]$LastWebResponse.StatusCode) error caught." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + "[{0}] Calling Wait-OVApplianceStart" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + Wait-OVApplianceStart -Appliance $ApplianceHost.Name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + + # Appliance startup should have finished. + "[{0}] Returning caller back to: $($method.ToUpper()) $uri" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if ($addHeader) + { + + return (Send-OVRequest -uri $uri -method $method -Body $body -addHeader $addHeader -Hostname $ApplianceHost.Name) + + } + + elseif ($body) + { + + return (Send-OVRequest -uri $uri -method $method -Body $body -Hostname $ApplianceHost.Name) + + } + + else + { + + return (Send-OVRequest -uri $uri -method $method -Hostname $ApplianceHost.Name) + + } + + } + + 501 + { + + $ErrorRecord = New-ErrorRecord InvalidOperationException (${Global:ResponseErrorObject} | Where-Object Name -eq $ApplianceHost.Name).ErrorResponse.errorCode SyntaxError 'Send-OVRequest' -Message ("[Send-OVRequest]: " + (${Global:ResponseErrorObject} | Where-Object Name -eq $ApplianceHost.Name).ErrorResponse.message + " " + (${Global:ResponseErrorObject} | Where-Object Name -eq $ApplianceHost.Name).ErrorResponse.recommendedActions) -InnerException (${Global:ResponseErrorObject} | Where-Object Name -eq $ApplianceHost.Name).ErrorResponse.details + Throw $ErrorRecord + + } + + } + + } + + else + { + + "[{0}] No Exception Response Object to return." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + return $null + + } + + } + + finally + { + + "[{0}] Cleaning up HttpWebRequest" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if ($reader) { $reader.Close() } + + if ($LastWebResponse) + { + + $LastWebResponse.Close() + + if ($LastWebResponse -is [System.IDisposable]) + { + + $LastWebResponse.Dispose() + + } + + } + + if ($req) + { + + if ($req -is [System.IDisposable]) + { + + $req.Dispose() + + } + + } + + $req = $null + + } + + "[{0}] Does nextPageUri member exist: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), [Bool]($resp | Get-Member -Name nextPageUri -ErrorAction SilentlyContinue) | Write-Verbose + "[{0}] Is nextPageUri Null or Empty: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), [String]::IsNullOrEmpty($resp.nextPageUri) | Write-Verbose + + $_Stop = $False + + # Always stop if manual paging + if ($ManualPaging) + { + + '[{0}] Stopping Do/Until loop because of manual paging' -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_Stop = $True + + } + + # If not manual paging and nextPageUri doesn't exist, stop + elseif (-not($ManualPaging) -and -not([Bool]($resp | Get-Member -Name nextPageUri -ErrorAction SilentlyContinue))) + { + + "[{0}] Stopping Do/Until loop because nextPageUri doesn't exist and have received all objects." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_Stop = $True + + } + + # If not manual paging, nextPageUri exists and it is null or empty + elseif (-not($ManualPaging) -and ([Bool]($resp | Get-Member -Name nextPageUri -ErrorAction SilentlyContinue)) -and [String]::IsNullOrEmpty($resp.nextPageUri)) + { + + "[{0}] Stopping Do/Until loop because nextPageUri is null/empty and have received all objects." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_Stop = $True + + } + + } until ($_Stop) + + $c++ + + } # Continue with next appliance + + } + + End + { + + "[{0}] End" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Return $AllResponses + + } + +} + +function Remove-ApplianceConnection +{ + + [CmdletBinding ()] + [Alias ('rac')] + Param + ( + + [Parameter (Mandatory = $false, ValueFromPipeline, Position = 0)] + #[ValidateNotNullorEmpty()] + [Object]$InputObject + + ) + + Begin + { + + # Write-Verbose "InputObject: $($InputObject | Out-String)" + + } + + Process + { + + if ($InputObject.GetType().FullName.StartsWith("HPEOneView.")) + { + + Write-Verbose 'Skipping HPEOneView class object processing.' + + Return $InputObject + + } + + else + { + + if ($InputObject -is [System.Collections.IEnumerable] -and $InputObject -isnot [String] -and $InputObject -isnot [Hashtable]) + { + + Write-Verbose 'InputObject is IEnumerable' + + $Collection = [System.Collections.ArrayList]::new() + + foreach ($object in $InputObject) + { + + $_UpdatedObject = Remove-ApplianceConnection $object + + [void]$Collection.Add($_UpdatedObject) + + } + + Return ,$Collection + + } + + # elseif ($InputObject.GetType().Name -eq 'PSCustomObject') + elseif ($InputObject -is [System.Management.Automation.PSCustomObject] -or $InputObject -is [PSCustomObject]) + { + + Write-Verbose 'InputObject is [PSCustomObject]. Copying...' + + $_ClonedObject = $InputObject.PSObject.Copy() + + foreach ($property in $InputObject.PSObject.Properties) + { + + if ($InputObject.($property.Name) -is [System.Collections.IEnumerable] -and $InputObject.($property.Name) -isnot [String] -and $InputObject.($property.Name) -isnot [Hashtable]) + { + + Write-Verbose 'Property is IEnumerable' + + $_SubCollection = [System.Collections.ArrayList]::new() + + foreach ($_subobject in $InputObject.($property.Name)) + { + + $_UpdatedObject = Remove-ApplianceConnection $_subobject + + [void]$_SubCollection.Add($_UpdatedObject) + + } + + $_ClonedObject.($property.Name) = $_SubCollection + + } + + else + { + + if ($property.Name -eq 'ApplianceConnection') + { + + Write-Verbose 'Found ApplianceConnection prop, removing' + + $_ClonedObject.PSObject.Properties.Remove($property.Name) + + } + + elseif ($InputObject.($property.Name) -is [PSCustomObject] -and $InputObject.($property.Name) -isnot [String]) + { + + "Nested [PSCustomObject] {0}, Processing..." -f $property.Name | Write-Verbose + + $_ClonedObject.($property.Name) = Remove-ApplianceConnection $InputObject.($property.Name) + + } + + } + + } + + Return $_ClonedObject + + } + + else + { + + Return $InputObject + + } + + } + + } + +} + +function ConvertTo-Object +{ + + [CmdletBinding ()] + Param + ( + + [Parameter (Mandatory)] + [ValidateNotNullOrEmpty()] + [System.Collections.ArrayList]$Objects + + ) + + Begin + { + + $NewObjects = [System.Collections.ArrayList]::new() + + } + + Process + { + + # Write-Verbose "Objects is '$($Objects.GetType().Fullname)' type." + + ForEach($_obj in $Objects) + { + + # Write-Verbose "_obj is '$($_obj.GetType().Fullname)' type." + + # Write-Verbose "Processing: $($_obj.name)" + + switch ($_obj.category) + { + + "ethernet-networks" + { + + #[HPEOneView.Networking.EthernetNetwork]$_newObj = $_obj + + $_obj.PSObject.TypeNames.Insert(0,'HPEOneView.Networking.EthernetNetwork') + + } + + "fc-networks" + { + + #[HPEOneView.Networking.FibreChannelNetwork]$_newObj = $_obj + $_obj.PSObject.TypeNames.Insert(0,'HPEOneView.Networking.FibreChannelNetwork') + + } + + "fcoe-networks" + { + + #[HPEOneView.Networking.FCoENetwork]$_newObj = $_obj + $_obj.PSObject.TypeNames.Insert(0,'HPEOneView.Networking.FCoENetwork') + + } + + default + { + + #$_newObj = $_obj + + } + + } + + + # Write-Verbose "_newObj is '$($_newObj.GetType().Fullname)' type." + + #[void]$NewObjects.Add($_newObj) + [void]$NewObjects.Add($_obj) + + } + + } + + End + { + + Return $NewObjects + + } + +} + +# Helper function +function Get-AllIndexResources +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding ()] + Param + ( + + [Parameter (Mandatory)] + [ValidateNotNullOrEmpty()] + [String]$Uri, + + [Parameter (Mandatory = $false)] + [ValidateNotNullOrEmpty()] + [Switch]$ReturnParent, + + [Parameter (Mandatory)] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + $_ResourcesFromIndexCol = [System.Collections.ArrayList]::new() + + } + + Process + { + + if (-not $Uri.StartsWith($IndexUri) -and -not $Uri.StartsWith($AssociationsUri)) + { + + Throw ("URI is incorrect. Does not begin with {0} or {1}." -f $IndexUri, $AssociationsUri) + + } + + "[{0}] Processing URI: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + Try + { + + $_IndexResults = Send-OVRequest -Uri $Uri -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + ForEach ($_IndexEntry in $_IndexResults.members) + { + + if ($Uri.StartsWith($AssociationsUri) -and -not $PSBoundParameters['ReturnParent']) + { + + "[{0}] Get full child associated object" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_Uri = $_IndexEntry.childUri + + } + + elseif ($Uri.StartsWith($AssociationsUri) -and $PSBoundParameters['ReturnParent']) + { + + "[{0}] Get full parent associated object" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_Uri = $_IndexEntry.parentUri + + } + + else + { + + "[{0}] Get full object: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_IndexEntry.name | Write-Verbose + + $_Uri = $_IndexEntry.uri + + } + + # Get the full server hardware resource + if ($_Uri.StartsWith($ServerHardwareUri) -or $_Uri.StartsWith($RackManagerUri)) + { + + $_Uri += '?expand=all' + + } + + Try + { + + $_FullIndexEntry = Send-OVRequest -Uri $_Uri -Hostname $ApplianceConnection + + [void]$_ResourcesFromIndexCol.Add($_FullIndexEntry) + + } + + Catch [HPEOneView.ResourceNotFoundException] + { + + "[{0}] Unable to get full object '{1}' ({2}). Resource URI was not found. Possible Index out of sync?" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_IndexEntry.name, $_IndexEntry.uri | Write-Verbose + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Return $_ResourcesFromIndexCol + + } + +} + +function Ping-OVAddress +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding ()] + Param + ( + + # Allow via pipeline + [Parameter (Mandatory, ValueFromPipeline)] + [ValidateNotNullOrEmpty()] + [String]$Address, + + [Parameter (Mandatory = $False)] + [ValidateNotNullOrEmpty()] + [Int]$Packets = 5, + + [Parameter (Mandatory = $False)] + [Switch]$Async, + + [Parameter (Mandatory= $false)] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + # Allow targets to be passed via pipeline + if (-not($PSBoundParameters['Address'])) + { + + $PipelineInput = $True + + } + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $_TaskCollection = [System.Collections.ArrayList]::new() + + } + + Process + { + + ForEach ($_appliance in $ApplianceConnection) + { + + $_PingObject = NewObject -Ping + + $_PingObject.address = $Address + + if ($PSBoundParameters['Packets']) + { + + $_PingObject.noOfPackets = $Packets + + } + + Try + { + + $_resp = Send-OVRequest $appliancePingTestUri POST $_PingObject -Hostname $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if (-not($PSBoundParameters['Async'])) + { + + $_resp = Wait-OVTaskComplete $_resp + + Write-Host " " + $_resp.progressUpdates.statusUpdate | Write-Host + Write-Host " " + + } + + [void]$_TaskCollection.Add($_resp) + + } + + } + + End + { + + Return $_TaskCollection + + } + +} + +function Wait-OVApplianceStart +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding ()] + Param + ( + + [Parameter (Mandatory)] + [Alias ('Appliance')] + [ValidateNotNullOrEmpty()] + [String]$Hostname = $null + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if ($Hostname -is [String]) + { + + if (-not(${Global:ConnectedSessions}.Name -contains $Hostname) -and (-not(${Global:ConnectedSessions} | Where-Object Name -eq $Hostname).SessionID)) + { + + "[{0}] Appliance Session not found. Running FTS sequence?" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Creating temporary Session object" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + $_ApplianceName = $Hostname + + [HPEOneView.Appliance.Connection]$Hostname = New-TemporaryConnection $Hostname + + "[{0}] {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Hostname.Name | Write-Verbose + + } + + else # If (${Global:ConnectedSessions}.Name -contains $Appliance) + { + + "[{0}] Appliance is a string value, lookup connection in global tracker." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + [HPEOneView.Appliance.Connection]$Hostname = ${Global:ConnectedSessions} | Where-Object Name -eq $Hostname + + "[{0}] Found connection in global tracker: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), ($Hostname | Out-String) | Write-Verbose + + } + + } + + elseif ($Hostname -is [HPEOneView.Appliance.Connection]) + { + + "[{0}] Appliance is a Connection: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), ($Hostname | Out-String) | Write-Verbose + + } + + } + + Process + { + + $_SW = [System.Diagnostics.Stopwatch]::new() + + $_SW.Start() + + do + { + + "[{0}] Services not started. Monitoring startup progress" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $waitRequest = $Null + $waitResponse = $Null + + [System.Net.httpWebRequest]$waitRequest = RestClient -uri $ApplianceStartProgressUri -appliance $Hostname.Name + $waitRequest.Timeout = 10000 + + "[{0}] REQUEST: {1} {2}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $waitRequest.Method, $waitRequest.RequestUri | Write-Verbose + + $i = 0 + + foreach ($h in $waitRequest.Headers) + { + + "[{0}] Request Header {1}: {2} = {3}" -f $MyInvocation.InvocationName.ToString().ToUpper(), ($i+1), $h, $waitRequest.Headers[$i] | Write-Verbose + + $i++ + + } + + try + { + + # Get response from appliance + "[{0}] Getting response..." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $waitResponse = $waitRequest.GetResponse() + [Int]$HttpStatusCode = $waitResponse.StatusCode + + "[{0}] Received HTTP\{1} status." -f $MyInvocation.InvocationName.ToString().ToUpper(), [Int]$waitResponse.StatusCode | Write-Verbose + + # This will trigger when the GetResponse() does not generate an HTTP Error Code and get trapped by the Catch statement below + If ($_displayflag) + { + + write-host "]" + + # Reset flag so we don't display the Ending brace + $_displayflag = $False + + } + + # Read the response + $reader = [System.IO.StreamReader]::new($waitResponse.GetResponseStream()) + $responseJson = $reader.ReadToEnd() + $reader.Close() + + $resp = ConvertFrom-json $responseJson + + $_ActualPercentComplete = ($resp.completeComponents / $resp.totalComponents) * 100 + + $StatusMessage = 'Step2: Resource managers {0} of {1}, {2:##}%' -f $resp.completeComponents, $resp.totalComponents, $_ActualPercentComplete + + # Handle the call from -Verbose so Write-Progress does not get borked on display. + if ($PSBoundParameters['Verbose'] -or $VerbosePreference -eq 'Continue') + { + + "[{0}] Skipping Write-Progress display." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + "[{0}] {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $StatusMessage | Write-Verbose + + } + + else + { + + # Display progress-bar + Write-Progress -activity "Appliance services starting" -Status $StatusMessage -percentComplete ('{0:##}' -f $resp.percentComplete) + + } + + } + + # Catch if we haven't received HTTP 200, as we should display a nice message stating services are still beginning to start + catch [Net.WebException] + { + + if ([RegEx]::Match($_.Exception.Message, 'The remote name could not be resolved', $RegExInsensitiveFlag).Success) + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if ($waitResponse) + { + + $reader = [System.IO.StreamReader]::new($waitResponse.GetResponseStream()) + + $responseJson = $reader.ReadToEnd() + + "[{0}] ERROR RESPONSE: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), ($responseJson | ConvertFrom-Json | out-string) | Write-Verbose + + "[{0}] Response Status: HTTP\{1} {2}" -f $MyInvocation.InvocationName.ToString().ToUpper(), [Int]$waitResponse.StatusCode, $waitResponse.StatusDescription | Write-Verbose + + foreach ($h in $waitResponse.Headers) + { + + "[{0}] Response Header: {1} = {2}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $h, $waitResponse.Headers[$i] | Write-Verbose + + $i++ + + } + + } + + "[{0}] EXCEPTION CAUGHT! HTTP Status Code: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), [Int]$waitResponse.StatusCode | Write-Verbose + + # Handle WebException errors that are not HTTP Status Code 503 or 0, and throw error + if ([Int]$waitResponse.StatusCode -ne 503 -and [Int]$waitResponse.StatusCode -ne 0) + { + + Throw $_.Exception.Message + + } + + Write-Verbose "$($waitResponse| Out-string)" + + # Only want to display this message once. + if (-not($_displayflag)) + { + + Write-host "Waiting for services to Begin starting [" -nonewline + + } + + if (-not ([Int]$waitResponse.StatusCode -eq 200)) + { + + Write-host "*" -nonewline -ForegroundColor Green + + $_displayflag = $true + + start-sleep -s 5 + + } + + } + + finally + { + + if ($waitResponse -is [System.IDisposable]) + { + + $waitResponse.Dispose() + + } + + } + + # Timeout after 10 minutes + if ($_SW.Elapsed.TotalSeconds -ge $ApplianceStartupTimeout) + { + + $_SW.Stop() + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.NetworkConnectionException ConnectionWaitTimeoutExceeded OperationTimeout -TargetObject 'Hostname' -Message "Timeout waiting for appliance to respond after restart event. Verify the appliance is operational and reconnect to the appliance." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + '[{0}] Ending Do Loop: {1}; Percent Complete: {2}; HTTP Status Code: {3}' -f $MyInvocation.InvocationName.ToString().ToUpper(), [Bool]([Int]$_ActualPercentComplete -eq 100 -and $HttpStatusCode -eq 200), $resp.percentComplete, $HttpStatusCode | Write-Verbose + + } until ([Int]$_ActualPercentComplete -eq 100 -and $HttpStatusCode -eq 200) + + # Remove Temporary appliance connection + if ((${Global:ConnectedSessions} | Where-Object Name -eq $ApplianceConnection.Name).SessionID -eq 'TemporaryConnection') + { + + "[{0}] Removing temporary Session object" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $ConnectedSessions.RemoveConnection($ApplianceConnection) + + } + + } + + End + { + + "[{0}] Web Services have started successfully" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + "[{0}] Pausing 10 seconds to let web services finish their final startup" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + start-sleep -s 10 + + } + +} + +function Connect-OVMgmt +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = 'UsernamePassword')] + Param + ( + + [Parameter (Mandatory, ParameterSetName = 'UsernamePassword')] + [Parameter (Mandatory, ParameterSetName = 'PSCredential')] + [Parameter (Mandatory, ParameterSetName = 'Certificate')] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance', 'Computername')] + [String]$Hostname, + + [Parameter (Mandatory = $false, ParameterSetName = 'UsernamePassword')] + [Parameter (Mandatory = $false, ParameterSetName = 'PSCredential')] + [ValidateNotNullOrEmpty()] + [Alias ('authProvider')] + [String]$AuthLoginDomain, + + [Parameter (Mandatory, ParameterSetName = 'UsernamePassword')] + [Obsolete()] + [ValidateNotNullOrEmpty()] + [Alias ("u",'user')] + [String]$UserName, + + [Parameter (Mandatory = $false, ParameterSetName = 'UsernamePassword')] + [Obsolete()] + [Alias ("p")] + [ValidateNotNullOrEmpty()] + [Object]$Password, + + [Parameter (Mandatory, ParameterSetName = 'PSCredential')] + [ValidateNotNullOrEmpty()] + [Alias ('PSCredential')] + [PSCredential]$Credential, + + [Parameter (Mandatory, ParameterSetName = 'Certificate')] + [Object]$Certificate, + + [Parameter (Mandatory = $false, ParameterSetName = 'UsernamePassword')] + [Parameter (Mandatory = $false, ParameterSetName = 'PSCredential')] + [Parameter (Mandatory = $false, ParameterSetName = 'Certificate')] + [Switch]$LoginAcknowledge + + ) + + Begin + { + + $AlreadyConnectedToSpecifiedAppliance = $False + + # Clone PSBoundParameters + $_Params = @{} + + $PSBoundParameters.GetEnumerator() | ForEach-Object { + + if ($_.Key -eq 'Password') + { + + $_Params['Password'] = '[*****REDACTED******]' + + } + + elseif ($_.Key -eq 'Certificate') + { + + $_Params['Certificate'] = '[*****REDACTED******]' + + } + + else + { + + $_Params.Add($_.Key,$_.Value) + + } + + } + + # RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + "[{0}] Bound PS Parameters: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), ($_Params | out-string) | Write-Verbose + + # Check to see if a connection to the appliance exists + if ((${Global:ConnectedSessions}.Name -contains $Hostname) -and ((${Global:ConnectedSessions} | Where-Object name -eq $Hostname).SessionID)) + { + + Write-Warning "You are already connected to $Hostname" + + $AlreadyConnectedToSpecifiedAppliance = $True + + Return + + } + + # Create the connection object for tracking + else + { + + # Look for Connection where Name exists but SessionID does not, and remove the object from $ConnectedSessions + if ((${Global:ConnectedSessions}.Name -contains $Hostname) -and (-not(${Global:ConnectedSessions} | Where-Object name -eq $Hostname).SessionID)) + { + + "[{0}] Found incomplete session object in `$ConnectedSessions for '{1}'. Removing." -f $MyInvocation.InvocationName.ToString().ToUpper(), $Hostname | Write-Verbose + + # Found incomplete session connection. must remove it from the collection first. + $_ndx = [array]::IndexOf(${Global:ConnectedSessions}, (${Global:ConnectedSessions}.Name -contains $Hostname)) + + if ($_ndx -gt 0) + { + + [void]${Global:ConnectedSessions}.RemoveAt($_ndx) + + } + + else + { + + "[{0}] Index was {1}, connection doesn't exist in global tracker." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_ndx | Write-Verbose + + } + + } + + "[{0}] Creating Session Container" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $tmpConnectionId = 1 + + # Figure out ConnectionId + if (${Global:ConnectedSessions}) + { + + While (${Global:ConnectedSessions}.ConnectionId -contains $tmpConnectionId) + { + + $tmpConnectionId++ + + } + + } + + # Store the entire auth request for later deletion when issuing Disconnect-OVmgmt + [HPEOneView.Appliance.Connection]$ApplianceConnection = [HPEOneView.Appliance.Connection]::new($tmpConnectionId, + $Hostname, + $UserName) + + if (-not(${Global:ConnectedSessions} | Where-Object Default)) + { + + $ApplianceConnection.SetDefault($True) + + } + + [void]${Global:ConnectedSessions}.Add($ApplianceConnection) + + if (-not($PSBoundParameters['Password']) -and $PSCmdlet.ParameterSetName -eq 'UsernamePassword') + { + + [SecureString]$password = read-host -AsSecureString "Password" + $decryptPassword = [Runtime.InteropServices.Marshal]::PtrToStringBSTR([Runtime.InteropServices.Marshal]::SecureStringToBSTR($Password)) + + } + + elseif ($Password -is [SecureString] -and $PSCmdlet.ParameterSetName -eq 'UsernamePassword') + { + + $decryptPassword = [Runtime.InteropServices.Marshal]::PtrToStringBSTR([Runtime.InteropServices.Marshal]::SecureStringToBSTR($Password)) + + } + + elseif ($PSCmdlet.ParameterSetName -eq 'UsernamePassword') + { + + $decryptPassword = $Password + + } + + elseif ($PSCmdlet.ParameterSetName -eq 'PSCredential') + { + + $Username = $Credential.UserName + $decryptPassword = [Runtime.InteropServices.Marshal]::PtrToStringBSTR([Runtime.InteropServices.Marshal]::SecureStringToBSTR($Credential.Password)) + + } + + elseif ($PSCmdlet.ParameterSetName -ne 'Certificate') + { + + $Credential = Get-Credential + $Username = $Credential.UserName + $decryptPassword = [Runtime.InteropServices.Marshal]::PtrToStringBSTR([Runtime.InteropServices.Marshal]::SecureStringToBSTR($Credential.Password)) + + } + + if (-not $PSBoundParameters['AuthLoginDomain']) + { + + "[{0}] Caller did not provide -AuthLoginDomain parameter. Checking for Domain Name or UPN formatted Username value." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + # Parse Username value for DOMAIN\Username or UPN value + $NTResults = $DetectLoginDomainInUsernameRegex.Match($Username) + $UPNResults = $DetectUPNInUsernameRegex.Match($Username) + + if ($NTResults.Success) + { + + $AuthLoginDomain = $NTResults.Groups['domain'].Value + $Username = $NTResults.Groups['username'].Value + + "[{0}] Found NT-style domain name in the username field, '{1}'" -f $MyInvocation.InvocationName.ToString().ToUpper(), $AuthLoginDomain | Write-Verbose + + } + + elseif ($UPNResults.Success) + { + + $AuthLoginDomain = $UPNResults.Groups['domain'].Value + + "[{0}] Found UPN-style domain name in the username field, '{1}'" -f $MyInvocation.InvocationName.ToString().ToUpper(), $AuthLoginDomain | Write-Verbose + + } + + } + + # Check to make sure the appliance X-API-Version is at least the supported minimum + "[{0}] Checking X-API Version." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + try + { + + $applianceVersion = (Send-OVRequest -Uri $ApplianceXApiVersionUri -Hostname $Hostname).currentVersion + + if ($applianceVersion -and $applianceVersion -lt $MinXAPIVersion ) + { + + [void] $ConnectedSessions.RemoveConnection($ApplianceConnection) + + # Display terminating error + $ErrorRecord = New-ErrorRecord System.NotImplementedException LibraryTooNew OperationStopped $Hostname -Message "The appliance you are connecting to supports an older version of this library. Please visit https://github.com/HewlettPackard/POSH-HPEOneView for a supported version of the library." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + catch + { + + "[{0}] Exception caught when checking X-API version." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + [void] $ConnectedSessions.RemoveConnection($ApplianceConnection) + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + Process + { + + if (-not $AlreadyConnectedToSpecifiedAppliance) + { + + try + { + + "[{0}] Getting global login settings to check for login message acknowledgement." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_LoginDetails = Send-OVRequest -Uri $ApplianceLoginDomainDetailsUri -Hostname $Hostname + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + # Build the parameters object depending on what type of credential passed + + $_Params = @{ + + Uri = $null; + Method = 'POST'; + Body = $null; + Hostname = $Hostname + + } + + # Username/Password or PSCredential auth + if ($PSCmdlet.ParameterSetName -ne 'Certificate') + { + + $_authinfo = NewObject -AuthLoginCredential + + $_authinfo.userName = $UserName + $_authinfo.password = $decryptPassword + + if (-not [String]::IsNullOrEmpty($AuthLoginDomain) -and -not $PSBoundParameters['AuthLoginDomain']) + { + + "[{0}] Using detected authentication directory: '{1}'" -f $MyInvocation.InvocationName.ToString().ToUpper(), $AuthLoginDomain | Write-Verbose + + # This is here as the name is case sensitive enforced by the API + $_authinfo.authLoginDomain = ($_LoginDetails.configuredLoginDomains | Where name -eq $AuthLoginDomain).name + + } + + elseif (-not $PSBoundParameters['AuthLoginDomain'] -and -not [String]::IsNullOrEmpty($_LoginDetails.defaultLoginDomain)) + { + + "[{0}] Using default authentication directory: '{1}'" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_LoginDetails.defaultLoginDomain | Write-Verbose + + $_authinfo.authLoginDomain = $_LoginDetails.defaultLoginDomain + + } + + elseif ($PSBoundParameters['AuthLoginDomain']) + { + + "[{0}] Using provided authentication directory: '{1}'" -f $MyInvocation.InvocationName.ToString().ToUpper(), $AuthLoginDomain | Write-Verbose + + # This is here as the name is case sensitive enforced by the API + if ($AuthLoginDomain -ne 'LOCAL') + { + + "[{0}] Auth directory is not LOCAL. Matching '{1}' to configured directories to get correct camel case value." -f $MyInvocation.InvocationName.ToString().ToUpper(), $AuthLoginDomain | Write-Verbose + $_authinfo.authLoginDomain = ($_LoginDetails.configuredLoginDomains | Where name -eq $AuthLoginDomain).name + + } + + else + { + + "[{0}] Auth directory is LOCAL." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + $_authinfo.authLoginDomain = $AuthLoginDomain.ToUpper() + + } + + } + + # Use LOCAL as the default + else + { + + "[{0}] Setting default auth directory to LOCAL." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + $_authinfo.authLoginDomain = 'LOCAL' + + } + + $_Params.Uri = $ApplianceLoginSessionsUri + + $_Params.Body = $_authinfo + + if ($PSBoundParameters['LoginAcknowledge']) + { + + $_Params.Body | Add-Member -NotePropertyName loginMsgAck -NotePropertyValue $True + + } + + } + + # Cert/SmartCard auth + else + { + + $_CertificateBase64Object = $Certificate + + $_Params.Uri = $ApplianceLoginSessionsSmartCardAuthUri + $_Params.Body = $_CertificateBase64Object + + if ($PSBoundParameters['LoginAcknowledge']) + { + + [void] $_Params.Add('AddHeader', @{'X-LoginMsgAck' = $True}) + + } + + } + + Try + { + + if (-not [String]::IsNullOrEmpty($_LoginDetails.loginMessageVersion600.message)) + { + + Write-Host ("{0}`n" -f $_LoginDetails.loginMessageVersion600.message) + + } + + # Send the auth request + $resp = Send-OVRequest @_Params + + } + + catch [HPEOneView.ResourceNotFoundException] + { + + [void] $ConnectedSessions.RemoveConnection($ApplianceConnection) + + if ($PSCmdlet.ParameterSetName -eq 'Certificate') + { + + $ExceptionMessage = "The appliance is not configured for 2-Factor authentication. Please provide a valid username and password in order to authenticate to the appliance." + $ErrorRecord = New-ErrorRecord HPEOneView.ResourceNotFoundException TwoFactorAuthenticationNotEnabled PermissionDenied 'Certificate' -Message $ExceptionMessage + + } + + else + { + + $ExceptionMessage = "The provided '{0}' authentication directory is not configured on the appliance '{1}'." -f $AuthLoginDomain, $Hostname + $ErrorRecord = New-ErrorRecord HPEOneView.ResourceNotFoundException AuthenticationDirectoryNotFound ObjectNotFound 'AuthLoginDomain' -Message $ExceptionMessage + + } + + + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + catch [HPEOneView.Appliance.AuthSessionException] + { + + "[{0}] Authentication Exception Caught." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_ErrorId = $_.FullyQualifiedErrorId.Split(',')[0] + + $_ErrorRecord = $_ + + switch ($_ErrorId) + { + + 'LoginMessageAcknowledgementRequired' + { + + "[{0}] Login Message Acknowledgement Required" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + # Get LoginMessage from appliance. + Try + { + + $caption = "Please Confirm"; + $message = "Do you acknowledge the login message?"; + $yes = [System.Management.Automation.Host.ChoiceDescription]::new("&Yes","Yes, I accept the login message."); + $no = [System.Management.Automation.Host.ChoiceDescription]::new("&No","No, I do not."); + $choices = [System.Management.Automation.Host.ChoiceDescription[]]($yes,$no); + $answer = $host.ui.PromptForChoice($caption,$message,$choices,1) + + switch ($answer) + { + + #YES + 0 + { + + "[{0}] Submitting auth request again, with login message acknowledgement." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if ($PSCMdlet.ParameterSetName -eq 'Certificate') + { + + $_Params.AddHeader.Add('X-LoginMsgAck', $True) + + } + + else + { + + $_Params.Body | Add-Member -NotePropertyName loginMsgAck -NotePropertyValue $True + + } + + Try + { + + $resp = Send-OVRequest @_Params + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + # NO + 1 + { + + "[{0}] User selected 'No'." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + 'You are not authenticated to {0}, as you chose not to accept the Login Message acknowledgement.' -f $Hostname | Write-Warning + + # Remove Connection from global tracker + [void] $ConnectedSessions.RemoveConnection($ApplianceConnection) + + Return + + } + + } + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + 'InvalidUsernameOrPassword' + { + + # Remove Connection from global tracker + [void] $ConnectedSessions.RemoveConnection($ApplianceConnection) + + $PSCmdlet.ThrowTerminatingError($_ErrorRecord) + + } + + default + { + + # Remove Connection from global tracker + [void] $ConnectedSessions.RemoveConnection($ApplianceConnection) + + #$ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException $_ErrorId InvalidResult 'Connect-OVMgmt' -Message $_.Exception.Message + $PSCmdlet.ThrowTerminatingError($_ErrorRecord) + + } + + } + + } + + catch [HPEOneView.Appliance.PasswordChangeRequired] + { + + "[{0}] Password needs to be changed. Use Set-OVInitialPassword if this is first time setup, or Set-OVUserPassword to update your own accounts password." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + [void] $ConnectedSessions.RemoveConnection($ApplianceConnection) + + # Throw terminating error + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.PasswordChangeRequired PasswordExpired PermissionDenied 'Username' -Message "The password has expired and needs to be updated. Use Set-OVInitialPassword if this is first time setup, or Set-OVUserPassword to update your own accounts password." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + catch [Net.WebException] + { + + [void] $ConnectedSessions.RemoveConnection($ApplianceConnection) + + if (([RegEx]::Match($_.Exception.Message, "Could not create SSL/TLS secure channel", $RegExInsensitiveFlag).Success -or [RegEx]::Match($_.Exception.Message, "An error occurred while sending the request", $RegExInsensitiveFlag).Success) -and $PSBoundParameters['Certificate'] -and $Certificate.NotAfter -lt [DateTime]::Now) + { + + $ExceptionMessage = "Your SmartCard certificate has expired. Please renew your smart card certificate." + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthPrivilegeException ExpiredSmartCard AuthenticationError Certificaet -TargetType "Object" -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + else + { + + "[{0}] Response: $($resp)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $ExceptionMessage = "The appliance at '{0}' is not responding on the network. Check for firewalls or ACL's prohibiting access to the appliance." -f $Hostname + $ErrorRecord = New-ErrorRecord System.Net.WebException ApplianceNotResponding OperationStopped $Hostname -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + # Something bad happened, should not leave connection in this state + catch + { + + [void] $ConnectedSessions.RemoveConnection($ApplianceConnection) + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + End + { + + if (-not $AlreadyConnectedToSpecifiedAppliance) + { + + "[{0}] Authentication Response Received. Processing final connection object." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + # If a sessionID is returned, then the user has authenticated + if ($resp.sessionId) + { + + $_RedactedResp = $resp.PSObject.Copy() + + $_RedactedResp.SessionId = '[*****REDACTED******]' + + $_Index = ${Global:ConnectedSessions}.IndexOf((${Global:ConnectedSessions} | Where-Object Name -EQ $Hostname)) + + ${Global:ConnectedSessions}[$_Index].SetSessionID($resp.sessionId) + + "[{0}] Session received: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $($_RedactedResp | Out-String) | Write-Verbose + + if ($PSCmdlet.ParameterSetName -eq 'Certificate') + { + + $_AuthType = 'Certificate' + $_UserName = $resp.userName + $_AuthLoginDomain = $resp.authLoginDomain + + } + + else + { + + $_AuthType = 'Credentials' + $_Username = $Username + $_AuthLoginDomain = $_authinfo.authLoginDomain + + } + + # Get list of supported Roles from the appliance + "[{0}] Getting list of supported roles from appliance." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_ApplianceSecurityRoles = $null + + try + { + + $_ApplianceSecurityRoles = (Send-OVRequest $ApplianceRolesUri -Hostname $Hostname).members.roleName + + } + + catch [HPEOneView.Appliance.AuthPrivilegeException] + { + + "[{0}] User is not authorizaed to get list of security groups." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + "[{0}] Get appliance platform version." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_applianceversioninfo = NewObject -ApplianceVersion + + Try + { + + $applVersionInfo = Send-OVRequest -Uri $ApplianceVersionUri -Hostname $Hostname + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + Try + { + + $_applianceversioninfo = [HPEOneView.Appliance.NodeInfo]::new($applVersionInfo.softwareVersion, (Get-OVXApiVersion -ApplianceConnection $Hostname).currentVersion, $applVersionInfo.modelNumber) + + $PSLibraryVersion | Add-Member -NotePropertyName $Hostname -NotePropertyValue $_applianceversioninfo -Force + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + "[{0}] Get users available Scopes and Permissions." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $_UserDefaultSession = Send-OVRequest -Uri $UserLoginSessionUri -Hostname $Hostname -AddHeader @{'Session-ID' = $resp.sessionId} + + $_UserDefaultSessionPermissions = [System.Collections.ArrayList]::new() + + ForEach ($_Permission in $_UserDefaultSession.permissions) + { + + "[{0}] Adding {1} into permissions collection." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_Permission.roleName | Write-Verbose + + $_Scope = $null + + if (-not [String]::IsNullOrWhiteSpace($_Permission.scopeUri)) + { + + $_Scope = Send-OVRequest -Uri $_Permission.scopeUri -Hostname $Hostname + + } + + $_NewPermission = [HPEOneView.Appliance.ConnectionPermission]::new($_Permission.roleName, + $_Scope.Name, + $_Permission.scopeUri, + $_Permission.active) + + [void]$_UserDefaultSessionPermissions.Add($_NewPermission) + + } + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + # Recreate the full appliance connection + $_NewConnection = [HPEOneView.Appliance.Connection]::new($ConnectedSessions[$_Index].ConnectionID, + $ConnectedSessions[$_Index].Name, + $_Username, + $resp.sessionId, + $_AuthLoginDomain, + $_AuthType, + $AppliancePlatformType[$applVersionInfo.platformType], + $ConnectedSessions[$_Index].Default, + [Array]$_ApplianceSecurityRoles, + [Array]$_UserDefaultSessionPermissions) + + ${Global:ConnectedSessions}[$_Index] = $_NewConnection + + # $Validator.AddTrustedHost($_NewConnection.Name) + [HPEOneView.PKI.SslValidation]::AddTrustedHost($_NewConnection.Name) + + Return $_NewConnection + + } + + else + { + + Return $resp + + } + + } + + } + +} + +function Push-OVAppliancePermission +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = 'Default')] + Param + ( + + [Parameter (Mandatory, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [Array]$SetActivePermissions, + + [Parameter (Mandatory = $False, ValueFromPipelineByPropertyName)] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + "[{0}] Bound PS Parameters: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), ($PSBoundParameters | out-string) | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + Process + { + + # First, compare the objects to see if permissions will be different. + "[{0}] Comparing permissions." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_PermissionsDiff = Compare-Object -ReferenceObject $ApplianceConnection.ActivePermissions -DifferenceObject $SetActivePermissions -Property RoleName, ScopeName -IncludeEqual + + if ($_PermissionsDiff | Where-Object SideIndicator -ne '==') + { + + "[{0}] Diff permissions: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), ($_PermissionsDiff | Where-Object SideIndicator -ne '==' | Out-String) | Write-Verbose + + $_UpdateToActivePermissions = NewObject -UpdateToActivePermissions + + $_UpdateToActivePermissions.sessionID = $ApplianceConnection.SessionID + + ForEach ($_Permission in $SetActivePermissions) + { + + $_PermissionToActivate = NewObject -DirectoryGroupPermissions + $_PermissionToActivate.roleName = $_Permission.RoleName + + if (-not [String]::IsNullOrWhiteSpace($_Permission.ScopeUri)) + { + + $_PermissionToActivate.scopeUri = $_Permission.ScopeUri + + } + + [void]$_UpdateToActivePermissions.permissionsToActivate.Add($_PermissionToActivate) + + } + + # Take the URI of the scopeUris and do a POST $UpdateApplianceSessionAuthUri to get new SessionID + Try + { + + $_UpdatedSessionID = Send-OVRequest -Uri $UpdateApplianceSessionAuthUri -Method POST -Body $_UpdateToActivePermissions -ApplianceConnection $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + # Update the appliance connection object + "[{0}] Updating SessionID of the appliance connection." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + ($ConnectedSessions | Where-Object Name -match $ApplianceConnection.Name).SetSessionID($_UpdatedSessionID.sessionID) + + # After the new sessionID has successfully been created, look at what existing permissions there are. Set the ones that do not + # match the $SetActivePermissions to .UpdateState($false) + + "[{0}] Updating ActivePermission(s) that were changed to 'false'." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + ForEach ($_PermissionToUpdate in ($_PermissionsDiff | Where-Object SideIndicator -eq '<=')) + { + + ($ApplianceConnection.ActivePermissions | Where-Object { $_.RoleName -eq $_PermissionToUpdate.RoleName -and $_.ScopeName -eq $_PermissionToUpdate.ScopeName}).UpdateState($false) + + } + + "[{0}] Updating ActivePermission(s) that should be active to 'true'." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + ForEach ($_PermissionToUpdate in ($_PermissionsDiff | Where-Object SideIndicator -eq '==')) + { + + ($ApplianceConnection.ActivePermissions | Where-Object { $_.RoleName -eq $_PermissionToUpdate.RoleName -and $_.ScopeName -eq $_PermissionToUpdate.ScopeName}).UpdateState($true) + + } + + "[{0}] Updated permissions: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), ($ApplianceConnection.ActivePermissions | Out-String) | Write-Verbose + + $ApplianceConnection.ActivePermissions + + } + + else + { + + "[{0}] No permissions to update." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Pop-OVAppliancePermission +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = 'Default')] + Param + ( + + [Parameter (Mandatory = $False, ValueFromPipelineByPropertyName)] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + "[{0}] Bound PS Parameters: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), ($PSBoundParameters | out-string) | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + Process + { + + $_UpdateToActivePermissions = NewObject -UpdateToActivePermissions + + $_UpdateToActivePermissions.sessionID = $ApplianceConnection.SessionID + + ForEach ($_Permission in $ApplianceConnection.ActivePermissions) + { + + $_PermissionToActivate = NewObject -DirectoryGroupPermissions + $_PermissionToActivate.roleName = $_Permission.RoleName + + if (-not [String]::IsNullOrWhiteSpace($_Permission.ScopeUri)) + { + + $_PermissionToActivate.scopeUri = $_Permission.ScopeUri + + } + + [void]$_UpdateToActivePermissions.permissionsToActivate.Add($_PermissionToActivate) + + } + + # Take the URI of the scopeUris and do a POST $UpdateApplianceSessionAuthUri to get new SessionID + Try + { + + $_UpdatedSessionID = Send-OVRequest -Uri $UpdateApplianceSessionAuthUri -Method POST -Body $_UpdateToActivePermissions -ApplianceConnection $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + # Update the appliance connection object + "[{0}] Updating SessionID of the appliance connection." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + ($ConnectedSessions | Where-Object Name -match $ApplianceConnection.Name).SetSessionID($_UpdatedSessionID.sessionID) + + # After the new sessionID has successfully been created, look at what existing permissions there are. Set the ones that do not + # match the $SetActivePermissions to .UpdateState($false) + + "[{0}] Updating ActivePermission(s) that were changed to 'false'." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + ForEach ($_PermissionToUpdate in $ApplianceConnection.ActivePermissions) + { + + $_PermissionToUpdate.UpdateState($true) + + } + + $ApplianceConnection.ActivePermissions + + } + +} + +function Disconnect-OVMgmt +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding ()] + Param + ( + + [Parameter (Mandatory = $false, ValueFromPipeline, Position = 0)] + [ValidateNotNullorEmpty()] + [Alias ('Appliance', 'ApplianceSession', 'Hostname')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + if (-not ($ApplianceConnection)) + { + + $ExceptionMessage = "No valid logon session available. Please use Connect-OVMgmt to connecto to an appliance, and then use Disconnect-OVmgmt to terminate your session." + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoAuthSession ResourceUnavailable 'ApplianceConnection' -Message $ExceptionMessage + $PSCmdlet.WriteError($ErrorRecord) + + } + + $_ConnectionsToProcess = [System.Collections.ArrayList]::new() + + } + + Process + { + + ForEach ($_ApplianceConnection in $ApplianceConnection) + { + + # Check first if the Hostname value is a ConnectionID Integer + [Int]$_tmpValue = 0 + + if ([Int]::TryParse($_ApplianceConnection, [ref]$_tmpValue)) + { + + "[{0}] Hostname is ConnectionID {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_tmpValue | Write-Verbose + + [void]$_ConnectionsToProcess.Add((${Global:ConnectedSessions} | Where-Object ConnectionID -eq $_tmpValue)) + + "[{0}] Found: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), (${Global:ConnectedSessions} | Where-Object ConnectionID -eq $_tmpValue) | Write-Verbose + + } + + elseif ($_ApplianceConnection -is [String]) + { + + "[{0}] Hostname provide, looking in global connection tracker for connection." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + [void]$_ConnectionsToProcess.Add((${Global:ConnectedSessions} | Where-Object Name -eq $_ApplianceConnection)) + + "[{0}] Found: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), (${Global:ConnectedSessions} | Where-Object Name -eq $_ApplianceConnection) | Write-Verbose + + } + + elseif ($Null -eq $_ApplianceConnection.SessionID) + { + + '[{0}] User Session not found in $Global:ConnectedSessions' -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $ExceptionMessage = "User session for '{0}' not found in library connection tracker (`$Global:ConnectedSessions). Did you accidentially remove it, or have you not created a session to an appliance?" -f $_ApplianceConnection.ToString() + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException UnableToLogoff ObjectNotFound 'ApplianceConnection' -Message $ExceptionMessage + $PSCmdlet.WriteError($ErrorRecord) + + } + + else + { + + "[{0}] Adding Connection: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_ApplianceConnection | Write-Verbose + + [void]$_ConnectionsToProcess.Add($_ApplianceConnection) + + } + + } + + } + + End + { + + For ($c = $_ConnectionsToProcess.Count - 1; $c -ge 0; $c--) + { + + "[{0}] Processing Connection: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_ConnectionsToProcess[$c].Name | Write-Verbose + + "[{0}] Attempting to logoff user '{1}' from '{2}'." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_ConnectionsToProcess[$c].Username, $_ConnectionsToProcess[$c] | Write-Verbose + + "[{0}] Sending Delete Session ID request" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + try + { + + $Resp = Send-OVRequest -Uri $ApplianceLoginSessionsUri -Method DELETE -Body $_ConnectionsToProcess[$c].SessionId -Hostname $_ConnectionsToProcess[$c] + + "[{0}] Removing connection from global connection tracker" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $ConnectedSessions.RemoveConnection($_ConnectionsToProcess[$c]) + + } + + catch + { + + "[{0}] Unable to complete logoff. Displaying error" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + + if ($ConnectedSessions.Count -eq 1 -and (-not($ConnectedSessions | Where-Object Default)) -and $null -ne $ConnectedSessions[0]) + { + + $ConnectedSessions[0].SetDefault($true) + + } + + Return $ConnectedSessions + + } + +} + +function Set-OVApplianceDefaultConnection +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding ()] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline)] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance', 'Connection')] + [Object]$ApplianceConnection + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + # Check to see if there is only a single connection in the global tracker + If (${Global:ConnectedSessions}.Count -eq 1) + { + + Write-Warning 'There is only a single Appliance Connection. This Cmdlet only supports multiple Appliance Connections.' + + if (-not($Global:ConnectedSessions[0].Default)) + { + + 'Appliance Connection "{0}" was not found to be the default connection. Setting as default.' -f ${Global:ConnectedSessions}[0].Name | Write-Warning + + $Global:ConnectedSessions[0].SetDefault($True) + + } + + Break + + } + + if ($ApplianceConnection -is [System.String]) + { + + "[{0}] Connection Name provided. Looking in Global connection tracker variable." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $ApplianceConnection = ${Global:ConnectedSessions} | Where-Object Name -eq $ApplianceConnection + + } + + Catch [System.Management.Automation.ValidationMetadataException] + { + + "[{0}] Connection was not found. Looking for matching name in Global connection tracker variable." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $ApplianceConnection = ${Global:ConnectedSessions} | Where-Object Name -Match $ApplianceConnection + + } + + Catch + { + + $_Message = "Unable to find an appliance connection with the provided ApplianceConnection Name, {0}. Please provide the Connection Object or validate the Name and try again." -f $ApplianceConnection + $ErrorRecord = New-ErrorRecord InvalidOperationException ApplianceConnectionNotFound ObjectNotFound 'ApplianceConnection' -Message $_Message + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + Process + { + + if ($ApplianceConnection -isnot [HPEOneView.Appliance.Connection]) + { + + $ExceptionMessage = "An invalid connection argument value type was provided, {0}. Please provide either a [String] or [HPEOneView.Appliance.Connection] object." -f $ApplianceConnection + $ErrorRecord = New-ErrorRecord InvalidOperationException InvalidConnectionParameterValue InvalidArgument 'ApplianceConnection' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + # Check for existing Default Connection + if (${Global:ConnectedSessions} | Where-Object Default) + { + + # Unset it + (${Global:ConnectedSessions} | Where-Object Default).SetDefault($false) + + } + + "[{0}] Setting {1} as the new default Appliance Connection." -f $MyInvocation.InvocationName.ToString().ToUpper(), $ApplianceConnection.Name | Write-Verbose + + (${Global:ConnectedSessions} | Where-Object Name -eq $ApplianceConnection.Name).SetDefault($true) + + } + + End + { + + Return ${Global:ConnectedSessions} + + } + +} + +function Test-OVAuth +{ + + [CmdletBinding ()] + Param + ( + + [Parameter (Mandatory = $false, ValueFromPipeline)] + [AllowEmptyString()] + [Object]$Appliance + + ) + + Begin + { + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Caller: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if ($PSBoundParameters['Appliance']) + { + + "[{0}] Verify Auth for {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Appliance | Write-Verbose + + } + + else + { + + "[{0}] -Appliance value via pipeline." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $PipelineInput = $True + + } + + $_ApplianceConnections = [System.Collections.ArrayList]::new() + + } + + Process + { + + if ([String]::IsNullOrWhiteSpace($Appliance)) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "$($Caller):$($_Appliance)" -Message 'No default active HPOV connection session found (check ${Global:ConnectedSessions} global variable.) Using this cmdlet requires either a default connection or the -ApplianceConnection parameter. Please use Connect-OVMgmt, if required, to establish a connection, or set a default connection and then try your command again.' + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + if ($PipelineInput) + { + + "[{0}] Verify Auth for {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Appliance.Name | Write-Verbose + + } + + if ($Appliance -is [System.Collections.IEnumerable]) + { + + ForEach ($_Appliance in $Appliance) + { + + Switch ($_Appliance.GetType().FullName) + { + + 'HPEOneview.Appliance.Connection' + { + + "[{0}] Received HPEOneview.Appliance.Connection Object: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), ($_Appliance | Out-String) | Write-Verbose + + If (-not(${Global:ConnectedSessions} | Where-Object name -eq $_Appliance.Name)) + { + + $ExceptionMessage = "No Appliance connection session found for '{0}' within `$Global:ConnectedSessions global variable. This CMDLET requires at least one active connection to an appliance. Please use Connect-OVMgmt to establish a connection, then try your command again." -f $_Appliance.Name + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "$($Caller):$($_Appliance.Name)" -Message $ExceptionMessage + + } + + if ($_Appliance.SessionID -eq 'TemporaryConnection') + { + + $ExceptionMessage = "The ApplianceConnection provided is a Temporary Connection, which is an invlaid state your PowerShell environment has become. Plesae restart your session and try your calls again." + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException InvalidApplianceConnectionState InvalidOperation "$($Caller):$($_Appliance.Name)" -Message $ExceptionMessage + + } + + $_Appliance = $Appliance + + } + + 'System.String' + { + + if (-not(${Global:ConnectedSessions} | Where-Object name -eq $_Appliance)) + { + + $ExceptionMessage = "No connection session found for '{0}' within `$Global:ConnectedSessions global variable. This CMDLET requires at least one active connection to an appliance. Please use Connect-OVMgmt to establish a connection, then try your command again." -f $_Appliance + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "$($Caller):$($_Appliance)" -Message $ExceptionMessage + + } + + elseif (${Global:ConnectedSessions} | Where-Object name -eq $_Appliance) + { + + $_Appliance = ${Global:ConnectedSessions} | Where-Object name -eq $_Appliance + + } + + } + + {'System.Management.Automation.PSCustomObject', 'HPEOneView.Library.ApplianceConnection' -contains $_} + { + + "[{0}] Received PSCustomObject: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), ($_Appliance | Out-String) | Write-Verbose + + If (-not(${Global:ConnectedSessions} | Where-Object name -eq $_Appliance.Name)) + { + + $ExceptionMessage = "No Appliance connection session found for '{0}' within `$Global:ConnectedSessions global variable. This CMDLET requires at least one active connection to an appliance. Please use Connect-OVMgmt to establish a connection, then try your command again." -f $_Appliance.Name + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "$($Caller):$($_Appliance.Name)" -Message $ExceptionMessage + + } + + $_Appliance = ${Global:ConnectedSessions} | Where-Object name -eq $_Appliance.Name + + } + + default + { + + "[{0}] Unsupported ApplianceConnection object: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_Appliance.GetType().FullName | Write-Verbose + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NotaValidApplianceConnection AuthenticationError "$($Caller)" -Message "The provided appliance object is not valid, as it is neither an [HPEOneView.Appliance.Connection] object, [String] value representing a potentially valid Appliance Connection, or a [PSCustomObject] property of a resource object obtained from an appliance. Please correct the ApplianceConnection Parameter value, and then try your command again." + + } + + } + + If ($ErrorRecord) + { + + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Else + { + + [void]$_ApplianceConnections.Add($_Appliance) + + } + + } + + } + + else + { + + "[{0}] `$Appliance is [{1}]" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Appliance.GetType().FullName | Write-Verbose + + Switch ($Appliance.GetType().FullName) + { + + 'HPEOneview.Appliance.Connection' + { + + "[{0}] Received HPEOneview.Appliance.Connection Object: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), ($Appliance | Out-String) | Write-Verbose + + If (-not(${Global:ConnectedSessions} | Where-Object name -eq $Appliance.Name)) + { + + $ExceptionMessage = "No Appliance connection session found for '{0}' within `$Global:ConnectedSessions global variable. This CMDLET requires at least one active connection to an appliance. Please use Connect-OVMgmt to establish a connection, then try your command again." -f $_Appliance.Name + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "$($Caller):$($_Appliance.Name)" -Message $ExceptionMessage + + } + + } + + 'System.String' + { + + if (-not(${Global:ConnectedSessions} | Where-Object name -eq $_Appliance)) + { + + $ExceptionMessage = "No connection session found for '{0}' within `$Global:ConnectedSessions global variable. This CMDLET requires at least one active connection to an appliance. Please use Connect-OVMgmt to establish a connection, then try your command again." -f $_Appliance + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "$($Caller):$($_Appliance)" -Message $ExceptionMessage + + } + + elseif (${Global:ConnectedSessions} | Where-Object name -eq $_Appliance) + { + + $Appliance = ${Global:ConnectedSessions} | Where-Object name -eq $Appliance + + } + + } + + {'System.Management.Automation.PSCustomObject', 'HPEOneView.Library.ApplianceConnection' -contains $_} + { + + If (-not(${Global:ConnectedSessions} | Where-Object name -eq $Appliance.Name)) + { + + $ExceptionMessage = "No Appliance connection session found for '{0}' within `$Global:ConnectedSessions global variable. This CMDLET requires at least one active connection to an appliance. Please use Connect-OVMgmt to establish a connection, then try your command again." -f $Appliance.Name + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "$($Caller):$($Appliance.Name)" -Message $ExceptionMessage + + } + + $Appliance = ${Global:ConnectedSessions} | Where-Object name -eq $Appliance.Name + + } + + default + { + + "[{0}] Unsupported ApplianceConnection object." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NotaValidApplianceConnection AuthenticationError "$($Caller)" -Message "The provided appliance object is not valid, as it is neither an [HPEOneView.Appliance.Connection] object, [String] value representing a potentially valid Appliance Connection, or a [PSCustomObject] property of a resource object obtained from an appliance. Please correct the ApplianceConnection Parameter value, and then try your command again." + + } + + } + + If ($ErrorRecord) + { + + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Else + { + + [void]$_ApplianceConnections.Add($Appliance) + + } + + } + + } + + End + { + + Return $_ApplianceConnections + + } + +} + +function New-OVResource +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding ()] + Param + ( + + [Parameter (Mandatory)] + [ValidateNotNullOrEmpty()] + [String]$Uri, + + [Parameter (ValueFromPipeline, Mandatory)] + [Alias('Resource')] + [ValidateNotNullOrEmpty()] + [object]$InputObject, + + [Parameter (Mandatory = $False, ValueFromPipelineByPropertyName)] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $_NewResourceCollection = [System.Collections.ArrayList]::new() + + } + + Process + { + + Try + { + + $_resp = Send-OVRequest -Uri $uri -Method POST -Body $InputObject -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + [void]$_NewResourceCollection.Add($_resp) + + } + + End + { + + Return $_NewResourceCollection + + } + +} + +function Set-OVResource +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + [CmdletBinding ()] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline)] + [Alias('Resource')] + [ValidateNotNullOrEmpty()] + [ValidateScript({$_.Uri})] + [object]$InputObject, + + [Parameter (Mandatory = $false)] + [Switch]$Force, + + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName)] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + Process + { + + $InputObject = $InputObject.PSObject.Copy() + + if ($Force.IsPresent) + { + + $InputObject.uri += "?force=true" + + } + + Try + { + + $_resp = Send-OVRequest -Uri $InputObject.uri -Method PUT -Body $InputObject -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $_resp + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Remove-OVResource +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding ()] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline)] + [Alias('Resource')] + [ValidateNotNullorEmpty()] + [Alias ("ro",'nameOruri','uri','name')] + [object]$InputObject, + + [Parameter (Mandatory = $false)] + [Switch]$force, + + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName)] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $_RemoveResourceCollection = [System.Collections.ArrayList]::new() + + } + + Process + { + + switch ($InputObject.GetType().Name) + { + + "PSCustomObject" + { + + "[{0}] Resource object passed." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + "[{0}] Name: $($InputObject.name)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + "[{0}] URI: $($InputObject.uri)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + "[{0}] Type: $($InputObject.type)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + [void]$_RemoveResourceCollection.Add($InputObject) + + } + + "String" + { + + # NameOrUri value is a URI + if ($InputObject.StartsWith("/rest")) + { + + "[{0}] Resource URI passed '$($InputObject)', getting object" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $_resource = Send-OVRequest $InputObject -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + [void]$_RemoveResourceCollection.Add($_resource) + + } + + # It's a string value + else + { + + "[{0}] Resource name provided: $($InputObject)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + "[{0}] Querying appliance index for resource." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + # Use Index filtering to locate object + Try + { + + $_resources = Send-OVRequest ($indexUri + "?filter=name='$InputObject'") -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + "[{0}] Found $($_resources.count) resources." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if($_resources.members) + { + + # Error should only be displayed if a Name was provided, and it wasn't globally unique on the appliance (i.e. Server Profile and Ethernet Network with the same name, which is completely valid.) + if($_resources.count -gt 1) + { + + "[{0}] Resources found: $($_resources.members | % { $_.name + " of type " + $_.category })" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $ErrorRecord = New-ErrorRecord InvalidOperationException ResourceNotUnique LimitsExceeded 'InputObject' -Message "'$InputObject' is not unique. Located $($_resources.count) resources with the same value." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + else + { + + [void]$_RemoveResourceCollection.Add($_resources.members) + + } + + } + + else + { + + $ErrorRecord = New-ErrorRecord InvalidOperationException ResourceNotFound ObjectNotFound 'InputObject' -Message "Resource '$InputObject' not found. Please check the resource value provided and try the call again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + } + + } + + } + + End + { + + $n = 1 + + ForEach ($_resource in $_RemoveResourceCollection) + { + + "[{0}] Processing '$($_resource.name)', $n of $($_RemoveResourceCollection.Count)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if ([Bool]$force) + { + + $_resource.uri += "?force=true" + + } + + $_Etag = "*" + + if ($null -ne $_resource.eTag) + { + + $_Etag = $_resource.eTag + + } + + Try + { + + Send-OVRequest -Uri $_resource.uri -Method DELETE -AddHeader @{'If-Match' = $_Etag } -Hostname $_resource.ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $n++ + + } + + } + +} + +function ConvertFrom-HTML +{ + + [CmdletBinding ()] + Param + ( + + [Parameter (ValueFromPipeline, Mandatory)] + [ValidateNotNullOrEmpty()] + [System.String] $html, + + [Switch]$NoClobber + + ) + + Begin { } + + Process + { + + # remove line breaks, replace with spaces + if (-not ($NoClobber.ispresent)) { $html = $html -replace "(`r|`n|`t)", " " } + + # remove invisible content + @('head', 'style', 'script', 'object', 'embed', 'applet', 'noframes', 'noscript', 'noembed') | ForEach-Object {$html = $html -replace "<$_[^>]*?>.*?", "" } + + # Condense extra whitespace + $html = $html -replace "( )+", " " + + # Add line breaks + @('div','p','blockquote','h[1-9]') | ForEach-Object { $html = $html -replace "]*?>.*?", ("`n" + '$0' )} + + # Add line breaks for self-closing tags + @('div','p','blockquote','h[1-9]','br') | ForEach-Object { $html = $html -replace "<$_[^>]*?/>", ('$0' + "`n")} + + # Strip tags + $html = $html -replace "<[^>]*?>", "" + + # replace common entities + @( + @("&bull;", " * "), + @("&lsaquo;", "<"), + @("&rsaquo;", ">"), + @("&(rsquo|lsquo);", "'"), + @("&(quot|ldquo|rdquo);", '"'), + @("&trade;", "(tm)"), + @("&frasl;", "/"), + @("&(quot|#34|#034|#x22);", '"'), + @('&(amp|#38|#038|#x26);', "&"), + @("&(lt|#60|#060|#x3c);", "<"), + @("&(gt|#62|#062|#x3e);", ">"), + @('&(copy|#169);', "(c)"), + @("&(reg|#174);", "(r)"), + @("&nbsp;", " "), + @("&(.{2,6});", ""), + @(" ", " ") + ) | ForEach-Object { $html = $html -replace $_[0], $_[1] } + + } + + End + { + + return $html + + } + +} + +function Start-OVLibraryTrace +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding ()] + Param + ( + + [Parameter (Mandatory = $false)] + [String]$Location = (Get-Location).path + + ) + + Throw "This Cmdlet is now deprecated. Please use Get-OVCommandTrace instead." + +} + +function Stop-OVLibraryTrace +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding ()] + Param + () + + Throw "This Cmdlet is now deprecated. Please use Get-OVCommandTrace instead." + +} + +function Get-OVCommandTrace +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding ()] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline)] + [ValidateNotNullOrEmpty()] + [Alias('Command')] + [ScriptBlock]$ScriptBlock = {}, + + [Parameter (Mandatory = $false)] + [Switch]$Passthru, + + [Parameter (Mandatory = $false)] + [ValidateNotNullOrEmpty()] + [String]$Location = (Get-Location).path + + ) + + Begin + { + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Caller: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if ($Caller -eq 'Get-OVCommandTrace') + { + + Throw "You cannot use the Cmdlet to trace itself. Please specify a different HPE OneView PowerShell Cmdlet." + + } + + $_TranscriptFile = $Location + '\' + (get-date -uformat %y%m%d%H%M) + '_HPEOV_transcript.log' + + if ([RegEx]::Match($host.name, 'ISE', $RegExInsensitiveFlag).Success -and $PSVersionTable.PSVersion -lt '5.0') + { + + Start-IseTranscript $_TranscriptFile | Out-Null + + } + + else + { + + Try + { + + '[{0}] Starting Transcript logging.' -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + '[{0}] Generating new trace file: {1}' -f $MyInvocation.InvocationName.ToString().ToUpper(), $_TranscriptFile | Write-Verbose + + Start-Transcript $_TranscriptFile | Out-Null + + } + + catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + ($PSLibraryVersion | Out-String) | Write-Verbose -Verbose:$true + + # Enable .Net Class Library tracing + [HPEOneView.Config]::EnableVerbose = $true + [HPEOneView.Config]::EnableDebug = $true + + } + + Process + { + + $sb = [System.Text.StringBuilder]::new() + [void]$sb.Append("`$VerbosePreference = 'Continue'`n") + [void]$sb.Append($ScriptBlock.ToString()) + + '[{0}] ScritpBlock to execute: {1}' -f $MyInvocation.InvocationName.ToString().ToUpper(), $sb.ToString() | Write-Verbose + + Invoke-Command -ScriptBlock ([Scriptblock]::Create($sb.ToString())) -ErrorVariable CapturedError -Outvariable ReturnToCaller | Out-Null + + if ($null -ne $CaptureError) + { + + $CapturedError | Write-Host + + } + + ([String]::Join('',(1..80 | ForEach-Object { "-" }))) | Write-Verbose -Verbose:$true + + if ($PSBoundParameters['Passthru']) + { + + Return $ReturnToCaller + + } + + } + + End + { + + [HPEOneView.Config]::EnableVerbose = $false + [HPEOneView.Config]::EnableDebug = $false + + Stop-Transcript | Out-Null + + '[{0}] Stopped transcript logging.' -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + [System.IO.FileInfo]$_TranscriptFile + + } + +} + +Function Start-iseTranscript +{ + + Param + ( + + [String]$logname = (Get-logNameFromDate -path "C:\fso" -postfix " $(hostname)" -Create) + + ) + + $transcriptHeader = '************************************** + Windows PowerShell ISE Transcript Start + Start Time: {0} + UserName: {1} + UserDomain: {2} + ComputerName: {3} + Windows version: {4} + ************************************** + Transcript started. Output file is {5}' -f [DateTime]::Now(), $env:username, $env:USERDNSDOMAIN, $env:COMPUTERNAME, (Get-CimObject win32_operatingsystem).version, $logname + + $transcriptHeader >> $logname + + $psISE.CurrentPowerShellTab.Output.Text >> $logname + + # Keep current Prompt + if ($null -eq $__promptDef) + { + + $__promptDef = (Get-ChildItem Function:Prompt).Definition + $promptDef = (Get-ChildItem Function:Prompt).Definition + + } + + else + { + + $promptDef = $__promptDef + + } + + $newPromptDef = ' + if ($global:_LastText -ne $psISE.CurrentPowerShellTab.Output.Text) + { + + Compare-Object -ReferenceObject $global:_LastText.Split("`n") -DifferenceObject $psISE.CurrentPowerShellTab.Output.Text.Split("`n") | ? { $_.SideIndicator -eq "=>" } | % { $_.InputObject.TrimEnd() } | Out-File -FilePath ($Global:_DSTranscript) -Append + $global:_LastText = $psISE.CurrentPowerShellTab.Output.Text + + } + ' + $promptDef + + New-Item -Path Function: -Name "Global:Prompt" -Value ([ScriptBlock]::Create($newPromptDef)) -Force | Out-Null + +} + +function Invoke-OVWebBrowser +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = 'Default')] + + Param + ( + + [Parameter (Mandatory = $false)] + [ValidateSet ("Dashboard", + "Settings", + "ServerProfiles", + "ServerProfileTemplates", + "ServerHardware", + "Enclosures", + "RackManagers", + "LogicalEnclosures", + "Networks", + "LogicalInterconnects", + "LogicaInterconnectGroups", + "StorageSystems", + "StoragePools", + "StorageVolumes")] + [String]$Resource = "Dashboard", + + [Parameter (Mandatory = $false)] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $_ApplianceStatus = [System.Collections.ArrayList]::new() + + } + + Process + { + + ForEach ($_appliance in $ApplianceConnection) + { + + "[{0}] Processing '{1}' Appliance (of {2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name, $ApplianceConnection.Count | Write-Verbose + + $_ResourceMap = @{ + Dashboard = 'dashboard'; + Settings = 'settings/show/overview'; + ServerProfiles = 'profiles'; + ServerProfileTemplates = 'profile-templates'; + ServerHardware = 'server-hardware'; + Enclosures = 'enclosures'; + RackManagers = 'rackmanagers'; + LogicalEnclosures = 'logicalenclosures'; + Networks = 'network'; + LogicalInterconnects = 'logicalswitch'; + LogicaInterconnectGroups = 'switchtemplate'; + StorageSystems = 'storage-systems'; + StoragePools = 'storage-pools'; + StorageVolumes = 'storage-volumes' + } + + Start-Process ("https://{0}/#/{1}?s_sid={2}" -f $_appliance.Name, $_ResourceMap.$Resource, $_appliance.SessionID) + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Show-OVActiveUser +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = 'Default')] + + Param + ( + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + Process + { + + ForEach ($_appliance in $ApplianceConnection) + { + + "[{0}] Processing '{1}' Appliance (of {2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name, $ApplianceConnection.Count | Write-Verbose + + Try + { + + $_ActiveUserSessions = Send-OVRequest -Uri $ActiveUserSessionsUri -Hostname $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + ForEach ($_usersession in $_ActiveUserSessions.members) + { + + "[{0}] Processing '{1}' Appliance (of {2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_usersession.username, $_ActiveUserSessions.count | Write-Verbose + + [HPEOneView.Appliance.ActiveUserSession]::new($_usersession.username, $_usersession.loginDomain, $_usersession.clientHost, $_usersession.timeCreated, [HPEOneView.Library.ApplianceConnection]$_usersession.ApplianceConnection) + + } + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function ConvertTo-OVPowerShellScript +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = 'Default')] + + Param + ( + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = 'Default')] + [ValidateNotNullorEmpty()] + [Object]$InputObject, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullorEmpty()] + [System.IO.FileInfo]$Export, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [Alias ('NoClobber')] + [ValidateNotNullorEmpty()] + [Switch]$Append + + ) + + Begin + { + + $DoubleQuote = '"' + $CRLF = "`r`n" + $Delimiter = "\" # Delimiter for CSV profile file + $SepHash = ";" # USe for multiple values fields + $Sep = ";" + $hash = '@' + $SepChar = '|' + $CRLF = "`r`n" + $OpenDelim = "{" + $CloseDelim = "}" + $OpenArray = "(" + $CloseArray = ")" + $CR = "`n" + $Comma = ',' + $Equal = '=' + $Dot = '.' + $Underscore = '_' + $Space = ' ' + $TAB = ' ' + $MAXLEN = 35 + + $Syn12K = 'SY12000' # Synergy enclosure type + [Hashtable]$LogicalDiskCmdletTypeEnum = @{ + + SasHdd = 'SAS'; + SataHdd = 'SATA'; + Sas = 'SASSSD'; + SasSsd = 'SASSSD'; + SataSsd = 'SATASSD'; + NVMeSsd = 'NVMeSas'; + NVMeHdd = 'NVMeSata' + + } + + } + + Process + { + + '[{0}] Processing "{1} ({2})" resource.' -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject.name, $InputObject.uri | Write-Verbose + + $ExportToFile = $PSBoundParameters['Export'] + + $ApplianceConnection = $InputObject.ApplianceConnection + + function Insert-BlankLine + { + + "" + + } + + Function Get-NamefromUri([String]$uri) + { + + $name = $null + + if (-not [String]::IsNullOrEmpty($Uri)) + { + + Try + { + + $resource = Send-OVRequest -Uri $Uri -ApplianceConnection $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + switch ($resource.category) + { + + $ResourceCategoryEnum.IPv4Subnet + { + + $name = $resource.networkId + + } + + 'storage-systems' + { + + $name = $resource.members.displayName + + } + + default + { + + $name = $resource.name + + } + + } + + return $name + + } + + Function Generate-CustomVarCode ([String]$Prefix, [String]$Suffix, [String]$Value, $indentlevel = 0, $isVar = $True) + { + + if (-not $Prefix.StartsWith("$") -and -not $Prefix.StartsWith("#")) + { + + $Prefix = '${0}' -f $Prefix + + } + + $Prefix = $TAB * $indentlevel + $Prefix + $VarName = '{0}{1}' -f $Prefix, $Suffix + + if ($Value) + { + + # Handle boolean values that were converted to String, and should still be a boolean value + if ('True', 'False' -icontains $Value -and -not $Value.StartsWith("$")) + { + + $Value = '$' + $Value + + } + + $len = $varName.Length + $len = if ($len -ge $MAXLEN) {$MAXLEN} else { $MAXLEN - $len} + $pad = $Space * $len + $out = '{0}{1} = {2}' -f $VarName, $pad, $Value + + } + + else + { + + $out = '{0}' -f $VarName + + } + + return $out + + } + + Function rebuild-fwISO ($BaselineObj) + { + + # ----------------------- Rescontruct FW ISO filename + # When uploading the FW ISO file into OV, all the '.' chars are replaced with "_" + # so if the ISO filename is: SPP_2018.06.20180709_for_HPE_Synergy_Z7610-96524.iso + # OV will show $fw.ISOfilename ---> SPP_2018_06_20180709_for_HPE_Synergy_Z7610-96524.iso + # + # This helper function will try to re-build the original ISO filename + + $newstr = $null + + switch ($BaselineObj.GetType().Fullname) + { + + 'HPEOneview.Appliance.Baseline' + { + + $arrList = [System.Collections.ArrayList]::new() + + $StrArray = $BaselineObj.ResourceId.Split($Underscore) + + ForEach ($string in $StrArray) + { + + [void]$arrList.Add($string.Replace($dot, $Underscore)) + + } + + $newstr = "{0}.iso" -f [String]::Join($Underscore, $arrList.ToArray()) + + } + + 'HPEOneview.Appliance.BaselineHotfix' + { + + $newStr = $BaselineObj.FwComponents.Filename + + } + + default + { + + $newstr = $null + + } + + } + + return $newStr + + } + + Function DisplayOutput ([System.Collections.ArrayList]$code, [bool]$InternalAppend = $false) + { + + if ($ExportToFile) + { + + if (-not $Append -and -not $InternalAppend) + { + + [System.IO.File]::WriteAllLines([String]$Export, $code, [System.Text.Encoding]::UTF8) + + } + + else + { + + [System.IO.File]::AppendAllLines([String]$Export, [string[]]$code.ToArray(), [System.Text.Encoding]::UTF8) + + } + + } + + else + { + + $code.ToArray() + + Insert-BlankLine + + } + + } + + Function Generate-fwBaseline-Script ($InputObject) + { + + foreach ($fwBase in $InputObject) + { + + $scriptCode = [System.Collections.ArrayList]::new() + + # - OV strips the dot from the ISOfilename, so we have to re-construct it + $filename = rebuild-fwISO -BaselineObj $fwBase + + [void]$scriptCode.Add(('## ------ Upload baseline "{0}"' -f $filename)) + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'filename' -Value ('"{0}"' -f $filename))) + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'isofolder' -Value ('read-host "Provide the folder location for "{0}"' -f $filename))) + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'isofile' -Value 'Join-Path $isofolder $filename')) + [void]$scriptCode.Add('Add-OVBaseline -file $isofile') + + DisplayOutput -Code $scriptCode + + } + + } + + Function Generate-proxy-Script ($InputObject) + { + + $scriptCode = [System.Collections.ArrayList]::new() + + $proxy = $InputObject + $server = $proxy.Server + + if ($server) + { + + $protocol = $proxy.protocol + $port = $proxy.port + $username = $proxy.username + $server = $server + + [void]$scriptCode.Add('## ------ Configure appliance proxy to "{0}"' -f $server) + $serverParam = ' -server $server' + $portParam = ' -port $port' + $credParam = $null + $userParam = $null + $isHttps = if ($protocol -eq 'Https') {$true} else {$false} + $protocolParam = ' -Https:$isHttps' + + + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'server' -Value ('"{0}"' -f $server))) + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'port' -Value ('{0}' -f $port))) + + if (-not [String]::IsNullOrEmpty($username)) + { + + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'username' -Value ('"{0}"' -f $username))) + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'password' -Value ('Read-Host -prompt "Enter password for user {0} for proxy server" -AsSecureString' -f $username))) + + $userParam = ' -Username {0} -Password $password' -f $username + + } + + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'isHttps' -Value ('${0}' -f $isHttps.ToString()))) + [void]$scriptCode.Add(('Set-OVApplianceProxy -hostname $server{0}{1}{2}' -f $userParam, $portParam, $protocolParam)) + + DisplayOutput -Code $scriptCode + + } + + } + + Function Generate-scope-Script ($InputObject) + { + + $scriptCode = [System.Collections.ArrayList]::new() + + $s = $InputObject + + $name = $s.name + $desc = $s.description + $members = $s.members + + $descParam = $null + $descCode = $null + + [void]$scriptCode.Add('## ------ Create scope {0}' -f $name) + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'name' -Value ('"{0}"' -f $name))) + + if ($desc) + { + + $descParam = ' -description $description' + + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'description' -Value ('"{0}"' -f $desc))) + + } + + if ($s.Members.Count -gt 0) + { + + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'thisScope' -Value ('New-OVScope -Name $name {0}' -f $descParam))) + + [void]$scriptCode.Add(('{0}## ------ Create resources to be included in scope {1}' -f $CR, $name)) + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'resources' -Value '[System.Collections.ArrayList]::new()')) + + foreach ($m in $members) + { + + $scopeMemberCode = $scopeMemberType = $null + + $m_type = $m.type + + switch ($m_type) + { + + 'EthernetNetwork' + { + + $scopeMemberCode = 'Get-OVNetwork -Name "{0}" -Type Ethernet' -f $m.name + + } + + 'FCoENetwork' + { + + $scopeMemberCode = 'Get-OVNetwork -Name "{0}" -Type FCoE' -f $m.name + + } + + 'FCNetwork' + { + + $scopeMemberCode = 'Get-OVNetwork -Name "{0}" -Type FC' -f $m.name + + } + + 'LogicalInterconnectGroup' + { + + $scopeMemberCode = 'Get-OVLogicalInterconnectGroup -Name "{0}"' -f $m.name + + } + + 'LogicalInterconnect' + { + + $scopeMemberCode = 'Get-OVLogicalInterconnect -Name "{0}"' -f $m.name + + } + + 'LogicalEnclosure' + { + + $scopeMemberCode = 'Get-OVLogicalEnclosure -Name "{0}"' -f $m.name + + } + + 'ServerProfileTemplate' + { + + $scopeMemberCode = 'Get-OVServerProfileTemplate -Name "{0}"' -f $m.name + + } + + 'ServerHardware' + { + + $scopeMemberCode = 'Get-OVServer -Name "{0}"' -f $m.name + + } + + 'StorageVolumeTemplate' + { + + $scopeMemberCode = 'Get-OVStorageVolumeTemplate -Name "{0}"' -f $m.name + + } + + 'StorageVolume' + { + + $scopeMemberCode = 'Get-OVStorageVolume -Name "{0}"' -f $m.name + + } + + 'StoragePool' + { + + + $scopeMemberCode = 'Get-OVStoragePool -Name "{0}"' -f $m.name + + } + + 'FirmwareBundle' + { + + $scopeMemberCode = 'Get-OVbaseline -Name "{0}"' -f $m.name + + } + + default {} + + } + + [void]$scriptCode.Add('[void]$resources.Add({0})' -f $scopeMemberCode) + + } + + [void]$scriptCode.Add('Add-OVResourceToScope -Scope $thisScope -InputObject $resources') + + } + + else + { + + [void]$scriptCode.Add('New-OVScope -Name $name {0}' -f $descParam) + + } + + DisplayOutput -Code $scriptCode + + } + + # Local OneView user accounts, with permissions and SBAC + Function Generate-User-Script ($InputObject) + { + + $scriptCode = [System.Collections.ArrayList]::new() + $scopePermissions = [System.Collections.ArrayList]::new() + $permissionsCode = [System.Collections.ArrayList]::new() + + $User = $InputObject + + $userName = $User.userName + $fullName = $User.fullName + $desc = $User.description + $permissions = $User.permissions + $emailAddress = $User.emailAddress + $officePhone = $User.officePhone + $mobilePhone = $User.mobilePhone + + $fullNameParam = $permissionsParam = $emailAddressParam = $officePhoneParam = $mobilePhoneParam = $descParam = $null + $roleParam = $scopeParam = $null + + [void]$scriptCode.Add('# ------ Create user {0}' -f $userName) + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'userName' -Value ('"{0}"' -f $userName))) + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'password' -Value ('Read-Host -Message "Provide the password for {0}" -AsSecureString' -f $userName))) + + if ($userName -ne $fullName -and -not [String]::IsNullOrEmpty($fullName) ) + { + + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'fullName' -Value ('"{0}"' -f $fullName))) + $fullNameParam = ' -Fullname $fullname' + + } + + if (-not [String]::IsNullOrWhiteSpace($emailAddress)) + { + + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'emailAddress' -Value ('"{0}"' -f $emailAddress))) + $emailAddressParam = ' -EmailAddress $emailAddress' + + } + + if (-not [String]::IsNullOrWhiteSpace($officePhone)) + { + + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'officePhone' -Value ('"{0}"' -f $officePhone))) + $officePhoneParam = ' -OfficePhone $officePhone' + + } + + if (-not [String]::IsNullOrWhiteSpace($mobilePhone)) + { + + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'mobilePhone' -Value ('"{0}"' -f $mobilePhone))) + $mobilePhoneParam = ' -MobilePhone $mobilePhone' + + } + + $n = 1 + + ForEach ($permission in $permissions) + { + + # Roles first, which have no scopeUri value + $ScopePermission = [PSCustomObject]@{Role = $null; Scope = '"All"'} + + $ScopePermission.Role = $permission.roleName + + if (-not [String]::IsNullOrWhiteSpace($permission.scopeUri)) + { + + $ScopeName = Get-NamefromUri $permission.scopeUri + + $ScopePermission.Scope = '$Scope{0}' -f $n + + $ScopeRoleVarCode = Generate-CustomVarCode -Prefix "Scope" -Suffix $n -Value ('Get-OVScope -Name "{0}"' -f $ScopeName) + + [void]$scriptCode.Add('{0}' -f $ScopeRoleVarCode) + + $n++ + + } + + [void]$scopePermissions.Add($ScopePermission) + + } + + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'permissions' -Value '@(')) + + $c = 1 + + ForEach ($perm in $scopePermissions) + { + + $eol = ',' + + if ($c -eq $n) + { + + $eol = $null + + } + + [void]$scriptCode.Add((' {0}Role = "{1}"; Scope = {2}{3}{4}' -f '@{', $perm.Role, $perm.Scope, '}', $eol)) + + $c++ + + } + + [void]$scriptCode.Add(')') + + $permissionsParam = ' -ScopePermissions $permissions' + + [void]$scriptCode.Add(('New-OVUser -Username $userName -Password $password{0}{1}{2}{3}{4}{5}' -f $fullNameParam, $descParam, $emailAddressParam, $officePhoneParam, $mobilePhoneParam, $permissionsParam)) + + DisplayOutput -Code $scriptCode + + } + + # User and Directory Group permissions + Function Generate-RBAC-Script ($InputObject) + { + + $scriptCode = [System.Collections.ArrayList]::new() + $scopePermissions = [System.Collections.ArrayList]::new() + + $Group = $InputObject + + $groupName = $Group.egroup + $dirName = $Group.loginDomain + $permissions = $Group.permissions + + [void]$scriptCode.Add('# ------ Create authentication directory group {0}' -f $groupName) + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'groupName' -Value ('"{0}"' -f $groupName))) + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'dirName' -Value ('"{0}"' -f $dirName))) + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'credentials' -Value ('Get-Credential -Message "Provide {0} authentication directory username and password"' -f $dirName))) + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'directory' -Value ('Get-OVLdapDirectory -Name $dirName'))) + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'thisGroup' -Value ('Show-OVLdapGroups -Directory $directory -GroupName $groupName -Credential $credentials'))) + + $n = 1 + + ForEach ($permission in $permissions) + { + + # Roles first, which have no scopeUri value + $ScopePermission = [PSCustomObject]@{Role = $null; Scope = "All"} + + $ScopePermission.Role = $permission.roleName + + if (-not [String]::IsNullOrWhiteSpace($permission.scopeUri)) + { + + $ScopeName = Get-NamefromUri $permission.scopeUri + + $ScopePermission.Scope = '$Scope{0}' -f $n + + $ScopeRoleVarCode = Generate-CustomVarCode -Prefix "Scope" -Suffix $n -Value ('Get-OVScope -Name "{0}"' -f $ScopeName) + + [void]$scriptCode.Add(('{0}' -f $ScopeRoleVarCode)) + + $n++ + + } + + [void]$scopePermissions.Add($ScopePermission) + + } + + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'permissions' -Value '@(')) + + $c = 1 + + ForEach ($perm in $scopePermissions) + { + + $eol = ',' + + if ($c -eq $n) + { + + $eol = $null + + } + + [void]$scriptCode.Add((' {0}Role = "{1}"; Scope = {2}{3}{4}' -f '@{', $perm.Role, $perm.Scope, '}', $eol)) + + $c++ + + } + + [void]$scriptCode.Add(')') + + [void]$scriptCode.Add('New-OVLdapGroup -Directory $directory -Credential $credentials -Roles $permissions') + + DisplayOutput -Code $scriptCode + + } + + # Directory authentication, including default auth directory and local login policies + Function Generate-DirectoryAuthentication-Script ($InputObject) + { + + $scriptCode = [System.Collections.ArrayList]::new() + + $Username = $serviceAccountParam = $AuthProtocolParam = $null + $UsrNameAttribParam = $LdapOUsParam = $null + + $Directory = $InputObject + $Name = $Directory.name + $AuthProt = $Directory.authProtocol + $UsrNameAttrib = $Directory.userNamingAttribute + $BaseDN = $Directory.baseDN + $OrgUnits = $Directory.orgUnits + $DirBindType = $Directory.directoryBindingType + $DirUsername = $Directory.credential.userName + $Servers = $Directory.directoryServers + + [void]$scriptCode.Add(('# ------ Create authentication directory {0} ({1})' -f $Name, $BaseDN)) + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'dirName' -Value ('"{0}"' -f $Name))) + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'baseDN' -Value ('"{0}"' -f $BaseDN))) + + if ($DirBindType -eq 'SERVICE_ACCOUNT') + { + + $serviceAccountParam = ' -ServiceAccount' + $Username = $DirUsername + + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'credential' -Value ('Get-Credential -Message "Provide authentication credentials for {0} authentication directory." -Username "{0}"' -f $Username))) + + } + + else + { + + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'credential' -Value ('Get-Credential -Message "Provide authentication credentials for {0} authentication directory."' -f $Name))) + + } + + if ($AuthProt -ne 'AD') + { + + $AuthProtocolParam = ' -OpenLDAP' + $LdapOUsParam = ' -OrganizationalUnits $ldapOrgUnits' + $UsrNameAttribParam = ' -UserNamingAttribute $usrNameAttrib' + + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'ldapOrgUnits' -Value ('"{0}"' -f $OrgUnits))) + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'usrNameAttrib' -Value ('"{0}"' -f $UsrNameAttrib))) + + } + + else + { + + $AuthProtocolParam = ' -AD' + + } + + $n = 1 + + ForEach ($server in $Servers) + { + + $ServerCode = $ServerNameCode = $ServerPortCode = $ServerCertCode = $null + + $ServerNameCode = ' -Hostname "{0}"' -f $server.directoryServerIpAddress + $ServerPortCode = ' -SSLPort {0}' -f $server.directoryServerSSLPortNumber + + if ($server.directoryServerCertificateBase64Data) + { + + [void]$scriptCode.Add('# -------- If you wish to provide the certificate in Base64 format from a file, uncomment the following line') + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix '#$certificate' -Value 'Get-ChildItem -Path "C:\Path\to\cert.cer"')) + [void]$scriptCode.Add('# -------- Comment out the following line to use the existing certificate value.') + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'certificate' -Value ('"{0}"' -f $BaseDN))) + + $ServerCertCode = ' -Certificate $certificate -TrustLeafCertificate' + + } + + $ServerCode = 'New-OVServer {0}{1}{2}' -f $ServerNameCode, $ServerPortCode, $ServerCertCode + + $ServerCode = Generate-CustomVarCode -Prefix "Server" -Suffix $n -Value $ServerCode + + [void]$scriptCode.Add(('{0}' -f $ServerCode)) + + $n++ + + } + + [void]$scriptCode.Add('$servers = @(') + + $c = 1 + + ForEach ($server in $Servers) + { + + $eol = ',' + + if ($c -eq $n) + { + + $eol = $null + + } + + [void]$scriptCode.Add(' $Server{0}' -f $c) + + $c++ + + } + + [void]$scriptCode.Add(')') + + [void]$scriptCode.Add(('New-OVLdapDirectory -Name $dirName{0}{1}{2} -BaseDN $baseDN -Servers $servers -Credential $credentials' -f $AuthProtocolParam, $LdapOUsParam, $UsrNameAttribParam)) + + DisplayOutput -Code $scriptCode + + } + + # ///TODO: OVRS, data collection schedule, Contacts, Default data center, and additional data centers with contacts + Function Generate-RemoteSupport-Script ($InputObject) + { + + $scriptCode = [System.Collections.ArrayList]::new() + + $RS = $InputObject + $companyName = $RS.companyName + $marketingOptIn = $RS.marketingOptIn + $autoEnableDevices = $RS.autoEnableDevices + $insightOnlineEnabled = $RS.InsightOnlineEnabled + + } + + Function Generate-snmp-Script ($InputObject) + { + + $scriptCode = [System.Collections.ArrayList]::new() + + $snmp = $InputObject + $readCommunity = $snmp.CommunityString + + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'readCommunity' -Value ('"{0}"' -f $readCommunity))) + [void]$scriptCode.Add('Set-OVSnmpReadCommunity -Name $readCommunity') + + #Trap destinations + Try + { + + $trapDestinations = Get-OVApplianceTrapDestination -ApplianceConnection $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + foreach ($t in $trapDestinations) + { + + $communitystr = $t.communitystring + $destinationAddress = $t.DestinationAddress + $port = $t.port + $type = $t.type + + $destParam = $formatParam = $communityParam = $portParam = $snmpV3UserParam = $null + $destCode = $formatCode = $communityCode = $portCode = $null + + if ($destinationAddress) + { + + $destParam = ' -destination $destination' + $portParam = ' -port $Port' + $formatParam = ' -SnmpFormat $type' + + [void]$scriptCode.Add(("#-- `tGenerating {0} Trap destination object for {1}" -f $type, $destinationAddress)) + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'destination' -Value ('"{0}"' -f $destinationAddress))) + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'port' -Value ('{0}' -f $port))) + + Switch ($t.GetType().Fullname) + { + + 'HPEOneview.Appliance.SnmpV1TrapDestination' + { + + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'communitystring' -Value ('"{0}"' -f $communitystr))) + + $communityParam = ' -Community $communitystring' + $type = "SNMPv1" + + } + + 'HPEOneview.Appliance.SnmpV3TrapDestination' + { + + # This needs to be expanded upon to configure SNMPv3 user + Try + { + + $snmpv3User = Get-OVSnmpV3user -Name $t.SnmpV3User -ApplianceConnection $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'snmpV3User' -Value ('Get-OVSnmpV3user -Name "{0}"' -f $t.SnmpV3User))) + $snmpV3UserParam = ' -SnmpV3User $snmpV3User' + $type = "SNMPv3" + + } + + } + + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'type' -Value ('"{0}"' -f $type))) + [void]$scriptCode.Add(('New-OVSnmpTrapDestination {0}{1}{2}{3}{4}' -f $destParam, $portParam, $formatParam, $communityParam, $snmpV3UserParam)) + + } + + } + + DisplayOutput -Code $scriptCode + + } + + Function Generate-snmpV3User-Script ($InputObject) + { + + $scriptCode = [System.Collections.ArrayList]::new() + + $user = $InputObject + $userName = $user.userName + + $securityLevelParam = $snmpv3UserPrivProtocolParam = $snmpv3UserAuthProtocolParam = $null + $authProtocolName = $privProtocolName = $null + + $securityLevelName = ($Snmpv3UserAuthLevelEnum.GetEnumerator() | Where-Object Value -eq $user.securityLevel).Name + + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'userName' -Value ('"{0}"' -f $userName))) + $userNameParam = ' -Username $userName' + + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'securityLevel' -Value ('"{0}"' -f $securityLevelName))) + $securityLevelParam = ' -SecurityLevel $securityLevel' + + switch ($user.securityLevel) + { + + $Snmpv3UserAuthLevelEnum["AuthOnly"] + { + + $authProtocolName = ($SnmpAuthProtocolEnum.GetEnumerator() | Where-Object Value -eq $user.authenticationProtocol).Name + + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'authProtocol' -Value ('"{0}"' -f $authProtocolName))) + + $snmpv3UserAuthProtocolParam = ' -AuthProtocol $authProtocol' + + if ($authProtocolName -ne 'none') + { + + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'AuthPassword' -Value ('Read-Host -prompt "Enter authentication password for SNMPv3 user {0}" -AsSecureString' -f $username))) + $snmpv3UserAuthProtocolParam += ' -AuthPassword $authPassword' + + } + + } + + $Snmpv3UserAuthLevelEnum["AuthAndPriv"] + { + + $authProtocolName = ($SnmpAuthProtocolEnum.GetEnumerator() | Where-Object Value -eq $user.authenticationProtocol).Name + + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'authProtocol' -Value ('"{0}"' -f $authProtocolName))) + + $snmpv3UserAuthProtocolParam = ' -AuthProtocol $authProtocol' + + if ($authProtocolName -ne 'none') + { + + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'AuthPassword' -Value ('Read-Host -prompt "Enter authentication password for SNMPv3 user {0}" -AsSecureString' -f $username))) + $snmpv3UserAuthProtocolParam += ' -AuthPassword $authPassword' + + } + + $privProtocolName = ($ApplianceSnmpV3PrivProtocolEnum.GetEnumerator() | Where-Object Value -eq $user.privacyProtocol).Name + + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'privProtocol' -Value ('"{0}"' -f $privProtocolName))) + + $snmpv3UserPrivProtocolParam = ' -PrivProtocol $privProtocol' + + if ($authProtoprivProtocolNamecolName -ne 'none') + { + + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'PrivPassword' -Value ('Read-Host -prompt "Enter privacy password for SNMPv3 user {0}" -AsSecureString' -f $username))) + $snmpv3UserPrivProtocolParam += ' -PrivPassword $PrivPassword' + + } + + } + + } + + [void]$scriptCode.Add(('New-OVSnmpV3User -ApplianceSnmpUser{0}{1}{2}{3}' -f $userNameParam, $securityLevelParam, $snmpv3UserAuthProtocolParam, $snmpv3UserPrivProtocolParam)) + + DisplayOutput -Code $scriptCode + + } + + Function Generate-smtp-Script ($InputObject) + { + + $scriptCode = [System.Collections.ArrayList]::new() + + $smtp = $InputObject + + $Email = $Smtp.senderEmailAddress + $Server = $Smtp.smtpServer + $Port = $Smtp.smtpPort + $ConnectionSecurity = ($SmtpConnectionSecurityEnum.GetEnumerator() | Where-Object Value -eq $Smtp.smtpProtocol).Name + + # Code and Parameters + if (-not $smtp.alertEmailDisabled -and $smtp.smtpServer) + { + + [void]$scriptCode.Add('# -------------- Attributes for SMTP alerting') + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'AlertEmailDisabled' -Value '$False')) + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'Email' -Value ('"{0}"' -f $Email))) + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'Server' -Value ('"{0}"' -f $Server))) + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'Port' -Value ('{0}' -f $Port))) + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'ConnectionSecurity' -Value ('{0}' -f $ConnectionSecurity))) + [void]$scriptCode.Add('# Omit the following line to if your SMTP server does not require a password.') + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'Password' -Value 'Read-Host "Please enter a password to connect to smtp Server " -AsSecureString')) + [void]$scriptCode.Add('Set-OVSmtpConfig -SenderEmailAddress $Email -password $Password -Server $Server -Port $Port') + [void]$scriptCode.Add("") + + if ($smtp.alertEmailFilters.Count -gt 0) + { + + ForEach ($filter in ($smtp.alertEmailFilters | Sort-Object filterName)) + { + + Insert-BlankLine + + $ScopeMatchPreferenceParam = $smtpAlertNameParam = $smtpAlertEmailsParam = $null + + [void]$scriptCode.Add(('# -------------- Attributes for SMTP Filter "{0}"' -f $filter.filterName)) + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'name' -Value ('"{0}"' -f $filter.filterName)) ) + $smtpAlertNameParam = '-Name $name' + + # Emails + $Emails = '"{0}"' -f [String]::Join('", "', $filter.emails) + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'emails' -Value ('{0}' -f $Emails))) + $smtpAlertEmailsParam = ' -Emails $emails' + + # FilterQuery + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'filter' -Value ('"{0}"' -f $filter.filter))) + $filterParam = ' -Filter $filter' + + # ScopeQuery + if ($null -ne $filter.scopeQuery) + { + + if ([RegEx]::Match($filter.scopeQuery, ' AND ', $RegExInsensitiveFlag).Success) + { + + $ScopeMatchPreference = "AND" + + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'ScopeMatchPreference' -Value ('"{0}"' -f $ScopeMatchPreference))) + $ScopeMatchPreferenceParam = ' -ScopeMatchPreference $ScopeMatchPreference' + + } + + else + { + + $ScopeMatchPreference = "OR" + + } + + $ScopeNames = [System.Collections.ArrayList]::new() + + ForEach ($scope in $filter.scopeQuery.Split(" $ScopeMatchPreference ", [StringSplitOptions]::RemoveEmptyEntries)) + { + + $scopeName = $scope.Replace("scope:", $null) + + [void]$ScopeNames.Add($scopeName) + + } + + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'scope' -Value ('{0}' -f [String]::Join(', ', $ScopeNames.ToArray())))) + $smtpAlertEmailsParam = ' -Scope $scope' + + } + + [void]$scriptCode.Add(('Add-OVSmtpAlertEmailFilter {0}{1}{2}' -f $smtpAlertNameParam, $smtpAlertEmailsParam, $filterParam, $smtpAlertEmailsParam)) + [void]$scriptCode.Add("") + + } + + } + + } + + DisplayOutput -Code $scriptCode + + } + + Function Generate-TimeLocale-Script ($InputObject) + { + + $scriptCode = [System.Collections.ArrayList]::new() + + $timeLocale = $InputObject + + $Locale = $TimeLocale.Locale + $ntpServers = $TimeLocale.NtpServers + $pollingInterval = $timeLocale.pollingInterval + $syncWithHost = $timeLocale.SyncWithHost + + $localeParm = $ntpParam = $ntpCode = $null + $syncWithHostParam = $syncWithHostCode = $null + $pollingParam = $pollingCode = $null + + [void]$scriptCode.Add('# -------------- Attributes for date and time') + + $locale = $locale.Split($dot)[0] + + if ($locale -ne 'en_US') + { + + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'locale' -Value ('"{0}"' -f $locale))) + $localeParm = ' -Locale $locale' + + } + + # will need to return NTP configuration + if (-not $syncWithHost) + { + + if ($ntpServers) + { + + $ntpServers = [String]::Join('", "', $ntpServers) + $ntpParam = ' -NtpServers $ntpServers' + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'ntpServers' -Value ('"{0}"' -f $ntpServers))) + + } + + if ($pollingInterval) + { + + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'pollingInterval' -Value ('{0}' -f $pollingInterval))) + $pollingParam = " -PollingInterval `$pollingInterval " + + } + + } + + else + { + + $syncWithHostParam = ' -SyncWithHost' + + } + + [void]$scriptCode.Add(('Set-OVApplianceDateTime{0}{1}{2}{3}' -f $localeParm, $syncWithHostParam, $ntpParam, $pollingParam)) + + DisplayOutput -Code $scriptCode + + } + + Function Generate-AddressPoolSubnet-Script ($InputObject) + { + + $scriptCode = [System.Collections.ArrayList]::new() + + $networkIdParam = $subnetMaskParam = $gatewayParam = $null + + $subnet = $InputObject + + $networkID = $subnet.NetworkID + + if ($subnet.Category -eq $ResourceCategoryEnum.IPv4Subnet) + { + + $subnetmask = $subnet.subnetmask + + $subnetMaskParam = 'Subnetmask' + + } + + else + { + + $subnetmask = $subnet.prefixLength + + $subnetMaskParam = 'Prefixlength' + + } + + $gateway = $subnet.gateway + $domain = $subnet.domain + $dns = $subnet.dnsservers + $rangeUris = $subnet.rangeUris + + [void]$scriptCode.Add('# -------------- Attributes for subnet "{0}"' -f $networkID) + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'networkID' -Value ('"{0}"' -f $networkID))) + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix $subnetMaskParam -Value ('"{0}"' -f $subnetmask))) + + $networkIdParam = ' -NetworkID $networkID' + $subnetMaskParam = ' -{0} $subnetmask' -f $subnetMaskParam + + if (-not [String]::IsNullOrEmpty($gateway)) + { + + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'networkgatewayID' -Value ('"{0}"' -f $gateway))) + + $gatewayParam = ' -Gateway $gateway' + + } + + # Code and attribute parameters + $dnsParam = $dnsCode = $null + + if ($dns) + { + + $dnsServers = [String]::Join('", "', $dns) + + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'dnsServers' -Value ('"{0}"' -f $dnsServers))) + $dnsParam = ' -DnsServers $dnsServers' + + } + + $domainParam = $domainCode = $null + + if ($domain) + { + + $domainParam = ' -Domain $domain' + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'domain' -Value ('"{0}"' -f $domain))) + + } + + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'thisSubnet' -Value ('New-OVAddressPoolSubnet{0}{1}{2}{3}{4}' -f $networkIdParam, $subnetMaskParam, $gatewayParam, $dnsParam, $domainParam))) + + foreach ($rangeUri in $rangeUris) + { + + $range = Send-OVRequest -Uri $rangeUri + $name = $range.Name + $startAddress = $range.startStopFragments.startAddress + $endAddress = $range.startStopFragments.endAddress + + [void]$scriptCode.Add('') + [void]$scriptCode.Add('# --- Attributes for Address Pool range associated with subnet {0}' -f $networkID) + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'name' -Value ('"{0}"' -f $name))) + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'startAddress' -Value ('"{0}"' -f $startAddress))) + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'endAddress' -Value ('"{0}"' -f $endAddress))) + [void]$scriptCode.Add('New-OVAddressPoolRange -InputObject $thisSubnet -Name $name -start $startAddress -end $endAddress') + + } + + DisplayOutput -Code $scriptCode + + } + + Function Generate-AddressPoolRange-Script ($InputObject) + { + + $scriptCode = [System.Collections.ArrayList]::new() + + $range = $InputObject + + $poolName = $range.Name + $rangeType = $range.rangeCategory + $startAddress = $range.startAddress + $endAddress = $range.endAddress + $cat = $range.category + + $rangeTypeParam = $poolTypeParam = $startEndParam = $null + + $poolType = $cat.Split('-')[-1] + + [void]$scriptCode.Add('# -------------- Attributes for address pool range {0}' -f $poolType) + + # Custom, non-IPv4 range + if ($poolType -notmatch 'IPv' -and $rangeType -eq 'Custom') + { + + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'poolType' -Value ('"{0}"' -f $poolType))) + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'rangeType' -Value ('"{0}"' -f $rangeType))) + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'startAddress' -Value ('"{0}"' -f $startAddress))) + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'endAddress' -Value ('"{0}"' -f $endAddress))) + + $rangeTypeParam = ' -rangeType $rangeType' + $poolTypeParam = ' -poolType $poolType' + $startEndParam = ' -start $startAddress -end $endAddress' + + } + + # Auto generated, non-IPv4 range + elseif ($poolType -notmatch 'IPv' -and $rangeType -eq 'Generated') + { + + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'poolType' -Value ('"{0}"' -f $poolType))) + $poolTypeParam = ' -poolType $poolType' + + } + + # IPv4 address range + else + { + + Try + { + + $AddressPoolSubnetId = Get-NamefromUri $range.subnetUri + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'subnet' -Value ('Get-OVAddressPoolSubnet -NetworkID {0}' -f $AddressPoolSubnetId))) + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'startAddress' -Value ('"{0}"' -f $startAddress))) + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'endAddress' -Value ('"{0}"' -f $endAddress))) + + $startEndParam = ' -InputObject $subnet -Start $startAddress -End $endAddress' + + } + + [void]$scriptCode.Add(('New-OVAddressPoolRange{0}{1}{2}' -f $poolTypeParam, $rangeTypeParam, $startEndParam)) + + DisplayOutput -Code $scriptCode + + } + + Function Generate-EthernetNetwork-Script ($InputObject) + { + + $scriptCode = [System.Collections.ArrayList]::new() + + $net = $InputObject + + # ----------------------- Construct Network information + $name = $net.name + $type = $net.type.Split("-")[0] # Value is like ethernet-v30network + + $vLANType = $net.ethernetNetworkType + $vLANID = $net.vLanId + + $pBandwidth = [String]$net.DefaultTypicalBandwidth + $mBandwidth = [String]$net.DefaultMaximumBandwidth + $smartlink = if ($net.SmartLink) { $true } else { $false } + $Private = if ($net.PrivateNetwork) { $true } else { $false } + $purpose = $net.purpose + + [void]$scriptCode.Add('# -------------- Attributes for Ethernet network "{0}"' -f $name) + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'name' -Value ('"{0}"' -f $name))) + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'type' -Value ('"{0}"' -f $type))) + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'vLANType' -Value ('"{0}"' -f $vLANType))) + + $vLANIDparam = $vLANIDcode = $null + + if ($vLANType -eq 'Tagged') + { + + if (($vLANID) -and ($vLANID -gt 0)) + { + + $vLANIDparam = ' -VlanID $VLANID' + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'vLANid' -Value ('{0}' -f $vLANID))) + + } + + } + + $pBWparam = $pBWCode = $null + $maxBWparam = $mBWCode = $null + + if ($PBandwidth) + { + + $pBWparam = ' -TypicalBandwidth $pBandwidth' + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'pBandwidth' -Value ('{0}' -f $pBandwidth))) + + } + + if ($MBandwidth) + { + + $maxBWparam = ' -MaximumBandwidth $mBandwidth' + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'mBandwidth' -Value ('{0}' -f $mBandwidth))) + + } + + $subnetURI = $net.subnetURI + $IPv6SubnetUri = $net.ipv6SubnetUri + + $subnetCode = $null + $subnetIDparam = @() + $IPv6subnetCode = $IPv6subnetIDparam = $null + + if ($subnetURI) + { + + Try + { + + $subnet = Send-OVRequest -Uri $subnetURI -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $ThisSubnetID = $subnet.NetworkID + $subnetName = $subnet.Name + + $subnetIDparam += '$ThisIPv4Subnet' + + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'IPv4NetworkID' -Value ('"{0}"' -f $ThisSubnetID))) + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'ThisIPv4Subnet' -Value ('Get-OVAddressPoolSubnet -NetworkID $IPv4NetworkID'))) + + } + + if ($IPv6SubnetUri) + { + + Try + { + + $subnet = Send-OVRequest -Uri $IPv6SubnetUri -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $ThisSubnetID = $subnet.NetworkID + $subnetName = $subnet.Name + + $subnetIDparam += '$ThisIPv6Subnet' + + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'IPv6NetworkID' -Value ('"{0}"' -f $ThisSubnetID))) + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'ThisIPv6Subnet' -Value ('Get-OVAddressPoolSubnet -NetworkID $IPv6NetworkID'))) + + } + + if ($subnetIDparam.Count -gt 0) + { + + $subnetIDparam = ' -Subnet {0}' -f [String]::Join(', ', $subnetIDparam) + + } + + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'PLAN' -Value ('${0}' -f $Private))) + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'smartLink' -Value ('${0}' -f $smartLink))) + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'purpose' -Value ('"{0}"' -f $purpose))) + + if ($null -eq $subnetIDparam -or $subnetIDparam.count -eq 0) + { + + $subnetIDparam = $null + + } + + [void]$scriptCode.Add(('New-OVNetwork -Name $name -Type $Type -PrivateNetwork $PLAN -SmartLink $smartLink -VLANType $VLANType{0}{1}{2}{3} -purpose $purpose' -f $vLANIDparam, $pBWparam, $maxBWparam, $subnetIDparam)) + + DisplayOutput -Code $scriptCode + + } + + Function Generate-NetworkSet-Script ($InputObject) + { + + $scriptCode = [System.Collections.ArrayList]::new() + + $ns = $InputObject + + $name = $ns.name + $description = $ns.description + $PBandwidth = $ns.TypicalBandwidth + $Mbandwidth = $ns.MaximumBandwidth + $untaggednetworkURI = $ns.nativeNetworkUri + $networkURIs = $ns.networkUris + $LargeNetSet = $ns.networkSetType + + [void]$scriptCode.Add('# -------------- Attributes for Network Set "{0}"' -f $name) + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'name' -Value ('"{0}"' -f $name))) + + $pBWparam = $pbWCode = $null + $mBWparam = $mBWCode = $null + $LargeNetSetParam = $null + + if ($LargeNetSet -eq 'Large') + { + + $LargeNetSetParam = ' -Large' + + } + + if ($PBandwidth) + { + + $pBWparam = ' -TypicalBandwidth $pBandwidth' + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'pBandwidth' -Value ('{0}' -f $pBandwidth))) + + } + + if ($MBandwidth) + { + + $mBWparam = ' -MaximumBandwidth $mBandwidth' + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'mBandwidth' -Value ('{0}' -f $mBandwidth))) + + } + + $untaggedParam = $untaggednetworkname = $untaggednetCode = $null + + if ($untaggednetworkURI) + { + + $untaggedParam = ' -UntaggedNetwork $untaggednetwork' + $untaggednetworkname = Get-NamefromUri -Uri $untaggednetworkURI + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'untaggednetworkname' -Value ('"{0}"' -f $untaggednetworkname))) + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'untaggednetwork' -Value 'Get-OVNetwork -Name $untaggednetworkname')) + + } + + $netParam = $netCode = $null + + if ($networkURIs) + { + + $netParam = ' -Networks $networks' + #Serialize Array + $arr = @() + + foreach ($el in $networkURIs) + { + + $name = Get-NamefromUri -Uri $el + $arr += '"{0}"' -f $name + + } # Add quote to string + + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'networks' -Value ('{0} | Get-OVNetwork' -f [String]::Join(', ', $arr)))) + + } + + [void]$scriptCode.Add(('New-OVNetworkSet -Name $name{0}{1}{2}{3}{4}' -f $pBWparam, $mBWparam, $netParam, $untaggedParam, $LargeNetSetParam)) + + DisplayOutput -Code $scriptCode + + } + + Function Generate-FCNetwork-Script ($InputObject) + { + + $scriptCode = [System.Collections.ArrayList]::new() + + $net = $InputObject + + $name = $net.name + $description = $net.description + $type = $net.type.Split("-")[0] # Value is 'fcoe-networksV300 + $fabrictype = $net.fabrictype + $pBandwidth = $net.defaultTypicalBandwidth + $mBandwidth = $net.defaultMaximumBandwidth + $sanURI = $net.ManagedSANuri + $linkStabilityTime = if ($net.linkStabilityTime) { $net.linkStabilityTime} else {30} + $autologinredistribution = if ($net.autologinredistribution) { $true } else { $false } + + [void]$scriptCode.Add('# -------------- Attributes for FibreChannel network "{0}"' -f $name) + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'name' -Value ('"{0}"' -f $name))) + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'type' -Value ('"{0}"' -f $type))) + + # fcoe network + $VLANID = $net.VLANID + $fabricUri = $net.fabricUri + + $pBWparam = $pBWCode = $null + $mBWparam = $mBWCode = $null + + if ($PBandwidth) + { + + $pBWparam = ' -typicalBandwidth $pBandwidth' + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'pBandwidth' -Value ('{0}' -f $pBandwidth))) + + } + + if ($MBandwidth) + { + + $mBWparam = ' -maximumBandwidth $mBandwidth' + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'mBandwidth' -Value ('{0}' -f $mBandwidth))) + + } + + $FCparam = $FCcode = $null + $vLANIDparam = $vLANIDcode = $null + $autologinParam = $autologinCode = $null + $linkParam = $linkCode = $null + + if ([RegEx]::Match($type, 'fcoe', $RegExInsensitiveFlag).Success) #FCOE network + { + + if (($vLANID) -and ($vLANID -gt 0)) + { + + $vLANIDparam = ' -vLanID $VLANID' + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'vLANid' -Value ('{0}' -f $vLANID))) + + } + + } + + else # FC network + { + + $FCparam = ' -FabricType $fabricType' + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'fabricType' -Value ('"{0}"' -f $fabricType))) + + if ($fabrictype -eq 'FabricAttach') + { + + if ($autologinredistribution) + { + + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'autologinredistribution' -Value ('${0}' -f $autologinredistribution))) + $autologinParam = ' -AutoLoginRedistribution $autologinredistribution' + + } + + if ($linkStabilityTime) + { + + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'LinkStabilityTime' -Value ('{0}' -f $LinkStabilityTime))) + $linkParam = ' -LinkStabilityTime $LinkStabilityTime' + + } + + $FCparam += $autologinParam + $linkParam + + } + + } + + + $sanParam = $sanCode = $null + + if ($sanURI) + { + + Try + { + + $ManagedSAN = Send-OVRequest -Uri $sanURI -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $SANname = $ManagedSAN.Name + $SANmanagerName = $ManagedSAN.devicemanagerName + + + $SANparam = ' -ManagedSAN $managedSAN' + + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'SANname' -Value ('"{0}"' -f $SANname))) + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'managedSAN' -Value ('Get-OVManagedSAN -Name $SANname'))) + + } + + [void]$scriptCode.Add(('New-OVNetwork -Name $name -Type $Type{0}{1}{2}{3}{4}' -f $pBWparam, $mBWparam, $FCparam, $vLANIDparam, $SANparam)) + + DisplayOutput -Code $scriptCode + + } + + Function Generate-SanManager-Script ($InputObject) + { + + $scriptCode = [System.Collections.ArrayList]::new() + + $SM = $InputObject + + if ($SM.isInternal) + { + + # Need to change this to non-terminating error? + Write-Host "Unable to generate PowerShell Cmdlet for Direct Attach SAN Managers." + + } + + else + { + + $name = $SM.name + + $displayName = $sm.providerDisplayName + + foreach ($CI in $SM.ConnectionInfo) + { + + Switch ($CI.Name) + { + + # ------ For HPE and Cisco + 'SnmpPort' + { + + $Port = $CI.Value + + } + + 'SnmpUsername' + { + + $snmpUsername = $CI.Value + + } + + 'SnmpAuthLevel' + { + + $v = $CI.Value + + if ($v -notlike 'AUTH*') + { + + $AuthLevel = 'None' + + } + + else + { + + if ($v -eq 'AUTHNOPRIV') + { + + $AuthLevel = 'AuthOnly' + + } + + else + { + + $AuthLevel = 'AuthAndPriv' + + } + + } + + } + + 'SnmpAuthProtocol' + { + + $AuthProtocol = $CI.Value + + } + + 'SnmpPrivProtocol' + { + + $PrivProtocol = $CI.Value + + } + + #---- For Brocade + 'Username' + { + + $username = $CI.Value + + } + + 'UseSSL' + { + + $UseSSL = if ($CI.Value) + { + + $true + + } + + else + { + + $false + + } + + } + + 'Port' + { + + $Port = $CI.Value + + } + + } + + } + + $credParam = $credCode = $null + $privProtocolParam = $privProtocolCode = $null + + [void]$scriptCode.Add('# -------------- Attributes for San Manager $name') + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'name' -Value ('"{0}"' -f $name))) + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'type' -Value ('"{0}"' -f $displayName))) + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'port' -Value ('{0}' -f $port))) + + if ($displayName -eq 'Brocade Network Advisor') + { + + $credParam = ' -username $username -password password -useSSL:$useSSL' + + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'username' -Value ('"{0}"' -f $username))) + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'password' -Value ('Read-Host "Provide password for user "$username" to connect to SANManager" -asSecureString'))) + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'useSSL' -Value ('${0}' -f $useSSL))) + + } + + else # Cisco or HPE + { + + $authProtocolParam = ' -SnmpAuthLevel $snmpAuthLevel -Snmpusername $snmpUsername -SnmpAuthPassword $snmpAuthPassword -SnmpAuthProtocol $snmpAuthProtocol' + + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'snmpUsername' -Value ('"{0}"' -f $snmpUsername))) + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'snmpAuthLevel' -Value ('"{0}"' -f $authLevel))) + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'snmpAuthProtocol' -Value ('"{0}"' -f $AuthProtocol))) + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'snmpAuthPassword' -Value ('Read-Host "Provide authentication password for user $snmpUsername" -asSecureString'))) + + if ($authLevel -eq 'AuthAndPriv') + { + + $privProtocolParam = ' -SnmpPrivPassword $snmpPrivPassword -snmpPrivProtocol $snmpPrivProtocol' + + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'snmpPrivProtocol' -Value ('"{0}"' -f $privProtocol))) + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'snmpPrivPassword' -Value ('Read-hHst "Provide privacy password" -asSecureString'))) + + } + + $credParam = $authProtocolParam + $privProtocolParam + + } + + [void]$scriptCode.Add('Add-OVSanManager -Hostname $name -Type $type -Port $port{0}' -f $credParam) + + DisplayOutput -Code $scriptCode + + } + + } + + Function Generate-StorageSystem-Script ($InputObject) + { + + $scriptCode = [System.Collections.ArrayList]::new() + + $StS = $InputObject + + $StoragePorts = $PortGroupPorts = @() + $PortGroupParam = $StoragePortsParam = $null + + $hostName = $Sts.hostname + $Username = $Sts.Credentials.username + $family = $sts.family + $DomainName = if ($StorageSystemFamilyTypeEnum['Primera'], $StorageSystemFamilyTypeEnum['StoreServ'] -contains $family) { $Sts.deviceSpecificAttributes.managedDomain } else {''} + + [void]$scriptCode.Add('# -------------- Attributes for StorageSystem "{0}"' -f $hostname) + + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'hostname' -Value ('"{0}"' -f $hostname))) + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'family' -Value ('"{0}"' -f $family))) + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'cred' -Value ('Get-OVCredential -Message "Provide the password for {0}" -Username {0}' -f $Username))) + + $portList = $Sts.Ports | Where-Object status -eq 'OK' | Sort-Object Name + + foreach ($MP in ($portList | Where-Object mode -eq 'Managed')) + { + + # 3PAR + if ($family -eq 'StoreServ') + { + + $Thisname = $MP.expectedSanName + + if ($Thisname) + { + + # Need to get the associated FC network to the expectedSanName value + + Try + { + + $AssociatedFcNetwork = Send-OVRequest -Uri $MP.expectedSanUri + + $AssociatedFcNetworkName = $AssociatedFcNetwork.associatedNetworks.name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $StoragePorts += "'{0}' = '{1}'" -f $MP.Name, $AssociatedFcNetworkName # Build Port syntax '0:1:2'= 'VSAN10' + + } + + if ($null -ne $MP.groupName) + { + + $PortGroupParam = ' -PortGroups $portGroups' + + $PortGroupPorts += "'{0}' = '{1}'" -f $MP.Name, $MP.groupName # Build Port syntax '0:1:2'= 'Portgroup 1' + + } + + } + + # VSA/StoreVirtual + else + { + + $Thisname = $MP.ExpectedNetworkName + + if ($Thisname) + { + + $StoragePorts = [PSCustomObject]@{PortName = $MP.Name; NetworkName = $Thisname} # Build Port syntax '192.168.1.1'= 'iSCSI Network' + + } + + } + + } + + if ($DomainName) + { + + $domainParam = ' -Domain $domainName' + + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'domainName' -Value ('"{0}"' -f $domainName))) + + } + + if ($StoragePorts -and $family -eq 'StoreServ' -and $StoragePorts.Count -gt 0) + { + + $storagePortsParam = ' -Ports $storageSystemPorts' + + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'storageSystemPorts' -Value ('{0}{1}{2}' -f '@{', [String]::Join("; ", $StoragePorts), '}'))) + + if ($PortGroupPorts.Count -gt 0) + { + + $PortGroupParam = ' -PortGroups $portGroupPorts' + + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'portGroupPorts' -Value ('{0}{1}{2}' -f '@{', [String]::Join("; ", $PortGroupPorts), '}'))) + + } + + } + + elseif ($StoragePorts -and $family -eq 'StoreVirtual') + { + + $storagePortsParam = ' -VIPS $vips' + + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'ThisiSCSINetwork' -Value ('Get-OVNetwork -Type Ethernet -Name "{0}"' -f $StoragePorts.NetworkName))) + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'vips' -Value ('{0}"{1}" = $ThisiSCSINetwork{2}' -f "@{", $StoragePorts.PortName, "}"))) + + } + + [void]$scriptCode.Add(('Add-OVStorageSystem -Hostname $hostName -Credential $cred -Family $family{0}{1}{2}' -f $domainParam, $storagePortsParam, $PortGroupParam)) + + + DisplayOutput -Code $scriptCode + + } + + Function Generate-StoragePool-Script ($InputObject) + { + + $scriptCode = [System.Collections.ArrayList]::new() + + $pool = $InputObject + + if ($pool.state -ne 'Managed') + { + + Write-Host ("Unable to create a Cmdlet for an unmanaged storage pool, {0}" -f $pool.name) + + } + + else + { + + $name = $pool.name + $description = $pool.description + + # --- Storage System + + $stsName = Get-NamefromUri -Uri $pool.StorageSystemUri + + [void]$scriptCode.Add('# -------------- Attributes for Storage Pool "{0}"' -f $pool.name) + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix '$stsName' -Value ('"{0}"' -f $stsName))) + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix '$storageSystem' -Value 'Get-OVStorageSystem -Name $stsName')) + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix '$pool' -Value (' Get-OVStoragePool -Name "{0}" -StorageSystem $storageSystem' -f $pool.name))) + [void]$scriptCode.Add('Set-OVStoragePool -Pool $pool -Managed $True') + + DisplayOutput -Code $scriptCode + + } + + } + + Function Generate-StorageVolumeTemplate-Script ($InputObject) + { + + $scriptCode = [System.Collections.ArrayList]::new() + + $Template = $InputObject + + $descParam = $PoolParam = $CapacityParam = $StoragePoolParam = $SnapshotPoolParam = $ProvisionTypeParam = $CompressionParam = $ScopeParam = $null + $DataProtectionLevelParam = $AdaptiveOptimizationParam = $null + + # Common SVT attributes + $name = $Template.Name + $description = $Template.Description + $family = $Template.family + $stsUri = $Template.compatibleStorageSystemsUri + + # Common SVT properties + $p = $template.Properties + $size = $p.size.default / 1GB + $sizeIsLocked = $p.size.meta.locked + $isShareable = $p.isShareable.default + $isShareableLocked = $p.isShareable.meta.locked + $PoolUri = $p.storagePool.default + $poolIsLocked = $p.storagePool.meta.locked + $ProvisioningType = $p.provisioningType.default + $provisionTypeLocked = $p.provisioningType.meta.locked + $stsName = Get-NamefromUri -Uri $stsUri + $poolName = Get-NamefromUri -Uri $PoolUri + + # Common attributes to set + [void]$scriptCode.Add(('#------ Attributes for storage volume template "{0}" (Family: {1})' -f $name, $family)) + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'name' -Value ('"{0}"' -f $name))) + + if ($description) + { + + $descParam = ' -Description $description' + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'description' -Value ('"{0}"' -f $description))) + + } + + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'poolName' -Value ('"{0}"' -f $poolName))) + + Switch ($family) + { + + 'StoreServ' + { + + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'stsName' -Value ('"{0}"' -f $stsName))) + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'storagePool' -Value ('Get-OVStoragePool -Name $poolName -StorageSystem $stsName'))) + + } + + 'StoreVirtual' + { + + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'storagePool' -Value ('Get-OVStoragePool -Name $poolName'))) + + } + + } + + $PoolParam = ' -StoragePool $StoragePool' + + if ($poolIsLocked) + { + + $PoolParam += ' -LockStoragePool' + + } + + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'capacity' -Value ('{0}' -f $size))) + + $CapacityParam = ' -Capacity $capacity' + + if ($sizeIsLocked) + { + + $CapacityParam += ' -LockCapacity' + + } + + if ($isShareable) + { + + $ProvisionTypeParam = ' -Shared' + + if ($isShareableLocked) + { + + $ProvisionTypeParam += ' -LockProvisionMode' + + } + + } + + # family specific properties + switch ($family) + { + + 'StoreServ' + { + + $SnapshotUri = $p.snapshotPool.default + $snpshotPoolIsLocked = $p.snapshotPool.meta.locked + $isDeduplicated = $p.isDeduplicated.default + $isDeduplicatedLocked = $p.isDeduplicated.meta.locked + $enableCompression = $p.enableCompression.default + $isCompressionLocked = $p.enableCompression.meta.locked + + if ($SnapshotUri -ne $PoolUri) + { + + $snapshotPoolName = Get-NamefromUri -Uri $snapshotUri + + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'snapShotPoolName' -Value ('"{0}"' -f $snapshotPoolName))) + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'snapShotPool' -Value ('Get-OVStoragePool -Name $snapShotPoolName -StorageSystem $stsName'))) + + $SnapshotPoolParam = ' -SnapshotStoragePool $snapShotPool' + + if ($snpshotPoolIsLocked) + { + + $SnapshotPoolParam += ' -LockSnapshotStoragePool' + + } + + } + + else + { + + $snapshotName = $poolName + + } + + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'enableDeduplication' -Value ('${0}' -f $isDeduplicated))) + + $DeduplicateParam = ' -EnableDeduplication $enableDeduplication' + + if ($isDeduplicatedLocked) + { + + $DeduplicateParam += ' -LockEnableDeduplication' + + } + + if (-not [String]::IsNullOrWhiteSpace($enableCompression)) + { + + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'enableCompression' -Value ('${0}' -f $enableCompression))) + + $CompressionParam = ' -EnableCompression $enableCompression' + + if ($isCompressionLocked) + { + + $CompressionParam += ' -LockEnableCompression' + + } + + } + + } + + } + + # Scopes + Try + { + + $ResourceScope = Send-OVRequest -Uri $Template.scopesUri -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $n = 1 + + if (-not [String]::IsNullOrEmpty($ResourceScope.scopeUris)) + { + + ForEach ($scopeUri in $ResourceScope.scopeUris) + { + + $scopeName = Get-NamefromUri -Uri $scopeUri + + $ScopeVarName = 'Scope' + $Value = 'Get-OVScope -Name "{0}"' -f $scopeName + + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix $ScopeVarName -Suffix $n -Value $Value)) + + $n++ + + } + + $ScopeParam = ' -Scope {0}' -f ([String]::Join(', ', (1..($n - 1) | ForEach-Object { '$Scope{0}' -f $_}))) + + } + + [void]$scriptCode.Add(('New-OVStorageVolumeTemplate -Name $name{0}{1}{2}{3}{4}{5}{6}{7}{8}' -f $descParam, $PoolParam, $CapacityParam, $ProvisionTypeParam, $SnapshotPoolParam, $CompressionParam, $DataProtectionLevelParam, $AdaptiveOptimizationParam, $ScopeParam)) + + DisplayOutput -Code $scriptCode + + } + + Function Generate-StorageVolume-Script ($InputObject) + { + + $scriptCode = [System.Collections.ArrayList]::new() + + $SV = $InputObject + + $name = $SV.name + $description = $SV.description + $poolUri = $SV.storagePoolUri + $size = $SV.provisionedCapacity / 1GB + $volTemplateUri = $SV.volumeTemplateUri + $ProvisioningType = $SV.provisioningType + $isShareable = $SV.isShareable + $p = $SV.deviceSpecificAttributes + $isCompressed = $p.isCompressed + $isDeduplicated = $p.isDeduplicated + $snapshotUri = $p.snapshotPoolUri + + $descParam = $PoolParam = $CapacityParam = $StoragePoolParam = $SnapshotPoolParam = $ProvisionTypeParam = $CompressionParam =$DeduplicateParam = $ScopeParam = $null + $DataProtectionLevelParam = $AdaptiveOptimizationParam = $null + + [void]$scriptCode.Add('#------ Attributes for storage volume "{0}"' -f $name) + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'name' -Value ('"{0}"' -f $name))) + + if ($description) + { + + $descParam = " -Description `$description " + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'description' -Value ('"{0}"' -f $description))) + + } + + $volumeParam = $storagePoolCode = $null + + if ($volTemplateUri) + { + + $volumeParam = ' -VolumeTemplate $volumeTemplate' + $volTemplateName = Get-NamefromUri -Uri $volTemplateUri + + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'volumeTemplateName' -Value ('"{0}"' -f $volTemplateName))) + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'volumeTemplate' -Value ('Get-OVStorageVolumeTemplate -Name $volTemplateName'))) + + } + + else # volume created without template + { + + Try + { + + $pool = Send-OVRequest -Uri $PoolUri -Hostname $ApplianceConnection + $sts = Send-OVRequest -Uri $pool.storageSystemUri -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $poolName = $pool.name + $family = $sts.family + + $volumeParam = '-StoragePool $storagePool -capacity $size -ProvisioningType $provisioningType' + + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'capacity' -Value ('{0}' -f $size))) + + $CapacityParam = ' -Capacity $capacity' + + if ($isShareable) + { + + $ProvisionTypeParam = ' -Shared' + + } + + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'provisioningType' -Value ('"{0}"' -f $ProvisioningType))) + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'poolName' -Value ('"{0}"' -f $poolName))) + + $storagePoolCode = Generate-CustomVarCode -Prefix 'storagePool' -Value 'Get-OVStoragePool -Name $poolName' + + Switch ($family) + { + + 'StoreServ' + { + + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'stsName' -Value ('"{0}"' -f $sts.name))) + $storagePoolCode += ' -StorageSystem $stsName' + + [void]$scriptCode.Add($storagePoolCode) + + if ($poolUri -ne $snapshotUri) + { + + $snapshotPoolName = Get-NamefromUri -Uri $snapshotUri + + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'snapShotPoolName' -Value ('"{0}"' -f $snapshotPoolName))) + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'snapShotPool' -Value 'Get-OVStoragePool -Name $snapShotPoolName -StorageSystem $stsName')) + + $SnapshotPoolParam = ' -SnapshotStoragePool $snapShotPool' + + } + + $isDeduplicated = $p.isDeduplicated + $enableCompression = $p.isCompressed + + if ($isDeduplicated) + { + + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'enableDeduplication' -Value ('${0}' -f $isDeduplicated))) + + $DeduplicateParam = ' -EnableDeduplication $enableDeduplication' + + } + + if ($enableCompression) + { + + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'enableCompression' -Value ('${0}' -f $enableCompression))) + + $CompressionParam = ' -EnableCompression $enableCompression' + + } + + } + + } + + } + + # Scopes + Try + { + + $ResourceScope = Send-OVRequest -Uri $SV.scopesUri -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $n = 1 + + if (-not [String]::IsNullOrEmpty($ResourceScope.scopeUris)) + { + + ForEach ($scopeUri in $ResourceScope.scopeUris) + { + + $scopeName = Get-NamefromUri -Uri $scopeUri + + $ScopeVarName = 'Scope' + $Value = 'Get-OVScope -Name "{0}"' -f $scopeName + + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix $ScopeVarName -Suffix $n -Value $Value)) + + $n++ + + } + + $ScopeParam = ' -Scope {0}' -f ([String]::Join(', ', (1..($n - 1) | ForEach-Object { '$Scope{0}' -f $_}))) + + } + + [void]$scriptCode.Add(('New-OVStorageVolume -Name $name{0}{1}{2}{3}{4}{5}{6}{7}{8}' -f $volumeParam, $descParam, $CapacityParam, $ProvisionTypeParam, $DeduplicateParam, $CompressionParam, $DataProtectionLevelParam, $AdaptiveOptimizationParam, $ScopeParam)) + + DisplayOutput -Code $scriptCode + + } + + Function Generate-LogicalInterConnectGroup-Script ($InputObject) + { + + $scriptCode = [System.Collections.ArrayList]::new() + + $ICModuleTypes = @{ + "VirtualConnectSE40GbF8ModuleforSynergy" = "SEVC40f8" ; + "VirtualConnectSE100GbF32ModuleforSynergy" = "SEVC100f32" ; + "Synergy50GbInterconnectLinkModule" = "SE50ILM"; + "Synergy20GbInterconnectLinkModule" = "SE20ILM"; + "Synergy10GbInterconnectLinkModule" = "SE10ILM"; + "VirtualConnectSE16GbFCModuleforSynergy" = "SEVC16GbFC"; + "VirtualConnectSE32GbFCModuleforSynergy" = "SEVC32GbFC"; + "Synergy12GbSASConnectionModule" = "SE12SAS"; + "571956-B21" = "FlexFabric"; + "455880-B21" = "Flex10"; + "638526-B21" = "Flex1010D"; + "691367-B21" = "Flex2040f8"; + "572018-B21" = "VCFC20"; + "466482-B21" = "VCFC24"; + "641146-B21" = "FEX" + } + + $FabricModuleTypes = @{ + "VirtualConnectSE40GbF8ModuleforSynergy" = "SEVC40f8" ; + "VirtualConnectSE100GbF32ModuleforSynergy" = "SEVC100f32" ; + "Synergy12GbSASConnectionModule" = "SAS"; + "VirtualConnectSE16GbFCModuleforSynergy" = "SEVCFC"; + "VirtualConnectSE32GbFCModuleforSynergy" = "SEVCFC"; + } + + $ICModuleToFabricModuleTypes = @{ + "SEVC40f8" = "SEVC40f8" ; + "SEVC100f32" = "SEVC100f32" ; + 'SE50ILM' = "SEVC100f32" ; + 'SE20ILM' = "SEVC40f8" ; + 'SE10ILM' = "SEVC40f8" ; + "SEVC16GbFC" = "SEVCFC" ; + "SEVC32GbFC" = "SEVCFC" ; + "SE12SAS" = "SAS" + } + + $UnsupportedLigTypes = 'FEX', 'SAS' + + $LigType = $ScopeParam = $QosParam = $null + + $lig = $InputObject + + $name = $lig.Name + $enclosureType = $lig.enclosureType + $description = $lig.description + $uplinkSets = $lig.uplinksets | Sort-Object Name + $qos = $lig.qosConfiguration.activeQosConfig + $qosConsistency = $lig.qosConfiguration.consistencyChecking -replace 'Match' , '' -replace 'NotChecked', 'None' + + switch ($lig.category) + { + + 'sas-logical-interconnect-groups' + { + + $LigType = 'SAS' + + } + + 'logical-interconnect-groups' + { + + $LigType = 'EthernetFC' + + $snmp = $lig.snmpConfiguration + $Telemetry = $lig.telemetryConfiguration + $sampleCount = $Telemetry.sampleCount + $sampleInterval = $Telemetry.sampleInterval + + # The following is only applicable to Ethernet LIG, not FC or SAS + $internalNetworkUris = $lig.internalNetworkUris + $redundancyType = $lig.redundancyType + $fastMacCacheFailover = $lig.ethernetSettings.enableFastMacCacheFailover + $macrefreshInterval = $lig.ethernetSettings.macRefreshInterval + $igmpSnooping = $lig.ethernetSettings.enableIGMPSnooping + $igmpIdleTimeout = $lig.ethernetSettings.igmpIdleTimeoutInterval + $networkLoopProtection = $lig.ethernetSettings.enablenetworkLoopProtection + $PauseFloodProtection = $lig.ethernetSettings.enablePauseFloodProtection + $EnableRichTLV = $lig.ethernetSettings.enableRichTLV + $LDPTagging = $lig.ethernetSettings.enableTaggedLldp + $StormControl = $lig.ethernetSettings.enableStormControl + $ICConsistencyChecking = $lig.EthernetSettings.ConsistencyChecking -replace 'Match' , '' -replace 'NotChecked', 'None' + $intNetConsistency = $lig.consistencyCheckingForInternalNetworks -replace 'Match' , '' -replace 'NotChecked', 'None' + + } + + } + + [void]$scriptCode.Add('# -------------- Attributes for Logical Interconnect Group "{0}"' -f $name) + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'name' -Value ('"{0}"' -f $name))) + + $FrameCount = $InterconnectBaySet = $frameCountParam = $StormControlParamParam = $null + $intnetParam = $null + + # ---------------------------- + # Find Interconnect devices + $Bays = [System.Collections.ArrayList]::new() + $UpLinkPorts = [System.Collections.ArrayList]::new() + $Frames = [System.Collections.ArrayList]::new() + + $LigInterconnects = $lig.interconnectMapTemplate.interconnectMapEntryTemplates | Where-Object { -not [String]::IsNullOrWhiteSpace($_.permittedInterconnectTypeUri) } + + $BayHashtable = [System.Collections.Specialized.OrderedDictionary]::new() + + foreach ($ligIC in $LigInterconnects) + { + + # ----------------- + # Locate the Interconnect device and its position + $ICTypeuri = $ligIC.permittedInterconnectTypeUri + + if ($enclosureType -eq $Syn12K) + { + + $ICtypeName = (Get-NamefromUri -Uri $ICTypeUri).Replace(' ',$null) # remove Spaces + $ICmoduleName = $ICModuleTypes[$ICtypeName] + + $BayNumber = ($ligIC.logicalLocation.locationEntries | Where-Object Type -eq "Bay").RelativeValue + $FrameNumber = [math]::abs(($ligIC.logicalLocation.locationEntries | Where-Object Type -eq "Enclosure").RelativeValue) + + $fabricModuleType = $ICModuleToFabricModuleTypes[$ICmoduleName] + + if (-not ($BayHashtable.GetEnumerator() | Where-Object Name -eq "Frame$FrameNumber")) + { + + $BayHashtable.Add("Frame$FrameNumber", ([Hashtable]::new())) + + } + + # Use this hashtable to build the final string value for scriptCode + $BayHashtable."Frame$FrameNumber".Add("Bay$BayNumber", $ICmoduleName) + + } + + else # C7K + { + + Try + { + + $PartNumber = (Send-OVRequest -Uri $ICTypeuri -Hostname $ApplianceConnection).partNumber + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if ("FEX" -eq $ICModuleTypes[$PartNumber]) + { + + $LigType = 'FEX' + + } + + $ICmoduleName = $ICModuleTypes[$PartNumber] + $BayNumber = ($ligIC.logicalLocation.locationEntries | Where-Object Type -eq "Bay").RelativeValue + + [void]$Bays.Add(('Bay{0} = "{1}"' -f $BayNumber, $ICmoduleName)) # Format is xx=Flex Fabric + + } + + } + + if ($enclosureType -eq $Syn12K ) + { + + $FrameCount = $lig.EnclosureIndexes.Count + + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'frameCount' -Value ('{0}' -f $FrameCount))) + + $frameCountParam = ' -FrameCount $frameCount' + + if ($StormControl) + { + + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'enableStormControl' -Value ('{0}' -f $StormControl))) + + $StormControlParamParam = ' -EnableStormControl $enableStormControl' + + } + + } + + # ---------------------------- + # Find Internal networks + $intNetworks = [System.Collections.ArrayList]::new() + $intNetworkNames = [System.Collections.ArrayList]::new() + + foreach ($uri in $internalNetworkUris) + { + + Try + { + + $net = Send-OVRequest -Uri $uri -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $netname = "'{0}'" -f $net.name + + [void]$intNetworkNames.Add($netname) + [void]$intNetworks.Add($net) + + } + + #Code and parameters + + [Array]::Sort($Bays) + + $BayConfig = [System.Collections.ArrayList]::new() + + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'bayConfig' -Value '@{')) + + if ($enclosureType -eq $Syn12K) # Synergy + { + + # $BayConfigperFrame = [System.Collections.ArrayList]::new() + $SynergyCode = [System.Collections.ArrayList]::new() + $CurrentFrame = $null + + $InterconnectBaySet = $lig.interconnectBaySet + + $f = 1 + + # Process Bays parameter + foreach ($b in ($BayHashtable.GetEnumerator() | Sort-Object Name)) + { + + [void]$scriptCode.Add(("`t{0} = @{1}" -f $b.Name, $OpenDelim)) + + $endDelimiter = $SepHash + + if ($f -eq $BayHashtable.Count) + { + + $endDelimiter = $null + + } + + $_b = 1 + + # Loop through ports + ForEach ($l in ($b.Value.GetEnumerator() | Sort-Object Name)) + { + + $subEndDelimiter = $SepHash + + if ($_b -eq $b.Value.Count) + { + + $subEndDelimiter = $null + + } + + [void]$scriptCode.Add(("`t`t{0} = '{1}'{2}" -f $l.Name, $l.Value, $subEndDelimiter)) + + $_b++ + + } + + [void]$scriptCode.Add(("`t{0}{1}" -f $CloseDelim, $endDelimiter)) + + $f++ + + } + + [void]$scriptCode.Add('}') + + if ($redundancyType) + { + + $redundancyParam = ' -fabricredundancy $redundancyType' + + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'redundancyType' -Value ('"{0}"' -f $redundancyType))) + + } + + $FabricModuleTypeParam = ' -FabricModuleType $fabricModuleType' + $ICBaySetParam = ' -InterConnectBaySet $InterconnectBaySet' + + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'fabricModuleType' -Value ('"{0}"' -f $fabricModuleType))) + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'InterconnectBaySet' -Value ('{0}' -f $InterconnectBaySet))) + + # Clear out parameters used for Synergy + $PauseFloodProtectionParam = $macRefreshIntervalParam = $fastMacCacheParam = $null + + } + + else # C7K + { + + $_b = 1 + + ForEach ($b in $Bays) + { + + $endDelimiter = $SepHash + + if ($_b -eq $Bays.Count) + { + + $endDelimiter = $null + + } + + [void]$scriptCode.Add(("`t{0}{1}" -f $b, $endDelimiter)) + + $_b++ + + } + + [void]$scriptCode.Add('}') + + #Parameters valid only for C7000 + if ($UnsupportedLigTypes -notcontains $LigType) + { + + if ($fastMacCacheFailover) + { + + $macRefreshIntervalParam = $macRefreshIntervalCode = $null + + if ($macRefreshInterval) + { + + $macRefreshIntervalParam = " -macRefreshInterval `$macReFreshInterval " + + $scriptCode.Add((Generate-CustomVarCode -Prefix 'macRefreshInterval' -Value ('$macRefreshInterval'))) + + } + + $fastMacCacheParam = ' -enableFastMacCacheFailover:$fastMacCacheFailover {0}' # + $FastMacCacheIntervalParam + + } + + $PauseFloodProtectionParam = " -enablePauseFloodProtection:`$pauseFloodProtection " + + } + + # -------Clear out parameters used for Synergy + $RedundancyParam = $null + $FabricModuleTypeParam = $null + $FrameCountParam = $ICBaySetParam = $null + + } + + # Code and Parameters + $igmpParam = $networkLoopProtectionParam = $EnhancedLLDPTLVParam = $LDPtaggingParam = $InterconnectConsistencyCheckingParam = $intNetConsistencyCheckingParam = $null + + # ---- Bay config + $baysParam = ' -Bays $bayConfig' + + if ($UnsupportedLigTypes -notcontains $LigType) + { + + $igmpIdleTimeoutParam = $igmpIdleTimeoutCode = $intnetParam = $intnetCode = $snmpParam = $null + + if ($igmpSnooping) + { + + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'igmpSnooping' -Value ('${0}' -f $igmpSnooping))) + + if ($igmpIdletimeOut) + { + + $igmpIdleTimeoutParam = ' -IgmpIdleTimeOutInterval $igmpIdleTimeout' + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'igmpIdletimeOut' -Value ('{0}' -f $igmpIdletimeOut))) + + } + + $igmpParam = ' -enableIGMP:$igmpSnooping {0};' -f $igmpIdleTimeoutParam + + } + + if ($networkLoopProtection) + { + + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'networkLoopProtection' -Value ('${0}' -f $networkLoopProtection))) + $networkLoopProtectionParam = ' -enablenetworkLoopProtection:$networkLoopProtection' + + } + + if ($LDPTagging) + { + + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'LDPtagging' -Value ('${0}' -f $LDPtagging))) + $LDPtaggingParam = ' -EnableLLDPTagging:$LDPtagging' + + } + + if ($EnableRichTLV) + { + + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'EnableRichTLV' -Value ('${0}' -f $EnableRichTLV))) + $EnhancedLLDPTLVParam = ' -enableEnhancedLLDPTLV:$EnableRichTLV' + + } + + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'InterconnectConsistency' -Value ('"{0}"' -f $ICConsistencyChecking))) + $InterconnectConsistencyCheckingParam = ' -InterconnectConsistencyChecking $InterconnectConsistency' + + if ($intNetworkNames.Count -gt 0) + { + + $intNetParam = ' -InternalNetworks $intNetnames' + + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'intNetnames' -Value ('{0} | Get-OVNetwork ' -f [String]::Join($Comma, $intNetworkNames.ToArray())))) + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'InternalNetworkConsistency' -Value ('"{0}"' -f $intNetConsistency))) + $intNetConsistencyCheckingParam = ' -InternalNetworkConsistencyChecking $InternalNetworkConsistency' + } + + if ($snmp) + { + + $isV1Snmp = $snmp.enabled + $isV3Snmp = $snmp.v3Enabled + + if ($isV1Snmp -or $isV3Snmp) + { + + $readCommunityParam = $snmpParam = $contactParam = $snmpV3UsersParam = $accessListParam = $informParam = $snmpConsistencyCheckingParam = $trapdestParam =$null + + $readCommunity = $snmp.readCommunity + $contact = $snmp.systemContact + $snmpUsers = $snmp.snmpUsers + $accessList = $snmp.snmpAccess + $trapdestinations = $snmp.trapDestinations + $snmpConsistency = $snmp.consistencyChecking -replace 'Match', '' -replace 'NotChecked', 'None' + + if ( -not ([string]::IsNullOrEmpty($readCommunity))) + { + [void]$scriptCode.Add('#-- Generating snmp object for LIG') + + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'snmpConsistencyChecking' -Value ('"{0}"' -f $snmpConsistency))) + $snmpConsistencyCheckingParam = ' -snmpConsistencyChecking $snmpConsistencyChecking' + $snmpParam += $snmpConsistencyCheckingParam + + $snmpV1 = if ($isV1Snmp) { '$True'} else {'$False'} + $snmpV3 = if ($isV3Snmp) { '$True'} else {'$False'} + $snmpParam += " -SnmpV1 $SnmpV1 -SnmpV3 $SnmpV3 " + + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'readCommunity' -Value ('"{0}"' -f $readCommunity))) + $readCommunityParam = ' -ReadCommunity $readCommunity' + } + + if ($Contact) + { + + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'contact' -Value ('"{0}"' -f $contact))) + $contactParam = ' -Contact $contact' + + } + + $snmpUsersArray = @() + $authProtParam = $privProtParam = $null + + $securitylevel = 'None' + + $u = 1 + foreach ($user in $snmpUsers) + { + $snmpV3AuthProtocol = $user.v3AuthProtocol + $snmpv3PrivacyProtocol = $user.v3PrivacyProtocol + $snmpUserName = $user.snmpV3UserName + + [void]$scriptCode.Add('# -------------- Generating SNMPv3 user "{0}"' -f $snmpUserName) + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'userName' -Value ('"{0}"' -f $snmpUserName))) + + $snmpUserNameParam = ' -Username $userName' + + if ($snmpV3AuthProtocol -ne 'NA') + { + + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'authProtocol' -Value ('"{0}"' -f $snmpV3AuthProtocol))) + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'authPassword' -Value ('Read-Host -AsSecureString -Message "Provide password for Authentication Protocol."' -f $destination))) + + $authProtParam = ' -AuthProtocol $authProtocol -AuthPassword $authPassword' + + $securitylevel = 'AuthOnly' + + if ($snmpv3PrivacyProtocol -ne 'NA') + { + + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'privProtocol' -Value ('"{0}"' -f $snmpv3PrivacyProtocol))) + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'privPassword' -Value ('Read-Host -AsSecureString -Message "Provide password for Privacy Protocol."' -f $destination))) + + $privProtParam = ' -PrivProtocol $privProtocol -PrivPassword $privPassword' + + $securitylevel = 'AuthAndPriv' + + } + + } + + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'securityLevel' -Value ('"{0}"' -f $securitylevel))) + $securityLevelParam = ' -SecurityLevel $securityLevel' + + $VarName = 'snmpv3User{0}' -f $u + $Value = 'New-OVSnmpV3User{0}{1}{2}{3}' -f $snmpUserNameParam, $securityLevelParam, $authProtParam, $privProtParam + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix $VarName -Value $Value )) + + $snmpUsersArray += "$varName" + + $u++ + } + + if ($snmpUsersArray) + { + $varName = 'snmpv3Users' + $value = '@(${0})' -f ($snmpUsersArray -join ', $') + $snmpV3UsersParam = ' -Snmpv3Users $snmpv3Users' + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix $VarName -Value $Value )) + + } + + + + $u = 1 + # Process trap destinations + foreach ($t in $trapdestinations) + { + + $destParam = $communityStrParam = $portParam = $trapFormatParam = $severityParam = $vcmCategoryParam = $enetCategoryParam = $fcCateoryParam = $snmpUserParam = $engineIdParam = $null + + $destination = $t.trapDestination + $communityString = $t.communityString + $trapFormat = $t.trapFormat + $severities = $t.trapSeverities + $vcmTrapCategories = $t.vcmTrapCategories + $enetTrapCategories = $t.enetTrapCategories + $fcTrapCategories = $t.fcTrapCategories + $port = $t.port + $snmpUserName = $t.userName + $snmpUserEngineId = $t.engineId + $inform = $t.inform + + [void]$scriptCode.Add('#-- Generating Trap destination object for "{0}" ' -f $destination) + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'destination' -Value ('"{0}"' -f $destination))) + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'trapFormat' -Value ('"{0}"' -f $trapFormat))) + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'port' -Value ('{0}' -f $port))) + + $destParam = ' -destination $destination' + $trapFormatParam = ' -SnmpFormat $trapformat' + $portParam = ' -Port $port' + + # Need to ccreate new SNMPv3 user param for each trap destination + if ([RegEx]::Match($trapFormat, 'SNMPv3', $RegExInsensitiveFlag).Success) + { + if ($snmpUserName) + { + + + $VarName = 'snmpv3User' + $Value = "Get-OVSnmpV3User -Name `'$snmpUserName`'" + $snmpV3UserParamVarName = '${0}' -f $VarName + + $snmpUserParam = ' -SnmpV3User {0}' -f $snmpV3UserParamVarName + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix $VarName -Value $Value)) + } + + + + + } + + if ($inform) + { + + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'inform' -Value ('"{0}"' -f 'Inform'))) + + if ([RegEx]::Match($trapFormat, 'SNMPv3', $RegExInsensitiveFlag).Success) + { + + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'engineId' -Value ('"{0}"' -f $snmpUserEngineId))) + $engineIdParam = ' -EngineID $engineId' + + } + + } + + else + { + + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'inform' -Value ('"{0}"' -f 'Trap'))) + + } + + $informParam = ' -NotificationType $inform' + + [void]$scriptCode.Add(('$trapDestinations += New-OVSnmpTrapDestination{0}{1}{2}{3}{4}{5}' -f $destParam, $portParam, $communityParam, $FormatParam, $snmpUserParam, $informParam, $engineIdParam)) + + } + + + + if ($accessList) + { + + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'accessList' -Value ('@("{0}")' -f [String]::Join('", "', $accessList)))) + + $accessListParam = ' -AccessList $accessList' + + } + + if ( -not ([string]::IsNullOrEmpty($readCommunity))) + { + $trapdestParam = if ($trapDestinations) {' -TrapDestinations $trapDestinations'} else {''} + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix '$snmpConfig' -Value ('New-OVSnmpConfiguration{0}{1}{2}{3}{4}{5}' -f $readCommunityParam, $contactParam, $trapdestParam, $snmpV3UsersParam, $accessListParam,$snmpParam))) + $snmpParam += ' -SNMP $snmpConfig' + + } + } + + } + + if ($qos.configType -ne 'Passthrough') + { + + $qosConfigType = $qos.configType + $uClassType = $qos.uplinkClassificationType + $dClassType = $qos.downlinkClassificationType + + [void]$scriptCode.Add('#-- Generating QoS Configuration "{0}" ' -f $qosConfigType) + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'qosConfigType' -Value ('"{0}"' -f $qosConfigType))) + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'uClassType' -Value ('"{0}"' -f $uClassType))) + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'dClassType' -Value ('"{0}"' -f $dClassType))) + + $q = 1 + + ForEach ($trafficClass in $qos.qosTrafficClassifiers) + { + + $ingressDot1pClassMappingParam = $ingressDscpClassMappingParam = $null + + $className = $trafficClass.qosTrafficClass.className + $realTime = $trafficClass.qosTrafficClass.realTime + $bandwidthShare = $trafficClass.qosTrafficClass.bandwidthShare + $maxBandwidth = $trafficClass.qosTrafficClass.maxBandwidth + $egressDot1pValue = $trafficClass.qosTrafficClass.egressDot1pValue + $isEnabled = $trafficClass.qosTrafficClass.enabled + $ingressDot1pClassMapping = $trafficClass.qosClassificationMapping.dot1pClassMapping + $ingressDscpClassMapping = $trafficClass.qosClassificationMapping.dscpClassMapping + + [void]$scriptCode.Add('#---- Generating QoS Traffic Class Mapping "{0}" ' -f $className) + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'dClassType' -Value ('"{0}"' -f $className))) + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'realTime' -Value ('${0}' -f $realTime))) + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'bandwidthShare' -Value ('{0}' -f $bandwidthShare))) + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'maxBandwidth' -Value ('{0}' -f $maxBandwidth))) + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'egressDot1pValue' -Value ('{0}' -f $egressDot1pValue))) + + if ($null -ne $ingressDot1pClassMapping) + { + + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'ingressDot1pClassMapping' -Value ('{0}' -f [String]::Join(', ', $ingressDot1pClassMapping)))) + + $ingressDot1pClassMappingParam = ' -IngressDot1pClassMapping $ingressDot1pClassMapping' + + } + + if ($null -ne $ingressDscpClassMapping) + { + + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'ingressDscpClassMapping' -Value ('"{0}"' -f [String]::Join('", "', $ingressDscpClassMapping)))) + + $ingressDscpClassMappingParam = ' -IngressDscpClassMapping $ingressDscpClassMapping' + + } + + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'isEnabled' -Value ('${0}' -f $isEnabled))) + + $VarName = 'trafficClass' + $Value = 'New-OVQosTrafficClass -Name $name -MaxBandwidth $maxBandwidth -BandwidthShare $bandwidthShare -RealTime:$realTime -EgressDot1pValue $egressDot1pValue{0}{1} -Enabled:$isEnabled' -f $ingressDot1pClassMappingParam, $ingressDscpClassMappingParam + + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix $VarName -Suffix $q -Value $Value)) + + $q++ + + } + + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'QosConfig' -Value ('New-OVQosConfig -ConfigType {0} -UplinkClassificationType {1} -UplinkClassificationType {2} -TrafficClassifiers {3}' -f $qosConfigType, $uClassType, $dClassType, ([String]::Join(', ', (1..($q - 1) | ForEach-Object { '$trafficClass{0}' -f $_})))))) + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'QosConsistency' -Value ('"{0}"' -f $qosConsistency ))) + $QosParam = ' -QosConfiguration $QosConfig -QoSConsistencyChecking $qosConsistency' + + } + + } + + + $ligVariable = '$lig' + [void]$scriptCode.Add(('{0} = New-OVLogicalInterconnectGroup -Name $name -Bays $bayConfig{1}{2}{3}{4}{5}{6}{7}{8}{9}{10}{11}{12}{13}{14}{15}' -f $LigVariable, $FabricModuleTypeParam, $redundancyParam, $FrameCountParam, $ICBaySetParam, $igmpParam, $intNetParam,$intNetConsistencyCheckingParam, $networkLoopProtectionParam, $EnhancedLLDPTLVParam, $LDPtaggingParam, $StormControlParamParam, $InterconnectConsistencyCheckingParam, $snmpParam, $QosParam, $ScopeParam)) + + + # Process Scope + Try + { + + $ResourceScope = Send-OVRequest -Uri $lig.scopesUri -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + + if (-not [String]::IsNullOrEmpty($ResourceScope.scopeUris)) + { + [void]$scriptCode.Add(('# -------------- Adding resource {0} to scope ' -f $ligVariable)) + ForEach ($scopeUri in $ResourceScope.scopeUris) + { + + $scopeName = Get-NamefromUri -Uri $scopeUri + [void]$scriptCode.Add(('Get-OVScope -name {0} | Add-OVResourceToScope -InputObject {1}' -f $scopeName, $LigVariable)) + + } + + } + DisplayOutput -Code $scriptCode + + + # Process Uplink Sets + Generate-uplinkSet-Script -InputObject $lig + + Insert-BlankLine + + } + + Function Generate-uplinkSet-Script ($InputObject) + { + + $Caller = (Get-PSCallStack)[1].Command + #Write-Host $Caller -Foreground Green + + $ShouldAppend = if ('Generate-LogicalInterConnectGroup-Script', 'Generate-LogicalInterConnect-Script' -contains $Caller) { $true } else { $false } + + $uplinkSets = $parentType = $RootLocationInfos = $subLocationInfo = $parentName = $enclosureType = $null + $scriptCode = [System.Collections.ArrayList]::new() + + switch ($InputObject.type) + { + + {[RegEx]::Match($_, 'uplink-set', $RegExInsensitiveFlag).Success} + { + + $parentType = 'LogicalInterconnect' + $RootLocationInfos = 'portConfigInfos' + $subLocationInfo = 'location' + + Try + { + + $parent = Send-OVRequest -Uri $InputObject.logicalInterconnectUri -Hostname $ApplianceConnection + + $parentName = $parent.name + $enclosureType = $parent.enclosureType + $interconnects = $parent.interconnectMap.interconnectMapEntries + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $uplinkSets = $InputObject + + } + + # Not supported + {[RegEx]::Match($_, 'sas-logical-interconnect', $RegExInsensitiveFlag).Success} + { + + $parentType = 'SasLogicalInterconnectGroup' + + } + + default + { + + $parentType = 'LogicalInterconnectGroup' + $RootLocationInfos = 'logicalPortConfigInfos' + $subLocationInfo = 'logicalLocation' + + $parent = $InputObject + + $parentName = $parent.Name + $enclosureType = $parent.enclosureType + $uplinkSets = $parent.uplinkSets | sort-object Name + $interconnects = $parent.interconnectMapTemplate.interconnectMapEntryTemplates + + } + + } + + foreach ($upl in $uplinkSets) + { + + $uplName = $Upl.name + $upLinkType = $Upl.ethernetNetworkType -eq "Tunnel" ? "Tunnel" : $Upl.networkType + $ethMode = $Upl.mode + $networkURIs = $upl.networkUris + $networksetURIs = $upl.networksetUris + $uplConsistency = $upl.ConsistencyChecking -replace 'Match' , '' -replace 'NotChecked', 'None' + + [void]$scriptCode.Add(('# -------------- Attributes for Uplink Set "{0}" associated to {1} "{2}"' -f $uplName, $parentType, $parentName)) + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'name' -Value ('"{0}"' -f $uplName))) + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'uplinkType' -Value ('"{0}"' -f $uplinkType))) + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'parentName' -Value ('"{0}"' -f $parentName))) + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'parent' -Value ('Get-OV{0} -Name $parentName' -f $parentType))) + + switch ($parentType) + { + + 'LogicalInterconnect' + { + + $uplLogicalPorts = $Upl.portConfigInfos + $LocationPropName = 'location' + $ValuePropName = 'value' + + } + + 'LogicalInterconnectGroup' + { + + $uplLogicalPorts = $Upl.logicalportconfigInfos + $LocationPropName = 'logicalLocation' + $ValuePropName = 'relativeValue' + + } + + } + + # ---------------------------- + # Find networks and NetworkSets + $netNamesArray = [System.Collections.ArrayList]::new() + $networkNames = $fcTrunkingParam = $null + $netsetNamesArray = [System.Collections.ArrayList]::new() + $networksetNames = $null + + switch ($upl.networkType) + { + + 'Ethernet' + { + + $nativeNetURI = $Upl.nativeNetworkUri + $netTagtype = $Upl.ethernetNetworkType + $lacpTimer = $Upl.lacpTimer + + if ($Null -ne $nativeNetURI) + { + + $nativeNetname = Get-NamefromUri -Uri $nativeuri + + } + + foreach ($neturi in $networkUris) + { + + $netName = Get-NamefromUri -Uri $neturi + [void]$netNamesArray.Add($netName) + + } + + foreach ($fcoeNetUri in $fcoeNetworkUris) + { + + $netName = Get-NamefromUri -Uri $fcoeNetUri + [void]$netNamesArray.Add($netName) + + } + + foreach ($netseturi in $networksetUris) + { + + $netsetName = Get-NamefromUri -Uri $netseturi + [void]$netsetNamesArray.Add($netsetName) + + } + + } + + 'FibreChannel' + { + + $fcMode = $upl.fcMode + + # //TODO: Is this even correct?? + $fcSpeed = $Upl.FCSpeed ? $Upl.FCSpeed : 'Auto' + + if ($fcMode -eq 'Trunk') + { + + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'enableTrunking' -Value '$true')) + + $fcTrunkingParam = ' -EnableTrunking $enableTrunking' + + } + + foreach ($fcNetUri in $fcNetworkUris) + { + + $netName = Get-NamefromUri -Uri $fcNetUri + [void]$netNamesArray.Add($netName) + + } + + } + + } + + # ---------------------------- + # Find uplink ports + $UpLinkArray = [System.Collections.ArrayList]::new() + + foreach ($logicalPort in $uplLogicalPorts) + { + + $Speed = $UpLinkLocation = $Port = $icm = $null + + $ThisBayNumber = ($logicalPort.$LocationPropName.locationEntries | Where-Object Type -eq 'Bay').$ValuePropName + $ThisPortNumber = ($logicalPort.$LocationPropName.locationEntries | Where-Object Type -eq 'Port').$ValuePropName + $ThisEnclosure = ($logicalPort.$LocationPropName.locationEntries | Where-Object Type -eq 'Enclosure').$ValuePropName + + # Loop through Interconnect Map Entry Template items looking for the provided Interconnet Bay number + ForEach ($l in $interconnects) + { + + $ThisIcmEnclosureLocation = ($l.$LocationPropName.locationEntries | Where-Object { $_.type -eq "Enclosure" -and $_.$ValuePropName -eq $ThisEnclosure}).$ValuePropName + $ThisIcmBayLocation = ($l.$LocationPropName.locationEntries | Where-Object { $_.type -eq "Bay" -and $_.$ValuePropName -eq $ThisBayNumber}).$ValuePropName + + if ($enclosureType -eq $Syn12K) + { + + if ($ThisIcmBayLocation -and $l.enclosureIndex -eq $ThisEnclosure) + { + + $permittedInterconnectTypeUri = $l.permittedInterconnectTypeUri + + } + + } + + else + { + + if ($l.$LocationPropName.locationEntries | Where-Object { $_.type -eq "Bay" -and $_.$ValuePropName -eq $ThisBayNumber }) + { + + $permittedInterconnectTypeUri = $l.permittedInterconnectTypeUri + + } + + } + + } + + Try + { + + $PermittedInterConnectType = Send-OVRequest $permittedInterconnectTypeUri -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + # 1. Find port numbers and port names from permittedInterconnectType + $PortInfos = $PermittedInterConnectType.PortInfos + + # 2. Find Bay number and Port number on uplinksets + $ICLocation = $icm.$RootLocationInfos.$subLocationInfo + $ICBay = ($ICLocation | Where-Object Type -eq "Bay").$ValuePropName + $ICEnclosure = ($IClocation | Where-Object Type -eq "Enclosure").$ValuePropName + + # 3. Get faceplate port name + $ThisPortName = ($PortInfos | Where-Object PortNumber -eq $ThisPortNumber).PortName + + if ($ThisEnclosure -eq -1) # FC module + { + + $UpLinkLocation = "Bay{0}:{1}" -f $ThisBayNumber, $ThisPortName # Bay1:1 + + } + + else # Synergy Frames or C7000 + { + + if ($enclosureType -eq $Syn12K) + { + + $UpLinkLocation = "Enclosure{0}:Bay{1}:{2}" -f $ThisEnclosure, $ThisBayNumber, $ThisPortName.Replace(":", ".") # Enclosure#:Bay#:Q1.3; In $PortInfos, format is Q1:4, output expects Q1.4 + + } + + else # C7000 + { + + $UpLinkLocation = "Bay{0}:{1}" -f $ThisBayNumber, $ThisPortName.Replace(":", ".") # Bay#:Q1.3; In $PortInfos, format is Q1:4, output expects Q1.4 + + } + + } + + [void]$UpLinkArray.Add($UpLinkLocation) + + } + + $UpLinkArray.Sort() + + # Uplink Ports + $uplinkPortParam = $uplinkPortCode = $null + + if ($UplinkArray) + { + + $uplinkPortParam = ' -UplinkPorts $uplinkPorts' + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'uplinkPorts' -Value ('"{0}"' -f [String]::Join('", "', $UpLinkArray.ToArray())))) + + } + + # Networks + $uplNetworkParam = $uplNetworkCode = $null + if ($netNamesArray.Count -gt 0) + { + + $uplNetworkParam = ' -Networks $networks' + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'networks' -Value ('"{0}" | Get-OVNetwork' -f [String]::Join('", "', $netNamesArray.ToArray())))) + + } + + # Consistency Checking + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'uplConsistency' -Value ('"{0}"' -f $uplConsistency ))) + $uplConsistencyParam = ' -ConsistencyChecking $uplConsistency' + + # Network sets + $uplNetworksetParam = $uplNetworksetCode = $null + if ($netsetNamesArray.Count -gt 0) + { + + $uplNetworksetParam = ' -NetworkSets $networkSets' + $netsetVarName = '"{0}" ' -f [String]::Join('", "', $netSetNamesArray.ToArray()) + '| % { Get-OVNetworkSet -name $_ }' + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'networkSets' -Value $netsetVarName)) + + } + + $lacpTimerParam = $netAttributesParam = $uplNativeNetParam = $null + + # Uplink Type + if ($uplinkType -eq 'FibreChannel') + { + + $netAttributesParam = ' -fcUplinkSpeed $FCSpeed' + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'fcSpeed' -Value ('"{0}"' -f $fcSpeed))) + + } + + else # Ethernet-type + { + + if ($null -ne $nativeNetname) + { + + $uplNativeNetParam = " -nativeEthnetwork $nativenetwork" + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'nativeNetwork' -Value ('Get-OVNetwork -Name "{0}"' -f $nativeNetname))) + + } + + if ($ethMode -ne 'Audo') + { + + $netAttributesParam += ' -EthMode $ethMode' + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'ethMode' -Value ('"{0}"' -f $ethMode))) + + } + + if ($lacpTimer) + { + + $netAttributesParam += ' -lacptimer $lacpTimer' + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'lacpTimer' -Value ('"{0}"' -f $lacpTimer))) + + } + + } + + [void]$scriptCode.Add(('New-OVUplinkSet -InputObject $parent -Name $name -Type $uplinkType{0}{1}{2}{3}{4}{5}{6}' -f $uplNetworkParam, $uplNetworksetParam, $uplConsistencyParam, $netAttributesParam, $uplinkPortParam, $uplNativeNetParam, $fcTrunkingParam)) + + } + + DisplayOutput -Code $scriptCode -InternalAppend $ShouldAppend + + } + + Function Generate-EnclosureGroup-Script ($InputObject) + { + + $scriptCode = [System.Collections.ArrayList]::new() + + $EG = $InputObject + + $name = $EG.name + $description = $EG.description + $enclosureCount = $EG.enclosureCount + $powerMode = $EG.powerMode + $scopesUri = $EG.scopesUri + + $manageOSDeploy = $EG.osDeploymentSettings.manageOSDeployment + $deploySettings = $EG.osDeploymentSettings.deploymentModeSettings + $deploymentMode = $deploySettings.deploymentMode + + $ipv4AddressType = $EG.ipAddressingMode + $ipv4RangeUris = $EG.ipRangeUris + $ipv6AddressType = $EG.ipv6AddressingMode + $ipv6RangeUris = $EG.ipv6RangeUris + $enclosureType = $EG.enclosureTypeUri.split('/')[-1] + $ICnetBayMappings = $EG.interConnectBayMappings # | Where-Object EnclosureIndex -eq $Null | Where-Object logicalInterconnectGroupUri -ne $Null + + $EnclosureCount = $EG.enclosureCount + $enclosuretype = $EG.enclosureTypeUri.Split('/')[-1] + + [void]$scriptCode.Add('# -------------- Attributes for enclosure group "{0}"' -f $name) + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'name' -Value ('"{0}"' -f $name))) + + # --- Find Enclosure Bay Mapping + ### + + $enclosureCountParam = $IPv4AddressTypeParam = $ligMappingParam = $null + + $LigCollection = [System.Collections.ArrayList]::new() + $FrameHashtable = [System.Collections.Specialized.OrderedDictionary]::new() + $BayHashtable = [System.Collections.Specialized.OrderedDictionary]::new() + $CurrentLigName = "" + $CurrentLigVarName = $NULL + + # Process all LIGs + + if ($ICnetBayMappings) + { + + $l = 1 + + # Process all ligs and add them to a collection to be used for mapping later on + ForEach ($LigUri in ($ICnetBayMappings.logicalInterconnectGroupURI | Sort-Object -Unique)) + { + + $LigObject = [PSCustomObject]@{ + Name = (Get-NamefromUri -Uri $LigUri); + Uri = $LigUri; + VarName = ('$lig{0}' -f $l) + } + + $Value = 'Get-OVLogicalInterconnectGroup -Name "{0}"' -f $LigObject.Name + + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix $LigObject.VarName -Value $Value)) + + [void]$LigCollection.Add($LigObject) + + $l++ + + } + + switch ($enclosureType) + { + + # Synergy + $Syn12K + { + + for ($frame = 1; $frame -le $EnclosureCount; $frame++) + { + + $FrameID = 'Frame{0}' -f $frame + $FrameMapping = [System.Collections.ArrayList]::new() + + ForEach ($lig in ($ICnetBayMappings | Where enclosureIndex -eq $frame)) + { + + $thisLigVarName = ($LigCollection | Where Uri -eq $lig.logicalInterconnectGroupUri).VarName + + if (-not $FrameMapping.Contains($thisLigVarName)) + { + + [void]$FrameMapping.Add($thisLigVarName) + + } + + } + + ForEach ($lig in ($ICnetBayMappings | Where { $null -eq $_.enclosureIndex })) + { + + $thisLigVarName = ($LigCollection | Where Uri -eq $lig.logicalInterconnectGroupUri).VarName + + if (-not $FrameMapping.Contains($thisLigVarName)) + { + + [void]$FrameMapping.Add($thisLigVarName) + + } + + } + + $FrameMapping.Sort() + + $BayHashtable.Add($FrameID, ([String]::Join(', ', $FrameMapping.ToArray()))) + + } + + $ligMappingParam = ' -LogicalInterconnectGroupMapping $LigMapping' + + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'LigMapping' -Value '@{')) + + $c = 1 + + ForEach ($l in $BayHashtable.GetEnumerator()) + { + $endDelimiter = $SepHash + + if ($c -eq $BayHashtable.Count) + { + + $endDelimiter = $null + + } + + + [void]$scriptCode.Add(("`t{0} = {1}{2}" -f $l.Name, $l.Value, $endDelimiter)) + + $c++ + + } + + [void]$scriptCode.Add('}') + + } + + # C7000 + default + { + + $EnclosureBayMapping = [System.Collections.ArrayList]::new() + + foreach ($LIG in ($ICnetBayMappings | Where { $null -ne $_.logicalInterconnectGroupUri })) + { + + $thisLigVarName = ($LigCollection | Where Uri -eq $lig.logicalInterconnectGroupUri).VarName + + if (-not $EnclosureBayMapping.Contains($thisLigVarName)) + { + + [void]$EnclosureBayMapping.Add($thisLigVarName) + + } + + $EnclosureBayMapping.Sort() + + } + + $ligMappingParam = ' -LogicalInterconnectGroupMapping $LigMapping' + + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'LigMapping' -Value ([String]::Join(', ', $EnclosureBayMapping.ToArray())))) + + } + + } + + } + + $addressPoolParam = $null + + if ($enclosuretype -eq $SYN12K) + { + + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'enclosureCount' -Value ('{0}' -f $enclosureCount))) + $enclosureCountParam = ' -EnclosureCount $enclosureCount' + + #---- IP Address Pool + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'ipV4AddressType' -Value ('"{0}"' -f $EnclosureGroupIpAddressModeEnum[$ipV4AddressType]))) + $addressPoolParam = ' -IPv4AddressType $ipV4AddressType' + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'ipv6AddressType' -Value ('"{0}"' -f $EnclosureGroupIpAddressModeEnum[$ipv6AddressType]))) + $addressPoolParam += ' -IPv6AddressType $ipv6AddressType' + + if ($ipV4AddressType -eq 'IpPool') + { + + $IPv4RangeNames = [System.Collections.ArrayList]::new() + + foreach ($uri in $ipv4RangeUris) + { + + $rangeName = Get-NamefromUri -Uri $uri + [void]$IPv4RangeNames.Add('{0}' -f $rangeName) + + } + + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'ipv4addressPoolNames' -Value ('"{0}"' -f [String]::Join('", "', $IPv4RangeNames.ToArray())))) + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'ipv4addressPool' -Value ('$ipv4addressPoolNames | % { Get-OVAddressPoolRange -Name $_ }'))) + + $addressPoolParam += ' -IPv4AddressRange $ipv4addressPool' + + } + + if ($ipv6AddressType -eq 'IpPool') + { + + $IPv6RangeNames = [System.Collections.ArrayList]::new() + + foreach ($uri in $ipv6RangeUris) + { + + $rangeName = Get-NamefromUri -Uri $uri + [void]$IPv6RangeNames.Add('{0}' -f $rangeName) + + } + + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'ipv6AddressRangeNames' -Value ('"{0}"' -f [String]::Join('", "', $IPv6RangeNames.ToArray())))) + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'IPv6AddressRange' -Value ('$ipv6AddressRangeNames | % { Get-OVAddressPoolRange -Name $_ }'))) + + $addressPoolParam += ' -IPv6AddressRange $IPv6AddressRange' + + } + + } + + # --- OS Deployment with IS + $OSdeploymentParam = $null + + if ($manageOSDeploy) + { + + $OSdeploymentParam = ' -DeploymentNetworkType $deploymentMode' + + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'deploymentMode' -Value ('"{0}"' -f $deploymentMode))) + + if ($deploymentMode -eq 'External') + { + + $deploynetworkname = Get-NamefromUri -Uri $deploySettings.deploymentNetworkUri + $OSdeploymentParam += ' -deploymentnetwork $deploymentnetwork' + + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'deploynetworkname' -Value ('"{0}"' -f $deploynetworkname ))) + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'deploymentnetwork' -Value ('Get-OVnetwork -Name $deploynetworkname'))) + + } + + } + + $powerModeParam = $null + + if ($null -ne $powerMode) + { + + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'powerMode' -Value ('"{0}"' -f $powerMode))) + $powerModeParam = ' -PowerRedundantMode $powerMode' + + } + + # Get the EG configuration script to add as a parameter + Try + { + + $uri = $EG.uri + '/script' + $egScript = Send-OVRequest -Uri $uri -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $ConfigScriptParam = $null + + if ($null -ne $egScript) + { + + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'confScript' -Value ("'{0}'" -f $egScript))) + $ConfigScriptParam = ' -ConfigurationScript $confScript' + + } + + # Scopes + Try + { + + $ResourceScope = Send-OVRequest -Uri $scopesUri -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $n = 1 + + $ScopeParam = $null + + if (-not [String]::IsNullOrEmpty($ResourceScope.scopeUris)) + { + + ForEach ($scopeUri in $ResourceScope.scopeUris) + { + + $scopeName = Get-NamefromUri -Uri $scopeUri + + $ScopeVarName = 'Scope' + $Value = 'Get-OVScope -Name "{0}"' -f $scopeName + + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix $ScopeVarName -Suffix $n -Value $Value)) + + $n++ + + } + + $ScopeParam = ' -Scope {0}' -f ([String]::Join(', ', (1..($n - 1) | ForEach-Object { '$Scope{0}' -f $_}))) + + } + + [void]$scriptCode.Add(('New-OVEnclosureGroup -Name $name{0}{1}{2}{3}{4}{5}{6}' -f $enclosureCountParam, $liGMappingParam, $addressPoolParam, $OSdeploymentParam, $powerModeParam, $ConfigScriptParam, $ScopeParam)) + + DisplayOutput -Code $scriptCode + + } + + Function Generate-LogicalEnclosure-Script ($InputObject) + { + + $scriptCode = [System.Collections.ArrayList]::new() + + $LE = $InputObject + + $name = $LE.name + $enclUris = $LE.enclosureUris + $EncGroupUri = $LE.enclosuregroupUri + $FWbaselineUri = $LE.firmware.firmwareBaselineUri + $FWinstall = $LE.firmware.forceInstallFirmware + $scopesUri = $LE.scopesUri + + $EGName = Get-NamefromUri -Uri $EncGroupUri + $enclNames = ($enclUris | ForEach-Object { Get-NamefromUri -Uri $_ }) + + $egParam = ' -EnclosureGroup $eg' + $enclParam = ' -Enclosure ($enclosures | Select -First 1)' + + [void]$scriptCode.Add('# -------------- Attributes for logical enclosure "{0}"' -f $name) + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix '$name' -Value ('"{0}"' -f $name))) + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix '$egName' -Value ('"{0}"' -f $egName))) + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix '$eg' -Value ('Get-OVEnclosureGroup -Name $egName'))) + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix '$enclNames' -Value ('"{0}"' -f [String]::Join('", "', $enclNames)))) + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix '$enclosures' -Value '$enclNames | % { Get-OVenclosure -Name $_ }')) + + $fwparam = $null + + if ($FWbaselineUri) + { + + $fwName = Get-NamefromUri -Uri $FWbaselineUri + $fwparam = ' -FirmwareBaseline $fwBaseline -ForceFirmwareBaseline $fwInstall' + + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix '$fwName' -Value ('"{0}"' -f $fwName))) + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix '$fwBaseline' -Value 'Get-OVBaseline -SPPname $fwName')) + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix '$fwInstall' -Value ('${0}' -f $fwInstall))) + + } + + # Scopes + $ScopeParam = $null + + Try + { + + $ResourceScope = Send-OVRequest -Uri $scopesUri -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $n = 1 + + if (-not [String]::IsNullOrEmpty($ResourceScope.scopeUris)) + { + + ForEach ($scopeUri in $ResourceScope.scopeUris) + { + + $scopeName = Get-NamefromUri -Uri $scopeUri + + $ScopeVarName = 'Scope' + $Value = 'Get-OVScope -Name "{0}"' -f $scopeName + + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix $ScopeVarName -Suffix $n -Value $Value)) + + $n++ + + } + + $ScopeParam = ' -Scope {0}' -f ([String]::Join(', ', (1..($n - 1) | ForEach-Object { '$Scope{0}' -f $_}))) + + } + + [void]$scriptCode.Add(('New-OVLogicalEnclosure -Name $name{0}{1}{2}{3}' -f $enclParam, $egParam, $fwParam, $ScopeParam)) + + DisplayOutput -Code $scriptCode + + } + + Function Generate-ProfileTemplate-Script ($InputObject) + { + + $scriptCode = [System.Collections.ArrayList]::new() + + $Type = ($ResourceCategoryEnum.GetEnumerator() | Where-Object value -eq $InputObject.category).Name + + $name = $InputObject.Name + $description = $InputObject.Description + $spDescription = $InputObject.serverprofileDescription + $shtUri = $InputObject.serverHardwareTypeUri + $egUri = $InputObject.enclosureGroupUri + $sptUri = $InputObject.serverProfileTemplateUri + $serverUri = $InputObject.serverHardwareUri + $enclosureUri = $InputObject.enclosureUri + $enclosureBay = $InputObject.enclosureBay + $affinity = $InputObject.affinity + $hideFlexNics = $InputObject.hideUnusedFlexNics + $macType = $InputObject.macType + $wwnType = $InputObject.wwnType + $snType = $InputObject.serialNumberType + $iscsiType = $InputObject.iscsiInitiatorNameType + $osdeploysetting = $InputObject.osDeploymentSettings + $scopesUri = $InputObject.scopesUri + $mpSettings = $InputObject.managementProcessor + + $isSpt = $Type -eq 'ServerProfileTemplate' + + [void]$scriptCode.Add(('# -------------- Attributes for {0} "{1}"' -f $Type, $name)) + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix '$name' -Value ('"{0}"' -f $name))) + + $descriptionParam = $spdescriptionParam = $null + $serverAssignParam = $null + $shtParam = $egParam = $null + $ConnectionsParam = $null + $osDeploymentParam = $null + $LOCALStorageParam = $null + $SANStorageParam = $null + $bootManageParam = '' + $biosParam = $null + $mpSettingsParam = $null + $ScopeParam = $null + + # Get SHT + Try + { + + $sht = Send-OVRequest -Uri $shtUri -Hostname $ApplianceConnection + $shtName = $sht.name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + # ------- Descriptions + if ($description) + { + + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix '$description' -Value ('"{0}"' -f $description))) + $descriptionParam = ' -Description $description' + + } + + if ($spdescription) + { + + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix '$spdescription' -Value ('"{0}"' -f $spdescription))) + $spdescriptionParam = ' -ServerProfileDescription $spdescription ' + + } + + # ------- Server hardware assigned + if (-not [String]::IsNullOrWhiteSpace($serverUri)) + { + + $serverName = Get-NamefromUri -uri $serverUri + + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix '$server' -Value ('Get-OVServer -Name "{0}"' -f $serverName))) + + $serverAssignParam += ' -AssignmentType Server -Server $server' + + } + + if (-not [String]::IsNullOrWhiteSpace($sptUri)) + { + + Try + { + + $spt = Send-OVRequest -Uri $sptUri -HostName $ApplianceConnection + $sptName = $spt.name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'sptName' -Value ('"{0}"' -f $sptName))) + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'spt' -Value ('Get-OVServerProfileTemplate -Name "{0}"' -f $sptName))) + + $serverAssignParam += ' -ServerProfileTemplate $spt' + + } + + # -------- SHT and EG + if ([String]::IsNullOrWhiteSpace($serverUri)) + { + + if ($Type -eq 'ServerProfile' -and [String]::IsNullOrWhiteSpace($enclosureUri)) + { + + $serverAssignParam += ' -AssignmentType Unassigned' + + } + + elseif ($Type -eq 'ServerProfile' -and -not [String]::IsNullOrWhiteSpace($enclosureUri) -and -not [String]::IsNullOrWhiteSpace($egUri)) + { + + $enclosureName = Get-NamefromUri -uri $enclosureUri + + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'enclosure' -Value ('Get-OVEnclosure -Name "{0}"' -f $enclosureName))) + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'bay' -Value $enclosureBay)) + $serverAssignParam += ' -AssignmentType Bay -Enclosure $enclosure -Bay $bay' + + } + + if ([String]::IsNullOrWhiteSpace($sptUri)) + { + + # ------- SHT + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix '$shtName' -Value ('"{0}"' -f $shtName))) + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix '$sht' -Value 'Get-OVServerHardwareType -Name $shtName')) + + $shtParam = ' -ServerHardwareType $sht' + + # ------- EG, if BL or SY, and only needed if SPT or unassigned server profile + if (-not [String]::IsNullOrWhiteSpace($egUri)) + { + + Try + { + + $eg = Send-OVRequest -Uri $egUri -Hostname $ApplianceConnection + $egName = $eg.name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix '$egName' -Value ('"{0}"' -f $egName))) + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix '$eg' -Value 'Get-OVEnclosureGroup -Name $egName')) + + $egParam = ' -EnclosureGroup $eg' + } + + } + + } + + # Need to not display specific settings of profile if SHT is assigned + if ([String]::IsNullOrWhiteSpace($sptUri)) + { + + # ------- Affinity + $affinityParam = $null + + if (-not [String]::IsNullOrWhiteSpace($affinity)) + { + + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix '$affinity' -Value ('"{0}"' -f $affinity))) + + $affinityParam = ' -Affinity $affinity' + + } + + } + + # ------- Firmware + $fwParam = $fwCode = $null + + $fw = $InputObject.firmware + $isFwManaged = $fw.manageFirmware + + if ($isFWmanaged) + { + + $FwCode, $fwParam = Generate-ManageFirmware-Script -Fw $fw + + ForEach ($line in $FwCode.ToArray()) + { + + [void]$scriptCode.Add($line) + + } + + } + + # Process server profile template or server profile without a server profile template + if ($isSpt -or [String]::IsNullOrWhiteSpace($sptUri)) + { + + [void]$scriptCode.Add('# -------------- Connections section') + + # ------- Network Connections + $ConnectionSettings = $InputObject.connectionSettings + $ListofConnections = $ConnectionSettings.connections + $ConnectionVarNames = [System.Collections.ArrayList]::new() + + # ------- Consistency + if ($isSpt) + { + + $manageConnections = if ($ConnectionSettings.manageConnections) { '$True' } else { '$False' } + + $ConnectionsParam = " -ManageConnections $manageConnections" + + if ($manageConnections -eq '$True') + { + + $cnConsistency = $ConnectionSettings.complianceControl.Replace('CheckedMinimum' , 'Minimum').Replace('Unchecked', 'None').Replace('Checked', 'Exact') + + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix '$cnConsistency' -Value ('"{0}"' -f $cnConsistency) )) + + $ConnectionsParam += ' -ConnectionsConsistencyChecking $cnConsistency ' + + } + + } + + if ($ListofConnections.Count -gt 0) + { + + ForEach ($c in $ListofConnections) + { + + $conCode, $varstr = Generate-NetConnection-Script -Conn $c -MacAssignType $InputObject.macType -WwnAssignType $InputObject.wwnType + + ForEach ($line in $conCode.ToArray()) + { + + [void]$scriptCode.Add($line) + + } + + [void]$ConnectionVarNames.Add($varstr) + + } + + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix '$connections' -Value ([String]::Join(', ', $ConnectionVarNames.ToArray())))) + + $ConnectionsParam += ' -Connections $connections' + + } + + # ------- Local Storage + $localStorageCfg = $InputObject.localStorage + $ListofControllers = $InputObject.localStorage.controllers + $lsConsistency = $InputObject.localStorage.complianceControl + + if ($ListofControllers.Count -gt 0) + { + + [void]$scriptCode.Add('# -------------- Local Storage section') + + $LOCALStorageCode, $vars = Generate-LocalStorageController-Script -LocalStorageConfig $localStorageCfg + + ForEach ($line in $LOCALStorageCode.ToArray()) + { + + [void]$scriptCode.Add($line) + + } + + $LOCALStorageParam = ' -LocalStorage ' + + if ($vars -ne $null) + { + + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'controllers' -Value ('{0}' -f [String]::Join(', ', $vars.ToArray())))) + $LOCALStorageParam += ' -StorageController $controllers' + + } + + if ($isSpt) + { + + $lsConsistency = $lsConsistency.Replace('CheckedMinimum', 'Minimum').Replace('Unchecked', 'None').Replace('Checked', 'Exact') + + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix '$lsConsistency' -Value ('"{0}"' -f $lsConsistency) )) + + $LOCALStorageParam += ' -LocalStorageConsistencyChecking $lsConsistency ' + + } + + } + + # ---------- SAN storage + $SANStorageCfg = $InputObject.SanStorage + $ManagedStorage = $InputObject.SanStorage.manageSanStorage + $sanConsistency = $InputObject.SanStorage.complianceControl + + if ($ManagedStorage) + { + + $OSType = $SANStorageCfg.hostOSType + $hostOSType = $ServerProfileSanManageOSType.GetEnumerator().Where({$_.Value -eq $OSType}).Name + + $IsManagedSAN = $SANStorageCfg.manageSanStorage + $volumeAttachment = $SANStorageCfg.volumeAttachments + + if ($volumeAttachment -ne $Null) + { + + [void]$scriptCode.Add('# -------------- Attributes for SAN Storage') + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'osType' -Value ('"{0}"' -f $hostOSType))) + + $SANStorageCode, $vars = Generate-SANStorage-Script -SANStorageConfig $SANStorageCfg + + ForEach ($line in $SANStorageCode.ToArray()) + { + + [void]$scriptCode.Add($line) + + } + + $SANStorageParam = ' -SanStorage -HostOsType $osType ' + + if ($vars -ne $Null) + { + + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'volumeAttachments' -Value ('{0}' -f [String]::Join(', ', $vars.ToArray())))) + $SANStorageParam += ' -StorageVolume $volumeAttachments' + + } + + if ($isSpt) + { + + $sanConsistency = $sanConsistency.Replace('CheckedMinimum', 'Minimum').Replace('Unchecked', 'None').Replace('Checked', 'Exact') + + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'sanConsistency' -Value ('"{0}"' -f $sanConsistency ))) + + $SANStorageParam += ' -SANStorageConsistencyChecking $sanConsistency' + + } + + } + + } + + # ---------- Boot Settings + $bo = $InputObject.boot + $isManageBoot = $bo.manageBoot + $bm = $InputObject.bootMode + $isbootOrderManaged = $bm.manageMode + + if ($isManageBoot) + { + + [void]$scriptCode.Add('# -------------- Attributes for Boot Mode settings') + + $bootMode = $bm.mode + $pxeBootPolicy = $bm.pxeBootPolicy + $secureBoot = $bm.secureBoot + + if ($isSpt) + { + + $bmConsistency = $bm.complianceControl.Replace('CheckedMinimum','Minimum').Replace('Unchecked', 'None').Replace('Checked', 'Exact') + + } + + # Set BIOS Boot Mode, PXE boot policy and secure boot + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'manageboot' -Value ('${0}' -f $isManageBoot))) + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'biosBootMode' -Value ('"{0}"' -f $bootMode))) + + $bootManageParam += ' -ManageBoot:$manageboot -BootMode $biosBootMode' + + if (-not [String]::IsNullOrWhiteSpace($bootPXE)) + { + + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'pxeBootPolicy' -Value ('"{0}"' -f $pxeBootPolicy))) + + $bootManageParam += ' -PxeBootPolicy $pxeBootPolicy' + + } + + if ($secureBoot -ne 'Unmanaged') + { + + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'secureBoot' -Value ('"{0}"' -f $secureBoot))) + + $bootManageParam += ' -SecureBoot $secureBoot' + + } + + } + + if ($isbootOrderManaged -and -not [string]::IsNullOrEmpty($bo.order)) + { + + [void]$scriptCode.Add('# -------------- Attributes for boot order settings') + + $bootOrder = '"{0}"' -f [String]::Join('", "', $bo.order) + + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'bootOrder' -Value ('{0}' -f $bootOrder))) + + $bootManageParam += ' -BootOrder $bootOrder' + + } + + $boConsistencyParam = $Null + + if ($isSpt) + { + + if ($isManageBoot) + { + + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'bmConsistency' -Value ('"{0}"' -f $bmConsistency ))) + + $bmConsistency = $bm.complianceControl.Replace('Checked', 'Exact').Replace('Unchecked', 'None').Replace('CheckedMinimum' , 'Minimum') + $bmConsistencyParam = ' -BootModeConsistencyChecking $bmConsistency' + + } + + $bootManageParam += $bmConsistencyParam + $boConsistencyParam + + } + + # ---------- BIOS Settings + $bios = $InputObject.bios + + $isBiosManaged = $bios.manageBios + + if ($isBiosManaged) + { + + $biosParam = ' -Bios' + + $biosSettings = $bios.overriddenSettings + + if ($biosSettings.Count -gt 0) + { + [void]$scriptCode.Add('# -------------- Attributes for BIOS settings') + + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'biosSettings' -Value ('@{0}' -f $OpenArray))) + + $_b = 1 + + ForEach ($b in $biosSettings) + { + + $endDelimiter = $Comma + + if ($_b -eq $biosSettings.Count) + { + + $endDelimiter = $null + + } + + [void]$scriptCode.Add(("`t@{0}id = '{1}'; value = '{2}'{3}{4}" -f $OpenDelim, $b.id, $b.value, $CloseDelim, $endDelimiter)) + + $_b++ + + } + + [void]$scriptCode.Add($CloseArray) + + + $biosParam += ' -BiosSettings $biosSettings' + + if ($isSpt) + { + + $biosConsistency = $bios.complianceControl.Replace('CheckedMinimum','Minimum').Replace('Unchecked', 'None').Replace('Checked', 'Exact') + + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'biosConsistency' -Value ('"{0}"' -f $bmConsistency ))) + + $biosParam += ' -BiosConsistencyChecking $biosConsistency ' + + } + + } + + } + + # ---------- iLO Settings + $manageMp = $mpSettings.manageMp + $settings = $mpSettings.mpSettings + $complianceControl = $mpSettings.complianceControl + + $mpParam = $mpSptComplianceParam = $Null + + if ($manageMp) + { + + Insert-BlankLine + + [void]$scriptCode.Add('# -------------- Attributes for iLO settings') + + if ($isSpt) + { + + $mpConsistency = $complianceControl.Replace('CheckedMinimum','Minimum').Replace('Unchecked', 'None').Replace('Checked', 'Exact') + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'mpConsistency' -Value ('"{0}"' -f $mpConsistency ))) + + $mpSptComplianceParam = ' -IloSettingsConsistencyChecking $mpConsistency' + + } + + $mpParam = ' -ManageIloSettings $True{0} -IloSettings $iloSettings' -f $mpSptComplianceParam + + $mpSettingsCode = Generate-mpSettings-Script -Setting $settings + + [void]$scriptCode.Add($mpSettingsCode) + + + } # end ManageMp + + # ---------- Advanced Settings + $AdvancedSettingsParam = $null + $hideUnusedFlexNics = $InputObject.hideUnusedFlexNics + $macType = $InputObject.macType + $wwnType = $InputObject.wwnType + $serialNumberType = $InputObject.serialNumberType + $iscsiInitiatorNameType = $InputObject.iscsiInitiatorNameType + + $AdvancedSettings = [System.Collections.ArrayList]::new() + + if ($hideFlexNics -and $sht.capabilities -contains 'VCConnections') + { + + [void]$AdvancedSettings.Add('hideFlexNics') + + } + + if ($macType -ne 'Virtual' -and $sht.capabilities -contains 'VirtualMAC') + { + + [void]$AdvancedSettings.Add('macType') + + } + + if ($wwnType -ne 'Virtual' -and $sht.capabilities -contains 'VirtualWWN') + { + + [void]$AdvancedSettings.Add('wwnType') + + } + + if ($serialNumberType -ne 'Virtual' -and $sht.capabilities -contains 'VirtualUUID') + { + + [void]$AdvancedSettings.Add('serialNumberType') + + } + + if ($iscsiInitiatorNameType -ne 'AutoGenerated' -and $sht.capabilities -contains 'VCConnections') + { + + [void]$AdvancedSettings.Add('iscsiInitiatorNameType') + + } + + if ($AdvancedSettings.Count -gt 0) + { + + [void]$scriptCode.Add('# -------------- Attributes for advanced settings') + + ForEach ($advSetting in $AdvancedSettings) + { + + switch ($advSetting) + { + + 'hideFlexNics' + { + + $AdvancedSettingsParam += ' -HideUnusedFlexNics $true' + + } + + 'macType' + { + + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'macType' -Value ('"{0}"' -f $macType))) + $AdvancedSettingsParam += ' -MacAssignment $macType' + + } + + 'wwnType' + { + + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'wwnType' -Value ('"{0}"' -f $wwnType))) + $AdvancedSettingsParam += ' -WwnAssignment $wwnType' + + } + + 'serialNumberType' + { + + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'serialNumberType' -Value ('"{0}"' -f $serialNumberType))) + $AdvancedSettingsParam += ' -SnAssignment $serialNumberType' + + } + + 'iscsiInitiatorNameType' + { + + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'iscsiInitiatorType' -Value ('"{0}"' -f $iscsiInitiatorNameType))) + $AdvancedSettingsParam += ' -IscsiInitiatorNameAssignmet $iscsiInitiatorType' + + } + + } + + } + + } + + } + + + # ---------- OS Deployment Settings + if (-not [String]::IsNullOrWhiteSpace($osdeploysetting.osDeploymentPlanUri)) + { + + [void]$scriptCode.Add('# -------------- Attributes for OS deployment settings') + + $osDeploymentParam = ' -OSDeploymentPlan $osDeploymentPlan -OSDeploymentPlanAttributes $CustomAttribs' + + $osDeployPlanUri = $osdeploysetting.osDeploymentPlanUri + $planAttributes = $osdeploysetting.osCustomAttributes | Sort-Object Name + + $deployPlanName = Get-NamefromUri -Uri $osDeployPlanUri + + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'planName' -Value ('"{0}"' -f $deployPlanName))) + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'osDeploymentPlan' -Value 'Get-OVOsDeploymentPlan -Name $planName')) + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'planAttribs' -Value 'Get-OVOsDeploymentPlanAttribute -InputObject $osDeploymentPlan')) + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix 'CustomAttribs' -Value '@()')) + + ForEach ($attrib in $planAttributes) + { + + # Set value + if ([RegEx]::Match($attrib.Name, 'Password', $RegExInsensitiveFlag).Success) + { + + [void]$scriptCode.Add(('$PasswordSecureString = Read-Host -AsSecureString -Prompt "Provide required password"')) + + [void]$scriptCode.Add(('($planAttribs | Where-Object name -eq "{0}").value = [Runtime.InteropServices.Marshal]::PtrToStringBSTR([Runtime.InteropServices.Marshal]::SecureStringToBSTR($PasswordSecureString))' -f $attrib.Name)) + + # Save into new array + [void]$scriptCode.Add(('$CustomAttribs += $planAttribs | Where-Object name -eq "{0}"' -f $attrib.Name)) + + } + + else + { + + # Check to see if the attribute contains the word URI, then get the object. Figure out what type of object it is, and substitute the Get-OV Cmdlet instead + if ([RegEx]::Match($attrib.Name, 'uri', $RegExInsensitiveFlag).Success) + { + + Try + { + + $Resource = Send-OVRequest -Uri $attrib.Value -Hostname $ApplianceConnection + + switch ($Resource.type) + { + + $ResourceCategoryEnum.EthernetNetwork + { + + $CmdletSyntax = 'Get-OVNetwork -Type Ethernet -Name "{0}" -ErrorAction Stop' -f $Resource.name + + } + + $ResourceCategoryEnum.FibreChannel + { + + $CmdletSyntax = 'Get-OVNetwork -Type FibreChannel -Name "{0}" -ErrorAction Stop' -f $Resource.name + + } + + $ResourceCategoryEnum.NetworkSet + { + + $CmdletSyntax = 'Get-OVNetworkSet -Name "{0}" -ErrorAction Stop' -f $Resource.name + + } + + } + + $value = '({0}).uri' -f $CmdletSyntax + + } + + Catch + { + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + else + { + + $value = '"{0}"' -f $attrib.Value + + } + + [void]$scriptCode.Add(('($planAttribs | Where-Object name -eq "{0}").value = {1}' -f $attrib.Name, $value)) + + # Save into new array + [void]$scriptCode.Add(('$CustomAttribs += $planAttribs | Where-Object name -eq "{0}"' -f $attrib.Name)) + + } + + } + + } + + # Scopes + Try + { + + $ResourceScope = Send-OVRequest -Uri $scopesUri -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $n = 1 + + if (-not [String]::IsNullOrEmpty($ResourceScope.scopeUris)) + { + + ForEach ($scopeUri in $ResourceScope.scopeUris) + { + + $scopeName = Get-NamefromUri -Uri $scopeUri + + $ScopeVarName = 'Scope' + $Value = 'Get-OVScope -Name "{0}"' -f $scopeName + + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix $ScopeVarName -Suffix $n -Value $Value)) + + $n++ + + } + + $ScopeParam = ' -Scope {0}' -f ([String]::Join(', ', (1..($n - 1) | ForEach-Object { '$Scope{0}' -f $_}))) + + } + + [void]$scriptCode.Add(('New-OV{0} -Name $name{1}{2}{3}{4}{5}{6}{7}{8}{9}{10}{11}{12}{13}{14}{15}{16}' -f $Type, $descriptionParam, $spdescriptionParam, $serverAssignParam, $shtParam, $egParam, $affinityParam, $osDeploymentParam, $fwParam, $ConnectionsParam, $LOCALStorageParam, $SANStorageParam, $bootManageParam, $biosParam, $mpParam, $AdvancedSettingsParam, $ScopeParam)) + + DisplayOutput -Code $scriptCode + + } + + # Internal helper + Function Generate-ManageFirmware-Script + { + + Param + ( + + $fw + + ) + + $FwManagedCode = [System.Collections.ArrayList]::new() + $FwParam = $null + + $fwInstallType = $fw.firmwareInstallType + $fwForceInstall = $fw.forceInstallFirmware + $fwActivation = $fw.firmwareActivationType + $fwSchedule = $fw.firmwareScheduleDateTime + $fwBaseUri = $fw.firmwareBaselineUri + + $sppName = Get-NamefromUri -Uri $fwBaseUri + + [void]$scriptCode.Add('# -------------- Firmware section') + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix '$sppName' -Value ('"{0}"' -f $sppName))) + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix '$fwBaseline' -Value 'Get-OVbaseline -SPPname $sppName')) + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix '$fwInstallType' -Value ('"{0}"' -f $fwInstallType))) + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix '$fwForceInstall' -Value ('${0}' -f $fwforceInstall))) + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix '$fwActivation' -Value ('"{0}"' -f $fwActivation))) + + $fwParam = ' -firmware -Baseline $fwbaseline -FirmwareInstallMode $fwInstallType -ForceInstallFirmware:$fwForceInstall -FirmwareActivationMode $fwActivation' + + if (-not [String]::IsNullOrEmpty($fwSchedule)) + { + + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix '$fwSchedule' -Value ('"{0}"' -f $fwSchedule))) + $FwParam += ' -FirmwareActivateDateTime $fwSchedule' + + } + + if ($isSpt) + { + + $fwConsistency = $fw.complianceControl.Replace('Unchecked', 'None').Replace('Checked', 'Exact') + [void]$scriptCode.Add((Generate-CustomVarCode -Prefix '$fwConsistency' -Value ('"{0}"' -f $fwConsistency) )) + $FwParam += ' -FirmwareConsistencyChecking $fwConsistency' + + } + + Return $FwManagedCode, $FwParam + + } + + # Internal helper + Function Generate-NetConnection-Script + { + + Param + ( + + $Conn, + + $MacAssignType, + + $WwnAssignType + + ) + + $NetworkTypeEnum = @{ + + 'ethernet-networks' = 'Get-OVNetwork -Type Ethernet'; + 'fc-networks' = 'Get-OVNetwork -Type FibreChannel'; + 'network-sets' = 'Get-OVNetworkSet' + + } + + $ScriptConnection = [System.Collections.ArrayList]::new() + + $connID = $Conn.id + $connName = $Conn.name + $ConnType = $Conn.functionType + $netUri = $Conn.networkUri + $portID = $Conn.portID + $requestedVFs = $Conn.requestedVFs + $bootSettings = $Conn.boot + + $ConnectionVarName = '$Conn{0}' -f $connID + + [void]$ScriptConnection.Add('# -------------- Attributes for connection "{0}"' -f $connID) + [void]$ScriptConnection.Add((Generate-CustomVarCode -Prefix '$connID' -Value $ConnID)) + + $connNameParam = $null + + if (-not [String]::IsNullOrWhiteSpace($connName)) + { + + [void]$ScriptConnection.Add((Generate-CustomVarCode -Prefix '$connName' -Value ('"{0}"' -f $ConnName))) + $connNameParam = ' -Name $connName' + + } + + [void]$ScriptConnection.Add((Generate-CustomVarCode -Prefix '$connType' -Value ('"{0}"' -f $ConnType))) + + if (-not [String]::IsNullOrEmpty($netUri)) + { + + Try + { + + # Just get the whole object in order to get the type and name + $thisNetwork = Send-OVRequest -Uri $netUri + + $netName = $thisNetwork.name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + [void]$ScriptConnection.Add((Generate-CustomVarCode -Prefix '$netName' -Value ('"{0}"' -f $netName))) + + [void]$ScriptConnection.Add((Generate-CustomVarCode -Prefix '$ThisNetwork' -Value ('{0} -Name $netName' -f $NetworkTypeEnum[$thisNetwork.category]))) # Will return the correct Get-OV Cmdlet name and syntax + + } + + else + { + + $netName = "Unassigned" + + [void]$ScriptConnection.Add((Generate-CustomVarCode -Prefix '$ThisNetwork' -Value ('"{0}"' -f $netName))) + + } + + # Managed connection (BL/SY) + if ($Conn.isManaged) + { + + [void]$ScriptConnection.Add((Generate-CustomVarCode -Prefix '$portID' -Value ('"{0}"' -f $PortID))) + $PortIDParam = ' -PortId $portID' + + $mac = $macParam = $null + + if ($MacAssignType -eq "UserDefined") + { + + $macParam = ' -MacAssignment UserDefined' + + # Not sure why these replace statements are here. + $mac = $Conn.mac #-replace '[0-9a-f][0-9a-f](?!$)', '$&:' + + # Specific to handle SPT versus SP. SPT will not have a MAC address value within the connection + if (-not [String]::IsNullOrWhiteSpace($mac)) + { + + $macParam += ' -mac $mac' + [void]$ScriptConnection.Add((Generate-CustomVarCode -Prefix '$mac' -Value ('"{0}"' -f $mac))) + + } + + } + + $wwpn = $wwnn = $wwwnParam = $null + + if ($WwnAssignType -eq "UserDefined") + { + + # Not sure why these replace statements are here. + $mac = $Conn.mac #-replace '[0-9a-f][0-9a-f](?!$)', '$&:' # Format 10:00:11 + $wwpn = $Conn.wwpn #-replace '[0-9a-f][0-9a-f](?!$)', '$&:' + $wwnn = $Conn.wwnn #-replace '[0-9a-f][0-9a-f](?!$)', '$&:' + $wwnParam = ' -WwnAssignment UserDefined' + + if (-not [String]::IsNullOrWhiteSpace($wwpn)) + { + + $wwnParam += ' -Wwpn $wwpn -Wwnn $wwnn' + + [void]$ScriptConnection.Add((Generate-CustomVarCode -Prefix '$wwpn' -Value ('"{0}"' -f $wwpn))) + [void]$ScriptConnection.Add((Generate-CustomVarCode -Prefix '$wwnn' -Value ('"{0}"' -f $wwnn))) + + } + + } + + $requestedMbps = $Conn.requestedMbps + + if ($null -eq $requestedMbps) + { + + $requestedMbps = '"Auto"' + + } + + $allocatededMbps = $Conn.allocatedMbps + $maximumMbps = $Conn.maximumMbps + + $mbpsParam = $mbpsCode = $null + + $mbpsParam = ' -RequestedBW $requestedMbps' + [void]$ScriptConnection.Add((Generate-CustomVarCode -Prefix '$requestedMbps' -Value ('{0}' -f $requestedMbps))) + + # ---- lag + $lagName = $Conn.lagName + + $lagParam = $null + + if ($lagName) + { + + $lagParam = ' -LagName $lagName' + [void]$ScriptConnection.Add((Generate-CustomVarCode -Prefix '$lagName' -Value ('"{0}"' -f $lagName))) + + } + + #--- Virtual Functions + $requestedVfsParam = $null + + if (($requestedVFs -gt 0 -or $requestedVFs -eq 'Auto') -and $bootSettings.ethernetBootType -ne 'iSCSI' -and $ConnType -ne 'iSCSI') + { + + if ($requestedVFs -ne 'Auto') + { + + $requestedVFs = '"{0}"' -f $requestedVFs + + $requestedVfsParam = ' -Virtualfunctions $requestedVFs' + [void]$ScriptConnection.Add((Generate-CustomVarCode -Prefix '$requestedVFs' -Value ('{0}' -f $requestedVFs))) + + } + + } + + $bootSettingsParam = $bootTargetParam = $null + + $bootPriority = $bootSettings.priority + $bootVolumeSource = $bootSettings.bootVolumeSource + + if ($bootPriority -ne 'NotBootable') + { + + [void]$ScriptConnection.Add((Generate-CustomVarCode -Prefix '$bootPriority' -Value ('"{0}"' -f $bootPriority))) + [void]$ScriptConnection.Add((Generate-CustomVarCode -Prefix '$volSource' -Value ('"{0}"' -f $bootVolumeSource))) + + $bootSettingsParam = ' -Bootable -Priority $bootPriority -BootVolumeSource $volSource' + + if ($bootVolumeSource -eq 'UserDefined') + { + + switch ($ConnType) + { + + 'FibreChannel' + { + + ForEach ($target in $bootSettings.targets) + { + + $bootTarget = [regex]::Replace($target.arrayWwpn, '[0-9a-f][0-9a-f](?!$)', '$&:') + [void]$ScriptConnection.Add((Generate-CustomVarCode -Prefix '$bootTarget' -Value ('"{0}"' -f $bootTarget))) + + $targetLun = $target.lun + [void]$ScriptConnection.Add((Generate-CustomVarCode -Prefix '$targeLun' -Value ('{0}' -f $targetLun))) + + $bootTargetParam = ' -TargetWwpn $bootTarget -LUN $targetLun' + + } + + } + + # Both HW and SW iSCSI connection support + default + { + + # Where address policy for connection resides + $ipv4Settings = $Conn.ipv4 + $addressSource = $ipv4Settings.ipAddressSource + $IPv4address = $ipv4Settings.address + $IPv4Subnet = $ipv4Settings.subnetMask + $IPv4gateway = $ipv4Settings.gateway + + [void]$ScriptConnection.Add((Generate-CustomVarCode -Prefix '$addressSource' -Value ('"{0}"' -f $addressSource))) + + $bootTargetParam = ' -IscsiIPv4AddressSource $addressSource' + + if ($addressSource -eq 'UserDefined') + { + + if (-not [String]::IsNullOrWhiteSpace($IPv4address)) + { + + [void]$ScriptConnection.Add((Generate-CustomVarCode -Prefix '$IPv4address' -Value ('"{0}"' -f $IPv4address))) + + $bootTargetParam += ' -IscsiIPv4Address $IPv4address' + + } + + [void]$ScriptConnection.Add((Generate-CustomVarCode -Prefix '$IPv4Subnet' -Value ('"{0}"' -f $IPv4Subnet))) + + $bootTargetParam += ' -IscsiIPv4SubnetMask $IPv4Subnet' + + if (-not [String]::IsNullOrWhiteSpace($IPv4gateway)) + { + + [void]$ScriptConnection.Add((Generate-CustomVarCode -Prefix '$IPv4gateway' -Value ('"{0}"' -f $IPv4gateway))) + + $bootTargetParam += ' -IscsiIPv4Gateway $IPv4gateway' + + } + + } + + # Where boot target and CHAP settings reside + $iSCSISettings = $bootSettings.iscsi + $initiatorSource = $iSCSISettings.initiatorNameSource + $initiatorName = $iSCSISettings.initiatorName + $bootTargetIqn = $iSCSISettings.bootTargetName + $bootTargetLun = $iSCSISettings.bootTargetLun + $firstBootTargetIP = $iSCSISettings.firstBootTargetIp + $firstBootTargetPort = $iSCSISettings.firstBootTargetPort + $secondBootTargetIP = $iSCSISettings.secondBootTargetIP + $secondBootTargetPort = $iSCSISettings.secondBootTargetPort + $chapLevel = $iSCSISettings.chapLevel + $chapName = $iSCSISettings.chapName + $mutualChapName = $iSCSISettings.mutualChapName + + # Initiator Name + if (-not [String]::IsNullOrWhiteSpace($initiatorName) -and $initiatorSource -eq 'UserDefined') + { + + [void]$ScriptConnection.Add((Generate-CustomVarCode -Prefix '$profileInitiatorName' -Value ('"{0}"' -f $initiatorName))) + + $bootTargetParam += ' -ISCSIInitatorName $profileInitiatorName' + + } + + # Target IQN and LUN + if (-not [String]::IsNullOrWhiteSpace($bootTargetIqn)) + { + + [void]$ScriptConnection.Add((Generate-CustomVarCode -Prefix '$bootTargetIqn' -Value ('"{0}"' -f $bootTargetIqn))) + + $bootTargetParam += ' -IscsiBootTargetIqn $bootTargetIqn' + + if (-not [String]::IsNullOrWhiteSpace($bootTargetLun)) + { + + [void]$ScriptConnection.Add((Generate-CustomVarCode -Prefix '$bootTargetLun' -Value ('"{0}"' -f $bootTargetLun))) + + $bootTargetParam += ' -LUN $bootTargetLun' + + } + + } + + # First boot target IP + if (-not [String]::IsNullOrWhiteSpace($firstBootTargetIP)) + { + + [void]$ScriptConnection.Add((Generate-CustomVarCode -Prefix '$firstBootTargetIP' -Value ('"{0}"' -f $firstBootTargetIP))) + + $bootTargetParam += ' -IscsiPrimaryBootTargetAddress $firstBootTargetIP' + + if ($firstBootTargetPort -ne 3260) + { + + [void]$ScriptConnection.Add((Generate-CustomVarCode -Prefix '$firstBootTargetPort' -Value ('{0}' -f $firstBootTargetPort))) + + $bootTargetParam += ' -IscsiPrimaryBootTargetPort $firstBootTargetPort' + + } + + } + + # Second boot target IP + if (-not [String]::IsNullOrWhiteSpace($secondBootTargetIP)) + { + + [void]$ScriptConnection.Add((Generate-CustomVarCode -Prefix '$secondBootTargetIP' -Value ('"{0}"' -f $secondBootTargetIP))) + + $bootTargetParam += ' -IscsiSecondaryBootTargetAddress $secondBootTargetIP' + + if ($firstBootTargetPort -ne 3260) + { + + [void]$ScriptConnection.Add((Generate-CustomVarCode -Prefix '$secondBootTargetPort' -Value ('{0}' -f $secondBootTargetPort))) + + $bootTargetParam += ' -IscsiSecondaryBootTargetPort $secondBootTargetPort' + + } + + } + + # CHAP settings + if ($chapLevel -ne 'None') + { + + # Only needed for SPT + if (-not [String]::IsNullOrWhiteSpace($chapName)) + { + + [void]$ScriptConnection.Add((Generate-CustomVarCode -Prefix '$chapName' -Value ('"{0}"' -f $chapName))) + + $bootTargetParam += ' -ChapName $chapName' + + [void]$ScriptConnection.Add((Generate-CustomVarCode -Prefix '$chapSecret' -Value 'Read-Host -AsSecureString -Prompt "Provide CHAP password"')) + + $bootTargetParam += ' -ChapSecret $chapSecret' + + } + + # Needed for SPT or if not MutualChap policy + if (-not [String]::IsNullOrWhiteSpace($mutualChapName)) + { + + [void]$ScriptConnection.Add((Generate-CustomVarCode -Prefix '$mutualChapName' -Value ('"{0}"' -f $mutualChapName))) + + $bootTargetParam += ' -MutualChapName $mutualChapName' + + [void]$ScriptConnection.Add((Generate-CustomVarCode -Prefix '$mutualChapSecret' -Value 'Read-Host -AsSecureString -Prompt "Provide mutual CHAP password"')) + + $bootTargetParam += ' -MutualChapSecret $mutualChapSecret' + + } + + } + + } + + } + + } + + } + + } + + # Unmanaged connection (non-VC enabled port) + else + { + + if ($ConnType -eq 'FibreChannel' -and -not [String]::IsNullOrWhiteSpace($Conn.wwpn)) + { + + $wwpn = $Conn.wwpn #-replace '[0-9a-f][0-9a-f](?!$)', '$&:' + + $wwnParam = $null + + $wwnParam = ' -Wwpn $wwpn' + + [void]$ScriptConnection.Add((Generate-CustomVarCode -Prefix '$wwpn' -Value ('"{0}"' -f $wwpn))) + + } + + } + + $Value = 'New-OVServerProfileConnection -ConnectionID $connID{0} -ConnectionType $connType -Network $ThisNetwork{1}{2}{3}{4}{5}{6}{7}{8}' -f $connNameParam, $portIDParam, $macParm, $wwnParam, $requestedVFsParam, $mbpsParam, $lagParam, $bootSettingsParam, $bootTargetParam + $Cmd = Generate-CustomVarCode -Prefix $ConnectionVarName -Value $Value + + [void]$ScriptConnection.Add($Cmd) + + Return $ScriptConnection, $ConnectionVarName + + } + + # Internal helper + Function Generate-LocalStorageController-Script + { + + Param + ( + + $LocalStorageConfig + + ) + + $LDAcceleratorEnum = @{ + + ControllerCache = 'Enabled'; + IOBypass = 'SsdSmartPath'; + None = 'Disabled'; + Unmanaged = 'Unmanaged' + + } + + $ScriptController = [System.Collections.ArrayList]::new() + $ControllerVarNames = [System.Collections.ArrayList]::new() + + $SasLogicalJBODs = $LocalStorageConfig.sasLogicalJBODs + + $c = 1 + $l = 1 # Needed here so that LogicalDiskVarName num doesn't overlap with other controllers present with their own logical disks + + ForEach ($controller in $LocalStorageConfig.controllers) + { + + $LogicalDiskVarNames = [System.Collections.ArrayList]::new() + + $deviceSlot = $controller.deviceSlot + $mode = $controller.mode + $initialize = $controller.initialize + $writeCache = $controller.driveWriteCache + $importCfg = $controller.importConfiguration + $logicalDrives = $controller.logicalDrives + + $ControllerVarName = '$controller{0}' -f $c + + [void]$ControllerVarNames.Add($ControllerVarName) + + if ($importCfg) + { + + $importCfgParam = ' -ImportExistingConfiguration' + + } + + else + { + + ForEach ($ld in $logicalDrives) + { + + $writeCacheParam = $initializeParam = $importCfgParam = $LogicalDisksParam = $null + + $LogicalDiskVarName = '$LogicalDisk{0}' -f $l + + [void]$LogicalDiskVarNames.Add($LogicalDiskVarName) + + $name = $ld.name + $RaidLevel = $ld.raidLevel + $bootable = $ld.bootable + $numPhysDrives = $ld.numPhysicalDrives + $driveTech = if ([String]::IsNullOrWhiteSpace($ld.driveTechnology)) { 'Auto' } else { $LogicalDiskCmdletTypeEnum[$ld.driveTechnology] } + $accelerator = $ld.accelerator + $sasLogicalJbodId = $ld.sasLogicalJBODId + $sasLogicalJbod = $SasLogicalJBODs | Where-Object { $_.deviceSlot -eq $deviceSlot -and $_.id -eq $sasLogicalJbodId } + + # Look for immediate attached disks, not D3940 + if (-not [String]::IsNullOrEmpty($name) -and [String]::IsNullOrEmpty($sasLogicalJbodId)) + { + + if ($null -eq $driveTech) + { + + $driveTech = 'Auto' + + } + + [void]$ScriptController.Add(('# -------------- Attributes for logical disk "{0}({1})"' -f $name, $RaidLevel)) + [void]$ScriptController.Add((Generate-CustomVarCode -Prefix "ldName" -Value ('"{0}"' -f $name))) + [void]$ScriptController.Add((Generate-CustomVarCode -Prefix "raidLevel" -Value ('"{0}"' -f $RaidLevel))) + [void]$ScriptController.Add((Generate-CustomVarCode -Prefix "numPhysDrives" -Value ('{0}' -f $numPhysDrives))) + [void]$ScriptController.Add((Generate-CustomVarCode -Prefix "driveTech" -Value ('"{0}"' -f $driveTech))) + + $LogicalDiskParams = ' -Raid $raidLevel -NumberofDrives $numPhysDrives -DriveType $driveTech' + + if ($bootable) + { + + $LogicalDiskParams += ' -Bootable $True' + + } + + if ($accelerator -ne 'Unmanaged') + { + + [void]$ScriptController.Add((Generate-CustomVarCode -Prefix "Accelerator" -Value ('"{0}"' -f $LDAcceleratorEnum[$accelerator]))) + + $LogicalDiskParams += ' -Accelerator $Accelerator' + + } + + # Internal drive configuration, so use -StorageLocation Internal + if ([RegEx]::Match($deviceSlot, 'Mezz', $RegExInsensitiveFlag).Success) + { + + [void]$ScriptController.Add((Generate-CustomVarCode -Prefix "Location" -Value '"Internal"')) + + $LogicalDiskParams += ' -StorageLocation $Location' + + } + + } + + # Synergy D3940 RAID disks + else + { + + $sasLJBODName = $sasLogicalJbod.name + $sasLJBODNumPhysDrives = $sasLogicalJbod.numPhysicalDrives + $sasLJBODMinDriveSize = $sasLogicalJbod.driveMinSizeGB + $sasLJBODMaxDriveSize = $sasLogicalJbod.driveMaxSizeGB + $sasLJBODdriveTech = if ([String]::IsNullOrWhiteSpace($sasLogicalJbod.driveTechnology)) { 'Auto' } else { $LogicalDiskCmdletTypeEnum[$sasLogicalJbod.driveTechnology] } + $sasLJBODeraseData = $sasLogicalJbod.eraseData + $sasLJBODpersistent = $sasLogicalJbod.persistent + + [void]$ScriptController.Add(('# -------------- Attributes for RAID logical JBOD "{0}" ({1})' -f $sasLJBODName, $deviceSlot)) + [void]$ScriptController.Add((Generate-CustomVarCode -Prefix "ldname" -Value ('"{0}"' -f $sasLJBODName))) + [void]$ScriptController.Add((Generate-CustomVarCode -Prefix "numPhysDrives" -Value ('{0}' -f $sasLJBODNumPhysDrives))) + + [void]$ScriptController.Add((Generate-CustomVarCode -Prefix "minDriveSize" -Value ('{0}' -f $sasLJBODMinDriveSize))) + [void]$ScriptController.Add((Generate-CustomVarCode -Prefix "maxDriveSize" -Value ('{0}' -f $sasLJBODMaxDriveSize))) + [void]$ScriptController.Add((Generate-CustomVarCode -Prefix "driveTech" -Value ('"{0}"' -f $sasLJBODdriveTech))) + + $LogicalDiskParams += ' -MinDriveSize $minDriveSize -MaxDriveSize $maxDriveSize -DriveType $driveTech' + + if ($sasLJBODeraseData) + { + + [void]$ScriptController.Add((Generate-CustomVarCode -Prefix "eraseDataOnDelete" -Value ('${0}' -f $sasLJBODeraseData))) + + $LogicalDiskParams += ' -EraseDataOnDelete $eraseDataOnDelete' + + } + + if ($sasLJBODpersistent) + { + + [void]$ScriptController.Add((Generate-CustomVarCode -Prefix "persistent" -Value ('${0}' -f $sasLJBODpersistent))) + + $LogicalDiskParams += ' -Permanent $persistent' + + } + + } + + $Value = 'New-OVServerProfileLogicalDisk -Name $ldName{0}' -f $LogicalDiskParams + $Cmd = Generate-CustomVarCode -Prefix $LogicalDiskVarName -Value $Value + + [void]$ScriptController.Add($Cmd) + + $l++ + + } + + # Exclusively for D3940 Logical JBOD within the controller + ForEach ($sasJBOD in ($SasLogicalJBODs | Where-Object deviceSlot -eq $deviceSlot)) + { + + $LogicalDiskParams = $null + + $LogicalDiskVarName = '$LogicalDisk{0}' -f $l + + [void]$LogicalDiskVarNames.Add($LogicalDiskVarName) + + $sasLJBODName = $sasJBOD.name + $sasLJBODNumPhysDrives = $sasJBOD.numPhysicalDrives + $sasLJBODMinDriveSize = $sasJBOD.driveMinSizeGB + $sasLJBODMaxDriveSize = $sasJBOD.driveMaxSizeGB + $sasLJBODdriveTech = $LogicalDiskCmdletTypeEnum[$sasJBOD.driveTechnology] + $sasLJBODeraseData = $sasJBOD.eraseData + $sasLJBODpersistent = $sasJBOD.persistent + + [void]$ScriptController.Add(('# -------------- Attributes for logical JBOD "{0}" ({1})' -f $sasLJBODName, $deviceSlot)) + [void]$ScriptController.Add((Generate-CustomVarCode -Prefix "ldname" -Value ('"{0}"' -f $sasLJBODName))) + [void]$ScriptController.Add((Generate-CustomVarCode -Prefix "numPhysDrives" -Value ('{0}' -f $sasLJBODNumPhysDrives))) + + [void]$ScriptController.Add((Generate-CustomVarCode -Prefix "minDriveSize" -Value ('{0}' -f $sasLJBODMinDriveSize))) + [void]$ScriptController.Add((Generate-CustomVarCode -Prefix "maxDriveSize" -Value ('{0}' -f $sasLJBODMaxDriveSize))) + [void]$ScriptController.Add((Generate-CustomVarCode -Prefix "driveTech" -Value ('"{0}"' -f $sasLJBODdriveTech))) + + $LogicalDiskParams += ' -MinDriveSize $minDriveSize -MaxDriveSize $maxDriveSize -DriveType $driveTech' + + if ($sasLJBODeraseData) + { + + [void]$ScriptController.Add((Generate-CustomVarCode -Prefix "eraseDataOnDelete" -Value ('${0}' -f $sasLJBODeraseData))) + + $LogicalDiskParams += ' -EraseDataOnDelete $eraseDataOnDelete' + + } + + if ($sasLJBODpersistent) + { + + [void]$ScriptController.Add((Generate-CustomVarCode -Prefix "persistent" -Value ('${0}' -f $sasLJBODpersistent))) + + $LogicalDiskParams += ' -Permanent $persistent' + + } + + $Value = 'New-OVServerProfileLogicalDisk -Name $ldName{0}' -f $LogicalDiskParams + $Cmd = Generate-CustomVarCode -Prefix $LogicalDiskVarName -Value $Value + + [void]$ScriptController.Add($Cmd) + + $l++ + + } + + } + + [void]$ScriptController.Add(('# -------------- Attributes for controller "{0}" ({1})' -f $deviceSlot, $mode)) + [void]$ScriptController.Add((Generate-CustomVarCode -Prefix "deviceSlot" -Value ('"{0}"' -f $deviceSlot))) + [void]$ScriptController.Add((Generate-CustomVarCode -Prefix "controllerMode" -Value ('"{0}"' -f $mode))) + + + $LogicalDisksParam = $null + if ($LogicalDiskVarNames -ne $null) + { + + [void]$ScriptController.Add((Generate-CustomVarCode -Prefix "LogicalDisks" -Value ('{0}' -f [String]::Join(', ', $LogicalDiskVarNames.ToArray())))) + + $LogicalDisksParam = ' -LogicalDisk $LogicalDisks' + + } + + if ($writeCache -ne 'Unmanaged' -and -not [String]::IsNullOrEmpty($writeCache)) + { + + [void]$ScriptController.Add((Generate-CustomVarCode -Prefix "writeCache" -Value ('"{0}"' -f $writeCache))) + $writeCacheParam = ' -WriteCache $writeCache' + + } + + if ($initialize) + { + + $initializeParam = ' -Initialize' + + } + + $Value = 'New-OVServerProfileLogicalDiskController -ControllerID $deviceSlot -Mode $controllerMode{0}{1}{2}{3}' -f $writeCacheParam, $initializeParam, $importCfgParam, $LogicalDisksParam + $Cmd = Generate-CustomVarCode -Prefix $ControllerVarName -Value $Value + + [void]$ScriptController.Add($Cmd) + + $c++ + + } + + Return $ScriptController, $ControllerVarNames + + } + + # Internal helper + Function Generate-SANStorage-Script + { + + Param + ( + + $SANStorageConfig + + ) + + $SanStorageCode = [System.Collections.ArrayList]::new() + $VolAttachVarNames = [System.Collections.ArrayList]::new() + + $IsManagedSAN = $SANStorageConfig.manageSanStorage + $volumeAttachment = $SANStorageConfig.volumeAttachments + + $_v = 1 + + $volIdParam = $lunParam = $lunTypeParam = $null + + foreach ($vol in $volumeAttachment) + { + + $lunParam = $volumeParam = $null + + $VarName = '$volume{0}' -f $_v + + [void]$VolAttachVarNames.Add($VarName) + + $volID = $vol.id + $isBootVolume = if ($vol.bootVolumePriority -eq 'Bootable') { $True } else { $False } + $lunType = $vol.lunType + + # Lets see if volume name can be added here. If existing vol, volume name is not present in attachment, need to get volume from volumeUri + [void]$SanStorageCode.Add('# ----------- SAN volume attributes for volume ID "{0}"' -f $volID) + [void]$SanStorageCode.Add((Generate-CustomVarCode -Prefix 'volId' -Value ('{0}' -f $volID))) + [void]$SanStorageCode.Add((Generate-CustomVarCode -Prefix 'lunIdType' -Value ('"{0}"' -f $lunType))) + $lunParam = ' -VolumeID $volId -LunIDType $lunIdType' + + if ($lunType -ne 'Auto') + { + + $lunID = $vol.lun + + [void]$SanStorageCode.Add((Generate-CustomVarCode -Prefix 'lunID' -Value ('{0}' -f $lunID))) + $lunParam += ' -lunID $lunID' + + } + + # Perminent storage vol + if (-not [String]::IsNullOrWhiteSpace($vol.volumeUri)) + { + + Try + { + + $volAttachment = Send-OVRequest -Uri $vol.volumeUri -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $volName = $volProperty.name + + [void]$SanStorageCode.Add((Generate-CustomVarCode -Prefix 'volName' -Value ('"{0}"' -f $volName))) + [void]$SanStorageCode.Add((Generate-CustomVarCode -Prefix $VarName -Value 'Get-OVStorageVolume -Name $volName')) + + $volumeParam = ' -Volume {0}' -f $VarName + + } + + # Dynamic private volume + else + { + + # Common ephemeral volume settings + $volProperty = $vol.volume.properties + $isPermanent = $vol.volume.isPermanent + $name = $volProperty.name + $size = $volProperty.size / 1GB + $isDeduplicated = $volProperty.isDeduplicated + $ProvisioningType = $volProperty.provisioningType + $storagePoolUri = $volProperty.storagePool + + $templateUri = $vol.volume.templateUri + + [void]$SanStorageCode.Add((Generate-CustomVarCode -Prefix 'volName' -Value ('"{0}"' -f $name))) + $volumeParam = ' -Name $volName' + + Try + { + + $template = Send-OVRequest -Uri $templateUri -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $isRoot = $template.isRoot + + # Administrator SVT, not storage system SVT + if (-not $isRoot) + { + + $volTemplateName = $template.name + + [void]$SanStorageCode.Add((Generate-CustomVarCode -Prefix 'volTemplateName' -Value ('"{0}"' -f $volTemplateName))) + [void]$SanStorageCode.Add((Generate-CustomVarCode -Prefix 'volumeTemplate' -Value 'Get-OVStorageVolumeTemplate -Name $volTemplateName')) + + $volumeParam += ' -VolumeTemplate $volumeTemplate' + + } + + # Ephemeral volume with parameters + else + { + + # Get storage pool object + Try + { + + $storagePool = Send-OVRequest -Uri $storagePoolUri -Hostname $ApplianceConnection + $storageSystem = Send-OVRequest -Uri $storagePool.storageSystemUri -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $storagePoolName = $storagePool.name + + # Get storage system name from pool + $storageSystemName = $storageSystem.name + + $volTemplateParam = $volTemplateCode = $null + + [void]$SanStorageCode.Add((Generate-CustomVarCode -Prefix 'capacity' -Value ('{0}' -f $size))) + [void]$SanStorageCode.Add((Generate-CustomVarCode -Prefix 'ProvisioningType' -Value ('"{0}"' -f $ProvisioningType))) + [void]$SanStorageCode.Add((Generate-CustomVarCode -Prefix 'storagePoolName' -Value ('"{0}"' -f $storagePoolName))) + [void]$SanStorageCode.Add((Generate-CustomVarCode -Prefix 'storageSystemName' -Value ('"{0}"' -f $storageSystemName))) + [void]$SanStorageCode.Add((Generate-CustomVarCode -Prefix 'storagePool' -Value 'Get-OVStoragePool -Name $storagePoolName -StorageSystem $storageSystemName')) + + $volumeParam += ' -Capacity $capacity -ProvisioningType $ProvisioningType -StoragePool $storagePool' + + switch ($storageSystem.family) + { + + 'StoreServ' + { + + $snapshotStoragePoolUri = $volProperty.snapshotPool + + if ($snapshotStoragePoolUri -ne $storagePoolUri) + { + + # Get snapshot storage pool object + Try + { + + $snapshotStoragePool = Send-OVRequest -Uri $snapshotStoragePoolUri -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + [void]$SanStorageCode.Add((Generate-CustomVarCode -Prefix 'snapshotPoolName' -Value ('"{0}"' -f $snapshotStoragePool.name))) + [void]$SanStorageCode.Add((Generate-CustomVarCode -Prefix 'snapshotStoragePool' -Value 'Get-OVStoragePool -Name $snapshotPoolName -StorageSystem $storageSystemName')) + + $volumeParam += ' -SnapshotStoragePool $snapshotStoragePool' + + } + + } + + } + + } + + + if ($isPermanent) + { + + $volumeParam += ' -Permanent' + + } + + $_v++ + + } + + $Value = 'New-OVServerProfileAttachVolume{0}{1}{2}' -f $lunParam, $volumeParam, $null + + $Cmd = Generate-CustomVarCode -Prefix $VarName -Value $Value + + [void]$SanStorageCode.Add($Cmd) + + } + + return $SanStorageCode, $VolAttachVarNames + + } + + + # Internal helper + Function Generate-mpSettings-Script + { + + Param + ( + + $Setting + + ) + + $mpSettingsCode = [System.Collections.ArrayList]::new() + + $mpSettingsVars = @() + $mpSettingsArray = "" + + foreach ($s in $Setting) + { + + switch ($s.settingType) + { + + 'AdministratorAccount' + { + + $adminParams = $null + + [void]$mpSettingsCode.Add('# ------------------- iLO Attribute: Manage local iLO Administrator account') + + if ($s.args.deleteAdministratorAccount) + { + + [void]$mpSettingsCode.Add((Generate-CustomVarCode -Prefix 'removeAdminAccount' -Value '$True')) + + $adminParams = ' -RemoveLocalAdministratorAccount $removeAdminAccount' + + } + + else + { + + [void]$mpSettingsCode.Add((Generate-CustomVarCode -Prefix 'localAdminPassword' -Value 'Read-Host -Prompt "Administrator password" -AsSecureString')) + + $adminParams = ' -LocalAdministratorPassword $localAdminPassword' + + } + + + $mpSettingsArray += ' -ManageLocalAdministratorAccount{0}' -f $adminParams + + } + + 'LocalAccounts' + { + + $localAccountsArray = [System.Collections.ArrayList]::new() + $l = 1 + + [void]$mpSettingsCode.Add('# ------------------- iLO Attribute: Local Accounts') + foreach ($account in $s.args.localAccounts) + { + + $userNameParam = $userPasswordParam = $displayNameParam = $null + + # iLO4 privileges + $userConfigPrivParam = $userRemoteConsolePrivParam = $userVirtualMediaPrivParam = $userVirtualPowerAndResetPrivParam = $userIloConfigPrivParam = $null + + # iLO5 privileges + $userLoginPrivParam = $userHostBIOSConfigPrivParam = $userHostNICConfigPrivParam = $userHostStorageConfigPrivParam = $null + + $user = 'user{0}' -f $l + $VarName = '${0}' -f $user + + [void]$localAccountsArray.Add($VarName) + + [void]$mpSettingsCode.Add(('# ---------- iLO User: {0}' -f $account.userName)) + + [void]$mpSettingsCode.Add((Generate-CustomVarCode -Prefix ('{0}userName' -f $user) -Value ('"{0}"' -f $account.userName))) + + $userNameParam = ' -Username ${0}' -f ('{0}userName' -f $user) + + if (-not [String]::IsNullOrEmpty($account.displayName)) + { + + [void]$mpSettingsCode.Add((Generate-CustomVarCode -Prefix ('{0}displayName' -f $user) -Value ('"{0}"' -f $account.displayName))) + + $displayNameParam = ' -DisplayName ${0}' -f ('{0}displayName' -f $user) + + } + + [void]$mpSettingsCode.Add((Generate-CustomVarCode -Prefix ('{0}Password' -f $user) -Value ('Read-Host -Prompt "{0} password" -AsSecureString' -f $user))) + + $userPasswordParam = ' -Password ${0}' -f ('{0}Password' -f $user) + + if ($account.userConfigPriv) + { + + [void]$mpSettingsCode.Add((Generate-CustomVarCode -Prefix ('{0}userConfigPriv' -f $user) -Value '$True')) + + $userConfigPrivParam = ' -AdministerUserAccounts ${0}' -f ('{0}userConfigPriv' -f $user) + + } + + if ($account.remoteConsolePriv) + { + + [void]$mpSettingsCode.Add((Generate-CustomVarCode -Prefix ('{0}remoteConsolePriv' -f $user) -Value '$True')) + + $userRemoteConsolePrivParam = ' -RemoteConsole ${0}' -f ('{0}remoteConsolePriv' -f $user) + + } + + if ($account.virtualMediaPriv) + { + + [void]$mpSettingsCode.Add((Generate-CustomVarCode -Prefix ('{0}virtualMediaPriv' -f $user) -Value '$True')) + + $userVirtualMediaPrivParam = ' -VirtualMedia ${0}' -f ('{0}virtualMediaPriv' -f $user) + + } + + if ($account.virtualPowerAndResetPriv) + { + + [void]$mpSettingsCode.Add((Generate-CustomVarCode -Prefix ('{0}virtualPowerAndResetPriv' -f $user) -Value '$True')) + + $userVirtualPowerAndResetPrivParam = ' -VirtualPowerAndReset ${0}' -f ('{0}virtualPowerAndResetPriv' -f $user) + + } + + if ($account.iLOConfigPriv) + { + + [void]$mpSettingsCode.Add((Generate-CustomVarCode -Prefix ('{0}iLOConfigPriv' -f $user) -Value '$True')) + + $userIloConfigPrivParam = ' -ConfigureIloSettings ${0}' -f ('{0}iLOConfigPriv' -f $user) + + } + + if ($account.loginPriv) + { + + [void]$mpSettingsCode.Add((Generate-CustomVarCode -Prefix ('{0}loginPriv' -f $user) -Value '$True')) + + $userLoginPrivParam = ' -Login ${0}' -f ('{0}loginPriv' -f $user) + + } + + if ($account.hostBIOSConfigPriv) + { + + [void]$mpSettingsCode.Add((Generate-CustomVarCode -Prefix ('{0}hostBIOSConfigPriv' -f $user) -Value '$True')) + + $userHostBIOSConfigPrivParam = ' -HostBIOS ${0}' -f ('{0}hostBIOSConfigPriv' -f $user) + + } + + if ($account.hostNICConfigPriv) + { + + [void]$mpSettingsCode.Add((Generate-CustomVarCode -Prefix ('{0}hostNICConfigPriv' -f $user) -Value '$True')) + + $userHostNICConfigPrivParam = ' -HostNIC ${0}' -f ('{0}hostNICConfigPriv' -f $user) + + } + + if ($account.hostStorageConfigPriv) + { + + [void]$mpSettingsCode.Add((Generate-CustomVarCode -Prefix ('{0}hostStorageConfigPriv' -f $user) -Value '$True')) + + $userHostStorageConfigPrivParam = ' -HostStorage ${0}' -f ('{0}hostStorageConfigPriv' -f $user) + + } + + $Value = 'New-OVIloLocalUserAccount{0}{1}{2}{3}{4}{5}{6}{7}{8}{9}{10}{11}' -f $userNameParam, $userPasswordParam, $displayNameParam, $userConfigPrivParam, $userRemoteConsolePrivParam, $userVirtualMediaPrivParam, $userVirtualPowerAndResetPrivParam, $userIloConfigPrivParam, $userLoginPrivParam, $userHostBIOSConfigPrivParam, $userHostNICConfigPrivParam, $userHostStorageConfigPrivParam + + $Cmd = Generate-CustomVarCode -Prefix $VarName -Value $Value + + [void]$mpSettingsCode.Add($Cmd) + + $l++ + + } + + $mpSettingsArray += ' -ManageLocalAccounts' + + if ($localAccountsArray.Count -gt 0) + { + + [void]$mpSettingsCode.Add((Generate-CustomVarCode -Prefix 'mpLocalAccounts' -Value ([String]::Join(', ', $localAccountsArray.ToArray())))) + + $mpSettingsArray += ' -LocalAccounts $mpLocalAccounts' + + } + + else + { + + [void]$mpSettingsCode.Add('# No local accounts configured. All existing accounts will be removed, except for the local Administrator and the _HPEOneViewAdmin priviledged account.') + + } + + } + + 'DirectoryGroups' + { + + $l = 1 + $directoryGroupAccountsArray = [System.Collections.ArrayList]::new() + + [void]$mpSettingsCode.Add('# ------------------- iLO Attribute: Directory Groups') + + foreach ($g in $s.args.directoryGroupAccounts) + { + + $groupDNParam = $groupSIDParam = $null + + # Group privileges + $groupUserConfigPrivParam = $groupRemoteConsolePrivParam = $groupVirtualMediaPrivParam = $groupVirtualPowerAndResetPrivParam = $groupIloConfigPrivParam = $null + + $group = 'group{0}' -f $l + $VarName = '${0}' -f $group + + [void]$directoryGroupAccountsArray.Add($VarName) + + [void]$mpSettingsCode.Add(('# ---------- iLO Directory Group: {0}' -f $g.groupDN)) + + [void]$mpSettingsCode.Add((Generate-CustomVarCode -Prefix ('{0}groupDN' -f $group) -Value ('"{0}"' -f $g.groupDN))) + $groupDNParam = ' -GroupDN ${0}' -f ('{0}groupDN' -f $group) + + [void]$mpSettingsCode.Add((Generate-CustomVarCode -Prefix ('{0}groupSID' -f $group) -Value ('"{0}"' -f $g.groupSID))) + $groupSIDParam = ' -GroupSID ${0}' -f ('{0}groupSID' -f $group) + + if ($g.userConfigPriv) + { + + [void]$mpSettingsCode.Add((Generate-CustomVarCode -Prefix ('{0}userConfigPriv' -f $group) -Value '$True')) + + $groupUserConfigPrivParam = ' -AdministerUserAccounts ${0}' -f ('{0}userConfigPriv' -f $group) + + } + + if ($g.remoteConsolePriv) + { + + [void]$mpSettingsCode.Add((Generate-CustomVarCode -Prefix ('{0}remoteConsolePriv' -f $group) -Value '$True')) + + $groupRemoteConsolePrivParam = ' -RemoteConsole ${0}' -f ('{0}remoteConsolePriv' -f $group) + + } + + if ($g.virtualMediaPriv) + { + + [void]$mpSettingsCode.Add((Generate-CustomVarCode -Prefix ('{0}virtualMediaPriv' -f $group) -Value '$True')) + + $groupVirtualMediaPrivParam = ' -VirtualMedia ${0}' -f ('{0}virtualMediaPriv' -f $group) + + } + + if ($g.virtualPowerAndResetPriv) + { + + [void]$mpSettingsCode.Add((Generate-CustomVarCode -Prefix ('{0}virtualPowerAndResetPriv' -f $group) -Value '$True')) + + $groupVirtualPowerAndResetPrivParam = ' -VirtualPowerAndReset ${0}' -f ('{0}virtualPowerAndResetPriv' -f $group) + + } + + if ($g.iLOConfigPriv) + { + + [void]$mpSettingsCode.Add((Generate-CustomVarCode -Prefix ('{0}iLOConfigPriv' -f $group) -Value '$True')) + + $groupIloConfigPrivParam = ' -ConfigureIloSettings ${0}' -f ('{0}iLOConfigPriv' -f $group) + + } + + $Value = 'New-OVIloDirectoryGroup{0}{1}{2}{3}{4}{5}{6}' -f $groupDNParam, $groupSIDParam, $groupUserConfigPrivParam, $groupRemoteConsolePrivParam, $groupVirtualMediaPrivParam, $groupVirtualPowerAndResetPrivParam, $groupIloConfigPrivParam + + $Cmd = Generate-CustomVarCode -Prefix $VarName -Value $Value + + [void]$mpSettingsCode.Add($Cmd) + + $l++ + + } + + $mpSettingsArray += ' -ManageDirectoryGroups' + + if ($directoryGroupAccountsArray) + { + + [void]$mpSettingsCode.Add((Generate-CustomVarCode -Prefix 'mpGroups' -Value ([String]::Join(', ', $directoryGroupAccountsArray.ToArray())))) + + $mpSettingsArray += ' -DirectoryGroups $mpGroups' + + } + + } + + 'Directory' + { + + $d = $s.args + $mpKDCPortParam = $null + $mpDirectoryParams = "" + + [void]$mpSettingsCode.Add('# ------------------- iLO Attribute: Directory') + [void]$mpSettingsCode.Add((Generate-CustomVarCode -Prefix 'mpDirectory' -Value ('"{0}"' -f $IloAuthDirectorySchemaEnum[$d.directoryAuthentication]))) + $mpSettingsArray += ' -ManageDirectoryConfiguration -LdapSchema $mpDirectory' + + if ($d.directoryAuthentication -ne "disabledSchema") + { + + if ($d.directoryGenericLDAP) + { + + [void]$mpSettingsCode.Add((Generate-CustomVarCode -Prefix 'mpGenericLDAP' -Value $d.directoryGenericLDAP)) + + $mpSettingsArray += ' -GenericLDAP $mpGenericLDAP' + + } + + if ($d.iloObjectDistinguishedName) + { + + [void]$mpSettingsCode.Add((Generate-CustomVarCode -Prefix 'mpIloObjectDistinguishedName' -Value ('"{0}"' -f $d.iloObjectDistinguishedName))) + + $mpSettingsArray += ' -LOMObjectDistinguishedName $mpIloObjectDistinguishedName' + + [void]$mpSettingsCode.Add((Generate-CustomVarCode -Prefix 'mpIloObjectPassword' -Value ('Read-Host -Prompt "iLO Object password" -AsSecureString'))) + + $mpSettingsArray += ' -IloObjectPassword $mpIloObjectPassword' + + } + + [void]$mpSettingsCode.Add((Generate-CustomVarCode -Prefix 'mpDirectoryServerAddress' -Value ('"{0}"' -f $d.directoryServerAddress))) + $mpSettingsArray += ' -DirectoryServerAddress $mpDirectoryServerAddress' + + if ($d.directoryServerPort -ne 636) + { + + [void]$mpSettingsCode.Add((Generate-CustomVarCode -Prefix 'mpDirectoryServerPort' -Value $d.directoryServerPort)) + $mpDirectoryParams += ' -DirectoryServerPort $mpDirectoryServerPort' + + } + + if ($d.directoryUserContext) + { + + $value = "'{0}'" -f [String]::join("', '", $d.directoryUserContext) + + [void]$mpSettingsCode.Add((Generate-CustomVarCode -Prefix 'mpDirectoryUserContext' -Value $value)) + + $mpSettingsArray += ' -DirectoryUserContext $mpDirectoryUserContext' + + } + + if (-not [String]::IsNullOrEmpty($d.directoryServerCertificate)) + { + + [void]$mpSettingsCode.Add((Generate-CustomVarCode -Prefix 'mpDirectoryCertBase64' -Value ('"{0}"' -f $d.directoryServerCertificate))) + $mpSettingsArray += ' -DirectoryServerCertificateBase64 $mpDirectoryCertBase64' + + } + + } + + if ($d.kerberosAuthentication) + { + + $mpSettingsArray += ' -EnableKerberosAuthentication $true' + + [void]$mpSettingsCode.Add((Generate-CustomVarCode -Prefix 'mpKerberosRealm' -Value ('"{0}"' -f $d.kerberosRealm))) + [void]$mpSettingsCode.Add((Generate-CustomVarCode -Prefix 'mpKerberosKDCServerAddress' -Value ('"{0}"' -f $d.kerberosKDCServerAddress))) + + if ($d.kerberosKDCServerPort -ne 88) + { + + [void]$mpSettingsCode.Add((Generate-CustomVarCode -Prefix 'mpKerberosKDCServerPort' -Value ('"{0}"' -f $d.kerberosKDCServerPort))) + $mpKDCPortParam = ' -KerberosKDCServerPort $mpKerberosKDCServerPort' + + } + + [void]$mpSettingsCode.Add((Generate-CustomVarCode -Prefix 'mpKerberosKeytab' -Value 'Read-Host -Prompt "Provide the full path to the Kerberos Keytab file"')) + + $mpSettingsArray += ' -KerberosRealm $mpKerberosRealm -KerberosKDCServerAddress $mpKerberosKDCServerAddress{0} -KerbersKeyTabFile $mpKerberosKeytab' -f $mpKDCPortParam + + } + + } + + 'HostName' + { + + [void]$mpSettingsCode.Add('# ------------------- iLO Attribute: Host Name') + + [void]$mpSettingsCode.Add((Generate-CustomVarCode -Prefix 'mpHostName' -Value ('"{0}"' -f $s.args.HostName))) + + + $mpSettingsArray += ' -ManageIloHostname -IloHostname $mpHostName' + + } + + 'KeyManager' + { + + $k = $s.args + + [void]$mpSettingsCode.Add('# ------------------- iLO Attribute: Key Manager') + $mpSettingsArray += ' -ManageKeyManager' + + + [void]$mpSettingsCode.Add((Generate-CustomVarCode -Prefix 'kmPrimaryServerAddress' -Value ('"{0}"' -f $k.primaryServerAddress))) + $mpSettingsArray += ' -PrimaryKeyServerAddress $kmPrimaryServerAddress' + + if ($k.primaryServerPort -ne 9000) + { + + [void]$mpSettingsCode.Add((Generate-CustomVarCode -Prefix 'kmPrimaryServerPort' -Value ('{0}' -f $k.primaryServerPort))) + $mpSettingsArray += ' -PrimaryKeyServerPort $kmPrimaryServerPort' + + } + + if (-not [String]::IsNullOrEmpty($k.secondaryServerAddress)) + { + + [void]$mpSettingsCode.Add((Generate-CustomVarCode -Prefix 'kmSecondaryServerAddress' -Value ('"{0}"' -f $k.secondaryServerAddress))) + $mpSettingsArray += ' -SecondaryKeyServerAddress $kmSecondaryServerAddress' + + if ($k.secondaryServerPort -ne 9000) + { + + [void]$mpSettingsCode.Add((Generate-CustomVarCode -Prefix 'kmSecondaryServerPort' -Value ('{0}' -f $k.secondaryServerPort))) + $mpSettingsArray += ' -SecondaryKeyServerPort $kmSecondaryServerPort' + + } + + [void]$mpSettingsCode.Add((Generate-CustomVarCode -Prefix 'kmRedundancyRequired' -Value ('${0}' -f $k.redundancyRequired))) + $mpSettingsArray += ' -RedundancyRequired $kmRedundancyRequired' + + } + + [void]$mpSettingsCode.Add((Generate-CustomVarCode -Prefix 'kmGroupName' -Value ('"{0}"' -f $k.groupName))) + $mpSettingsArray += ' -KeymanagerGroupName $kmGroupName' + + if (-not [String]::IsNullOrEmpty($k.certificateName)) + { + + [void]$mpSettingsCode.Add((Generate-CustomVarCode -Prefix 'kmCertificateName' -Value ('"{0}"' -f $k.certificateName))) + $mpSettingsArray += ' -KeymanagerLocalCertificateName $kmCertificateName' + + } + + [void]$mpSettingsCode.Add((Generate-CustomVarCode -Prefix 'kmLoginName' -Value ('"{0}"' -f $k.loginName))) + $mpSettingsArray += ' -KeymanagerLoginName $kmLoginName' + + [void]$mpSettingsCode.Add((Generate-CustomVarCode -Prefix 'kmPassword' -Value ('Read-Host -Prompt "iLO Object password" -AsSecureString'))) + $mpSettingsArray += ' -KeymanagerPassword $kmPassword' + + } + + } + + } + + [void]$mpSettingsCode.Add('# ------------------- iLO Settings Policy') + + $Cmd = (Generate-CustomVarCode -Prefix 'iloSettings' -Value ('New-OVServerProfileIloPolicy{0}' -f $mpSettingsArray)) + + [void]$mpSettingsCode.Add($Cmd) + + return $mpSettingsCode + + } + + switch ($InputObject.GetType().FullName) + { + + {[RegEx]::Match($_, 'HPEOneview.Appliance.Baseline', $RegExInsensitiveFlag).Success} + { + + Generate-fwBaseline-Script -InputObject $InputObject + + } + + 'HPEOneview.Appliance.ProxyServer' + { + + Generate-proxy-Script -InputObject $InputObject + + } + + 'HPEOneview.Appliance.ScopeCollection' + { + + Generate-Scope-Script -InputObject $InputObject + + } + + 'HPEOneview.Appliance.SnmpReadCommunity' + { + + Generate-Snmp-Script -InputObject $InputObject + + } + + 'HPEOneview.Appliance.SnmpV3User' + { + + Generate-snmpV3User-Script -InputObject $InputObject + + } + + 'HPEOneview.Appliance.ApplianceLocaleDateTime' + { + + Generate-TimeLocale-Script -InputObject $InputObject + + } + + 'HPEOneView.Storage.StoragePool' + { + + Generate-StoragePool-Script -InputObject $InputObject + + } + + default + { + + switch ($InputObject.type) + { + + 'EmailNotificationV3' + { + + Generate-smtp-Script -InputObject $InputObject + + } + + 'Subnet' + { + + Generate-AddressPoolSubnet-Script -InputObject $InputObject + + } + + 'Range' + { + + Generate-AddressPoolRange-Script -InputObject $InputObject + + } + + {[RegEx]::Match($_, 'ethernet-network', $RegExInsensitiveFlag).Success} + { + + Generate-EthernetNetwork-Script -InputObject $InputObject + + } + + {[RegEx]::Match($_, 'network-set', $RegExInsensitiveFlag).Success} + { + + Generate-NetworkSet-Script -InputObject $InputObject + + } + + {[RegEx]::Match($_, 'fc(oe)*-network', $RegExInsensitiveFlag).Success} + { + + Generate-FCNetwork-Script -InputObject $InputObject + + } + + {[RegEx]::Match($_, 'FCDeviceManager', $RegExInsensitiveFlag).Success} + { + + Generate-SanManager-Script -InputObject $InputObject + + } + + {[RegEx]::Match($_, 'StorageSystem', $RegExInsensitiveFlag).Success} + { + + Generate-StorageSystem-Script -InputObject $InputObject + + } + + {[RegEx]::Match($_, 'StorageVolumeTemplate', $RegExInsensitiveFlag).Success} + { + + Generate-StorageVolumeTemplate-Script -InputObject $InputObject; Break + + } + + {[RegEx]::Match($_, 'StorageVolume', $RegExInsensitiveFlag).Success} + { + + Generate-StorageVolume-Script -InputObject $InputObject; Break + + } + + {[RegEx]::Match($_, 'UserAndPermissions', $RegExInsensitiveFlag).Success} + { + + Generate-User-Script -InputObject $InputObject + + } + + {[RegEx]::Match($_, 'LoginDomainGroupPermission', $RegExInsensitiveFlag).Success} + { + + Generate-RBAC-Script -InputObject $InputObject + + } + + {[RegEx]::Match($_, 'LoginDomainConfig', $RegExInsensitiveFlag).Success} + { + + Generate-DirectoryAuthentication-Script -InputObject $InputObject + + } + + # {[RegEx]::Match($_, 'Configuration', $RegExInsensitiveFlag).Success} + # { + + # Generate-RemoteSupport-Script -InputObject $InputObject + + # } + + {[RegEx]::Match($_, 'logical-interconnect-group', $RegExInsensitiveFlag).Success} + { + + Generate-LogicalInterConnectGroup-Script -InputObject $InputObject + + } + + {[RegEx]::Match($_, 'enclosure', $RegExInsensitiveFlag).Success} + { + + switch ($InputObject.category) + { + + 'enclosure-groups' + { + + Generate-EnclosureGroup-Script -InputObject $InputObject + + } + + 'logical-enclosures' + { + + if (($ConnectedSessions | Where-Object Name -eq $InputObject.ApplianceConnection.Name).ApplianceType -ne 'Composer') + { + + $ErrorRecord = [Management.Automation.ErrorRecord]::new([HPEOneView.Appliance.ComposerNodeException]::new('The ApplianceConnection {0} is not a Synergy Composer. The logical enclosure resource and this Cmdlet is only supported with Synergy Composers.' -f $ApplianceConnection)), 'InvalidOperation', 'InvalidOperation', 'ApplianceConnection' + + $PSCmdlet.WriteError($ErrorRecord) + + } + + else + { + + Generate-LogicalEnclosure-Script -InputObject $InputObject + + } + + } + + default + { + + if ($InputObject.enclosureType -eq 'C7000') + { + + Try + { + + $EnclosureGroup = Send-OVRequest -Uri $InputObject.enclosureGroupUri -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + Generate-EnclosureGroup-Script -InputObject $EnclosureGroup + + } + + else + { + + Try + { + + $LogicalEnclosure = Send-OVRequest -Uri $InputObject.logicalEnclosureUri -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + Generate-LogicalEnclosure-Script -InputObject $LogicalEnclosure + + } + + } + + } + + break + + } + + {[RegEx]::Match($_, 'server', $RegExInsensitiveFlag).Success} + { + + switch ($InputObject.category) + { + + 'server-profiles' + { + + Generate-ProfileTemplate-Script -InputObject $InputObject + + } + + 'server-profile-templates' + { + + Generate-ProfileTemplate-Script -InputObject $InputObject + + } + + # Generate Profile script code + 'server-hardware' + { + + Try + { + + $ServerProfile = Send-OVRequest -Uri $InputObject.serverProfileUri -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + # If a template is associated, get template code first + if ($null -ne $ServerProfile.serverProfileTemplateUri) + { + + Try + { + + $ServerProfileTemplate = Send-OVRequest -Uri $ServerProfile.serverProfileTemplateUri -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + Generate-ProfileTemplate-Script -InputObject $ServerProfileTemplate + + } + + Generate-Profile-Script -InputObject $ServerProfile + + } + + } + + } + + default + { + + $ExceptionMessage = 'The "{0}" resource category for "{1}" is currently not supported. ' -f $InputObject.type, $InputObject.name + $ErrorRecord = New-ErrorRecord HPEOneView.InputObjectResourceException InvalidInputObjectResource InvalidArgument "InputObject" -TargetType $InputObject.GetType().Name -Message $ExceptionMessage + + $PSCmdlet.WriteError($ErrorRecord) + + } + + } + + } + + } + + } + + End + { + + '[{0}] Done.' -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +####################################################### +# Appliance Configuration: +# + +function Get-OVComputeOpsManagement +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = 'Default')] + [OutputType ([HPEOneView.Appliance.CloudSettings])] + Param + ( + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $_ApplianceStatus = [System.Collections.ArrayList]::new() + + } + + Process + { + + Try + { + + $_ApplianceComputeOpsManagementSettings = Send-OVRequest -Uri $ApplianceComputeOpsManagementUri -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + [HPEOneView.Appliance.CloudSettings]::new($_ApplianceComputeOpsManagementSettings.enabled, + $_ApplianceComputeOpsManagementSettings.serial, + $_ApplianceComputeOpsManagementSettings.accountID, + $_ApplianceComputeOpsManagementSettings.connectionStatus, + $_ApplianceComputeOpsManagementSettings.instanceUrl, + $_ApplianceComputeOpsManagementSettings.ccsRegion, + $_ApplianceComputeOpsManagementSettings.ApplianceConnection) + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Set-OVComputeOpsManagement +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = 'Default')] + [OutputType ([HPEOneView.Appliance.TaskResource])] + Param + ( + + [Parameter (Mandatory, ParameterSetName = 'Default')] + [ValidateNotNullorEmpty()] + [String]$ActivationKey, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [Switch]$Async, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $_ApplianceStatus = [System.Collections.ArrayList]::new() + + } + + Process + { + + # Check to see if the appliance has an ApplianceID already configured + Try + { + + $_ApplianceComputeOpsManagementSettings = Send-OVRequest -Uri $ApplianceComputeOpsManagementUri -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if ($_ApplianceComputeOpsManagementSettings.enabled -and [String]::IsNullOrempty($_ApplianceComputeOpsManagementSettings.accountID)) + { + + "[{0}] Appliance has a generated appliance ID: " -f $MyInvocation.InvocationName.ToString().ToUpper(), $_ApplianceComputeOpsManagementSettings.serial | Write-Verbose + + $_body = @{ activationKey = $ActivationKey } + + Try + { + + $_TaskResponse = Send-OVRequest -Uri $ApplianceComputeOpsManagementUri -Method PATCH -Body $_body -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if (-not $PSBoundParameters['Async']) + { + + $_TaskResponse = Wait-OVTaskComplete -InputObject $_TaskResponse + + } + + $_TaskResponse + + } + + # Appliance is not configured yet for COMOVE and user must use Enable-OVComputeOpsmanagement + else + { + + $ExceptionMessage = 'The appliance is not configured to connect to Compute Ops Management. Use Enable-OVComputeOpsmanagement to generate the ApplianceID.' + $ErrorRecord = New-ErrorRecord HPEOneView.Appliance.ComputeOpsManagementSettingsException InvalidOperationException InvalidOperation ApplianceNotEnabled -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Connect-OVComputeOpsManagement +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = 'Default')] + [OutputType ([HPEOneView.Appliance.TaskResource])] + Param + ( + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $_ApplianceStatus = [System.Collections.ArrayList]::new() + + } + + Process + { + + Try + { + + $_ApplianceComputeOpsManagementSettings = Send-OVRequest -Uri $ApplianceComputeOpsManagementUri -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + # Appliance is already connected + if ($_ApplianceComputeOpsManagementSettings.enabled -and + $_ApplianceComputeOpsManagementSettings.connectionStatus -eq [HPEOneView.Appliance.CloudManagementConnectionEnum]::Connected) + { + + $ExceptionMessage = 'The appliance is already configured and connected to Compute Ops Management.' + $ExceptionReasonCode = 'ApplianceAlreadyConnected' + $ErrorRecord = New-ErrorRecord HPEOneView.Appliance.ComputeOpsManagementSettingsException InvalidOperationException InvalidOperation $ExceptionReasonCode -Message $ExceptionMessage + $PSCmdlet.WriteError($ErrorRecord) + } + + elseif ($_ApplianceComputeOpsManagementSettings.enabled -and + $_ApplianceComputeOpsManagementSettings.connectionStatus -eq [HPEOneView.Appliance.CloudManagementConnectionEnum]::Disconnected) + { + + "[{0}] Appliance has been configured with a valid ApplianceID (serial) and activated, but in a disconnected state." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $_TaskResponse = Send-OVRequest -Uri $ApplianceComputeOpsManagementUri -Method PATCH -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if (-not $PSBoundParameters['Async']) + { + + $_TaskResponse = Wait-OVTaskComplete -InputObject $_TaskResponse + + } + + $_TaskResponse + + } + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Enable-OVComputeOpsmanagement +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = 'Default')] + [OutputType ([HPEOneView.Appliance.TaskResource])] + Param + ( + + [Parameter (Mandatory, ParameterSetName = 'Activate')] + [ValidateNotNullorEmpty()] + [String]$ActivationKey, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [Switch]$Async, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $_ApplianceStatus = [System.Collections.ArrayList]::new() + + } + + Process + { + + # Get the current state of COM-OVE settings + Try + { + + $_ApplianceComputeOpsManagementSettings = Send-OVRequest -Uri $ApplianceComputeOpsManagementUri -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + # Appliance has an ApplianceID generated by hasn't been activated, user needs to provide the activation key either with the -ActivationKey param or use Set-OVComputeOpsmanagement + if ($_ApplianceComputeOpsManagementSettings.enabled) + { + + "[{0}] Appliance is already enabled." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $ExceptionMessage = 'The appliance is already configured to connect to Compute Ops Management.' + $ExceptionReasonCode = 'ApplianceAlreadyEnabled' + + if ($_ApplianceComputeOpsManagementSettings.connectionStatus -ne [HPEOneView.Appliance.CloudManagementConnectionEnum]::Connected) + { + + $ExceptionMessage += ' The appliance is not currently connected. Use the Connect-OVComputeOpsManagement Cmdlet to reestablish the connection.' + $ExceptionReasonCode = 'ApplianceAlreadyConfiguredNotConnected' + + } + + elseif ([String]::IsNullOrempty($_ApplianceComputeOpsManagementSettings.accountID)) + { + + $ExceptionMessage += " Appliance has not been activated to Compute Ops Management with an activation key. Use Set-OVComputeOpsManagement or the -ActivationKey parameter." + $ExceptionReasonCode = 'ApplianceNotActivated' + + } + + $ErrorRecord = New-ErrorRecord HPEOneView.Appliance.ComputeOpsManagementSettingsException InvalidOperationException InvalidOperation $ExceptionReasonCode -Message $ExceptionMessage + $PSCmdlet.WriteError($ErrorRecord) + + } + + # Appliance been configured (appliance has serial) but no activation key (account ID is null) + elseif (-not $PSBoundParameters['ActivationKey'] -and + -not $_ApplianceComputeOpsManagementSettings.enabled -and + -not [String]::IsNullOrempty($_ApplianceComputeOpsManagementSettings.serial) -and + [String]::IsNullOrempty($_ApplianceComputeOpsManagementSettings.accountID)) + { + + "[{0}] Appliance has been configured with a valid ApplianceID (serial). No accountID as an activation key has not been used to connect the appliance." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $ExceptionMessage = 'The appliance has not been configured with a valid ApplianceID. You must provide the activate key using the -ActivationKey parameter or Set-OVComputeOpsmanagement.' + $ErrorRecord = New-ErrorRecord HPEOneView.Appliance.ComputeOpsManagementSettingsException InvalidOperationException InvalidOperation EnableComputeOpsManagement -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($PSBoundParameters['ActivationKey'] -and + -not $_ApplianceComputeOpsManagementSettings.enabled -and + -not [String]::IsNullOrEmpty($_ApplianceComputeOpsManagementSettings.serial)) + { + + "[{0}] Appliance has been configured with a valid ApplianceID (serial), but not activated." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $_body = @{ activationKey = $ActivationKey } + + $_TaskResponse = Send-OVRequest -Uri $ApplianceComputeOpsManagementUri -Method POST -Body $_body -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if (-not $PSBoundParameters['Async']) + { + + $_TaskResponse = Wait-OVTaskComplete -InputObject $_TaskResponse + + } + + $_TaskResponse + + } + + # Appliance has not been configured, no activation key, no appliance id (serial) and no account ID. Will generate an appliance ID (serial) + else + { + + "[{0}] Appliance has not been configured. Geneating ApplianceID (serial)." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $_TaskResponse = Send-OVRequest -Uri $ApplianceComputeOpsManagementUri -Method POST -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if (-not $PSBoundParameters['Async']) + { + + $_TaskResponse = Wait-OVTaskComplete -InputObject $_TaskResponse + + } + + $_TaskResponse + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Disable-OVComputeOpsManagement +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = 'Default', SupportsShouldProcess, ConfirmImpact = 'High')] + [OutputType ([HPEOneView.Appliance.TaskResource])] + Param + ( + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [Switch]$Async, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $_ApplianceStatus = [System.Collections.ArrayList]::new() + + } + + Process + { + + Try + { + + $_ApplianceComputeOpsManagementSettings = Send-OVRequest -Uri $ApplianceComputeOpsManagementUri -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + # Appliance has an ApplianceID generated by hasn't been activated, user needs to provide the activation key either with the -ActivationKey param or use Set-OVComputeOpsmanagement + if (-not $_ApplianceComputeOpsManagementSettings.enabled) + { + + $ExceptionMessage = 'The appliance is not configured to connect to Compute Ops Management.' + $ErrorRecord = New-ErrorRecord HPEOneView.Appliance.ComputeOpsManagementSettingsException InvalidOperationException InvalidOperation ApplianceNotConfigured -Message $ExceptionMessage + $PSCmdlet.WriteError($ErrorRecord) + + } + + else + { + + $_ConfirmPromptMessage = "disable Compute Ops management" + + if ($PSCmdlet.ShouldProcess($ApplianceConnection, $_ConfirmPromptMessage)) + { + + Try + { + + $_TaskResponse = Send-OVRequest -Uri $ApplianceComputeOpsManagementUri -Method DELETE -AddHeader @{'If-Match' = "*"} -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if (-not $PSBoundParameters['Async']) + { + + $_TaskResponse = Wait-OVTaskComplete -InputObject $_TaskResponse + + } + + $_TaskResponse + + } + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + +} + +function Get-OVApplianceStaticRoute +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = 'Default')] + [OutputType ([HPEOneView.Appliance.StaticRoute])] + Param + ( + + [Parameter (Mandatory = $false)] + [ValidateNotNullorEmpty()] + [String]$Destination, + + [Parameter (Mandatory = $false)] + [ValidateNotNullorEmpty()] + [String]$Interface, + + [Parameter (Mandatory = $false)] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $_ApplianceStatus = [System.Collections.ArrayList]::new() + + } + + Process + { + + if ($ApplianceConnection.ApplianceType -eq 'Composer') + { + + $ExceptionMessage = 'The ApplianceConnection {0} is a Synergy Composer, which does not support IP static route configuration.' -f $ApplianceConnection + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.ComposerNodeException InvalidOperation InvalidOperation 'ApplianceConnection' -Message $ExceptionMessage + $PSCmdlet.WriteError($ErrorRecord) + + } + + else + { + + $_uri = $ApplinaceStaticRoutesUri + + if ($PSBoundParameters['Interface']) + { + + $_uri = '{0}/{1}' -f $ApplinaceStaticRoutesUri, $Interface + + Try + { + + $_AvailableInterfaces = Send-OVRequest -Uri $ApplianceNetworkConfigUri -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if (-not $_AvailableInterfaces.applianceNetworks | ? interfacename -eq $Interface) + { + + $AvailableNetworkInterfaceNames = $_AvailableInterfaces.applianceNetworks | Select -Expand interfacename + + $ExceptionMessage = "The provided interface {0} was not found on the appliance. Please specify '{1}'." -f $Interface, [String]::Join("' or '", $AvailableNetworkInterfaceNames) + $ErrorRecord = New-ErrorRecord HPEOneView.Library.ParameterValidationException InvalidParameterValue InvalidOperation 'Interface' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + try + { + + $_staticroutes = Send-OVRequest -Uri $_uri -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + # This will need to be parsed after the routes are returned from the API, as the API doesn't provide any filter functionality + if ($PSBoundParameters['Destination']) + { + + $_staticroutes.members = $_staticroutes.members | ? destination -eq $Destination + + } + + ForEach ($_routes in $_staticroutes.members) + { + + [HPEOneView.Appliance.StaticRoute]::new($_routes.id, + $_routes.destination, + $_routes.gateway, + $_routes.Interface, + $_routes.metric, + $_routes.created, + $_routes.modified, + $_routes.etag, + $_routes.uri, + $_routes.applianceConnection) + + } + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function New-OVApplianceStaticRoute +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = 'Default')] + Param + ( + + [Parameter (Mandatory, ParameterSetName = 'Default')] + [ValidateNotNullorEmpty()] + [String]$Destination, + + [Parameter (Mandatory, ParameterSetName = 'Default')] + [ValidateNotNullorEmpty()] + [IPAddress]$Gateway, + + [Parameter (Mandatory, ParameterSetName = 'Default')] + [ValidateNotNullorEmpty()] + [String]$Interface, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateSet(0,100000)] + [Int]$Metric, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $_ApplianceStatus = [System.Collections.ArrayList]::new() + + } + + Process + { + + if ($ApplianceConnection.ApplianceType -eq 'Composer') + { + + $ExceptionMessage = 'The ApplianceConnection {0} is a Synergy Composer, which does not support IP static route configuration.' -f $ApplianceConnection + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.ComposerNodeException InvalidOperation InvalidOperation 'ApplianceConnection' -Message $ExceptionMessage + $PSCmdlet.WriteError($ErrorRecord) + + } + + else + { + + $_uri = $ApplinaceStaticRoutesUri + + $_StaticRoute = NewObject -ApplianceStaticRoute + + # Validate the provided interface + Try + { + + $_AvailableInterfaces = Send-OVRequest -Uri $ApplianceNetworkConfigUri -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if (-not $_AvailableInterfaces.applianceNetworks | ? interfacename -eq $Interface) + { + + $AvailableNetworkInterfaceNames = $_AvailableInterfaces.applianceNetworks | Select -Expand interfacename + + $ExceptionMessage = "The provided interface {0} was not found on the appliance. Please specify '{1}'." -f $Interface, [String]::Join("' or '", $AvailableNetworkInterfaceNames) + $ErrorRecord = New-ErrorRecord HPEOneView.Library.ParameterValidationException InvalidParameterValue InvalidOperation 'Interface' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + $_StaticRoute.destination = $Destination + $_StaticRoute.gateway = $Gateway + $_StaticRoute.interface = $Interface + + if ($PSBoundParameters['Metric']) + { + + $_StaticRoute.metric = $Metric.ToString() + + } + + try + { + + Send-OVRequest -Uri $_uri -Method POST -Body $_StaticRoute -Hostname $ApplianceConnection | Wait-OVTaskComplete + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Set-OVApplianceStaticRoute +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = 'Default', SupportsShouldProcess, ConfirmImpact = 'High')] + Param + ( + + [Parameter (Mandatory, ParameterSetName = 'Default', ValueFromPipeline)] + [ValidateNotNullorEmpty()] + [HPEOneView.Appliance.StaticRoute]$InputObject, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullorEmpty()] + [String]$Destination, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullorEmpty()] + [IPAddress]$Gateway, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullorEmpty()] + [String]$Interface, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateSet(0,100000)] + [Int]$Metric, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default', ValueFromPipelineByPropertyName)] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not $PSBoundParameters['InputObject']) + { + + "[{0}] InputObject provided from pipeline." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + else + { + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + $_ApplianceStatus = [System.Collections.ArrayList]::new() + + } + + Process + { + + if ((${Global:ConnectedSessions} | Where-Object Name -eq $ApplianceConnection.Name).ApplianceType -eq 'Composer') + { + + $ExceptionMessage = 'The ApplianceConnection {0} is a Synergy Composer, which does not support IP static route configuration.' -f $ApplianceConnection + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.ComposerNodeException InvalidOperation InvalidOperation 'ApplianceConnection' -Message $ExceptionMessage + $PSCmdlet.WriteError($ErrorRecord) + + } + + else + { + + $_uri = $InputObject.Uri.ToString() + + $_UpdatedStaticRoute = NewObject -ApplianceStaticRoute + + $_OriginalDestination = $InputObject.Destination.Copy() + $_UpdatedStaticRoute.destination = $InputObject.Destination + $_UpdatedStaticRoute.gateway = $InputObject.Gateway + $_UpdatedStaticRoute.interface = $InputObject.Interface + $_UpdatedStaticRoute.metric = $InputObject.Metric + + switch ($PSBoundParameters.Keys) + { + + 'Destination' + { + + "[{0}] Update destination to: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Destination | Write-Verbose + + $_UpdatedStaticRoute.destination = $Destination + + } + + 'Gateway' + { + + "[{0}] Update gateway to: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Gateway | Write-Verbose + + $_UpdatedStaticRoute.gateway = $Gateway + + } + + 'Interface' + { + + "[{0}] Update interface to: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Interface | Write-Verbose + "[{0}] Validate provided interface name exists." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + # Validate the provided interface + Try + { + + $_AvailableInterfaces = Send-OVRequest -Uri $ApplianceNetworkConfigUri -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if (-not $_AvailableInterfaces.applianceNetworks | ? interfacename -eq $Interface) + { + + $AvailableNetworkInterfaceNames = $_AvailableInterfaces.applianceNetworks | Select -Expand interfacename + + $ExceptionMessage = "The provided interface {0} was not found on the appliance. Please specify '{1}'." -f $Interface, [String]::Join("' or '", $AvailableNetworkInterfaceNames) + $ErrorRecord = New-ErrorRecord HPEOneView.Library.ParameterValidationException InvalidParameterValue InvalidOperation 'Interface' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + $_UpdatedStaticRoute.interface = $Interface + + } + + 'Metric' + { + + "[{0}] Update metric to: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Metric | Write-Verbose + + $_UpdatedStaticRoute.metric = $Metric + + } + + } + + $_ConfirmPromptMessage = "update '{0}' route" -f $_OriginalDestination + + if ($PSCmdlet.ShouldProcess($ApplianceConnection, $_ConfirmPromptMessage)) + { + + try + { + + Send-OVRequest -Uri $_uri -Method PUT -Body $_UpdatedStaticRoute -Hostname $ApplianceConnection | Wait-OVTaskComplete + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + else + { + + if ($PSBoundParameters['WhatIf']) + { + + Write-Warning "-WhatIf was passed, would have proceeded '$_ConfirmPromptMessage'." + + } + + } + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Remove-OVApplianceStaticRoute +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = 'Default', SupportsShouldProcess, ConfirmImpact = 'High')] + Param + ( + + [Parameter (Mandatory, ParameterSetName = 'Default', ValueFromPipeline)] + [ValidateNotNullorEmpty()] + [HPEOneView.Appliance.StaticRoute]$InputObject, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default', ValueFromPipelineByPropertyName)] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not $PSBoundParameters['InputObject']) + { + + "[{0}] InputObject provided from pipeline." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + else + { + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + $_ApplianceStatus = [System.Collections.ArrayList]::new() + + } + + Process + { + + if ((${Global:ConnectedSessions} | Where-Object Name -eq $ApplianceConnection.Name).ApplianceType -eq 'Composer') + { + + $ExceptionMessage = 'The ApplianceConnection {0} is a Synergy Composer, which does not support IP static route configuration.' -f $ApplianceConnection + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.ComposerNodeException InvalidOperation InvalidOperation 'ApplianceConnection' -Message $ExceptionMessage + $PSCmdlet.WriteError($ErrorRecord) + + } + + else + { + + $_uri = $InputObject.Uri.ToString() + $_OriginalDestination = $InputObject.Destination.Copy() + + $_ConfirmPromptMessage = "remove '{0}' route" -f $_OriginalDestination + + if ($PSCmdlet.ShouldProcess($ApplianceConnection, $_ConfirmPromptMessage)) + { + + try + { + + Send-OVRequest -Uri $_uri -Method DELETE -Hostname $ApplianceConnection | Wait-OVTaskComplete + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + else + { + + if ($PSBoundParameters['WhatIf']) + { + + Write-Warning "-WhatIf was passed, would have proceeded '$_ConfirmPromptMessage'." + + } + + } + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + + +function Get-OVApplianceAuditLogForwarding +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = 'Default')] + [OutputType([HPEOneView.Appliance.AuditLogForwardingConfig[]])] + Param + ( + + [Parameter (Mandatory = $false)] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $_ApplianceStatus = [System.Collections.ArrayList]::new() + + } + + Process + { + + $_Uri = $ApplianceAuditLogForwardingUri + + ForEach ($_appliance in $ApplianceConnection) + { + + Try + { + + $_CurrentConfig = Send-OVRequest -Uri $_Uri -ApplianceConnection $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $_Destinations = [System.Collections.Generic.List[HPEOneView.Appliance.Destination]]::new() + + ForEach ($_Dest in $_CurrentConfig.remoteDestinations) + { + + $_NewDestination = [HPEOneView.Appliance.Destination]::new($_Dest.remoteDestination, $_Dest.remotePort) + + [void]$_Destinations.Add($_NewDestination) + + } + + [HPEOneView.Appliance.AuditLogForwardingConfig]::new($_CurrentConfig.forwardingEnabled, + $_Destinations, + $_CurrentConfig.ApplianceConnection) + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Set-OVApplianceAuditLogForwarding +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = 'Default')] + [OutputType([HPEOneView.Appliance.AuditLogForwardingConfig[]])] + Param + ( + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [Switch]$Enable, + + [Parameter (Mandatory, ParameterSetName = 'Disable')] + [Switch]$Disable, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullorEmpty()] + [String[]]$ComputerName, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullorEmpty()] + [Int]$Port = 514, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullorEmpty()] + [String[]]$RemoveComputerName, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [Parameter (Mandatory = $false, ParameterSetName = 'Disable')] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $_ApplianceStatus = [System.Collections.ArrayList]::new() + + } + + Process + { + + $_Uri = $ApplianceAuditLogForwardingUri + + ForEach ($_appliance in $ApplianceConnection) + { + + # Get the current configuration + Try + { + + $_CurrentConfig = Send-OVRequest -Uri $_Uri -ApplianceConnection $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if ($PSBoundParameters['Disable']) + { + + "[{0}] Will disable forwarding." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_CurrentConfig.forwardingEnabled = $false + + } + + else + { + + if ($PSBoundParameters['Enable']) + { + + "[{0}] Will enable forwarding." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_CurrentConfig.forwardingEnabled = $True + + } + + # Rebuild remoteDestinations as an ArrayList + $_OriginalDestinations = $_CurrentConfig.remoteDestinations.Clone() + $_CurrentConfig.remoteDestinations = [System.Collections.ArrayList]::new() + + ForEach ($_Dest in $_OriginalDestinations) + { + + [void]$_CurrentConfig.remoteDestinations.Add($_Dest) + + } + + # Add the $ComputerName to the destinations + # Use Port if $Computername does not follow "ServerName:PORT" format + ForEach ($_NewDest in $ComputerName) + { + + if ($ComputerName.Contains(':')) + { + + $_Target = $_NewDest.Split(':')[0] + $_Port = $_NewDest.Split(':')[1] + + } + + else + { + + $_Target = $_NewDest + $_Port = $Port + + } + + if ($_CurrentConfig.remoteDestinations.remoteDestination -NotContains $_Target) + { + + "[{0}] Adding '{1}:{2}' to the remoteDestinations collection." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_Target, $_Port | Write-Verbose + + [void]$_CurrentConfig.remoteDestinations.Add(@{remoteDestination = $_Target; remotePort = $_Port}) + + } + + elseif ($_CurrentConfig.remoteDestinations.remoteDestination -Contains $_Target -and ($_CurrentConfig.remoteDestinations | ? remoteDestination -eq $_Target).remotePort -ne $_Port) + { + + "[{0}] Updating '{1}' to new port '{2}' ." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_Target, $_Port | Write-Verbose + + } + + } + + # Process RemoveComputerName value + ForEach ($_RemoveDest in $RemoveComputerName) + { + + if ($_DestToRemove = $_CurrentConfig.remoteDestinations | ? remoteDestination -eq $_RemoveDest) + { + + "[{0}] Removing '{1}:{2}' from the remoteDestinations collection." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_DestToRemove.remoteDestination, $_DestToRemove.remotePort | Write-Verbose + + [void]$_CurrentConfig.remoteDestinations.Remove($_DestToRemove) + + } + + else + { + + "[{0}] Host '{1}' not found in collection." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_RemoveDest | Write-Verbose + + } + + } + + } + + # Save config + Try + { + + Send-OVRequest -Uri $_Uri -Method PUT -Body $_CurrentConfig -AddHeader @{'If-Match' = $_CurrentConfig.eTag} -ApplianceConnection $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Test-OVApplianceAuditLogForwarding +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = 'Default')] + Param + ( + + [Parameter (Mandatory = $false)] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $_ApplianceStatus = [System.Collections.ArrayList]::new() + + } + + Process + { + + ForEach ($_appliance in $ApplianceConnection) + { + + Try + { + + Send-OVRequest -Uri $ApplianceTestAuditLogForwardingUri -Method POST -ApplianceConnection $_appliance + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Get-OVApplianceCertificateStatus +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = 'Default')] + + Param + ( + + [Parameter (Mandatory = $false)] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $_ApplianceStatus = [System.Collections.ArrayList]::new() + + } + + Process + { + + ForEach ($_appliance in $ApplianceConnection) + { + + "[{0}] Processing '{1}' Appliance (of {2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name, $ApplianceConnection.Count | Write-Verbose + + Try + { + + $_status = Send-OVRequest $applianceSslCert -Hostname $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $_status.PSObject.TypeNames.insert(0,'HPEOneview.Appliance.ApplianceSslCertificateStatus') + + $_status + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function New-OVApplianceSelfSignedCertificate +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = 'Default', SupportsShouldProcess, ConfirmImpact = 'High')] + + Param + ( + + [Parameter (Mandatory, ParameterSetName = 'Default')] + [Alias ('C')] + [ValidateNotNullOrEmpty()] + [String]$Country, + + [Parameter (Mandatory, ParameterSetName = 'Default')] + [Alias ('ST','Province')] + [ValidateNotNullOrEmpty()] + [String]$State, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [Alias ('L','Locality')] + [ValidateNotNullOrEmpty()] + [String]$City, + + [Parameter (Mandatory, ParameterSetName = 'Default')] + [Alias ('O')] + [ValidateNotNullOrEmpty()] + [String]$Organization, + + [Parameter (Mandatory, ParameterSetName = 'Default')] + [Alias ('CN')] + [ValidateNotNullOrEmpty()] + [String]$CommonName, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [Alias ('OU')] + [ValidateNotNullOrEmpty()] + [String]$OrganizationalUnit, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [Alias ('SAN')] + [ValidateNotNullOrEmpty()] + [String]$AlternativeName, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [Alias ('Contact')] + [ValidateNotNullOrEmpty()] + [String]$ContactName, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [String]$Email, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [Alias ('Sur')] + [ValidateNotNullOrEmpty()] + [String]$Surname, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [Alias ('Giv')] + [ValidateNotNullOrEmpty()] + [String]$GivenName, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [String]$Initials, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [String]$DNQualifier, + + [Parameter (Mandatory = $False, ParameterSetName = 'Default')] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $_TaskStatus = [System.Collections.ArrayList]::new() + + if ($Country.length -gt 2) + { + + $TempCountry = $Country.Clone() + + $Country = GetTwoLetterCountry -Name $Country + + if (-not($Country)) + { + + $ErrorRecord = New-ErrorRecord InvalidOperationException CountryNameNotFound ObjectNotFound 'Country' -Message ('{0} is not a valid Country Name, or unable to find mapping to RegionInfo ISO3166-2 compliant 2-Character name.' -f $Country ) + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + } + + Process + { + + $_SelfSignedCertObject = NewObject -SelfSignedCert + + $_SelfSignedCertObject.country = $Country.ToUpper() + $_SelfSignedCertObject.state = $State + $_SelfSignedCertObject.locality = $City + $_SelfSignedCertObject.organization = $Organization + $_SelfSignedCertObject.commonName = $CommonName + $_SelfSignedCertObject.organizationalUnit = $OrganizationalUnit + $_SelfSignedCertObject.alternativeName = $AlternativeName + $_SelfSignedCertObject.contactPerson = $ContactName + $_SelfSignedCertObject.email = $Email + $_SelfSignedCertObject.surname = $Surname + $_SelfSignedCertObject.givenName = $GivenName + $_SelfSignedCertObject.initials = $Initials + $_SelfSignedCertObject.dnQualifier = $DNQualifier + + Try + { + + Write-Warning 'Updates to the certificate will require the appliance internal web server to be restarted. There will be a temporary service interruption estimated to last 30 seconds.' + + if ($PSCmdlet.ShouldProcess($ApplianceConnection.Name,"generate new self-signed certificate")) + { + + "[{0}] Generating new self-signed certificate." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_resp = Send-OVRequest -Uri $applianceSslCert -Method PUT -Body $_SelfSignedCertObject -HostName $ApplianceConnection + + } + + else + { + + if ($PSBoundParameters['whatif'].ispresent) + { + + write-warning "-WhatIf was passed, would have proceeded 'New Self-Signed Certificate for Appliance $($ApplianceConnection.Name)'." + + $_resp = $null + + } + + else + { + + # If here, user chose "No", End Processing + $_resp = $Null + + } + + } + + [void]$_TaskStatus.Add($_resp) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + End + { + + Return $_TaskStatus + + } + +} + +function New-OVApplianceCsr +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = 'Default')] + + Param + ( + + [Parameter (Mandatory, ParameterSetName = 'Default')] + [Alias ('C')] + [ValidateNotNullOrEmpty()] + [String]$Country, + + [Parameter (Mandatory, ParameterSetName = 'Default')] + [Alias ('ST','Province')] + [ValidateNotNullOrEmpty()] + [String]$State, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [Alias ('L','Locality')] + [ValidateNotNullOrEmpty()] + [String]$City, + + [Parameter (Mandatory, ParameterSetName = 'Default')] + [Alias ('O')] + [ValidateNotNullOrEmpty()] + [String]$Organization, + + [Parameter (Mandatory, ParameterSetName = 'Default')] + [Alias ('CN')] + [ValidateNotNullOrEmpty()] + [String]$CommonName, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [Alias ('OU')] + [ValidateNotNullOrEmpty()] + [String]$OrganizationalUnit, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [Alias ('SAN')] + [ValidateNotNullOrEmpty()] + [String]$AlternativeName, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [Alias ('Contact')] + [ValidateNotNullOrEmpty()] + [String]$ContactName, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [String]$Email, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [Alias ('Sur')] + [ValidateNotNullOrEmpty()] + [String]$Surname, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [Alias ('Giv')] + [ValidateNotNullOrEmpty()] + [String]$GivenName, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [String]$Initials, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [String]$DNQualifier, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [String]$ChallengePassword, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [Alias ('UN')] + [ValidateNotNullOrEmpty()] + [String]$UnstructuredName, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [Bool]$CnsaCompliantRequest = $false, + + [Parameter (Mandatory = $False, ParameterSetName = 'Default')] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $_TaskStatus = [System.Collections.ArrayList]::new() + + # Handle runtime, none-script use + if ($PSBoundParameters['ChallengePassword'] -and $ChallengePassword -eq '*' ) + { + + Do + { + + [SecureString]$ChallengePassword = Read-Host "Challenge Password:" -AsSecureString + + [SecureString]$ChallengePasswordConfirm = Read-Host "Confirm Challenge Password:" -AsSecureString + + $pwd1_text = [Runtime.InteropServices.Marshal]::PtrToStringBSTR([Runtime.InteropServices.Marshal]::SecureStringToBSTR($ChallengePassword)) + + $pwd2_text = [Runtime.InteropServices.Marshal]::PtrToStringBSTR([Runtime.InteropServices.Marshal]::SecureStringToBSTR($ChallengePasswordConfirm)) + + if (-not($pwd1_text -ceq $pwd2_text)) + { + + Write-Error "Passwords to not match. Please try again." -ea Continue + + $PasswordsMatch = $False + + } + + else { $PasswordsMatch = $True } + + } Until ($PasswordsMatch) + + } + + if ($Country.length -gt 2) + { + + $TempCountry = $Country.Clone() + + $Country = GetTwoLetterCountry -Name $Country + + if (-not($Country)) + { + + $ErrorRecord = New-ErrorRecord InvalidOperationException CountryNameNotFound ObjectNotFound 'Country' -Message ('{0} is not a valid Country Name, or unable to find mapping to RegionInfo ISO3166-2 compliant 2-Character name.' -f $Country ) + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + } + + Process + { + + $_CsrObject = NewObject -ApplianceCSR + + $_CsrObject.country = $Country.ToUpper() + $_CsrObject.state = $State + $_CsrObject.locality = $City + $_CsrObject.organization = $Organization + $_CsrObject.commonName = $CommonName + $_CsrObject.organizationalUnit = $OrganizationalUnit + $_CsrObject.alternativeName = $AlternativeName.Replace(" ", $null) # Remove spaces? + $_CsrObject.contactPerson = $ContactName + $_CsrObject.email = $Email + $_CsrObject.surname = $Surname + $_CsrObject.givenName = $GivenName + $_CsrObject.initials = $Initials + $_CsrObject.dnQualifier = $DNQualifier + $_CsrObject.unstructuredName = $UnstructuredName + $_CsrObject.challengePassword = $ChallengePassword + + Try + { + + "[{0}] Sending CSR request" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_resp = Send-OVRequest -Uri $applianceCsr -Method POST -Body $_CsrObject -HostName $ApplianceConnection + + [void]$_TaskStatus.Add($_resp) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + + } + + End + { + + Return $_TaskStatus + + } + +} + +function GetTwoLetterCountry +{ + + <# + .DESCRIPTION + Helper function to get ISO3166-2 Compliant Country Name + + .Parameter Country + Helper function to get ISO3166-2 Compliant Country Name + + .INPUTS + None. You cannot pipe objects to this cmdlet. + + .OUTPUTS + System.String + ISO3166-2 Compliant two character country name + + .EXAMPLE + PS C:\> GetTwoLetterCountry 'United States' + US + + Returns the ISO3166-2 Compliant 2-character Country name. + + #> + + [CmdletBinding (DefaultParameterSetName = 'Default')] + + Param + ( + + [Parameter (Mandatory, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [String]$Name + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + } + + Process + { + + Write-Verbose 'Building Country collection.' + + $CountriesCollection = [Hashtable]::new() + + $Countries = [System.Globalization.CultureInfo]::GetCultures([System.Globalization.CultureTypes]'AllCultures') + + foreach ($ObjCultureInfo in [System.Globalization.CultureInfo]::GetCultures([System.Globalization.CultureTypes]'AllCultures')) + { + + Try + { + + [System.Globalization.RegionInfo]$_Country = $ObjCultureInfo.LCID + + if ([RegEx]::Match($_Country.EnglishName, ' AND ', $RegExInsensitiveFlag).Success) + { + + $_CountriesSplit = $_Country.EnglishName.Split(' AND ') + + ForEach ($_split in $_CountriesSplit) + { + + if (-not($CountriesCollection.ContainsKey($_split))) + { + + $CountriesCollection.Add($_split, $_Country.TwoLetterISORegionName.ToUpper()); + + } + + } + + } + + else + { + + if (-not($CountriesCollection.ContainsKey($_Country.EnglishName))) + { + + + $CountriesCollection.Add($_Country.EnglishName, $_Country.TwoLetterISORegionName.ToUpper()); + + } + + } + + } + + Catch + { + + Write-Verbose ("{0} Doesn't have RegionInfo" -f $ObjCultureInfo) + + } + + } + + } + + End + { + + Write-Verbose 'Returning value' + + Write-Verbose ('Country Collection: {0}' -f ($CountriesCollection | Out-String)) + + Write-Verbose ('ISO3166-2 Country Name: {0}' -f $CountriesCollection[$Name]) + + $_Return = $CountriesCollection[$Name] + + if (-not($_Return)) + { + + $ErrorRecord = New-ErrorRecord InvalidOperationException CountryNameNotFound ObjectNotFound 'Name' -Message ('{0} is not a valid Country Name, or unable to find mapping to RegionInfo ISO3166-2 compliant 2-Character name.' -f $Name ) + $PSCmdlet.ThrowTerminatingError($ErrorRecord)` + + } + + Return $_Return + + } + +} + +function Install-OVApplianceCertificate +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = 'Default')] + + Param + ( + + [Parameter (Mandatory, ParameterSetName = 'Default', ValueFromPipeline)] + [Alias ('PrivateKey', 'Certificate')] + [ValidateNotNullOrEmpty()] + [System.IO.FileInfo]$Path, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [SecureString]$Passphrase, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [Switch]$Async, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $_TaskStatus = [System.Collections.ArrayList]::new() + + } + + Process + { + + $_CertificateObject = NewObject -ApplianceSslCertificate + + '[{0}] Path is valid: {1}' -f $MyInvocation.InvocationName.ToString().ToUpper(), (Test-Path $Path) | Write-Verbose + + if (-not (Test-Path $Path)) + { + + $Exceptionmessage = 'The supplied Path value is not a valid X.509 certificate, System.IO.FileInfo object, or path to a valid X.509 certificate.' + $ErrorRecord = New-ErrorRecord InvalidOperationException PathValueInvalid InvalidArgument 'Path' -Message $Exceptionmessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + if ($Path.Extension -eq ".pfx") + { + + "[{0}] Uploading PKCS#12 certificate {1} to appliance." -f $MyInvocation.InvocationName.ToString().ToUpper(), $Path | Write-Verbose + + Try + { + + $_DecryptedPassword = [Runtime.InteropServices.Marshal]::PtrToStringBSTR([Runtime.InteropServices.Marshal]::SecureStringToBSTR($Passphrase)) + + $_resp = Upload-File -Uri $ApplianceCertPFXUploadUri -Method PUT -File $File -AddHeader @{Password = $_DecryptedPassword} -ApplianceConnection $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + else + { + + "[{0}] Opening X509 cert file {1} for reading." -f $MyInvocation.InvocationName.ToString().ToUpper(), $Path | Write-Verbose + + Try + { + + $_ReadFile = [System.IO.File]::OpenText($Path) + $_Certificate = $_ReadFile.ReadToEnd() + + $_ReadFile.Close() + + $_CertificateObject.base64Data = ($_Certificate | Out-String) -join "`n" + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + Try + { + + "[{0}] Installing appliance CA signed certificate" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_resp = Send-OVRequest -Uri $applianceCsr -Method PUT -Body $_CertificateObject -HostName $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + if ($PSBoundParameters['Async']) + { + + $_resp + + } + + else + { + + $_resp | Wait-OVTaskComplete + + } + + } + + End + { + + '[{0}] Done.' -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Get-OVPendingUpdate +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding ()] + Param + ( + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + Process + { + + ForEach ($_appliance in $ApplianceConnection) + { + + "[{0}] Processing '{1}' Appliance (of {2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name, $ApplianceConnection.Count | Write-Verbose + + # Check to see if ane existing update is present. Report to user if it is, and tell them to use -InstallNow + Try + { + + "[{0}] - Checking if Pending update exists" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_PendingUpdate = Send-OVRequest -Uri $ApplianceUpdatePendingUri -Hostname $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if ($_PendingUpdate) + { + + "[{0}] - Update found $($_PendingUpdate.fileName), $($_PendingUpdate.version)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_PendingUpdate.PSObject.TypeNames.Insert(0,'HPEOneview.Appliance.Update.Pending') + + } + + $_PendingUpdate + + } + + } + + End + { + + "[{0}] - Finished" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Install-OVUpdate +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = 'Update', SupportsShouldProcess, ConfirmImpact = 'High')] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = 'Update')] + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = 'Stage')] + [Alias ('f')] + [ValidateScript({Test-Path $_})] + [String]$File, + + [Parameter (Mandatory = $false, ParameterSetName = 'Update')] + [Parameter (Mandatory = $false, ParameterSetName = 'StageInstall')] + [String]$Eula, + + [Parameter (Mandatory = $false, ParameterSetName = 'Update')] + [Parameter (Mandatory = $false, ParameterSetName = 'Stage')] + [Parameter (Mandatory = $false, ParameterSetName = 'List')] + [Switch]$DisplayReleaseNotes, + + [Parameter (Mandatory, ParameterSetName = 'Stage')] + [Switch]$Stage, + + [Parameter (Mandatory, ParameterSetName = 'StageInstall')] + [Switch]$InstallNow, + + [Parameter (Mandatory, ParameterSetName = 'List')] + [Alias ('list')] + [Switch]$ListPending, + + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = "Update")] + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = "Stage")] + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = "List")] + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = "StageInstall")] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not $File) + { + + $Pipeline = $true + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + $_StatusCollection = [System.Collections.ArrayList]::new() + + } + + Process + { + + ForEach ($_appliance in $ApplianceConnection) + { + + "[{0}] Processing '{1}' Appliance (of {2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name, $ApplianceConnection.Count | Write-Verbose + + # Check to see if ane existing update is present. Report to user if it is, and tell them to use -InstallNow + Try + { + + "[{0}] - Checking if Pending update exists" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_PendingUpdate = Send-OVRequest -Uri $ApplianceUpdatePendingUri -Hostname $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if ($_PendingUpdate) + { + + "[{0}] - Update found '{1}', '{2}'" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_PendingUpdate.fileName, $_PendingUpdate.version | Write-Verbose + + $_PendingUpdate.PSObject.TypeNames.Insert(0,'HPEOneview.Appliance.Update.Pending') + + } + + Switch ($PSCmdlet.ParameterSetName) + { + + # List staged update + "List" + { + + # If the request is to install a staged update, we need to handle no response. If request is Update, then no Pending update will exist yet. + If (-not($_PendingUpdate)) + { + + "[{0}] - No Pending update found. Return is Null" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $ErrorRecord = New-ErrorRecord InvalidOperationException PendingUpdateNotFound ObjectNotFound 'Install-OVUpdate' -Message "No Pending update found. Please first upload update and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + $_PendingUpdate + + If ($PSBoundParameters['DisplayReleaseNotes']) + { + + "[{0}] - Displaying Release Notes" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + # Display Release Notes + Try + { + + $uri = "/rest/appliance/firmware/document-content/{0}/release" -f $Upload.fileName + Send-OVRequest -Uri $uri -Hostname $_appliance | ConvertFrom-HTML + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + "[{0}] - Done. Displayed update release notes." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + Return + } + + # Stage Update + "Stage" + { + + if (-not($_PendingUpdate)) + { + + "[{0}] - Stage Only" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + "[{0}] - UPLOAD FILE: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $File | Write-Verbose + + Try + { + + # Upload update + $FileName = Get-Item $File + + $_upload = Upload-File -Uri $ApplianceUpdateImageUri -File $File -ApplianceConnection $_appliance.Name + + } + + Catch + { + + $ErrorRecord = New-ErrorRecord InvalidOperationException StageUpdateFailed InvalidResult 'Install-OVUpdate' -Message $_.Exception.Message + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + If ($PSBoundParameters['DisplayReleaseNotes']) + { + + "[{0}] - Displaying Release Notes" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + # Display Release Notes + Try + { + + $uri = "/rest/appliance/firmware/document-content/{0}/release" -f $Upload.fileName + Send-OVRequest -Uri $uri -Hostname $_appliance | ConvertFrom-HTML + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + "[{0}] - Done. Displayed update release notes." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + Return $_upload + + } + + else + { + + $ExceptionMessage = "An existing appliance update has been staged. Version: '{0}' Filename: '{1}' Please use the -InstallUpdate Parameter to proceed with the update, or use Remove-OVPendingUpdate cmdlet to remove the staged update." -f $_PendingUpdate.version, $_PendingUpdate.fileName + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.FirmwareUpdateException PendingUpdateConflict ResourceExists 'File' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + # Upload update then install update below. + "Update" + { + + if ($_PendingUpdate) + { + + $ExceptionMessage = "A Pending update was found. File name: '{0}'; Update Version: '{1}'. Please remove the update before continuing and try again." -f $_PendingUpdate.version, $_PendingUpdate.fileName + $ErrorRecord = New-ErrorRecord InvalidOperationException PendingUpdateFound ResourceExists 'File' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + "[{0}] - UPLOAD FILE: '{1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $File | Write-Verbose + + Try + { + + # Upload update + $FileName = Get-Item $File + + $_PendingUpdate = Upload-File -Uri $ApplianceUpdateImageUri -File $File -ApplianceConnection $_appliance.Name + + # Pause for 30 seconds? need to make sure appliance has finished Processing update file before invoking update + "[{0}] - Sleeping for 5 seconds." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Start-Sleep -Seconds 5 + + } + + Catch + { + + $ErrorRecord = New-ErrorRecord InvalidOperationException UploadUpdateFailed InvalidResult 'File' -Message $_.Exception.Message + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + "[{0}] - Getting verification results from appliance." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + try + { + + $_PendingUpdate = Send-OVRequest -Uri $ApplianceUpdatePendingUri -Hostname $_appliance + $_PendingUpdate.PSObject.TypeNames.Insert(0,'HPEOneView.Appliance.Update.Pending') + + } + + catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + # Process Pending update + if (($PSCmdlet.ParameterSetName -eq "StageInstall") -or ($PSCmdlet.ParameterSetName -eq "Update" )) + { + + # If the request is to install a staged update, we need to handle no response. If request is Update, then no Pending update will exist yet. + If ((-not($_PendingUpdate)) -and ($PSCmdlet.ParameterSetName -eq "StageInstall")) + { + + "[{0}] - No Pending update found. Return is Null" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $ErrorRecord = New-ErrorRecord InvalidOperationException PendingUpdateResourceNotFound ObjectNotFound 'Install-OVUpdate' -Message "No Pending update found. Please first upload update and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + + "[{0}] - Install Now" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_PendingUpdate + + If ($Eula -ne "accept") + { + + "[{0}] - EULA NOT Accepted" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $Url = "https://{0}/ui-js/pages/upgrade/eula_content.html" -f $_appliance.Name + + try + { + + # Display eula of update + + $_WebClient = ([HPEOneView.Utilities.Net]::new()).RestClient($Url, 'GET', 600) + + [System.Net.WebResponse]$_response = $_WebClient.GetResponse() + $_reader = [IO.StreamReader]::new($_response.GetResponseStream()) + $_reader.ReadToEnd() | ConvertFrom-HTML -NoClobber + $_reader.close() + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + Do { $acceptEula = Read-Host "Accept EULA (Must type ACCEPT)" } Until ($acceptEula -eq "Accept") + + } + + "[{0}] - EULA Accepted" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + "[{0}] - Beginning update $($_PendingUpdate.fileName)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + "[{0}] - Estimated Upgrade Time $($_PendingUpdate.estimatedUpgradeTime) minutes" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_resp = $Null + + # Check to see if the update requires an appliance reboot. + if ($_PendingUpdate.rebootRequired) + { + + "[{0}] - Appliance reboot required $($_PendingUpdate.rebootRequired)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + "[{0}] - Prompting for confirmation" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + "[{0}] - Is confirmation overridden $([Bool]$confirm)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Write-Warning "Reboot required for the update." + + # If it does require a reboot, then we need to prompt for confirmation. Overriden by -confirm:$false + if ($PSCmdlet.ShouldProcess($_appliance.Name,"upgrade appliance using $($_PendingUpdate.fileName)")) + { + + "[{0}] - Appliance reboot required and user selected YES or passed -Confirm:`$false, executing Invoke-Upgrade" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $_resp = Invoke-Upgrade $_PendingUpdate -ApplianceConnection $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + else + { + + if ($PSBoundParameters['whatif']) + { + + write-warning "-WhatIf was passed, would have initiated appliance update." + + } + + else + { + + # If here, user chose "No", End Processing + "[{0}] - User selected NO." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + } + + } + + else + { + + "[{0}] - Appliance reboot NOT required, executing Invoke-Upgrade" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $_resp = Invoke-Upgrade $_PendingUpdate -ApplianceConnection $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + if ($null -ne $_resp) + { + + # Update PSLibraryVersion variable with new appliance version + Try + { + + $applVersionInfo = Send-OVRequest -Uri $ApplianceVersionUri -Hostname $_appliance + $PSLibraryVersion."$($_appliance.Name)" = [HPEOneView.Appliance.NodeInfo]::new($applVersionInfo.softwareVersion, (Get-OVXApiVersion -ApplianceConnection $_appliance).currentVersion, $applVersionInfo.modelNumber) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $_resp + + } + + } + + } + + End + { + + "[{0}] - Finished" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Invoke-Upgrade +{ + + [CmdletBinding ()] + Param + ( + + [Parameter (Mandatory)] + [ValidateNotNullorEmpty()] + [Object]$PendingUpdate, + + [Parameter (Mandatory)] + [ValidateNotNullorEmpty()] + [HPEOneView.Appliance.Connection]$ApplianceConnection + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + $_FinalStatus = $null + + } + + Process + { + + Try + { + + $uri = "{0}?file={1}" -f $ApplianceUpdatePendingUri, $PendingUpdate.fileName + $_updateTask = Send-OVRequest -Uri $uri -Method PUT -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $sw = [System.Diagnostics.Stopwatch]::StartNew() + + $_PreviousTaskStep = $null + + # Loop to display progress-bar + Do + { + + # Connect to update monitor web Process + Try + { + + $_MonitorUpdate = Send-OVRequest -Uri $ApplianceUpdateMonitorUri -Hostname $ApplianceConnection + + if ($_MonitorUpdate.taskStep) + { + + $_PreviousTaskStep = $_MonitorUpdate.taskStep.Replace(" ", $null) + + } + + elseif (-not [String]::IsNullOrEmpty($_MonitorUpdate.error)) + { + + $ErrorStateMessage = 'Could not open file to retrieve update progress information' + + # CHeck to see what the error is. If it is {"error":"Error:Could not open file to retrieve update progress information"}, then do a loop to see if the status changes. + # But only wait for 5 minutes, then generate error + + if ($_MonitorUpdate.error -match $ErrorStateMessage) + { + + "[{0}] API reported an error opening the update progress internal file. Looping for 5 minutes to get state." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_sw2 = [System.Diagnostics.Stopwatch]::new() + $_sw2.Start() + + Do + { + + Try + { + + $_MonitorUpdate = Send-OVRequest -Uri $ApplianceUpdateMonitorUri -Hostname $ApplianceConnection + + } + + Catch + { + + + if (-not [String]::IsNullOrEmpty($_MonitorUpdate.error) -and $_MonitorUpdate.error -match $ErrorStateMessage) + { + + "[{0}] Waiting for the API to recover from accessing it update progress tracking file, for 5 minutes." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + else + { + + $ExceptionMessage = "An error ocurred with the update installation: {0}" -f [String]::Join(" ", $_MonitorUpdate.error) + $ErrorRecord = New-ErrorRecord InvalidOperationException InvokeUpdateInstallError InvalidResult 'Install-OVUpdate' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + # Pause 10 seconds so we don't overwhelm the API + Start-Sleep -Seconds 10 + + } Until ($_sw2.ElapsedMilliseconds -ge 300000 -or $null -eq $_Response.error) + + # Generate a non-terminating error that 5 minutes have elapsed and the API is still returning an error. + if ($_sw2.ElapsedMilliseconds -ge 300000 -and -not [String]::IsNullOrEmpty($_Response.error)) + { + + $ExceptionMessage = "Time out waiting for API to recover. The last reported error that ocurred with the update installation: {0} Please reconnect to the appliance to ensure it is updated sucessfully." -f [String]::Join(" ", $_MonitorUpdate.error) + $ErrorRecord = New-ErrorRecord InvalidOperationException InvokeUpdateInstallError InvalidResult 'Install-OVUpdate' -Message $ExceptionMessage + $PSCmdlet.WriteError($ErrorRecord) + + } + + $_sw2.Stop() + + if ($_MonitorUpdate.taskStep) + { + + $_PreviousTaskStep = $_MonitorUpdate.taskStep.Replace(" ", $null) + + } + + else + { + + $_PreviousTaskStep = $_MonitorUpdate.status.Replace(" ", $null) + + } + + } + + else + { + + $ExceptionMessage = "An error ocurred with the update installation: {0}" -f [String]::Join(" ", $_MonitorUpdate.error) + $ErrorRecord = New-ErrorRecord InvalidOperationException InvokeUpdateInstallError InvalidResult 'Install-OVUpdate' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + else + { + + $_PreviousTaskStep = $_MonitorUpdate.status.Replace(" ", $null) + + } + + } + + Catch + { + + # Sleep 30 seconds to see make sure it wasn't a brief Apache issue + "[{0}] Pausing 30 seconds after '{1}' exception was caught." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_.Exception.Message | Write-Verbose + Start-Sleep -Seconds 30 + + # Attempt a second connection, as appliance may have restarted Apache + Try + { + + "[{0}] Trying 2nd time to get update monitor status." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_MonitorUpdate = Send-OVRequest -Uri $ApplianceUpdateMonitorUri -Hostname $ApplianceConnection + + if ($_MonitorUpdate.taskStep) + { + + $_PreviousTaskStep = $_MonitorUpdate.taskStep.Replace(" ", $null) + + } + + else + { + + $_PreviousTaskStep = $_MonitorUpdate.status.Replace(" ", $null) + + } + + } + + Catch + { + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + # Remove % from value in order to get INT + if ($_MonitorUpdate.percentageCompletion) + { + + $PercentComplete = $_MonitorUpdate.percentageCompletion.Replace("%",$null).Replace(" ",$null) + + } + + else + { + + $PercentComplete = 0 + + } + + # Remove " State = " to get proper status + if ($_MonitorUpdate.status) + { + + $UpdateStatus = $_MonitorUpdate.status.Replace(" ", $null).Replace("State=", $null) + + if ($_MonitorUpdate.phase) + { + + $UpdateStatus = '{0} - {1}' -f $UpdateStatus, $_MonitorUpdate.phase + + } + + } + + else + { + + $UpdateStatus = "Starting" + + } + + $Status = "{0} {1}% [{2}min {3}sec]" -f $UpdateStatus, $PercentComplete, $sw.elapsed.minutes, $sw.elapsed.seconds + + # Handle the call from -Verbose so Write-Progress does not get borked on display. + if ($PSBoundParameters['Verbose'] -or $VerbosePreference -eq 'Continue') + { + + "[{0}] Skipping Write-Progress display." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + "[{0}] Update Status: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Status | Write-Verbose + + } + + else + { + + Write-Progress -id 1 -Activity ("Installing appliance update {0}" -f $PendingUpdate.fileName) -Status $Status -PercentComplete $PercentComplete + + } + + if ([RegEx]::Match($UpdateStatus, "UpdateReboot", $RegExInsensitiveFlag).Success) + { + + # Handle the call from -Verbose so Write-Progress does not get borked on display. + if ($PSBoundParameters['Verbose'] -or $VerbosePreference -eq 'Continue') + { + + "[{0}] pausing for 5 minutes while appliance reboots. Invoking Start-Sleep" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Start-Sleep -Seconds 300 + + } + + else + { + + $time = 300 + + foreach ($i in (1..$time)) + { + + $percentage = $i / $time + + Write-Progress -id 1 -activity ("Installing appliance update {0}" -f $PendingUpdate.fileName) -Status $Status -PercentComplete $PercentComplete + + Write-Progress -id 2 -parent 1 -activity "Appliance Rebooting" -status "Pausing for 5 minutes" -percentComplete ($percentage * 100) -SecondsRemaining ($time - $i) + + Start-Sleep 1 + + } + + Write-Progress -id 2 -parent 1 -activity "Appliance Rebooting" -status "Pausing for 5 minutes" -Completed + + } + + } + + } Until ([Int]$percentComplete -eq 100 -or [RegEx]::Match($_PreviousTaskStep, 'FAILED', $RegExInsensitiveFlag).Success) + + $sw.Stop() + + "[{0}] Upgrade operation took {1}min, {2}sec." -f $MyInvocation.InvocationName.ToString().ToUpper(), $sw.elapsed.minutes, $sw.elapsed.seconds | Write-Verbose + + # Retrieve final update status + Try + { + + $_FinalStatus = Send-OVRequest -Uri $ApplianceUpdateNotificationUri -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + Write-Progress -Activity ("Installing appliance update {0}" -f $PendingUpdate.fileName) -status $updateStatus -percentComplete $percentComplete + + Write-Progress -Activity ("Installing appliance update {0}" -f $PendingUpdate.fileName) -status $updateStatus -Completed + + } + + End + { + + Return $_FinalStatus + + } + +} + +function Remove-OVPendingUpdate +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = 'Default', SupportsShouldProcess,ConfirmImpact = 'High')] + Param + ( + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $_ColStatus = [System.Collections.ArrayList]::new() + + } + + Process + { + + ForEach ($_appliance in $ApplianceConnection) + { + + $_resp = $null + + "[{0}] Processing '{1}' Appliance (of {2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name, $ApplianceConnection.Count | Write-Verbose + + # Check to see if ane existing update is present. Report to user if it is, and tell them to use -InstallNow + Try + { + + "[{0}] - Checking if Pending update exists" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_PendingUpdate = Send-OVRequest -Uri $ApplianceUpdatePendingUri -Hostname $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if ($_PendingUpdate) + { + + "[{0}] - Update found $($_PendingUpdate.fileName), $($_PendingUpdate.version)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_PendingUpdate.PSObject.TypeNames.Insert(0,'HPEOneview.Appliance.Update.Pending') + + $_PendingUpdate + + $RemoveMessage = "remove Pending update, {0}" -f $_PendingUpdate.fileName + + if ($PSCmdlet.ShouldProcess($_appliance.Name, $RemoveMessage)) + { + + "[{0}] Removing Pending update from applinace." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + "[{0}] - Checking if Pending update exists" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_resp = Send-OVRequest -Uri $ApplianceUpdatePendingUri -Method DELETE -AddHeader @{'If-Match' = '*' } -Hostname $_appliance + + [void]$_ColStatus.Add($_resp) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + else + { + + "[{0}] No Pending update found" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + } + + } + + } + + End + { + + Return $_ColStatus + + } + +} + +function Get-OVVersion +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = 'Default')] + Param + ( + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [Switch]$ApplianceVer, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [Parameter (Mandatory = $false, ParameterSetName = 'CheckOnlineOnly')] + [Switch]$CheckOnline, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullorEmpty()] + [Alias ('appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if ($ApplianceConnection.Count -eq 0 -and (-not($PSBoundParameters['CheckOnline'])) -and $PSBoundParameters['ApplianceVer']) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoAuthSessionFound InvalidArgument 'ApplianceConnection' -Message 'No ApplianceConnections were found. Please use Connect-OVMgmt to establish an appliance connection.' + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($PSBoundParameters['ApplianceVer']) + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + $_ApplianceVersionCollection = [System.Collections.ArrayList]::new() + + } + + Process + { + + if ($PSboundParameters['CheckOnline']) + { + + try + { + + "[{0}] Testing for Proxy settings" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + [Uri]$_ProxyUri = $null + + $_Options = @{Uri = $Repository} + + $_Proxy = [System.Net.WebRequest]::GetSystemWebProxy() + + $_Proxy.Credentials = [System.Net.CredentialCache]::DefaultCredentials + $_ProxyUri = $_Proxy.GetProxy($_Options.Uri) + + if ($_ProxyUri.OriginalString -ne $_Options.Uri) + { + + $_Options.Add('Proxy',$_proxyUri) + $_Options.Add('ProxyUseDefaultCredentials', $true) + + } + + $_OriginalProgressPreference = $ProgressPreference + + # Hide the display of Write-Progress Invoke-RestMethod displays + $ProgressPreference = 'silentlyContinue' + + "[{0}] Invoke-RestMethod Options: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), ($_Options | Out-String) | Write-Verbose + + $resp = Invoke-RestMethod @_Options + + $ProgressPreference = $_OriginalProgressPreference + + $versionMajorMinor = "{0}.{1}" -f $PSLibraryVersion.Major, $PSLibraryVersion.Minor + + # Filter for versions that match Major and Minor release, and exclude the HPE VCM to OneView Migration Tool + $matchedVersions = $resp | Where-Object { $_.tag_name -like "v$versionMajorMinor*" -and (-not($_.tag_name.startswith('HPVCtoOV'))) -and (-not($_.tag_name.startswith('HPSIMtoOV'))) } + + "[{0}] Found versions online: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), [System.String]::Join(' ,', $resp.tag_name) | Write-Verbose + + $newerVersion = $false + + # Compare the releases + $matchedVersions | ForEach-Object { + + if ($newerVersion) + { + + Write-Verbose "Found previous version to compare: $newerVersion" + + } + + [version]$version = $_.tag_name -replace "v","" + + "[{0}] Comparing {1} to {2}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $version, $PSLibraryVersion.LibraryVersion | Write-Verbose + + # Compare found version with library + if (-not($newerVersion) -and $version.build -gt $PSLibraryVersion.LibraryVersion.build) + { + + [version]$newerVersion = $version + $newerVersionObj = $_ + + "[{0}] Newer version found: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $newerVersion | Write-Verbose + + } + + elseif ($newerVersion.Build -lt $version.Build -and $version.build -gt $PSLibraryVersion.LibraryVersion.build) + { + + [version]$newerVersion = $version + $newerVersionObj = $_ + + "[{0}] Newer version found: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $newerVersion | Write-Verbose + + } + + } + + if ($newerVersion) + { + + "[{0}] Found: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), [String]$version | Write-Verbose + + $PSLibraryVersion | Add-Member -NotePropertyName UpdateAvailable -NotePropertyValue $True + + if ($ReleaseNotes) { $newerVersionObj.body -replace "## ","" -replace "\*"," ? " } + + $caption = "Please Confirm"; + $message = "You currently have v{0} installed. The HPE OneView PowerShell Library v{1} was found that is newer. Do you want to download the current version of the HPE OneView POSH Library (will open your web browser for you to download)?" -f $PSLibraryVersion.LibraryVersion, [String]$newerVersion + $yes = [System.Management.Automation.Host.ChoiceDescription]::new("&Yes","Open your browser to download latest HPE OneView POSH Library version."); + $no = [System.Management.Automation.Host.ChoiceDescription]::new("&No","No, you will do this later."); + $choices = [System.Management.Automation.Host.ChoiceDescription[]]($yes,$no); + $answer = $host.ui.PromptForChoice($caption,$message,$choices,0) + + switch ($answer) + { + + 0 + { + + "[{0}] Launching users browser to '{1}'" -f $MyInvocation.InvocationName.ToString().ToUpper(), $newerVersionObj.html_url | Write-Verbose + + Start-Process "$($newerVersionObj.html_url)" + + } + + } + + } + + else + { + + $PSLibraryVersion | Add-Member -NotePropertyName UpdateAvailable -NotePropertyValue $False + + "[{0}] Library is already up-to-date." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + $PSLibraryVersion + + } + + catch + { + + $errorMessage = "$($_[0].exception.message). $($_[0].exception.InnerException.message)" + $ErrorRecord = New-ErrorRecord HPEOneView.Library.UpdateConnectionError InvalidResult ConnectionError 'CheckOnline' -TargetType 'Switch' -Message "$($_[0].exception.message)." -InnerException $_.exception.InnerException + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + else + { + + $PSLibraryVersion + + } + + } + + end + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Get-OVHealthStatus +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding ()] + Param + ( + + [Parameter (Mandatory = $false)] + [ValidateNotNullOrEmpty()] + [Alias ('appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $_HealthStatusCollection = [System.Collections.ArrayList]::new() + + } + + Process + { + + ForEach ($_appliance in $ApplianceConnection) + { + + Try + { + + $healthStatus = Send-OVRequest $ApplianceHealthStatusUri -Hostname $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $healthStatus.members | ForEach-Object { + + $_.PSObject.TypeNames.Insert(0,"HPEOneview.Appliance.HealthStatus") + + [void]$_HealthStatusCollection.Add($_) + + } + + } + + } + + End + { + + Return $_HealthStatusCollection | Sort-Object ApplianceConnection.Name,resourceType + + } + +} + +function Get-OVXApiVersion +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding ()] + Param + ( + + [Parameter (Mandatory = $false)] + [ValidateNotNullorEmpty()] + [Alias ('appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Cmdlet does not require authentication." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + # Check to see if a connection to the appliance exists + # If ($ApplianceConnection -isnot [HPEOneView.Appliance.Connection] -and $ApplianceConnection -isnot [System.Collections.IEnumerable] -and $ApplianceConnection -is [String]) + if ($ApplianceConnection -is [String]) + { + + if ((${Global:ConnectedSessions}.Name -notcontains $ApplianceConnection) -and (-not(${Global:ConnectedSessions} | Where-Object Name -eq $ApplianceConnection).SessionID)) + { + + "[{0}] Appliance Session not found. Running FTS sequence?" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + "[{0}] Creating temporary Session object" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_ApplianceName = $ApplianceConnection + + [HPEOneView.Appliance.Connection]$ApplianceConnection = New-TemporaryConnection $ApplianceConnection + + # $ApplianceConnection.Name = $_ApplianceName + + "[{0}] $($ApplianceConnection | Format-List * )" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + else + { + + [HPEOneView.Appliance.Connection]$ApplianceConnection = ${Global:ConnectedSessions} | Where-Object Name -eq $ApplianceConnection + + } + + } + + $_XAPICollection = [System.Collections.ArrayList]::new() + + } + + Process + { + + if ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + ForEach ($_appliance in $ApplianceConnection) + { + + Try + { + + $_XAPIVersion = Send-OVRequest -Uri $ApplianceXApiVersionUri -Hostname $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + finally + { + + # Remove Temporary appliance connection + if ((${Global:ConnectedSessions} | Where-Object Name -eq $_appliance.Name).SessionID -eq 'TemporaryConnection') + { + + "[{0}] Removing temporary Session object" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $ConnectedSessions.RemoveConnection($_appliance) + + } + + } + + $_XAPIVersion | ForEach-Object { $_.PSObject.TypeNames.insert(0,'HPEOneview.Appliance.XAPIVersion') } + + [void]$_XAPICollection.Add($_XAPIVersion) + + } + + } + + else + { + + Try + { + + $_XAPIVersion = Send-OVRequest -Uri $ApplianceXApiVersionUri -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + finally + { + + # Remove Temporary appliance connection + if ((${Global:ConnectedSessions} | Where-Object Name -eq $ApplianceConnection.Name).SessionID -eq 'TemporaryConnection') + { + + "[{0}] Removing temporary Session object" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $ConnectedSessions.RemoveConnection($ApplianceConnection) + + } + + } + + [HPEOneView.Appliance.XApiVersion]::new( $_XAPIVersion.currentVersion, $_XAPIVersion.minimumVersion, $_XAPIVersion.ApplianceConnection) + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Get-OVEulaStatus +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding ()] + Param + ( + + [Parameter (Mandatory)] + [ValidateNotNullOrEmpty()] + [Object]$Appliance + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + # Need to create temporary Global:ConnectedSessions after validating it doesn't exist for appliance connection being created. + # otherwise, cmdlet will fail when making call to REstClient and it performs the SSL validation and flag value in SSLChecked property + # need to do the same with Set-OVEulaStatus + # Check to see if a connection to the appliance exists + + if ($Appliance -is [String]) + { + + if (-not(${Global:ConnectedSessions}.Name -contains $Appliance) -and (-not(${Global:ConnectedSessions} | Where-Object Name -eq $Appliance).SessionID)) + { + + "[{0}] Appliance Session not found. Running FTS sequence?" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + "[{0}] Creating temporary Session object" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_ApplianceName = $Appliance + + [HPEOneView.Appliance.Connection]$Appliance = New-TemporaryConnection $Appliance + + "[{0}] {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Appliance.Name | Write-Verbose + + } + + else # If (${Global:ConnectedSessions}.Name -contains $Appliance) + { + + "[{0}] Appliance is a string value, lookup connection in global tracker." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + [HPEOneView.Appliance.Connection]$Appliance = ${Global:ConnectedSessions} | Where-Object Name -eq $Appliance + + "[{0}] Found connection in global tracker: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), ($Appliance | Out-String) | Write-Verbose + + } + + } + + elseif ($Appliance -is [HPEOneView.Appliance.Connection]) + { + + "[{0}] Appliance is a Connection: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), ($Appliance | Out-String) | Write-Verbose + + } + + } + + Process + { + + "[{0}] Getting EULA Status from '$($Appliance.Name)'." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $_ApplianceEulaStatus = Send-OVRequest $ApplianceEulaStatusUri -Hostname $Appliance.Name + + $_EulaStatus = [HPEOneView.Appliance.EulaStatus]::new($Appliance.Name, !$_ApplianceEulaStatus) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + finally + { + + # Remove Temporary appliance connection + if ((${Global:ConnectedSessions} | Where-Object Name -eq $Appliance.Name).SessionID -eq 'TemporaryConnection') + { + + "[{0}] Removing temporary Session object" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $ConnectedSessions.RemoveConnection($Appliance) + + } + + } + + } + + End + { + + Return $_EulaStatus + + } + +} + +function Set-OVEulaStatus +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding ()] + Param + ( + + [Parameter (Mandatory)] + [ValidateNotNullOrEmpty()] + [Object]$Appliance, + + [Parameter (Mandatory)] + [ValidateNotNullOrEmpty()] + [ValidateSet ('Yes', 'No')] + [String]$SupportAccess + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + # Check to see if a connection to the appliance exists + if ($Appliance -is [String]) + { + + if (-not(${Global:ConnectedSessions}.Name -contains $Appliance) -and (-not(${Global:ConnectedSessions} | Where-Object Name -eq $Appliance).SessionID)) + { + + "[{0}] Appliance Session not found. Running FTS sequence?" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Creating temporary Session object" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + $_ApplianceName = $Appliance + + [HPEOneView.Appliance.Connection]$Appliance = New-TemporaryConnection $Appliance + + "[{0}] {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Appliance.Name | Write-Verbose + + } + + else # If (${Global:ConnectedSessions}.Name -contains $Appliance) + { + + "[{0}] Appliance is a string value, lookup connection in global tracker." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + [HPEOneView.Appliance.Connection]$Appliance = ${Global:ConnectedSessions} | Where-Object Name -eq $Appliance + + "[{0}] Found connection in global tracker: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), ($Appliance | Out-String) | Write-Verbose + + } + + } + + elseif ($Appliance -is [HPEOneView.Appliance.Connection]) + { + + "[{0}] Appliance is a Connection: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), ($Appliance | Out-String) | Write-Verbose + + } + + else + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException UnknownCondition InvalidOperation "Appliance" -Message "An unknown condition has ocurred." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + Process + { + + $body = [PSCustomObject]@{ + + supportAccess = $supportAccess + + } + + Try + { + + $_eulastatus = Send-OVRequest -Uri $ApplianceEulaSaveUri -Method POST -Body $body -Hostname $Appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + Finally + { + + if ((${Global:ConnectedSessions} | Where-Object Name -eq $Appliance.Name).SessionID -eq 'TemporaryConnection') + { + + "[{0}] Removing temporary Session object" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + $ConnectedSessions.RemoveConnection($Appliance) + + } + + } + + } + + End + { + + Return $_eulastatus + + } + +} + +function New-TemporaryConnection +{ + + [CmdletBinding ()] + Param + ( + + [Parameter (Mandatory, Position = 0)] + [ValidateNotNullOrEmpty()] + [String]$Hostname + + ) + + Process + { + + $_ID = 99 + + While (-not($FoundID)) + { + + if ($ConnectedSessions.ConnectionID -notcontains $_ID) + { + + $FoundID = $_ID + + } + + $_ID-- + + } + + $_TemporaryConnection = [HPEOneView.Appliance.Connection]::new($_ID, $Hostname, 'TemporaryConnection') + + [void]${Global:ConnectedSessions}.Add($_TemporaryConnection) + + Return $_TemporaryConnection + + } + +} + +function Get-OVApplianceNetworkConfig +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding ()] + Param + ( + + [Parameter (Mandatory = $false)] + [Alias ("x", "export", 'exportFile')] + [ValidateScript({Test-Path $_})] + [String]$Location, + + [Parameter (Mandatory = $false)] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $_ApplianceNetworkConfiguration = [System.Collections.ArrayList]::new() + + } + + Process + { + + ForEach ($_appliance in $ApplianceConnection) + { + + "[{0}] Processing Appliance Connection: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name | Write-Verbose + + Try + { + + $_appliancenetconfig = Send-OVRequest -Uri $ApplianceNetworkConfigUri -Hostname $_appliance.Name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + + $_appliancenetconfig | ForEach-Object { $_.PSObject.TypeNames.Insert(0,"HPEOneview.Appliance.ApplianceServerConfiguration") } + $_appliancenetconfig.applianceNetworks | ForEach-Object { $_.PSObject.TypeNames.Insert(0,"HPEOneview.Appliance.ApplianceServerConfiguration.ApplianceNetworks") } + + [void]$_ApplianceNetworkConfiguration.Add($_appliancenetconfig) + + } + + } + + End + { + + If ($PSBoundParameters['Location']) + { + + ForEach ($_ApplianceConfig in $_ApplianceNetworkConfiguration) + { + + $_filename = "{0}_ApplianceNetConf.json" -f $_ApplianceConfig.ApplianceConnection.Name + + ForEach ($nic in $_ApplianceConfig.applianceNetworks) + { + + if ($nic.IPv4Type -eq "DHCP") { $nic.app1IPv4Addr = $null } + + if ($nic.IPv6Type -eq "DHCP") { $nic.app1IPv6Addr = $null } + + } + + $_ApplianceConfig = $_ApplianceConfig | Select-Object * -ExcludeProperty ApplianceConnection + + $_ApplianceConfig | convertto-json -depth 99 > ($Location + '\' + $_filename) + + Get-ChildItem ($Location + '\' + $_filename) + + } + + } + + Else + { + + Return $_ApplianceNetworkConfiguration + + } + + } + +} + +function Get-OVApplianceIPAddress +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + [OutputType ([HPEOneView.Appliance.NetworkInterface])] + [OutputType ([HPEOneView.Appliance.ComposerNetworkInterface])] + [CmdletBinding ()] + Param + ( + + [Parameter (Mandatory = $false)] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $_ApplianceDateTimeCol = [System.Collections.ArrayList]::new() + + } + + Process + { + + ForEach ($_appliance in $ApplianceConnection) + { + + "[{0}] Processing Appliance Connection {1} (of {2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name, $ApplianceConnection.Count | Write-Verbose + + try + { + + $_appliancenetconfig = Send-OVRequest -Uri $ApplianceNetworkConfigUri -Hostname $_appliance + + } + + catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + ForEach ($_applianceNetwork in $_appliancenetconfig.appliancenetworks) + { + + switch (($ConnectedSessions | Where-Object Name -eq $_appliance.Name).ApplianceType) + { + + 'Composer' + { + + # Process Node1 + $Node1Role = if ($_applianceNetwork.activeNode -eq '1') { 'Active'} else { "Standby" } + + [HPEOneView.Appliance.ComposerNetworkInterface]::new($_applianceNetwork.interfaceName, + $_applianceNetwork.device, + $_applianceNetwork.macAddress, + $_applianceNetwork.ipv4Type, + $_applianceNetwork.virtIpv4Addr, + $_applianceNetwork.app1Ipv4Addr, + $_applianceNetwork.ipv4Subnet, + $_applianceNetwork.ipv4Gateway, + $_applianceNetwork.ipv6Type, + $_applianceNetwork.virtIpv6Addr, + $_applianceNetwork.app1Ipv6Addr, + $_applianceNetwork.ipv6Subnet, + $_applianceNetwork.ipv6Gateway, + $_applianceNetwork.ipv4NameServers, + $_applianceNetwork.overrideIpv4DhcpDnsServers, + $_applianceNetwork.ipv6NameServers, + $_applianceNetwork.overrideIpv6DhcpDnsServers, + $_applianceNetwork.searchDomains, + $_applianceNetwork.hostname, + $Node1Role, + $_appliancenetconfig.ApplianceConnection) + + # Only process Node 2 if there is a configured IPv4 or IPv6 maintenance address + if (-not [String]::IsNullOrEmpty($_applianceNetwork.app2Ipv4Addr) -or -not [String]::IsNullOrEmpty($_applianceNetwork.app2Ipv6Addr)) + { + + $Node2Role = if ($Node1Role -eq 'Active') { "Standby" } else { 'Standby' } + + [HPEOneView.Appliance.ComposerNetworkInterface]::new($_applianceNetwork.interfaceName, + $_applianceNetwork.device, + $_applianceNetwork.macAddress, + $_applianceNetwork.ipv4Type, + $_applianceNetwork.virtIpv4Addr, + $_applianceNetwork.app2Ipv4Addr, + $_applianceNetwork.ipv4Subnet, + $_applianceNetwork.ipv4Gateway, + $_applianceNetwork.ipv6Type, + $_applianceNetwork.virtIpv6Addr, + $_applianceNetwork.app2Ipv6Addr, + $_applianceNetwork.ipv6Subnet, + $_applianceNetwork.ipv6Gateway, + $_applianceNetwork.ipv4NameServers, + $_applianceNetwork.overrideIpv4DhcpDnsServers, + $_applianceNetwork.ipv6NameServers, + $_applianceNetwork.overrideIpv6DhcpDnsServers, + $_applianceNetwork.searchDomains, + $_applianceNetwork.hostname, + $Node2Role, + $_appliancenetconfig.ApplianceConnection) + + } + + } + + 'VMA' + { + + [HPEOneView.Appliance.NetworkInterface]::new($_applianceNetwork.interfaceName, + $_applianceNetwork.device, + $_applianceNetwork.macAddress, + $_applianceNetwork.ipv4Type, + $_applianceNetwork.app1Ipv4Addr, + $_applianceNetwork.ipv4Subnet, + $_applianceNetwork.ipv4Gateway, + $_applianceNetwork.ipv6Type, + $_applianceNetwork.app1Ipv6Addr, + $_applianceNetwork.ipv6Subnet, + $_applianceNetwork.ipv6Gateway, + $_applianceNetwork.ipv4NameServers, + $_applianceNetwork.overrideIpv4DhcpDnsServers, + $_applianceNetwork.ipv6NameServers, + $_applianceNetwork.overrideIpv6DhcpDnsServers, + $_applianceNetwork.searchDomains, + $_applianceNetwork.hostname, + $_appliancenetconfig.applianceConnection) + + } + + } + + } + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Get-OVApplianceDateTime +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding ()] + Param + ( + + [Parameter (Mandatory = $false)] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $_ApplianceDateTimeCol = [System.Collections.ArrayList]::new() + + } + + Process + { + + ForEach ($_appliance in $ApplianceConnection) + { + + "[{0}] Processing Appliance Connection {1} (of {2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name, $ApplianceConnection.Count | Write-Verbose + + Try + { + + $_appliancedatetime = Send-OVRequest -Uri $ApplianceDateTimeUri -Hostname $_appliance.Name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $SyncWithHost = $true + + if ($_appliancedatetime.ntpServers.Count -gt 0) + { + + $SyncWithHost = $false + + } + + [HPEOneView.Appliance.ApplianceLocaleDateTime]::new($_appliancedatetime.locale, + $_appliancedatetime.timezone, + $_appliancedatetime.dateTime, + [String[]]$_appliancedatetime.ntpServers, + $_appliancedatetime.pollingInterval, + $SyncWithHost, + $_appliancedatetime.LocaleDisplayName, + $_appliancedatetime.ApplianceConnection) + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Set-OVApplianceDateTime +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = 'SyncHost')] + Param + ( + + [Parameter (Mandatory, ParameterSetName = 'SyncHost')] + [Switch]$SyncWithHost, + + [Parameter (Mandatory, ParameterSetName = 'NTPServers')] + [Array]$NTPServers, + + [Parameter (Mandatory = $false, ParameterSetName = 'NTPServers')] + [Int]$PollingInterval, + + [Parameter (Mandatory = $False, ParameterSetName = 'SyncHost')] + [Parameter (Mandatory = $False, ParameterSetName = 'NTPServers')] + [ValidateSet ('en_US','zh_CN','ja_JP')] + [String]$Locale, + + [Parameter (Mandatory = $False, ParameterSetName = 'SyncHost')] + [Parameter (Mandatory = $False, ParameterSetName = 'NTPServers')] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + Process + { + + ForEach ($_appliance in $ApplianceConnection) + { + + $_SyncWithHost = $false + + "[{0}] Processing Appliance Connection {1} (of {2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name, $ApplianceConnection.Count | Write-Verbose + + Try + { + + $_CurrentConfig = Send-OVRequest -Uri $ApplianceDateTimeUri -Hostname $_appliance.Name + + } + + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $_ApplianceTimeConfig = NewObject -ApplianceTimeLocale + + switch ($PSCmdlet.ParameterSetName) + { + + 'SyncWithHost' + { + + "[{0}] Seting ntpServers to 'null' for Sync with Host." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + $_ApplianceTimeConfig.ntpServers = @() + $_SyncWithHost = $true + + } + + 'NTPServers' + { + + ForEach ($_ntpserver in $NTPServers) + { + + "[{0}] Adding '{1}' to collection."-f $MyInvocation.InvocationName.ToString().ToUpper(), $_ntpserver | Write-Verbose + + [void]$_ApplianceTimeConfig.ntpServers.Add($_ntpserver) + + } + + if ($PSBoundParameters['PollingInterval']) + { + + $_ApplianceTimeConfig.pollingInterval = $PollingInterval.ToString() + + } + + } + + } + + if ($PSBoundParameters['TimeZone']) + { + + $_ApplianceTimeConfig.timezone = $TimeZone + + } + + else + { + + $_ApplianceTimeConfig.timezone = $_CurrentConfig.timezone + + } + + if ($PSBoundParameters['Locale']) + { + + $_ApplianceTimeConfig.locale = $ApplianceLocaleSetEnum[$Locale] + + } + + else + { + + $_ApplianceTimeConfig.locale = $_CurrentConfig.locale + + } + + Try + { + + $_Results = Send-OVRequest -Uri $ApplianceDateTimeUri -Method POST -Body $_ApplianceTimeConfig -Hostname $_appliance.Name | Wait-OVTaskComplete + + if ('Warning', 'Completed' -notcontains $_Results.taskState) + { + + $ExceptionMessage = [String]::Join(' ', $_Results.taskErrors.Message) + $ErrorRecord = New-ErrorRecord InvalidOperationException ApplianceDateTimeInvalidOperation InvalidOperation $ApplianceConnection.Name -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + $_appliancedatetime = Send-OVRequest -Uri $ApplianceDateTimeUri -Hostname $_appliance.Name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + [HPEOneView.Appliance.ApplianceLocaleDateTime]::new($_appliancedatetime.locale, + $_appliancedatetime.timezone, + $_appliancedatetime.dateTime, + [String[]]$_appliancedatetime.ntpServers, + $_appliancedatetime.pollingInterval, + $SyncWithHost, + $_appliancedatetime.LocaleDisplayName, + $_appliancedatetime.ApplianceConnection) + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Set-OVApplianceNetworkConfig +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "VMA")] + Param + ( + + [Parameter (Mandatory, ParameterSetName = "VMA")] + [Parameter (Mandatory, ParameterSetName = "Composer")] + [ValidateNotNullorEmpty()] + [String]$Hostname, + + [Parameter (Mandatory = $false, ParameterSetName = "VMA")] + [Parameter (Mandatory = $false, ParameterSetName = "Composer")] + [ValidateSet ('DHCP','STATIC')] + [String]$IPv4Type = 'STATIC', + + [Parameter (Mandatory = $false, ParameterSetName = "VMA")] + [Parameter (Mandatory, ParameterSetName = "Composer")] + [ValidateScript({ [String]::IsNullOrEmpty($_) -or + $_ -match '^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.' + + '(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.' + + '(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.' + + '(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)' + + '(/0*([1-9]|[12][0-9]|3[0-2]))?$' })] + [Net.IPAddress]$IPv4Addr, + + [Parameter (Mandatory = $false, ParameterSetName = "VMA")] + [Parameter (Mandatory, ParameterSetName = "Composer")] + [ValidateScript({ + + ($_ -ge 1 -and $_ -le 32) -or + ($_ -match [Net.IPAddress]$_) + + })] + [String]$IPv4Subnet, + + [Parameter (Mandatory = $false, ParameterSetName = "VMA")] + [Parameter (Mandatory, ParameterSetName = "Composer")] + [ValidateScript({ [String]::IsNullOrEmpty($_) -or + $_ -match [Net.IPAddress]$_})] + [Net.IPAddress]$IPv4Gateway, + + [Parameter (Mandatory = $false, ParameterSetName = "VMA")] + [Parameter (Mandatory = $false, ParameterSetName = "Composer")] + [ValidateSet ('DHCP','STATIC','UNCONFIGURE')] + [String]$IPv6Type = 'UNCONFIGURE', + + [Parameter (Mandatory = $false, ParameterSetName = "VMA")] + [Parameter (Mandatory = $false, ParameterSetName = "Composer")] + [ValidateScript({ [String]::IsNullOrEmpty($_) -or + $_ -match [Net.IPAddress]$_})] + [Net.IPAddress]$IPv6Addr, + + [Parameter (Mandatory = $false, ParameterSetName = "VMA")] + [Parameter (Mandatory = $false, ParameterSetName = "Composer")] + [ValidateNotNullorEmpty()] + [String]$IPv6Subnet, + + [Parameter (Mandatory = $false, ParameterSetName = "VMA")] + [Parameter (Mandatory = $false, ParameterSetName = "Composer")] + [ValidateScript({ [String]::IsNullOrEmpty($_) -or + $_ -match [Net.IPAddress]$_})] + [String]$IPv6Gateway, + + [Parameter (Mandatory, ParameterSetName = "Composer")] + [ValidateScript({ [String]::IsNullOrEmpty($_) -or + $_ -match [Net.IPAddress]$_})] + [Net.IPAddress]$ServiceIPv4Node1, + + [Parameter (Mandatory, ParameterSetName = "Composer")] + [ValidateScript({ [String]::IsNullOrEmpty($_) -or + $_ -match [Net.IPAddress]$_})] + [Net.IPAddress]$ServiceIPv4Node2, + + [Parameter (Mandatory= $false, ParameterSetName = "Composer")] + [ValidateScript({ [String]::IsNullOrEmpty($_) -or + $_ -match [Net.IPAddress]$_})] + [Net.IPAddress]$ServiceIPv6Node1, + + [Parameter (Mandatory= $false, ParameterSetName = "Composer")] + [ValidateScript({ [String]::IsNullOrEmpty($_) -or + $_ -match [Net.IPAddress]$_})] + [Net.IPAddress]$ServiceIPv6Node2, + + [Parameter (Mandatory = $false, ParameterSetName = "VMA")] + [Parameter (Mandatory = $false, ParameterSetName = "Composer")] + [Alias ('overrideDhcpDns')] + [Switch]$OverrideIPv4DhcpDns, + + [Parameter (Mandatory = $false, ParameterSetName = "VMA")] + [Parameter (Mandatory = $false, ParameterSetName = "Composer")] + [Switch]$OverrideIPv6DhcpDns, + + [Parameter (Mandatory = $false, ParameterSetName = "VMA")] + [Parameter (Mandatory = $false, ParameterSetName = "Composer")] + [ValidateNotNullorEmpty()] + [String]$DomainName, + + [Parameter (Mandatory = $false, ParameterSetName = "VMA")] + [Parameter (Mandatory = $false, ParameterSetName = "Composer")] + [ValidateNotNullorEmpty()] + [Array]$SearchDomains, + + [Parameter (Mandatory = $false, ParameterSetName = "VMA")] + [Parameter (Mandatory = $false, ParameterSetName = "Composer")] + [ValidateNotNullorEmpty()] + [Alias ('nameServers')] + [Array]$IPv4NameServers, + + [Parameter (Mandatory = $false, ParameterSetName = "VMA")] + [Parameter (Mandatory = $false, ParameterSetName = "Composer")] + [ValidateNotNullorEmpty()] + [Array]$IPv6NameServers, + + [Parameter (Mandatory = $false, ParameterSetName = "VMA")] + [Object]$NtpServers, + + [Parameter (Mandatory, ParameterSetName = "importFile")] + [Alias ("i", "import")] + [ValidateScript({Test-Path $_})] + [Object]$importFile, + + [Parameter (Mandatory = $false, ParameterSetName = "VMA")] + [Parameter (Mandatory = $false, ParameterSetName = "Composer")] + [Parameter (Mandatory = $false, ParameterSetName = "importFile")] + [ValidateNotNullOrEmpty()] + [object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if ($PSBoundParameters['NtpServers']) + { + + Write-Warning 'The -NtpServer Parameter has been deprecated, and is now controlled in the Set-OVApplianceDateTime Cmdlet. Please update your scripts accordingly.' + + } + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + if ($ApplianceConnection.Count -gt 1) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException MultipleApplianceConnections InvalidArgument 'ApplianceConnection' -Message 'The specified ApplianceConnection Parameter contains multiple Appliance Connections. This CMDLET only supports 1 Appliance Connection in the ApplianceConnect Parameter value. Please correct this and try again.' + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + $colStatus = [System.Collections.ArrayList]::new() + + } + + Process + { + + # Locate the Enclosure Group specified + "[{0}] - Starting" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if ($ApplianceConnection.ApplianceType -eq 'Composer' -and (-not($PSBoundParameters['ServiceIPv4Node1']) -or -not($PSBoundParameters['ServiceIPv4Node2']))) + { + + $ErrorRecord = New-ErrorRecord InvalidOperationException MissingParameterValues InvalidOperation $ApplianceConnection.Name -Message 'The connected appliance type is a Synergy Composer, however the required -ServiceIPv4Node1 and/or -ServiceIPv4Node2 Parameter (s) was(were) not provided. Please correct the call and try again.' + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + # Validate the appliance can Begin Network configuration of the appliance + Try + { + + "[{0}] Validating Network can be configured on the appliance." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $_resp = Send-OVRequest -Uri $ApplianceNetworkStatusUri -Hostname $ApplianceConnection.Name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if (-not($_resp.networkingAllowed)) + { + + $ErrorRecord = New-ErrorRecord InvalidOperationException UnableToEditApplianceNetwork InvalidOperation $ApplianceConnection.Name -Message ($_resp.disabledReason -join " ") + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + # Get the current config (to get ETag & ensure we don't overwrite anything): + Try + { + + $_currentconfig = Send-OVRequest -Uri $ApplianceNetworkConfigUri -Hostname $ApplianceConnection.Name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + Switch ($PSCmdlet.ParameterSetName) + { + + {"VMA",'Composer' -contains $_} + { + + "[{0}] Looking for Primary interface configuration." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + [Int]$i = 0 + + $_deviceIndex = $null + + For ($i -eq 0; $i -le ($_currentconfig.applianceNetworks.Count - 1); $i++) + { + + if($_currentconfig.applianceNetworks[$i].interfaceName -eq "Appliance") + { + + "[{0}] Found interface: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_currentconfig.applianceNetworks[$i].interfaceName | Write-Verbose + + $_deviceIndex = $i + + $_configured = $true + + #break out of for loop + break + + } + + } + + } + + "importFile" + { + + try + { + + $_importConfig = [String]::Join("", (Get-Content $importfile -ErrorAction Stop)) + + $_importConfig = $_importConfig -replace "\s","" | convertfrom-json -ErrorAction Stop + + } + + catch [System.Management.Automation.ItemNotFoundException] + { + + $ErrorRecord = New-ErrorRecord System.Management.Automation.ItemNotFoundException ImportFileNotFound ObjectNotFound 'Set-OVApplianceNetworkConfig' -Message "$importFile not found!" + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + catch [System.ArgumentException] + { + + $ErrorRecord = New-ErrorRecord System.ArgumentException InvalidJSON ParseErrror 'Set-OVApplianceNetworkConfig' -Message "Input JSON format incorrect!" + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + + [Int]$i = 0 + + For ($i -eq 0; $i -le ($_importConfig.applianceNetworks.Count - 1); $i++) + { + + if ($_importConfig.applianceNetworks[$i].IPv4Gateway -eq "127.0.0.1") + { + + $_importConfig.applianceNetworks[$i].IPv4Gateway = $null + + } + + if ($_importConfig.applianceNetworks[$i].nameServers -is [String]) + { + + $_importConfig.applianceNetworks[$i].nameServers = [System.Collections.ArrayList]::new() + + } + + if ($_importConfig.applianceNetworks[$i].searchDomains -is [String]) + { + + $importConfig.applianceNetworks[$i].searchDomains = [System.Collections.ArrayList]::new() + + } + + if (-not($_importConfig.applianceNetworks[$i].macAddress)) + { + + #$_macAddr = ($_importConfig.applianceNetworks | ? { $_.device -eq $_importConfig.applianceNetworks[$i].device }).macAddress + + if (-not $_importConfig.applianceNetworks[$i].macAddress) + { + + $_macAddr = ($_currentconfig.applianceNetworks | Where-Object { $_.device -eq $_importConfig.applianceNetworks[$i].device }).macAddress + + } + + if(-not $_macAddr) + { + + $ErrorRecord = New-ErrorRecord InvalidOperationException ApplianceNICResourceNotFound ObjectNotFound 'Device' -Message ($_importConfig.applianceNetworks[$i].device + "does not exist on the appliance.") + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + $_importConfig.applianceNetworks[$i] | Add-Member -NotePropertyName macAddress -NotePropertyValue $_macAddr + + } + + if ($_importConfig.applianceNetworks[$i].interfaceName -eq 'Appliance' -and $_importConfig.applianceNetworks[$i].ipv4Type -eq 'STATIC') + { + + # Clear non-virtIpv4Addr value for non-Composer appliances + if ($ApplianceConnection.ApplianceType -ne 'Composer') + { + + $_importConfig.applianceNetworks[$i].virtIpv4Addr = $null + $_importConfig.applianceNetworks[$i].app2Ipv4Addr = $null + + } + + # This is needed for when we attempt to reconnect back to the appliance + [IPAddress]$IPv4Addr = $_importConfig.applianceNetworks[$i].app1Ipv4Addr + + } + + } + + #zero the $currentConfig.applianceNetworks array so we can sEnd it all new values + $_currentConfig.applianceNetworks = $_importConfig.applianceNetworks + + } + + } + + if ($_configured) + { + + # Update any non-null values that were passed-in: + + if ($Hostname) + { + + if ($DomainName) + { + + $Hostname += '.{0}' -f $DomainName + + } + + $_currentconfig.applianceNetworks[$_deviceIndex].hostname = $Hostname + + } + + if ($DomainName) { $_currentconfig.applianceNetworks[$_deviceIndex].domainName = $DomainName } + if ($SearchDomains) { $_currentconfig.applianceNetworks[$_deviceIndex].searchDomains = $SearchDomains } + + $_currentconfig.applianceNetworks[$_deviceIndex].IPv4Type = $IPv4Type.ToUpper() + $_currentconfig.applianceNetworks[$_deviceIndex].IPv6Type = $IPv6Type.ToUpper() + + switch ($IPv4Type) + { + + 'DHCP' + { + + if ($ApplianceConnection.ApplianceType -eq 'Composer') + { + + $ErrorRecord = New-ErrorRecord InvalidOperationException InvalidIPv4AddressType InvalidOperation 'IPv4Type' -Message 'The connected appliance type is a Synergy Composer, only Static IPv4Address configurations are allowed.' + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + '[{0}] Configuring DHCP for NIC' -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_currentconfig.applianceNetworks[$_deviceIndex].app1IPv4Addr = $null + + # If $overrideIPv4DhcpDns is true, set it, if not make sure it is fale + if ($PSBoundParameters['OverrideIPv4DhcpDns']) + { + + $_currentconfig.applianceNetworks[$_deviceIndex].overrideIPv4DhcpDnsServers = [Bool]$OverrideIPv4DhcpDns + + } + + else + { + + $_currentconfig.applianceNetworks[$_deviceIndex].overrideIPv4DhcpDnsServers = $false + + } + + } + + 'STATIC' + { + + '[{0}] Configuring STATIC for NIC' -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + # Make sure override.. is false if STATIC ip addresses are in use. + $_currentconfig.applianceNetworks[$_deviceIndex].overrideIPv4DhcpDnsServers = $false + + if ((-not($PSBoundParameters['IPv4Subnet'])) -or ([Net.IPAddress]$IPv4Subnet -eq 0.0.0.0) -or $null -eq $IPv4Subnet) + { + + $Message = 'A static IPv4 Address was provided, but not a valid IPv4Subnet Parameter value. Please correct this and try again.' + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.NetworkConfigurationException InvalidIPv4Subnet InvalidArgument 'IPv4Subnet' -Message $Message + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + # Calculate the CIDR bit value to the SubnetMask Address + if ($PSBoundParameters['IPv4Subnet'].Length -le 2) + { + + Try + { + + "[{0}] Converting Subnet CIDR Bit value to Subnet Mask Address." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + [Int64]$_Int64Value = ([convert]::ToInt64(('1' * $IPv4Subnet + '0' * (32 - $IPv4Subnet)), 2)) + + $IPv4Subnet = '{0}.{1}.{2}.{3}' -f ([math]::Truncate($_Int64Value / 16777216)).ToString(), + ([math]::Truncate(($_Int64Value % 16777216) / 65536)).ToString(), + ([math]::Truncate(($_Int64Value % 65536)/256)).ToString(), + ([math]::Truncate($_Int64Value % 256)).ToString() + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $_currentconfig.applianceNetworks[$_deviceIndex].IPv4Subnet = $IPv4Subnet + $_currentconfig.applianceNetworks[$_deviceIndex].IPv4Gateway = $IPv4Gateway.IPAddressToString + + if ($PSBoundParameters['IPv4NameServers']) + { + + $_currentconfig.applianceNetworks[$_deviceIndex].IPv4NameServers = $IPv4NameServers + + } + + if ($ApplianceConnection.ApplianceType -eq 'Composer') + { + + '[{0}] Appliance is Composer, setting Service IP1 and Service IP2' -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_currentconfig.applianceNetworks[$_deviceIndex].virtIPv4Addr = $IPv4Addr.IPAddressToString + $_currentconfig.applianceNetworks[$_deviceIndex].app1IPv4Addr = $ServiceIPv4Node1.IPAddressToString + $_currentconfig.applianceNetworks[$_deviceIndex].app2IPv4Addr = $ServiceIPv4Node2.IPAddressToString + + } + + else + { + + $_currentconfig.applianceNetworks[$_deviceIndex].app1IPv4Addr = $IPv4Addr.IPAddressToString + + } + + } + + } + + switch ($IPv6Type) + { + + 'STATIC' + { + + if ($ApplianceConnection.ApplianceType -eq 'Composer') + { + + $_currentconfig.applianceNetworks[$_deviceIndex].virtIPv6Addr = $IPv6Addr.IPAddressToString + + if ($ServiceIPv6Node1 -and $ServiceIPv6Node2) + { + + '[{0}] Appliance is Composer, setting Service IPv6 1' -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_currentconfig.applianceNetworks[$_deviceIndex].app1IPv6Addr = $ServiceIPv6Node1.IPAddressToString + + '[{0}] Appliance is Composer, setting Service IPv6 2' -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_currentconfig.applianceNetworks[$_deviceIndex].app2IPv6Addr = $ServiceIPv6Node2.IPAddressToString + + } + + } + + else + { + + $_currentconfig.applianceNetworks[$_deviceIndex].app1IPv6Addr = $IPv6Addr.IPAddressToString + + } + + $_currentconfig.applianceNetworks[$_deviceIndex].IPv6Subnet = $IPv6Subnet + $_currentconfig.applianceNetworks[$_deviceIndex].IPv6Gateway = $IPv6Gateway.IPAddressToString + + if ($PSBoundParameters['IPv6NameServers']) + { + + $_currentconfig.applianceNetworks[$_deviceIndex].IPv6NameServers = $IPvV6NameServers + + } + + } + + 'DHCP' + { + + # If setting DHCP, clear any existing IP address: + if ($IPv6Type -ieq "DHCP") + { + + $_currentconfig.applianceNetworks[$_deviceIndex].app1IPv6Addr = $null + + } + + if ($PSBoundParameters['OverrideIPv6DhcpDns']) + { + + $_currentconfig.applianceNetworks[$_deviceIndex].overrideIPv6DhcpDnsServers = [Bool]$overrideIPv6DhcpDns + $_currentconfig.applianceNetworks[$_deviceIndex].IPv6NameServers = $IPv6NameServers + + } + + } + + } + + # Hard code the following settings, for now: + $_currentconfig.applianceNetworks[$_deviceIndex].confOneNode = "true" # Always "true", for now + $_currentconfig.applianceNetworks[$_deviceIndex].activeNode = "1" # Always "1", for now + + } + + "[{0}] Configuration to be applied: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), ($_currentconfig | ConvertTo-Json -Depth 99 | out-string) | Write-Verbose + + # Remove MAC Address value or DHCP setting will break + if ($_currentconfig.macAddress -and $ApplianceConnectionApplianceType -ne 'Composer') + { + + $_currentconfig.macAddress = $null + + } + + # This is an asynch method, so get the returned Task object + Try + { + + $_task = Send-OVRequest -uri $ApplianceNetworkConfigUri -Method POST -Body $_currentconfig -Hostname $ApplianceConnection | Wait-OVTaskStart + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + # Validate status code 200, even though it should be HTTP/202 + if ($_task.category -eq $ResourceCategoryEnum.Tasks -and $_task.taskState -eq "Running") + { + + # Start a new stopwatch object + $sw = [diagnostics.stopwatch]::StartNew() + + Do + { + + # Should I make this 120 seconds instead of 90? + $_PercentComplete = [Math]::Round(((($sw.Elapsed.Minutes * 60) + $sw.Elapsed.Seconds) / 90) * 100,$MathMode) + + if ($PSBoundParameters['Verbose'] -or $VerbosePreference -eq 'Continue') + { + + "[{0}] Skipping Write-Progress display." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + "[{0}] Percent Complete: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_PercentComplete | Write-Verbose + Start-Sleep -s 1 + + } + + else + { + + # Display progress-bar + Write-Progress -activity "Update Appliance Network Configuration" -Status "Processing $_PercentComplete%" -percentComplete $_PercentComplete + + } + + } until ($_PercentComplete -eq 100) + + # Stop the stopwatch + $sw.stop() + + Write-Progress -activity "Update Appliance Network Configuration" -Completed + + } + + # Task failed validation + elseif ($_task.taskState -eq "Error") + { + + if ($_task.taskErrors -is [Array] -and $_task.taskErrors.count -gt 1 ) + { + + for ($e = 0; $e -gt $_task.taskErrors.count; $e++) + { + + if ($e -ne $_task.taskErrors.length) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.NetworkConfigurationException NoAuthSession AuthenticationError 'Set-OVApplianceNetworkConfig' -Message "No valid session ID found. Please use Connect-OVMgmt to connect and authenticate to an appliance." + $PSCmdlet.WriteError($ErrorRecord) + + } + + else + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoAuthSession AuthenticationError 'Set-OVApplianceNetworkConfig' -Message "No valid session ID found. Please use Connect-OVMgmt to connect and authenticate to an appliance." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + } + + } + + if ($IPv4Type -eq "static") + { + + Start-Sleep -Seconds 5 + + "[{0}] Connecting to new static IP address {1} to validate it is an HPE OneView appliance." -f $MyInvocation.InvocationName.ToString().ToUpper(), $IPv4Addr.IPAddressToString | Write-Verbose + + "[{0}] Add appliance address {1} to TrustedHosts collection." -f $MyInvocation.InvocationName.ToString().ToUpper(), $IPv4Addr.IPAddressToString | Write-Verbose + + [HPEOneView.PKI.SslValidation]::AddTrustedHost($IPv4Addr.IPAddressToString) + + # Check to make sure we connect to a OneView appliance + Try + { + + $Url = "https://{0}" -f $IPv4Addr.IPAddressToString + + $_WebClient = ([HPEOneView.Utilities.Net]::new()).RestClient($Url, 'GET', $MinXAPIVersion) + + [System.Net.WebResponse]$_response = $_WebClient.GetResponse() + $_reader = [IO.StreamReader]::new($_response.GetResponseStream()) + $_resp = $_reader.ReadToEnd() + $_reader.close() + + } + + Catch + { + + "[{0}] Exception caught: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_.Exception.Message | Write-Verbose + + # Try to connect to the appliance with the original address + Try + { + + $_task = Send-OVRequest -uri $_task.uri -Hostname $ApplianceConnection + + if ($_task.taskState -eq 'Error') + { + + $Message = $_task.taskErrors | ForEach-Object { ('{0} {1} ({2}) {3}' -f $_.message, $_.details, $_.errorCode, ($_.recommendedActions -Join ' ')) } + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.NetworkConfigurationException InvalidApplianceNetworkConfigResult InvalidResult 'Set-OVApplianceNetworkConfig' -Message $Message + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + else + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $PSCmdlet.ThrowTerminatingError($_) + + } + + # If successful, update current POSH session + if ([RegEx]::Match($_resp, "OneView", $RegExInsensitiveFlag).Success) + { + + "[{0}] Updating Global Connection Sessions appliance object with new appliance address: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $IPv4Addr.IPAddressToString | Write-Verbose + + # if ($Validator.TrustedHosts.ContainsKey($ApplianceConnection.Name)) + if ([HPEOneView.PKI.SslValidation]::TrustedHosts.ContainsKey($ApplianceConnection.Name)) + { + + "[{0}] Removing appliance address {1} from TrustedHosts collection." -f $MyInvocation.InvocationName.ToString().ToUpper(), $ApplianceConnection.Name | Write-Verbose + + # $Validator.RemoveTrustedHost($ApplianceConnection.Name) + [HPEOneView.PKI.SslValidation]::RemoveTrustedHost($ApplianceConnection.Name) + + } + + "[{0}] Updating ConnectedSessions Name property with updated address value: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $IPv4Addr.IPAddressToString | Write-Verbose + + ($Global:ConnectedSessions | Where-Object name -eq $ApplianceConnection.Name).SetName($IPv4Addr.IPAddressToString) + + } + + else + { + + # Unable to connect to new appliance address or connection failed. Need to generate error here. + $ExceptionMessage = "Unable to reconnect to the appliance. Please check to make sure there are no IP Address conflicts or your set the IP Address and Subnet Mask correctly." + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.NetworkConnectionException ApplianceUnreachable ConnectionError 'IPv4Addr' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + # Check to see if we can get the final status of the task resource + Try + { + + $Task = Send-OVRequest $_task.uri -Hostname $ApplianceConnection.Name | Wait-OVTaskComplete + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + [void]$colStatus.Add($Task) + + } + + End + { + + Return $colStatus + + } + +} + +# Should this ultimately replace Set-OVApplianceNetworkConfig? +# Ideally +function Set-OVApplianceNetworkAddress +{ + + +} + +function Get-OVSnmpReadCommunity +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding ()] + Param + ( + + [Parameter (Mandatory = $false)] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $_ApplianceSnmpConfigCollection = [System.Collections.ArrayList]::new() + + } + + Process + { + + ForEach ($_appliance in $ApplianceConnection) + { + + "[{0}] Processing '{1}' Appliance (of {2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name, $ApplianceConnection.Count | Write-Verbose + + Try + { + + $_applSnmpReadCommunityStr = Send-OVRequest $ApplianceSnmpReadCommunityUri -Hostname $_appliance + + [HPEOneView.Appliance.SnmpReadCommunity]::new($_applSnmpReadCommunityStr.communityString, + $_applSnmpReadCommunityStr.uri, + $_applSnmpReadCommunityStr.ApplianceConnection) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + End + { + + '[{0}] Done.' -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Set-OVSnmpReadCommunity +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding ()] + Param + ( + + [Parameter (Mandatory)] + [ValidateNotNullOrEmpty()] + [String]$Name, + + [Parameter (Mandatory = $false)] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $_ApplianceSnmpConfigCollection = [System.Collections.ArrayList]::new() + + } + + Process + { + + ForEach ($_appliance in $ApplianceConnection) + { + + "[{0}] Processing '{1}' Appliance (of {2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name, $ApplianceConnection.Count | Write-Verbose + + "[{0}] New SNMP Read Community Value: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Name | Write-Verbose + + $_NewApplSnmpReadCommunityStr = [PsCustomObject]@{ "communityString" = $name } + + Try + { + + $_rspNewApplSnmpReadCommunity = Send-OVRequest -Uri $ApplianceSnmpReadCommunityUri -Method PUT -Body $_NewApplSnmpReadCommunityStr -Hostname $_appliance + + $_rspNewApplSnmpReadCommunity.PSObject.TypeNames.Insert(0,'HPEOneview.Appliance.SnmpCommunity') + + [void]$_ApplianceSnmpConfigCollection.Add($_rspNewApplSnmpReadCommunity) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + End + { + + Return $_ApplianceSnmpConfigCollection + + } + +} + +function New-OVSnmpV3User +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "Default")] + Param + ( + + [Parameter (Mandatory, ParameterSetName = "Default")] + [Parameter (Mandatory, ParameterSetName = "ApplianceSnmpUser")] + [ValidateNotNullOrEmpty()] + [String]$Username, + + [Parameter (Mandatory, ParameterSetName = "ApplianceSnmpUser")] + [Switch]$ApplianceSnmpUser, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Parameter (Mandatory = $false, ParameterSetName = "ApplianceSnmpUser")] + [ValidateSet ("None", "AuthOnly","AuthAndPriv")] + [ValidateNotNullOrEmpty()] + [String]$SecurityLevel = "None", + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Parameter (Mandatory = $false, ParameterSetName = "ApplianceSnmpUser")] + [ValidateSet ('none', "MD5", "SHA", 'SHA1', 'SHA256', 'SHA384', 'SHA512')] + [ValidateNotNullOrEmpty()] + [String]$AuthProtocol = 'none', + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Parameter (Mandatory = $false, ParameterSetName = "ApplianceSnmpUser")] + [ValidateNotNullOrEmpty()] + [SecureString]$AuthPassword, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Parameter (Mandatory = $false, ParameterSetName = "ApplianceSnmpUser")] + [ValidateSet ('none', "des56", '3des', 'aes128', 'aes192', 'aes256')] + [ValidateNotNullOrEmpty()] + [String]$PrivProtocol = 'none', + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Parameter (Mandatory = $false, ParameterSetName = "ApplianceSnmpUser")] + [ValidateNotNullOrEmpty()] + [SecureString]$PrivPassword, + + [Parameter (Mandatory = $False, ParameterSetName = "ApplianceSnmpUser")] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + "[{0}] Bound PS Parameters: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), ($PSBoundParameters | out-string) | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if ($PSCmdlet.ParameterSetName -eq 'ApplianceSnmpUser') + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + $_CredentialsCol = [System.Collections.ArrayList]::new() + + if ($SecurityLevel -eq "AuthOnly" -and + -not $PSBoundParameters['AuthPassword']) + { + + # Generate Terminateing error + $ExceptionMessage = "The -SecurityLevel Parameter was set to 'AuthOnly', but did not include -AuthPassword Parameter. An AuthPassword is required." + $ErrorRecord = New-ErrorRecord HPEOneView.SanManagerResourceException MissingRequiredParameters InvalidArgument 'SecurityLevel' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + if ($SecurityLevel -eq "AuthAndPriv" -and ( + -not $PSBoundParameters['AuthPassword'] -or + -not $PSBoundParameters['PrivPassword'])) + { + + # Generate Terminateing error + $ExceptionMessage = "The -SecurityLevel Parameter was set to 'AuthAndPriv', but did not include -AuthPassword and/or -PrivPassword Parameters." + $ErrorRecord = New-ErrorRecord HPEOneView.SanManagerResourceException MissingRequiredParameters InvalidArgument 'SecurityLevel' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + Process + { + + if ($PSBoundParameters['AuthPassword']) + { + + $_DecryptAuthPassword = [Runtime.InteropServices.Marshal]::PtrToStringBSTR([Runtime.InteropServices.Marshal]::SecureStringToBSTR($AuthPassword)) + + } + + if ($PSBoundParameters['PrivPassword']) + { + + $_DecryptPrivPassword = [Runtime.InteropServices.Marshal]::PtrToStringBSTR([Runtime.InteropServices.Marshal]::SecureStringToBSTR($PrivPassword)) + + } + + if (-not $ApplianceSnmpUser) + { + + if ($SecurityLevel -ne "None") + { + + if ($PSBoundParameters['AuthPassword']) + { + + '[{0}] Adding Auth Password' -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_DecryptAuthPassword = [Runtime.InteropServices.Marshal]::PtrToStringBSTR([Runtime.InteropServices.Marshal]::SecureStringToBSTR($AuthPassword)) + $_AuthPasswordConnectionAttributes = [HPEOneView.Library.GenericAttributes]::new('SnmpV3AuthorizationPassword', $_DecryptAuthPassword, 'SecuritySensitive') + + [void]$_CredentialsCol.Add($_AuthPasswordConnectionAttributes) + + } + + if ($PSBoundParameters['PrivPassword']) + { + + '[{0}] Adding Privacy Password' -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_DecryptPrivPassword = [Runtime.InteropServices.Marshal]::PtrToStringBSTR([Runtime.InteropServices.Marshal]::SecureStringToBSTR($PrivPassword)) + $_PrivPasswordConnectionAttributes = [HPEOneView.Library.GenericAttributes]::new('SnmpV3PrivacyPassword', $_DecryptAuthPassword, 'SecuritySensitive') + + [void]$_CredentialsCol.Add($_PrivPasswordConnectionAttributes) + + } + + } + + else + { + + '[{0}] Creating an SNMPv3 user without authentication or privacy password.' -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + [HPEOneView.Networking.SnmpV3User]::new($Username, $_CredentialsCol, $SnmpAuthProtocolEnum[$AuthProtocol], $SnmpPrivProtocolEnum[$PrivProtocol]) + + } + + else + { + + $_NewSnmpV3User = [HPEOneView.Appliance.SnmpV3User]::new($Username, + $Snmpv3UserAuthLevelEnum[$SecurityLevel], + $SnmpAuthProtocolEnum[$AuthProtocol], + $_DecryptAuthPassword, + $ApplianceSnmpV3PrivProtocolEnum[$PrivProtocol], + $_DecryptPrivPassword) + + ForEach ($_appliance in $ApplianceConnection) + { + + '[{0}] Adding SNMPv3 User to: {1}' -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name | Write-Verbose + + Try + { + + $_resp = Send-OVRequest -Uri $ApplianceSnmpV3UsersUri -Method POST -Body $_NewSnmpV3User -Hostname $_appliance + + $_SnmpV3User = [HPEOneView.Appliance.SnmpV3User]::new($_resp.userName, + $_resp.securityLevel, + $_resp.authenticationProtocol, + $null, + $_resp.privacyProtocol, + $null, + $_resp.id, + $_resp.created, + $_resp.modified, + $_resp.eTag, + $_resp.uri) + + $_SnmpV3User | Add-Member -NotePropertyName ApplianceConnection -NotePropertyValue $_resp.ApplianceConnection + + $_SnmpV3User + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + } + + End + { + + '[{0}] Done.' -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Get-OVSnmpV3User +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "Default")] + Param + ( + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [ValidateNotNullOrEmpty()] + [String]$Name, + + [Parameter (Mandatory = $False, ParameterSetName = "Default")] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + "[{0}] Bound PS Parameters: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), ($PSBoundParameters | out-string) | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if ($PSCmdlet.ParameterSetName -eq 'ApplianceSnmpUser') + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + } + + Process + { + + $_Uri = $ApplianceSnmpV3UsersUri + + if ($Name) + { + + $_operator = 'eq' + + if ($Name.Contains('*')) + { + + $_operator = 'matches' + + } + + $_Uri = "{0}?filter=userName {1} '{2}'" -f $_Uri, $_operator, $Name.Replace('*', '%25') + + } + + ForEach ($_appliance in $ApplianceConnection) + { + + "[{0}] Processing appliance {1} (of {2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name, $ApplianceConnection.Count | Write-Verbose + + Try + { + + $_resp = Send-OVRequest -Uri $_Uri -Hostname $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if ($_resp.Count -eq 0 -and $Name) + { + + + $_Message = "SNMPv3 User '{0}' was not found on {1} Appliance Connection." -f $Name, $_appliance.Name + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.SnmpV3UserResourceException SnmpV3UserNotFound ObjectNotFound "Name" -Message $_Message + $PSCmdlet.WriteError($ErrorRecord) + + } + + else + { + + ForEach ($_entry in $_resp.members) + { + + $_SnmpV3User = [HPEOneView.Appliance.SnmpV3User]::new($_entry.userName, + $_entry.securityLevel, + $_entry.authenticationProtocol, + "", + $_entry.privacyProtocol, + "", + $_entry.id, + $_entry.created, + $_entry.modified, + [String]$_entry.eTag, + $_entry.uri) + + $_SnmpV3User | Add-Member -NotePropertyName ApplianceConnection -NotePropertyValue $_entry.ApplianceConnection + + $_SnmpV3User + + } + + } + + } + + } + + End + { + + '[{0}] Done.' -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Remove-OVSnmpV3User +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "Default", SupportsShouldProcess, ConfirmImpact = 'High')] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = "Default")] + [ValidateNotNullorEmpty()] + [HPEOneView.Appliance.SnmpV3User]$InputObject, + + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = "Default")] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not($PSBoundParameters['InputObject'])) + { + + $PipelineInput = $true + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + $_ResourceCol = [System.Collections.ArrayList]::new() + + } + + Process + { + + if ($InputObject -is [PSCustomObject]) + { + + "[{0}] Processing Pipeline input" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + "[{0}] SNMPv3 User object provided: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject.Username | Write-Verbose + + $RemoveMessage = "Remove SNMPv3 user '{0}'" -f $InputObject.Username + + if ($PSCmdlet.ShouldProcess($InputObject.ApplianceConnection, $RemoveMessage)) + { + + Try + { + + Send-OVRequest -Uri $InputObject.uri -Method DELETE -AddHeader @{'If-Match' = $InputObject.eTag } -Hostname $InputObject.ApplianceConnection + + } + + Catch + { + + if ([RegEx]::Match($_.Exception.Message, "Supplied SNMPv3 user id is invalid. Please provide a valid SNMPv3 User id and retry.", $RegExInsensitiveFlag).Success) + { + + $ExceptionMessage = "The SNMPv3 user you are trying to remove is associated with an existing SNMPv3 Trap Destination. Please remove the trap destination prior to attempting to remove the user." + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.SnmpV3UserResourceException InvalidOperation InvalidOperation "InputObject" -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + else + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + elseif ($PSBoundParameters['WhatIf']) + { + + "[{0}] Caller passed -WhatIf Parameter." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + else + { + + "[{0}] Caller selected NO to confirmation prompt." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Get-OVApplianceSnmpV3EngineId +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding ()] + Param + ( + + [Parameter (Mandatory = $false)] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + Process + { + + ForEach ($_appliance in $ApplianceConnection) + { + + "[{0}] Processing '{1}' Appliance (of {2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name, $ApplianceConnection.Count | Write-Verbose + + Try + { + + $_resp = Send-OVRequest -Uri $ApplianceSnmpV3EngineIdUri -Hostname $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError + + } + + [HPEOneView.Appliance.SnmpV3EngineId]::new($_resp.value, $_resp.uri, $_resp.ApplianceConnection) + + } + + } + + End + { + + '[{0}] Done.' -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Set-OVApplianceSnmpV3EngineId +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding ()] + Param + ( + + [Parameter (Mandatory)] + [ValidateNotNullOrEmpty()] + [String]$EngineID, + + [Parameter (Mandatory = $false)] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + if (-not ($ApplianceSnmpV3EngineIdValidationPattern.Match($EngineId)).Success) + { + + $ExceptionMessage = "The provided EngineId value is not the required 16 character length." + $ErrorRecord = New-ErrorRecord HPEOneView.Library.ParameterValidationException InvalidParameter InvalidOperation 'EngineId' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + Process + { + + $_Uri = $ApplianceSnmpV3EngineIdUri + + $_UpdatedGlobalSetting = NewObject -GlobalSetting + $_UpdatedGlobalSetting.name = "applianceSNMPv3EngineId" + $_UpdatedGlobalSetting.value = $EngineID + + "[{0}] Updating applianceSNMPv3EngineId setting: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $EngineID | Write-Verbose + + ForEach ($_appliance in $ApplianceConnection) + { + + "[{0}] Processing '{1}' Appliance (of {2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name, $ApplianceConnection.Count | Write-Verbose + + Try + { + + $_resp = Send-OVRequest -Uri $_Uri -Method PUT -Body $_UpdatedGlobalSetting -Hostname $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + [HPEOneView.Appliance.SnmpV3EngineId]::new($_resp.value, $_resp.uri, $_resp.ApplianceConnection) + + } + + } + + End + { + + '[{0}] Done.' -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Get-OVApplianceTrapDestination +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding ()] + Param + ( + + [Parameter (Mandatory = $false)] + [ValidateNotNullOrEmpty()] + [String]$Destination, + + [Parameter (Mandatory = $false)] + [ValidateSet ('SNMPv1', 'SNMPv3')] + [String[]]$Type, + + [Parameter (Mandatory = $false)] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + Process + { + + if (-not $PSBoundParameters['Type']) + { + + $Type = @('SNMPv1','SNMPv3') + + } + + ForEach ($_appliance in $ApplianceConnection) + { + + $SnmpTrapDestinationCol = [System.Collections.ArrayList]::new() + + "[{0}] Processing '{1}' Appliance (of {2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name, $ApplianceConnection.Count | Write-Verbose + + Switch ($Type) + { + + 'SNMPv1' + { + + # This code does not work. Will need to create a collection of results and do PowerShell Linq-style filtering + + $_Uri = $ApplianceSnmpV1TrapDestUri + + Try + { + + $_ApplianceSnmpV1trapDestinations = Send-OVRequest -Uri $_Uri -Hostname $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if ($Destination) + { + + if ($Destination.Contains('*')) + { + + $_ApplianceSnmpV1trapDestinations.members = $_ApplianceSnmpV1trapDestinations.members | Where-Object destination -matches $Destination + + } + + else + { + + $_ApplianceSnmpV1trapDestinations.members = $_ApplianceSnmpV1trapDestinations.members | Where-Object destination -eq $Destination + + } + + } + + ForEach ($_entry in $_ApplianceSnmpV1trapDestinations.members) + { + + $_SnmpTrap = [HPEOneView.Appliance.SnmpV1TrapDestination]::new($_entry.destination, + $_entry.port, + $_entry.communityString, + $_entry.uri, + $_entry.ApplianceConnection) + + [void]$SnmpTrapDestinationCol.Add($_SnmpTrap) + + } + + } + + 'SNMPv3' + { + + $_Uri = $ApplianceSnmpV3TrapDestUri + + if ($Destination) + { + + $_operator = 'eq' + + if ($Destination.Contains('*')) + { + + $_operator = 'matches' + + } + + $_Uri = "{0}?filter=destinationAddress {1} '{2}'" -f $_Uri, $_operator, $Destination.Replace('*', '%25') + + } + + Try + { + + $_ApplianceSnmpV3trapDestinations = Send-OVRequest -Uri $_Uri -Hostname $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + ForEach ($_entry in $_ApplianceSnmpV3trapDestinations.members) + { + + Try + { + + $_SnmpV3User = Send-OVRequest -Uri $_entry.userUri -Hostname $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + # (string Username, string SecurityLevel, string AuthProtocol, string AuthPassphrase, string PrivateProtocol, string PrivatePassphrase) + $_SnmpV3UserObject = [HPEOneView.Appliance.SnmpV3User]::new($_SnmpV3User.userName, + $_SnmpV3User.securityLevel, + $_SnmpV3User.authenticationProtocol, + $_SnmpV3User.authenticationPassphrase, + $_SnmpV3User.privacyProtocol, + $_SnmpV3User.privacyPassphrase, + $_SnmpV3User.id, + $_SnmpV3User.created, + $_SnmpV3User.modified, + [String]$_SnmpV3User.eTag, + $_SnmpV3User.uri) + + # (string TrapDestinationAddress, int Port, string Uri, SnmpV3User SnmpV3User, string SnmpV3UserUri, Library.ApplianceConnection ApplianceConnection ) + $_SnmpTrap = [HPEOneView.Appliance.SnmpV3TrapDestination]::new($_entry.destinationAddress, + $_entry.port, + $_entry.uri, + $_SnmpV3UserObject, + $_entry.userUri, + $_entry.ApplianceConnection) + + [void]$SnmpTrapDestinationCol.Add($_SnmpTrap) + + } + + } + + } + + if ($SnmpTrapDestinationCol.Count -eq 0 -and $Destination) + { + + $_Message = "SNMP Trap Destination '{0}' was not found on {1} Appliance Connection." -f $Destination, $_appliance.Name + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.SnmpResourceException SnmpTrapDestinationNotFound ObjectNotFound "Destination" -Message $_Message + $PSCmdlet.WriteError($ErrorRecord) + + } + + else + { + + $SnmpTrapDestinationCol.ToArray() + + } + + } + + } + + End + { + + '[{0}] Done.' -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function New-OVApplianceTrapDestination +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = 'Default')] + Param + ( + + [Parameter (Mandatory, ParameterSetName = 'Default')] + [Parameter (Mandatory, ParameterSetName = 'SnmpV3')] + [ValidateNotNullOrEmpty()] + [String]$Destination, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [Parameter (Mandatory = $false, ParameterSetName = 'SnmpV3')] + [ValidateNotNullOrEmpty()] + [Int]$Port = 162, + + [Parameter (Mandatory, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [String]$CommunityString, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [Parameter (Mandatory = $false, ParameterSetName = 'SnmpV3')] + [ValidateSet ('SNMPv1', 'SNMPv3')] + [String]$Type = 'SNMPv1', + + [Parameter (Mandatory, ParameterSetName = 'SnmpV3')] + [HPEOneView.Appliance.SnmpV3User]$SnmpV3User, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [Parameter (Mandatory = $false, ParameterSetName = 'SnmpV3')] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + "[{0}] Bound PS Parameters: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), ($PSBoundParameters | out-string) | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + Process + { + ForEach ($_appliance in $ApplianceConnection) + { + + "[{0}] Processing '{1}' Appliance (of {2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name, $ApplianceConnection.Count | Write-Verbose + + Switch ($Type) + { + + 'SNMPv1' + { + + '[{0}] Creating an SNMPv1 trap destination.' -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + '[{0}] Getting list of existing SNMPv1 trap destinations.' -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $_ExistingTrapDestinations = Send-OVRequest -Uri $ApplianceSnmpV1TrapDestUri -Hostname $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $_SnmpV1TrapDest = [HPEOneView.Appliance.SnmpTrapDestinationValidation]::new($Destination) + + ForEach ($_entry in $_ExistingTrapDestinations.members) + { + + [void]$_SnmpV1TrapDest.existingDestinations.Add($_entry.destination) + + } + + '[{0}] Validating SNMPv1 trap destination.' -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $_resp = Send-OVRequest -Uri $ApplianceSnmpV3TrapDestValidationUri -Method POST -Body $_SnmpV1TrapDest -Hostname $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + + $_Uri = '{0}/{1}' -f $ApplianceSnmpV1TrapDestUri, ($_SnmpV1TrapDest.existingDestinations.Count + 1) + + $_NewSnmpTrapDestination = [HPEOneView.Appliance.NewSnmpV1TrapDestination]::new($Destination, $Port, $CommunityString, $_Uri) + + } + + 'SNMPv3' + { + + '[{0}] Creating an SNMPv3 trap destination.' -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + '[{0}] SNMPv3 User ID: {1}' -f $MyInvocation.InvocationName.ToString().ToUpper(), $SnmpV3User.id | Write-Verbose + + $_Uri = $ApplianceSnmpV3TrapDestUri + + $_NewSnmpTrapDestination = [HPEOneView.Appliance.NewSnmpV3TrapDestination]::new($Destination, $Port, $SnmpV3User) + + } + + } + + Try + { + + $_resp = Send-OVRequest -Uri $_Uri -Method POST -Body $_NewSnmpTrapDestination -Hostname $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + switch ($Type) + { + + 'SNMPv1' + { + + [HPEOneView.Appliance.SnmpV1TrapDestination]::new($_resp.destination, + $_resp.port, + $_resp.communityString, + $_resp.uri, + $_resp.ApplianceConnection) + + } + + 'SNMPv3' + { + + Try + { + + $_SnmpV3User = Send-OVRequest -Uri $_resp.userUri -Hostname $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $_SnmpV3UserObject = [HPEOneView.Appliance.SnmpV3User]::new($_SnmpV3User.userName, + $_SnmpV3User.securityLevel, + $_SnmpV3User.authenticationProtocol, + $_SnmpV3User.authenticationPassphrase, + $_SnmpV3User.privacyProtocol, + $_SnmpV3User.privacyPassphrase, + $_SnmpV3User.id, + $_SnmpV3User.created, + $_SnmpV3User.modified, + [String]$_SnmpV3User.eTag, + $_SnmpV3User.uri) + + [HPEOneView.Appliance.SnmpV3TrapDestination]::new($_resp.destinationAddress, + $_resp.port, + $_resp.uri, + $_SnmpV3UserObject, + $_resp.userUri, + $_resp.ApplianceConnection) + } + + } + + } + + } + + End + { + + '[{0}] Done.' -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Remove-OVApplianceTrapDestination +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "Default", SupportsShouldProcess, ConfirmImpact = 'High')] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = "Default")] + [ValidateNotNullorEmpty()] + [Object]$InputObject, + + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = "Default")] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not($PSBoundParameters['InputObject'])) + { + + $PipelineInput = $true + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + $_ResourceCol = [System.Collections.ArrayList]::new() + + } + + Process + { + + if ($InputObject -is [PSCustomObject]) + { + + "[{0}] Processing Pipeline input" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + if ($InputObject -isnot [HPEOneView.Appliance.SnmpV3TrapDestination] -and $InputObject -isnot [HPEOneView.Appliance.SnmpV1TrapDestination]) + { + + $ExceptionMessage = "The InputObject is not a supported object type. Only HPEOneview.Appliance.SnmpV1TrapDestination and HPEOneview.Appliance.SnmpV1TrapDestination objects are supported." + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.SnmpResourceException InvalidObjectType InvalidOperation "InputObject" -Message $ExceptionMessage + $PSCmdlet.WriteError($ErrorRecord) + + } + + $RemoveMessage = "Remove {0} trap destination '{1}'" + + switch ($InputObject.Gettype().FullName) + { + + 'HPEOneview.Appliance.SnmpV3TrapDestination' + { + + "[{0}] SNMPv3 Trap Destination object provided: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject.DestinationAddress | Write-Verbose + + $RemoveMessage = $RemoveMessage -f 'SNMPv3', $InputObject.DestinationAddress + + } + + 'HPEOneview.Appliance.SnmpV1TrapDestination' + { + + "[{0}] SNMPv1 Trap Destination object provided: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject.DestinationAddress | Write-Verbose + + $RemoveMessage = $RemoveMessage -f 'SNMPv1', $InputObject.DestinationAddress + + } + + } + + "[{0}] Object uri: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject.Uri | Write-Verbose + + if ($PSCmdlet.ShouldProcess($InputObject.ApplianceConnection, $RemoveMessage)) + { + + Try + { + + $_Etag = '*' + + if ($null -ne $InputObject.eTag) + { + + $_Etag = $InputObject.eTag + + } + + Send-OVRequest -Uri $InputObject.uri -Method DELETE -AddHeader @{'If-Match' = $_Etag } -Hostname $InputObject.ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + elseif ($PSBoundParameters['WhatIf']) + { + + "[{0}] Caller passed -WhatIf Parameter." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + else + { + + "[{0}] Caller selected NO to confirmation prompt." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Get-OVApplianceGlobalSetting +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding ()] + [OutputType ([HPEOneView.Appliance.GlobalSetting])] + Param + ( + + [Parameter (Mandatory = $false)] + [String]$name, + + [Parameter (Mandatory = $false)] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $_ApplianceGlobalSettingCol = [System.Collections.ArrayList]::new() + + } + + Process + { + + ForEach ($_appliance in $ApplianceConnection) + { + + "[{0}] Processing '{1}' Appliance (of {2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name, $ApplianceConnection.Count | Write-Verbose + + Try + { + + $_settings = Send-OVRequest $ApplianceGlobalSettingsUri -Hostname $_appliance + + if ($Name) + { + + $_settings.members = $_settings.members | Where-Object name -like $Name + + } + + ForEach ($_setting in $_settings.members) + { + + [HPEOneView.Appliance.GlobalSetting]::new($_setting.name, + $_setting.value, + $_setting.etag, + $_setting.created, + $_setting.modified, + $_setting.group, + $_setting.settingCategory, + $_setting.uri, + $_setting.applianceConnection) + + } + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Set-OVApplianceGlobalSetting +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = 'Default')] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = 'Pipeline')] + [Alias ('Object')] + [ValidateNotNullorEmpty()] + [HPEOneView.Appliance.GlobalSetting]$InputObject, + + [Parameter (Mandatory, ParameterSetName = 'Default')] + [ValidateNotNullorEmpty()] + [String]$Name, + + [Parameter (Mandatory, ParameterSetName = 'Default')] + [Parameter (Mandatory, ParameterSetName = 'Pipeline')] + [ValidateNotNullorEmpty()] + [String]$Value, + + [Parameter (Mandatory = $false, ValueFromPipelinebyPropertyName, ParameterSetName = 'Pipeline')] + [Parameter (Mandatory = $false, ValueFromPipelinebyPropertyName, ParameterSetName = 'Default')] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if ($PSCmdlet.ParameterSetName -eq 'Pipeline') + { + + $PipelineInput - $True + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + $_ApplianceGlobalSettingCol = [System.Collections.ArrayList]::new() + + } + + Process + { + + if ($PipelineInput) + { + + + "[{0}] Processing object: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject | Write-Verbose + + Try + { + + $_UpdatedGlobalSetting = NewObject -GlobalSetting + $_UpdatedGlobalSetting.name = $InputObject.Name + $_UpdatedGlobalSetting.value = $Value + + "[{0}] Updated Global Setting: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject | Write-Verbose + + $_results = Send-OVRequest -Uri $Object.Uri -Method PUT -Body $_UpdatedGlobalSetting -Hostname $Object.ApplianceConnection + + [HPEOneView.Appliance.GlobalSetting]::new($_results.name, + $_results.value, + $_results.etag, + $_results.created, + $_results.modified, + $_results.group, + $_results.settingCategory, + $_results.uri, + $_results.applianceConnection) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + else + { + + ForEach ($_appliance in $ApplianceConnection) + { + + "[{0}] Processing '{1}' Appliance (of {2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name, $ApplianceConnection.Count | Write-Verbose + + "[{0}] Getting current global setting value for $Name" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $_setting = Get-OVApplianceGlobalSetting -Name $Name -ApplianceConnection $_appliance -ErrorAction Stop + + $_UpdatedGlobalSetting = NewObject -GlobalSetting + $_UpdatedGlobalSetting.name = $Name + $_UpdatedGlobalSetting.value = $Value + + "[{0}] Updated Global Setting: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_setting | Write-Verbose + + $_results = Send-OVRequest -Uri $_setting.Uri -Method PUT -Body $_UpdatedGlobalSetting -Hostname $_appliance + + [HPEOneView.Appliance.GlobalSetting]::new($_results.name, + $_results.value, + $_results.etag, + $_results.created, + $_results.modified, + $_results.group, + $_results.settingCategory, + $_results.uri, + $_results.applianceConnection) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + + } + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Get-OVRotateMPPasswordPolicy +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = 'Default')] + [OutputType([HPEOneView.Appliance.RotateMPPasswordPolicy])] + Param + ( + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + Process + { + + # [ + # { + # "type": "SettingV2", + # "uri": "/rest/global-settings/appliance/security/lastRotatedCycle", + # "category": "global-settings", + # "eTag": null, + # "created": "2024-09-12T06:03:12.53Z", + # "modified": "2024-09-12T06:03:12.546Z", + # "name": "lastRotatedCycle", + # "value": "Sep 12 06:03:12 AM 2024", + # "group": "security", + # "settingCategory": "appliance", + # "description": null, + # "state": null, + # "status": null, + # "ApplianceConnection": { + # "Name": "siberian.cc.rdlabs.hpecorp.net", + # "ConnectionId": 1 + # } + # }, + # { + # "type": "SettingV2", + # "uri": "/rest/global-settings/appliance/security/managedDeviceAuthentication", + # "category": "global-settings", + # "eTag": null, + # "created": "2024-09-11T23:01:53.698Z", + # "modified": "2024-09-11T23:01:53.698Z", + # "name": "managedDeviceAuthentication", + # "value": "Enabled", + # "group": "security", + # "settingCategory": "appliance", + # "description": null, + # "state": null, + # "status": null, + # "ApplianceConnection": { + # "Name": "siberian.cc.rdlabs.hpecorp.net", + # "ConnectionId": 1 + # } + # }, + # { + # "type": "SettingV2", + # "uri": "/rest/global-settings/appliance/security/passwordRotationFrequency", + # "category": "global-settings", + # "eTag": null, + # "created": "2024-09-11T23:01:53.706Z", + # "modified": "2024-09-11T23:02:12.406Z", + # "name": "passwordRotationFrequency", + # "value": "1", + # "group": "security", + # "settingCategory": "appliance", + # "description": null, + # "state": null, + # "status": null, + # "ApplianceConnection": { + # "Name": "siberian.cc.rdlabs.hpecorp.net", + # "ConnectionId": 1 + # } + # }, + # { + # "type": "SettingV2", + # "uri": "/rest/global-settings/appliance/security/passwordRotationTime", + # "category": "global-settings", + # "eTag": null, + # "created": "2024-09-11T23:01:53.714Z", + # "modified": "2024-09-11T23:01:53.714Z", + # "name": "passwordRotationTime", + # "value": "06:03", + # "group": "security", + # "settingCategory": "appliance", + # "description": null, + # "state": null, + # "status": null, + # "ApplianceConnection": { + # "Name": "siberian.cc.rdlabs.hpecorp.net", + # "ConnectionId": 1 + # } + # } + # ] + + + # + # This API lookup only provides the configuration state. I'll need to find out how to get the Activity and "last ran" time. + # According to the docs, the report is in the Activity log. Will need to find out the name of this entry. + + ForEach ($_appliance in $ApplianceConnection) + { + + # Validate appliance is VMA + if ($_appliance.ApplianceType -eq 'Composer') + { + + $ExceptionMessage = 'The ApplianceConnection {0} is a Synergy Composer. Management Process password rotation is only supported with non-HPE Synergy servers.' -f $ApplianceConnection.Name + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.ComposerNodeException InvalidOperation InvalidOperation 'ApplianceConnection' -Message $ExceptionMessage + $PSCmdlet.WriteError($ErrorRecord) + + } + + else + { + + "[{0}] Processing '{1}' Appliance (of {2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name, $ApplianceConnection.Count | Write-Verbose + + "[{0}] Getting current password rotation policy." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + Try + { + + $_currentPolicyConfiguration = Send-OVRequest -Uri $ManagedDevicePasswordRotationUri -Hostname $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $regex = "(?'month'\w{3})\s(?'day'\d{2})\s(?'time'\d{2}:\d{2}:\d{2} (AM|PM))\s(?'year'\d{4})" + $replace = '${year}-${month}-${day} ${time}' + + # Parse out the correct date format + $_LastRotatedOne = ($_currentPolicyConfiguration.members | Where-Object name -eq 'lastRotatedCycle') ? [regex]::Replace(($_currentPolicyConfiguration.members | Where-Object name -eq 'lastRotatedCycle').value, $regex, $replace) : [DateTime]::new(1970, 1, 1, 0, 0, 0, [DateTimeKind]::Utc) + + [HPEOneView.Appliance.RotateMPPasswordPolicy]::new( + ($_currentPolicyConfiguration.members | Where-Object name -eq 'managedDeviceAuthentication').value, + ($_currentPolicyConfiguration.members | Where-Object name -eq 'passwordRotationFrequency').value, + ($_currentPolicyConfiguration.members | Where-Object name -eq 'passwordRotationTime').value, + $_LastRotatedOne, + $_currentPolicyConfiguration.members[0].ApplianceConnection + ) + + } + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Get-OVRotateMPPasswordPolicyReport +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = 'Default')] + [OutputType([HPEOneView.Appliance.RotateMPPasswordPolicyReport])] + Param + ( + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [Switch]$GetAllReports, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + Process + { + + ForEach ($_appliance in $ApplianceConnection) + { + + # Validate appliance is VMA + if ($_appliance.ApplianceType -eq 'Composer') + { + + $ExceptionMessage = 'The ApplianceConnection {0} is a Synergy Composer. Management Process password rotation is only supported with non-HPE Synergy servers.' -f $ApplianceConnection.Name + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.ComposerNodeException InvalidOperation InvalidOperation 'ApplianceConnection' -Message $ExceptionMessage + $PSCmdlet.WriteError($ErrorRecord) + + } + + else + { + + "[{0}] Processing '{1}' Appliance (of {2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name, $ApplianceConnection.Count | Write-Verbose + + # Need to get the lastRotatedCycle value from the global settings API lookup /rest/global-settings/appliance/security/lastRotatedCycle + try + { + + "[{0}] Getting last rotated cycle date." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_currentPolicyConfiguration = Send-OVRequest -Uri ($ManagedDevicePasswordRotationUri + "/lastRotatedCycle") -Hostname $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + # Then, lookup the activity log for the "Rotate OneView account password for server hardwares" task and value of the lastRotatedCycle value to the startTime value of the parent task from /rest/tasks?view=tree&filter=name="Rotate OneView account password for server hardwares"&startTime=2024-09-12T06:03:12.53Z + $regex = "(?'month'\w{3})\s(?'day'\d{2})\s(?'time'\d{2}:\d{2}:\d{2} (AM|PM))\s(?'year'\d{4})" + $replace = '${year}-${month}-${day} ${time}' + + # Parse out the correct date format to use with the API queries needed + $_reportedLastRotatedTime = [regex]::Replace($_currentPolicyConfiguration.value, $regex, $replace) + $_reportedLastRotatedTimeAPICompliant = [datetime]::parse($_reportedLastRotatedTime).ToString("yyyy-MM-ddTHH:mm:sss.fffZ") + $_reportedLastRotatedTimePlusTwoSecAPICompliant = [datetime]::parse($_reportedLastRotatedTime).AddSeconds(2).ToString("yyyy-MM-ddTHH:mm:sss.fffZ") + $_ParentTaskName = "Rotate HPE OneView device management account password for server hardware" + + if ($PSBoundParameters['GetAllReports']) + { + + "[{0}] Getting all reports." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_uri = "{0}?filter='name' eq '{1}'" -f $TasksUri, $_ParentTaskName + + } + + else + { + + "[{0}] Getting most current report." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_uri = "{0}?filter='name' eq '{1}' AND 'startTime' gt {2} AND 'startTime' lt {3}" -f $TasksUri, $_ParentTaskName, $_reportedLastRotatedTimeAPICompliant, $_reportedLastRotatedTimePlusTwoSecAPICompliant + + } + + try + { + + # This call will get the filter results. Next still need to get the full tree view of the parent and child tasks + $_taskLookup = Send-OVRequest -Uri $_uri -Hostname $_appliance + + # if more than 1 task was found and the caller didn't want all possible reports, was this an error? + if ($_taskLookup.count -gt 1 -and -not $PSBoundParameters['GetAllReports']) + { + + Write-Host "We should not have reached here. More than 1 task." + + } + + elseif ($_taskLookup.count -eq 0) + { + + Write-Host "No tasks found based on the query. Did the task name change? Or did the first task not run yet?" + + } + + else + { + + ForEach ($_task in $_taskLookup.members) + { + + "[{0}] Processing parent task: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_task.name | Write-Verbose + + $_Collection = [System.Collections.Generic.List[HPEOneView.Appliance.RotateMPPasswordPolicyReport+Server]]::New($_fullTaskTree.children.Count) + + $_fullTaskUri = $_task.uri + "?view=tree" + + "[{0}] Getting full parent task with children information." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_fullTaskTree = Send-OVRequest -Uri $_fullTaskUri -Hostname $_appliance + + # Figure out how many child tasks failed + $_FailedChildTasks = ($_fullTaskTree.children.resource | ? { 'Failed', 'Error' -contains $_.taskState } | Measure-Object).Count + + ForEach ($_childTask in $_fullTaskTree.children) + { + + "[{0}] Processing child task for: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_childTask.resource.associatedResource.resourceName | Write-Verbose + + if ("Error", "Failed" -contains $_childTask.resource.taskState) + { + + "[{0}] Child task failed." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + "[{0}] Child task error message: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_childTask.taskErrors.message | Write-Verbose + "[{0}] Child task error recommendation: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_childTask.taskErrors.recommendedActions | Write-Verbose + + $_TaskErrorMessage = $_childTask.resource.taskErrors.message + $_TaskErrorRecommendation = $_childTask.resource.taskErrors.recommendedActions + $_Message = "{0} {1}" -f $_TaskErrorMessage, $_TaskErrorRecommendation + + $_Server = [HPEOneView.Appliance.RotateMPPasswordPolicyReport+Server]::new($_childTask.resource.associatedResource.resourceName, + $_childTask.resource.associatedResource.resourceUri, + "Failed", + $_Message) + + [void]$_Collection.Add($_Server) + } + + else + { + + "[{0}] Child task succeeded." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_Server = [HPEOneView.Appliance.RotateMPPasswordPolicyReport+Server]::new($_childTask.resource.associatedResource.resourceName, + $_childTask.resource.associatedResource.resourceUri, + "Completed", + $_childTask.resource.taskStatus) + + [void]$_Collection.Add($_Server) + + } + + } + + $_TaskState = $_FailedChildTasks -gt 0 ? [HPEOneView.Appliance.ReportState]::CompletedWithErrors : $_task.taskState + + [HPEOneView.Appliance.RotateMPPasswordPolicyReport]::new([datetime]::parse($_task.startTime), + $_TaskState, + [datetime]::parse($_task.modified), + $_Collection, + $_fullTaskTree.ApplianceConnection) + + } + + } + + } + + Catch [HPEOneView.ResourceNotFoundException] + { + + # The policy has not been run yet. + "[{0}] Policy has not been run yet." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + [HPEOneView.Appliance.RotateMPPasswordPolicyReport]::new("NotRun", $_appliance) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +# Does this return an async task? +function Set-OVRotateMPPasswordPolicy +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = 'Enable', SupportsShouldProcess, ConfirmImpact = 'High')] + [OutputType([HPEOneView.Appliance.RotateMPPasswordPolicy])] + Param + ( + + # Number of days + [Parameter (Mandatory, ParameterSetName = 'Enable')] + [ValidateRange(1,365)] + [Int]$Frequency, + + # What hour of the day to rotate the password, which will be in UTC + [Parameter (Mandatory, ParameterSetName = 'Enable')] + [ValidateNotNullorEmpty()] + [TimeSpan]$Time, + + [Parameter (Mandatory, ParameterSetName = 'Disable')] + [Switch]$Disable, + + [Parameter (Mandatory = $false, ParameterSetName = 'Enable')] + [Parameter (Mandatory = $false, ParameterSetName = 'Disable')] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + Process + { + + ForEach ($_appliance in $ApplianceConnection) + { + + $_PatchOperation = [System.Collections.ArrayList]::new() + + # Validate appliance is VMA + if ($_appliance.ApplianceType -eq 'Composer') + { + + $ExceptionMessage = 'The ApplianceConnection {0} is a Synergy Composer. Management Process password rotation is only supported with non-HPE Synergy servers.' -f $ApplianceConnection.Name + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.ComposerNodeException InvalidOperation InvalidOperation 'ApplianceConnection' -Message $ExceptionMessage + $PSCmdlet.WriteError($ErrorRecord) + + } + + else + { + + "[{0}] Processing '{1}' Appliance (of {2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name, $ApplianceConnection.Count | Write-Verbose + + "[{0}] Getting current password rotation policy." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Switch ($PSCmdlet.ParameterSetName) + { + + 'Disable' + { + + "[{0}] Disabling password rotation policy." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_disableConfig = NewObject -GlobalSetting + $_disableConfig.name = 'managedDeviceAuthentication' + $_disableConfig.value = [HPEOneView.Appliance.StateEnum]::Disabled.ToString() + + [void]$_PatchOperation.Add($_disableConfig) + + } + + default + { + + "[{0}] Enabling password rotation policy." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_enableConfig = NewObject -GlobalSetting + $_enableConfig.name = 'managedDeviceAuthentication' + $_enableConfig.value = [HPEOneView.Appliance.StateEnum]::Enabled.ToString() + + [void]$_PatchOperation.Add($_enableConfig) + + $_frequencyConfig = NewObject -GlobalSetting + $_frequencyConfig.name = 'passwordRotationFrequency' + $_frequencyConfig.value = $Frequency + + [void]$_PatchOperation.Add($_frequencyConfig) + + $_timeConfig = NewObject -GlobalSetting + $_timeConfig.name = 'passwordRotationTime' + $_timeConfig.value = $Time + + # Convert TimeSpan to DateTime, then to UTC and format to HH:mm + $baseDate = [System.DateTime]::MinValue.Add($Time).AddDays(30) + $_timeConfig.value = $baseDate.ToUniversalTime().ToString("HH:mm") + + [void]$_PatchOperation.Add($_timeConfig) + + } + + } + + if ($PSCmdlet.ShouldProcess("${PSCmdlet.ParameterSetName} managed device password rotation policy", "Update")) + { + + Try + { + + $_currentPolicyConfiguration = Send-OVRequest -Uri ($ManagedDevicePasswordRotationUri + "?multiResource=true") -Method POST -Body $_PatchOperation -Hostname $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + [HPEOneView.Appliance.RotateMPPasswordPolicy]::new( + ($_currentPolicyConfiguration.members | Where-Object name -eq 'managedDeviceAuthentication').value, + ($_currentPolicyConfiguration.members | Where-Object name -eq 'passwordRotationFrequency').value, + ($_currentPolicyConfiguration.members | Where-Object name -eq 'passwordRotationTime').value, + $_currentPolicyConfiguration.members[0].ApplianceConnection + ) + + } + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Set-OVApplianceProxy +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = 'Default')] + Param + ( + + [Parameter (Mandatory, ParameterSetName = 'Default')] + [Parameter (Mandatory, ParameterSetName = 'Authentication')] + [ValidateNotNullorEmpty()] + [String]$Hostname, + + [Parameter (Mandatory, ParameterSetName = 'Default')] + [Parameter (Mandatory, ParameterSetName = 'Authentication')] + [ValidateNotNullorEmpty()] + [Int]$Port, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [Parameter (Mandatory = $false, ParameterSetName = 'Authentication')] + [ValidateNotNullorEmpty()] + [Switch]$Https, + + [Parameter (Mandatory, ParameterSetName = 'Authentication')] + [ValidateNotNullorEmpty()] + [String]$Username, + + [Parameter (Mandatory, ParameterSetName = 'Authentication')] + [ValidateNotNullorEmpty()] + [SecureString]$Password, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [Parameter (Mandatory = $false, ParameterSetName = 'Authentication')] + [Switch]$Async, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [Parameter (Mandatory = $false, ParameterSetName = 'Authentication')] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + Process + { + + $_ApplianceProxyConfig = NewObject -ApplianceProxy + $_ApplianceProxyConfig.server = $Hostname + $_ApplianceProxyConfig.port = $Port + + if ($PSCmdlet.ParameterSetName -eq 'Authentication') + { + + $_ApplianceProxyConfig.username = $Username + $_ApplianceProxyConfig.password = [Runtime.InteropServices.Marshal]::PtrToStringBSTR([Runtime.InteropServices.Marshal]::SecureStringToBSTR($Password)) + + } + + ForEach ($_appliance in $ApplianceConnection) + { + + '[{0}] Processing "{1}" appliance connection.' -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name | Write-Verbose + + if ($Https) + { + + '[{0}] Setting Proxy to HTTPS.' -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_ApplianceProxyConfig.communicationProtocol = 'HTTPS' + + '[{0}] Getting HTTPS certificate from endpoint.' -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_Uri = '{0}/{1}' -f $RetrieveHttpsCertRemoteUri, $Hostname + + Try + { + + $_resp = Send-OVRequest -Uri $_Uri Hostname $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + Try + { + + $_resp = Send-OVRequest -uri $ApplianceProxyConfigUri -Method POST -Body $_ApplianceProxyConfig -Hostname $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if ($PSBoundParameters['Async']) + { + + $_resp + + } + + else + { + + $_resp | Wait-OVTaskComplete + + } + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Remove-OVApplianceProxy +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = 'Default', SupportsShouldProcess, ConfirmImpact = 'High')] + Param + ( + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + Process + { + + ForEach ($_appliance in $ApplianceConnection) + { + + '[{0}] Processing "{1}" appliance connection.' -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name | Write-Verbose + + $RemoveMessage = "remove appliance HTTP/HTTPS proxy configuration" + + if ($PSCmdlet.ShouldProcess($_appliance.Name, $RemoveMessage)) + { + + Try + { + + $_resp = Send-OVRequest -Uri $ApplianceProxyConfigUri -Method DELETE -AddHeader @{'If-Match' = "*" } -Hostname $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if ($PSBoundParameters['Async']) + { + + $_resp + + } + + else + { + + $_resp | Wait-OVTaskComplete + + } + + } + + elseif ($PSBoundParameters['WhatIf']) + { + + "[{0}] Caller passed -WhatIf Parameter." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + else + { + + "[{0}] Caller selected NO to confirmation prompt." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Get-OVApplianceProxy +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = 'Default')] + Param + ( + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + Process + { + + ForEach ($_appliance in $ApplianceConnection) + { + + '[{0}] Processing "{1}" appliance connection.' -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name | Write-Verbose + + Try + { + + $_resp = Send-OVRequest -uri $ApplianceProxyConfigUri -Hostname $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + [HPEOneView.Appliance.ProxyServer]::new($_resp.server, + $_resp.port, + $_resp.communicationProtocol, + $_resp.username, + $_resp.ApplianceConnection) + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Get-OVRemoteSupport +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = 'Default')] + Param + ( + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $_ApplianceRemoteSupportCol = [System.Collections.ArrayList]::new() + + } + + Process + { + + ForEach ($_appliance in $ApplianceConnection) + { + + '[{0}] Processing "{1}" appliance connection.' -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name | Write-Verbose + + # Get Appliance Remote Support registration + Try + { + + $_ApplianceRegistration = Send-OVRequest -Uri $RemoteSupportRegistrationUri -Hostname $_appliance.Name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + # Get Appliance Remote Support configuration + Try + { + + $_ApplianceConfig = Send-OVRequest -Uri $RemoteSupportConfigUri -Hostname $_appliance.Name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + [HPEOneView.Appliance.RemoteSupport.Configuration]::new($_ApplianceRegistration.registered, + $_ApplianceConfig.enableRemoteSupport, + $_ApplianceRegistration.registered, + $_ApplianceConfig.companyName, + $_ApplianceConfig.marketingOptIn, + $_ApplianceConfig.autoEnableDevices, + $_ApplianceConfig.enableEmailNotification, + $_ApplianceConfig.eTag, + $_ApplianceConfig.created, + $_ApplianceConfig.modified, + $_ApplianceConfig.uri, + $_ApplianceConfig.ApplianceConnection) + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Set-OVRemoteSupport +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = 'Default')] + Param + ( + + [Parameter (Mandatory, ParameterSetName = 'Default')] + [Parameter (Mandatory, ParameterSetName = 'InsightOnline')] + [ValidateNotNullorEmpty()] + [String]$CompanyName, + + [Parameter (Mandatory = $False, ParameterSetName = 'Default')] + [Parameter (Mandatory = $False, ParameterSetName = 'InsightOnline')] + [Switch]$OptimizeOptIn, + + [Parameter (Mandatory = $False, ParameterSetName = 'Default')] + [Parameter (Mandatory = $False, ParameterSetName = 'InsightOnline')] + [Bool]$AutoEnableDevices, + + [Parameter (Mandatory = $false, ParameterSetName = 'InsightOnline')] + [Obsolete("HPE Insight Online is no longer available.")] + [String]$InsightOnlineUsername, + + [Parameter (Mandatory = $false, ParameterSetName = 'InsightOnline')] + [Obsolete("HPE Insight Online is no longer available.")] + [SecureString]$InsightOnlinePassword, + + [Parameter (Mandatory, ParameterSetName = 'Enable')] + [Switch]$Enable, + + [Parameter (Mandatory, ParameterSetName = 'Disable')] + [Switch]$Disable, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [Parameter (Mandatory = $false, ParameterSetName = 'InsightOnline')] + [Parameter (Mandatory = $false, ParameterSetName = 'Enable')] + [Parameter (Mandatory = $false, ParameterSetName = 'Disable')] + [Switch]$Async, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [Parameter (Mandatory = $false, ParameterSetName = 'InsightOnline')] + [Parameter (Mandatory = $false, ParameterSetName = 'Enable')] + [Parameter (Mandatory = $false, ParameterSetName = 'Disable')] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $_ApplianceRemoteSupportCol = [System.Collections.ArrayList]::new() + + } + + Process + { + + ForEach ($_appliance in $ApplianceConnection) + { + + '[{0}] Processing "{1}" appliance connection.' -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name | Write-Verbose + + Try + { + + $_CurrentConfiguration = Send-OVRequest -Uri $RemoteSupportConfigUri -Hostname $_appliance.Name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if ($PSBoundParameters['Disable']) + { + + $_CurrentConfiguration.enableRemoteSupport = $false + + } + + elseif ($PSBoundParameters['Enable']) + { + + $_CurrentConfiguration.enableRemoteSupport = $true + + # Check to make sure that 1 RS contact is default + Try + { + + RemoteSupportDefaultContactExists $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + else + { + + # Check to make sure that 1 RS contact is default + Try + { + + RemoteSupportDefaultContactExists $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + switch ($PSBoundParameters.Keys) + { + + 'CompanyName' + { + + $_CurrentConfiguration.companyName = $CompanyName + + } + + 'OptimizeOptIn' + { + + $_CurrentConfiguration.marketingOptIn = $OptimizeOptIn + + } + + 'AutoEnableDevices' + { + + $_CurrentConfiguration.autoEnableDevices = $AutoEnableDevices + + } + + } + + $_CurrentConfiguration.enableRemoteSupport = $true + + } + + # Obsolete and no longer supported. + # if ($PSCmdlet.ParameterSetName -eq 'InsightOnline') + # { + + # $_PortalRegistrationObject = NewObject -InsightOnlineRegistration + # $_PortalRegistrationObject.userName = $InsightOnlineUsername + # $_PortalRegistrationObject.password = [Runtime.InteropServices.Marshal]::PtrToStringBSTR([Runtime.InteropServices.Marshal]::SecureStringToBSTR($InsightOnlinePassword)) + + # Try + # { + + # $_InsightOnlineConfig = Send-OVRequest -uri $InsightOnlinePortalRegistraionUri -Method POST -Body $_PortalRegistrationObject -Hostname $_appliance.Name + + # } + + # Catch + # { + + # $PSCmdlet.ThrowTerminatingError($_) + + # } + + # } + + Try + { + + $_UpdatedConfiguration = Send-OVRequest -uri $RemoteSupportConfigUri -Method PUT -Body $_CurrentConfiguration -Hostname $_appliance.Name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if (-not $Async) + { + + $_UpdatedConfiguration = $_UpdatedConfiguration | Wait-OVTaskComplete + + } + + $_UpdatedConfiguration + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Enable-OVRemoteSupport +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdLetBinding (DefaultParameterSetName = "default")] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = "default")] + [ValidateNotNullOrEmpty()] + [Object]$InputObject, + + [Parameter (Mandatory = $false, ParameterSetName = "default")] + [Switch]$Async, + + [Parameter (ValueFromPipelineByPropertyName, Mandatory = $false, ParameterSetName = "default")] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + "[{0}] Bound PS Parameters: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), ($PSBoundParameters | out-string) | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + + if (-not $PSBoundParameters['InputObject']) + { + + $PipelineInput = $True + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -gt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + $_TaskCollection = [System.Collections.ArrayList]::new() + $_Collection = [System.Collections.ArrayList]::new() + + } + + Process + { + + $_PatchOperation = NewObject -PatchOperation + $_PatchOperation.op = 'replace' + $_PatchOperation.path = '/supportEnabled' + $_PatchOperation.value = $true + + switch ($InputObject.category) + { + + 'server-hardware' + { + + $_uri = '{0}/{1}' -f $RemoteSupportComputeSettingsUri, $InputObject.uuid + + } + + 'enclosures' + { + + $_uri = '{0}/{1}' -f $RemoteSupportEnclosureSettingsUri, $InputObject.uuid + + } + + 'interconnects' + { + + $_ID = $InputObject.uri.Split("/")[3] + $_uri = '{0}/{1}' -f $RemoteSupportInterconnectSettingsUri,$_ID + + } + + default + { + + # Unsupported + $ExceptionMessage = 'The {0} input object is an unsupported resource category type, "{1}". Only "server-hardware" or "enclosure" resources are supported.' -f $InputObject.category, $InputObject.name + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.RemoteSupportResourceException InvalidResourceObject InvalidArgument "InputObject" -TargetType 'PSObject' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + try + { + + $_Resp = Send-OVRequest -Uri $_uri -Method PATCH -Body $_PatchOperation -Hostname $ApplianceConnection + + } + + catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if ($PSBoundParameters['Async']) + { + + $_Resp + + } + + else + { + + Try + { + + $_Resp | Wait-OVTaskComplete + + } + + Catch + { + + $PSCmdlet.ThrowTerninatingError($_) + + } + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Disable-OVRemoteSupport +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdLetBinding (DefaultParameterSetName = "default", SupportsShouldProcess, ConfirmImpact = 'High')] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = "default")] + [ValidateNotNullOrEmpty()] + [Object]$InputObject, + + [Parameter (Mandatory = $false, ParameterSetName = "default")] + [Switch]$Async, + + [Parameter (ValueFromPipelineByPropertyName, Mandatory = $false, ParameterSetName = "default")] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + "[{0}] Bound PS Parameters: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), ($PSBoundParameters | out-string) | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + + if (-not $PSBoundParameters['InputObject']) + { + + $PipelineInput = $True + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -gt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + $_TaskCollection = [System.Collections.ArrayList]::new() + $_Collection = [System.Collections.ArrayList]::new() + + } + + Process + { + + $_PatchOperation = NewObject -PatchOperation + $_PatchOperation.op = 'replace' + $_PatchOperation.path = '/supportEnabled' + $_PatchOperation.value = $false + + switch ($InputObject.category) + { + + 'server-hardware' + { + + $_uri = '{0}/{1}' -f $RemoteSupportComputeSettingsUri, $InputObject.uuid + + } + + 'enclosures' + { + + $_uri = '{0}/{1}' -f $RemoteSupportEnclosureSettingsUri,$InputObject.uuid + + } + + 'interconnects' + { + + $_ID = $InputObject.uri.Split("/")[3] + $_uri = '{0}/{1}' -f $RemoteSupportInterconnectSettingsUri,$_ID + + } + + default + { + + # Unsupported + $ExceptionMessage = 'The {0} input object is an unsupported resource category type, "{1}". Only "server-hardware" or "enclosure" resources are supported.' -f $InputObject.category, $InputObject.name + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.RemoteSupportResourceException InvalidResourceObject InvalidArgument "InputObject" -TargetType 'PSObject' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + $_ShouldProcessMessage = "disable remote support" + if ($PSCmdlet.ShouldProcess($InputObject.name, $_ShouldProcessMessage)) + { + + try + { + + $_Resp = Send-OVRequest -Uri $_uri -Method PATCH -Body $_PatchOperation -Hostname $ApplianceConnection + + } + + catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if ($PSBoundParameters['Async']) + { + + $_Resp + + } + + else + { + + Try + { + + $_Resp | Wait-OVTaskComplete + + } + + Catch + { + + $PSCmdlet.ThrowTerninatingError($_) + + } + + } + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Get-OVRemoteSupportPortalConnectionStatus +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = 'Default')] + [OutputType([HPEOneView.Appliance.RemoteSupport.PortalConnection])] + [OutputType([HPEOneView.Appliance.RemoteSupport.PortalConnectionToken])] + Param + ( + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [Switch]$GetGeneratedToken, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ExceptionMessage = "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + Process + { + + + + # NOT REGISTERED + # { + # "type": "PortalConnection", + # "uri": "/rest/support/portal-connection", + # "category": "support", + # "eTag": "1726502117124", + # "created": "2024-09-16T16:22:12.069Z", + # "modified": "2024-09-16T16:22:12.069Z", + # "registrationStatus": "false", + # "registrationTimestamp": null, + # "initiatedUser": null, + # "connectionName": null, + # "message": "", + # "ApplianceConnection": { + # "Name": "OV1.doctors-lab.local", + # "ConnectionId": 1 + # } + # } + # + # TOKEN CREATED AND MESSAGE FROM APPLIANCE + # { + # "type": "PortalConnection", + # "uri": "/rest/support/portal-connection", + # "category": "support", + # "eTag": "1726504764575", + # "created": "2024-09-16T16:41:30.249Z", + # "modified": "2024-09-16T16:41:30.249Z", + # "registrationStatus": "false", + # "registrationTimestamp": null, + # "initiatedUser": "Administrator", + # "connectionName": null, + # "message": "", + # "ApplianceConnection": { + # "Name": "OV1.doctors-lab.local", + # "ConnectionId": 1 + # } + # } + + + + # Send-OVRequest -Uri $RemoteSupportPortalConnectionUri -Method GET -Hostname $ApplianceConnection + + # Process each appliance connection + # Return a new instance of [HPEOneView.Appliance.RemoteSupport.PortalConnection](bool RegistrationStatus, + # string RegistrationTimestamp, + # string InitiatedUser, + # string ConnectionName, + # string Message, + # ApplianceConnection ApplianceConnection) class + + ForEach ($_appliance in $ApplianceConnection) + { + + '[{0}] Processing "{1}" appliance connection.' -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name | Write-Verbose + + $_Uri = $RemoteSupportPortalConnectionUri + + if ($PSBoundParameters['GetGeneratedToken']) + { + + $_Uri = $RemoteSupportPortalRegistrationCodeUri + + } + + # Get Appliance Remote Support Portal registration + Try + { + + $_Resp = Send-OVRequest -Uri $_Uri -Hostname $_appliance.Name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if ($PSBoundParameters['GetGeneratedToken']) + { + + [HPEOneView.Appliance.RemoteSupport.PortalConnectionToken]::new($_Resp.state, + $_Resp.token, + $_Resp.requestTime, + $_Resp.expirationTime, + $_Resp.expirationTimeLeft, + $_Resp.validToken, + $_Resp.message, + $_Resp.ApplianceConnection) + + } + + else + { + + [HPEOneView.Appliance.RemoteSupport.PortalConnection]::new($_Resp.registrationStatus, + $_Resp.registrationTimestamp, + $_Resp.initiatedUser, + $_Resp.connectionName, + $_Resp.message, + $_Resp.ApplianceConnection) + + } + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Register-OVRemoteSupportPortalConnection +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = 'Default', SupportsShouldProcess, ConfirmImpact = 'High')] + [OutputType([HPEOneView.Appliance.RemoteSupport.PortalConnectionToken])] + Param + ( + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [Switch]$LaunchBrowser, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [Switch]$GenerateNewCode, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ExceptionMessage = "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + Process + { + + $_BrowserUrlDestination = "https://support.hpe.com/connect/s/myremotesupportconnections?registrationCode={TOKEN}" + + # [String]$RemoteSupportPortalConnectionUri = '/rest/support/portal-connection' + # [String]$RemoteSupportPortalRegistrationCodeUri = '/rest/support/portal-connection/registration-code' + # + # If $GenerateNewCode is specified, append ?useGenerated=true to the $RemoteSupportPortalRegistrationCodeUri URI + # Need to loop through each appliance connection and generate a new registration code for each + # If $LaunchBrowser is specified, launch the browser to the $_BrowserUrlDestination URL + # If $GenerateNewCode is specified, generate a new registration code for each appliance connection + # Loop through calling $RemoteSupportPortalRegistrationCodeUri waiting for the code to be generated, is null until created, in the token property of the response + + ForEach ($_appliance in $ApplianceConnection) + { + + '[{0}] Processing "{1}" appliance connection.' -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name | Write-Verbose + + $_uri = '{0}' -f $RemoteSupportPortalRegistrationCodeUri + + # Check first if appliance is connected to the remote support portal + Try + { + + $_Resp = Send-OVRequest -Uri $RemoteSupportPortalConnectionUri -Hostname $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if ([Convert]::ToBoolean($_Resp.registrationStatus)) + { + + $ExceptionMessage = 'The appliance {0} is already registered with the remote support portal.' -f $_appliance.Name + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.RemoteSupportPortalConnectionException RemoteSupportPortalConnectionExists InvalidArgument "ApplianceConnection" -TargetType 'PSObject' -Message $ExceptionMessage + $PSCmdlet.WriteError($ErrorRecord) + + } + + else + { + + $_ShouldProcessMessage = "register remote support portal connection" + + # This API call is not async, and instead is syncronous waiting for the token to be created and verified with the HPESC backend. + if ($PSCmdlet.ShouldProcess($_appliance.Name, $_ShouldProcessMessage)) + { + + Write-Progress -Activity "Registering Remote Support Portal Connection" -Status "Starting" -PercentComplete 0 + + Write-Progress -Activity "Registering Remote Support Portal Connection" -Status "Generating Registration Code" -PercentComplete 0 + + # Generate a new registration code + if ($GenerateNewCode) + { + + Write-progress -Activity "Registering Remote Support Portal Connection" -Status "Generating New Registration Code" -PercentComplete 50 + + $_uri = '{0}?useGenerated=false' -f $RemoteSupportPortalRegistrationCodeUri + + Try + { + + $_Resp = Send-OVRequest -Uri $_uri -Method POST -Hostname $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $_Resp + + } + + else + { + + Do + { + + Write-progress -Activity "Registering Remote Support Portal Connection" -Status "Waiting for Registration Code to be generated" -PercentComplete 50 + + Try + { + + $_Resp = Send-OVRequest -Uri $_uri -Method GET -Hostname $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + Start-Sleep -Seconds 5 + + } While (-not $_Resp.token -and $_Resp.state -eq $RemoteSupportPortalRegistrationStateEnum.Recieved) + + } + + Write-progress -Activity "Registering Remote Support Portal Connection" -Status "Registration Code Generated" -PercentComplete 100 + write-progress -Activity "Registering Remote Support Portal Connection" -Completed + + [HPEOneView.Appliance.RemoteSupport.PortalConnectionToken]::new($_Resp.state, + $_Resp.token, + $_Resp.requestTime, + $_Resp.expirationTime, + $_Resp.expirationTimeLeft, + $_Resp.validToken, + $_Resp.message, + $_Resp.ApplianceConnection) + + # Launch the browser + if ($LaunchBrowser) + { + + $_BrowserUrl = $_BrowserUrlDestination.Replace('{TOKEN}', $_Resp.token) + Start-Process $_BrowserUrl + + } + + } + + } + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Unregister-OVRemoteSupportPortalConnection +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + [OutputType([HPEOneView.Appliance.RemoteSupport.PortalConnection])] + + [CmdletBinding (DefaultParameterSetName = 'Default', SupportsShouldProcess, ConfirmImpact = 'High')] + Param + ( + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ExceptionMessage = "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + Process + { + + + ForEach ($_appliance in $ApplianceConnection) + { + + '[{0}] Processing "{1}" appliance connection.' -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name | Write-Verbose + + # Get Appliance Remote Support Portal registration + Try + { + + $_ApplianceRegistration = Send-OVRequest -Uri $RemoteSupportPortalConnectionUri -Hostname $_appliance.Name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if (-not [Convert]::ToBoolean($_ApplianceRegistration.registrationStatus)) + { + + $ExceptionMessage = 'The appliance {0} is not registered with the remote support portal.' -f $_appliance.Name + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.RemoteSupportPortalConnectionException RemoteSupportPortalConnectionNotExists InvalidArgument "ApplianceConnection" -TargetType 'PSObject' -Message $ExceptionMessage + $PSCmdlet.WriteError($ErrorRecord) + + } + + else + { + + $_ShouldProcessMessage = "unregister remote support portal connection" + + if ($PSCmdlet.ShouldProcess($_appliance.Name, $_ShouldProcessMessage)) + { + + Try + { + + $_Resp = Send-OVRequest -Uri $RemoteSupportPortalConnectionUri -Method DELETE -Hostname $_appliance.Name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + [HPEOneView.Appliance.RemoteSupport.PortalConnection]::new($_Resp.registrationStatus, + $_Resp.registrationTimestamp, + $_Resp.initiatedUser, + $_Resp.connectionName, + $_Resp.message, + $_Resp.ApplianceConnection) + + } + + } + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function RemoteSupportDefaultContactExists +{ + + [CmdletBinding ()] + Param + ( + + [Object]$ApplianceConnection + + ) + + Process + { + + # Check to make sure that 1 RS contact is default + Try + { + + $_Contacts = Send-OVRequest -Uri $RemoteSupportContactsUri -Hostname $ApplianceConnection + + # No default contact exists, generate terminating error + if (-not $_Contacts.members.default) + { + + $ExceptionMessage = 'The appliance {0} does not have a configured default contact. One must exist before enabling Remote Support.' -f $ApplianceConnection + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.RemoteSupportException NoDefaultContact InvalidOperation 'ApplianceConnection' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + } + + '[{0}] Default Contact: ' -f $MyInvocation.InvocationName.ToString().ToUpper(), ($_Contacts.members | Where-Object default).uri | Write-Verbose + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + +} + +function Get-OVRemoteSupportContact +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "Default" )] + Param + ( + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [ValidateNotNullorEmpty()] + [String]$Name, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $_RemoteSupportContactsCol = [System.Collections.ArrayList]::new() + + } + + Process + { + + ForEach($_appliance in $ApplianceConnection) + { + + Try + { + + $_RemoteSupportContacts = Send-OVRequest -Uri $RemoteSupportContactsUri -appliance $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if ($PSBoundParameters['Name']) + { + + [Array]$_RemoteSupportContacts.members = $_RemoteSupportContacts.members | Where-Object { ('{0} {1}' -f $_.firstName, $_.lastName) -like $Name} + + if (-not $_RemoteSupportContacts.members) + { + + '[{0}] The "{1}" Remote Support Contact was not found on {2}. Please check the name and try again.' -f $MyInvocation.InvocationName.ToString().ToUpper(), $Name, $_appliance.Name | Write-Verbose + + $ExceptionMessage = 'The "{0}" Remote Support Contact was not found on {1}. Please check the name and try again.' -f $Name, $_appliance.Name + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.RemoteSupportContactException ObjectNotFound ObjectNotFound 'Name' -Message $ExceptionMessage + $PSCmdlet.WriteError($ErrorRecord) + + } + + } + + ForEach ($_Contact in $_RemoteSupportContacts.members) + { + + $_Contact.PSObject.TypeNames.Insert(0,'HPEOneview.Appliance.RemoteSupport.Contact') + + $_Contact + + } + + } + + } + + End + { + + '[{0}] Done.' -f $MyInvocation.InvocationName.ToString().ToUpper(), $Name, $_appliance.Name | Write-Verbose + + } + +} + +function New-OVRemoteSupportContact +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "Default" )] + Param + ( + + [Parameter (Mandatory, ParameterSetName = "Default")] + [ValidateNotNullorEmpty()] + [Alias ('GivenName')] + [String]$Firstname, + + [Parameter (Mandatory, ParameterSetName = "Default")] + [ValidateNotNullorEmpty()] + [Alias ('Surname')] + [String]$Lastname, + + [Parameter (Mandatory, ParameterSetName = "Default")] + [ValidateNotNullorEmpty()] + [String]$Email, + + [Parameter (Mandatory, ParameterSetName = "Default")] + [ValidateNotNullorEmpty()] + [String]$PrimaryPhone, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [ValidateNotNullorEmpty()] + [String]$AlternatePhone, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [ValidateNotNullorEmpty()] + [String]$Language = 'en', + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [ValidateNotNullorEmpty()] + [Alias('Notes')] + [String]$SpecialInstructions, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Switch]$Default, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Switch]$DefaultSecondary, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $_RemoteSupportContactCol = [System.Collections.ArrayList]::new() + + } + + Process + { + + $_c = 0 + + ForEach($_Connection in $ApplianceConnection) + { + + $_c++ + + "[{0}] Processing {1} of {2} Appliance Connection(s)" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_c, ($ApplianceConnection | Measure-Object).Count | Write-Verbose + + $_RemoteSupportContact = NewObject -RemoteSupportContact + + $_RemoteSupportContact.default = $PSBoundParameters['Default'].IsPresent + $_RemoteSupportContact.defaultSecondary = $PSBoundParameters['DefaultSecondary'].IsPresent + $_RemoteSupportContact.alternatePhone = $AlternatePhone + $_RemoteSupportContact.email = $Email + $_RemoteSupportContact.firstName = $Firstname + $_RemoteSupportContact.lastName = $Lastname + $_RemoteSupportContact.language = $Language + $_RemoteSupportContact.notes = $SpecialInstructions + $_RemoteSupportContact.primaryPhone = $PrimaryPhone + + $_PatchOp = NewObject -PatchOperation + $_PatchOP.op = 'add' + $_PatchOP.path = '/contacts' + $_PatchOP.value = $_RemoteSupportContact + + Try + { + + $_Contacts = Send-OVRequest -Uri $RemoteSupportContactsUri -Hostname $_Connection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + # Check to see if there is a default contact, if so, add it as an array to the operation and set its default property to false + if ($PSBoundParameters['Default']) + { + + "[{0}] Checking for existing default contact" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if ($_Contacts.members | Where-Object default) + { + + "[{0}] Default contact found: {0} {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), ($_Contacts.members | Where-Object default).firstName, ($_Contacts.members | Where-Object default).lastName | Write-Verbose + + $_DefaultContact = $_Contacts.members | Where-Object default + $_DefaultContact.default = $false + + $_UpdatePatchOp = NewObject -PatchOperation + $_UpdatePatchOp.op = 'replace' + $_UpdatePatchOp.path = '/contacts/{0}' -f $_DefaultContact.contactKey + $_UpdatePatchOp.value = $_DefaultContact + + $_NewContact = $_PatchOp.PSObject.Copy() + + $_PatchOp = [System.Collections.ArrayList]::new() + [void]$_PatchOp.Add($_NewContact) + [void]$_PatchOp.Add($_UpdatePatchOp) + + } + + else + { + + "[{0}] No default contact. Configured contacts: {0}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_Contacts.count | Write-Verbose + + } + + } + + elseif (-not ($_Contacts.members | Where-Object default) -and -not $PSBoundParameters['Default']) + { + + "[{0}] No default contacts were present, and new contact was not specified as default. Setting it as Default contact." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + $_PatchOP.value.default = $true + + } + + # Check to see if there is a defaultSecondary contact, if so, add it as an array to the operation and set its default property to false + if ($PSBoundParameters['DefaultSecondary']) + { + + "[{0}] Checking for existing defaultSecondary contact" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if ($_Contacts.members | Where-Object defaultSecondary) + { + + "[{0}] Default contact found: {0} {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), ($_Contacts.members | Where-Object defaultSecondary).firstName, ($_Contacts.members | Where-Object defaultSecondary).lastName | Write-Verbose + + $_DefaultSecondaryContact = $_Contacts.members | Where-Object defaultSecondary + $_DefaultSecondaryContact.defaultSecondary = $false + + $_UpdatePatchOp = NewObject -PatchOperation + $_UpdatePatchOp.op = 'replace' + $_UpdatePatchOp.path = '/contacts/{0}' -f $_DefaultSecondaryContact.contactKey + $_UpdatePatchOp.value = $_DefaultSecondaryContact + + $_NewContact = $_PatchOp.PSObject.Copy() + + $_PatchOp = [System.Collections.ArrayList]::new() + [void]$_PatchOp.Add($_NewContact) + [void]$_PatchOp.Add($_UpdatePatchOp) + + } + + else + { + + "[{0}] No default contact. Configured contacts: {0}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_Contacts.count | Write-Verbose + + } + + } + + elseif (-not ($_Contacts.members | Where-Object default) -and -not $PSBoundParameters['Default']) + { + + "[{0}] No default contacts were present, and new contact was not specified as default. Setting it as Default contact." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + $_PatchOP.value.default = $true + + } + + Try + { + + # Task object is returned dur to PATCH operation + $_resp = Send-OVRequest -Uri $RemoteSupportUri -Method PATCH -Body $_PatchOp -Hostname $_Connection | Wait-OVTaskComplete + + # If not successful, generate terminating error + if ($_resp.taskState -ne 'Completed') + { + + $ExceptionMessage = [String]::Join(' ', $_resp.taskErrors.Message) + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.RemoteSupportContactException InvalidResult InvalidResult "Contact" -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + Try + { + + # Get newly created contact + $_Contacts = Send-OVRequest -Uri $RemoteSupportContactsUri -Hostname $_Connection + + $_NewContact = $_Contacts.members | Where-Object { ('{0} {1}' -f $_.firstName, $_.lastName) -like ('{0} {1}' -f $Firstname, $Lastname) } + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $_NewContact.PSObject.TypeNames.Insert(0,'HPEOneview.Appliance.RemoteSupport.Contact') + + $_NewContact + + } + + } + + End + { + + "Done." | Write-Verbose + + } + +} + +function Set-OVRemoteSupportPrimaryContact +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "Default", SupportsShouldProcess, ConfirmImpact = 'High')] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = "Default")] + [ValidateNotNullorEmpty()] + [Alias ('Contact')] + [Object]$InputObject, + + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = "Default")] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not($PSBoundParameters['InputObject'])) + { + + $PipelineInput = $true + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + } + + Process + { + + "[{0}] Remote Support Contact Object provided: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject.name | Write-Verbose + + If ($InputObject.type -eq 'Contact') + { + + If (-not ($InputObject.ApplianceConnection)) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.RemoteSupportContactException InvalidArgumentValue InvalidArgument "InputObject" -TargetType PSObject -Message "The InputObject object resource provided is missing the source ApplianceConnection property. Please check the object provided and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + else + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.RemoteSupportContactException InvalidArgumentValue InvalidArgument "InputObject" -TargetType $InputObject.GetType().Name -Message "The InputObject object resource is not an expected type. The allowed resource category type is 'Contact'. Please check the object provided and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Try + { + + $InputObject.default = $true + + $_PatchOp = NewObject -PatchOperation + $_PatchOp.op = 'replace' + $_PatchOp.path = "/contacts/{0}" -f $InputObject.contactKey + $_PatchOp.value = $InputObject + + Send-OVRequest -Uri $RemoteSupportUri -Method PATCH -Body $_PatchOp -Hostname $InputObject.ApplianceConnection | Wait-OVTaskComplete + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Set-OVRemoteSupportSecondaryContact +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "Default", SupportsShouldProcess, ConfirmImpact = 'High')] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = "Default")] + [ValidateNotNullorEmpty()] + [Alias ('Contact')] + [Object]$InputObject, + + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = "Default")] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not($PSBoundParameters['InputObject'])) + { + + $PipelineInput = $true + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + } + + Process + { + + "[{0}] Remote Support Contact Object provided: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject.name | Write-Verbose + + If ($InputObject.type -eq 'Contact') + { + + If (-not ($InputObject.ApplianceConnection)) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.RemoteSupportContactException InvalidArgumentValue InvalidArgument "InputObject" -TargetType PSObject -Message "The InputObject object resource provided is missing the source ApplianceConnection property. Please check the object provided and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + else + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.RemoteSupportContactException InvalidArgumentValue InvalidArgument "InputObject" -TargetType $InputObject.GetType().Name -Message "The InputObject object resource is not an expected type. The allowed resource category type is 'Contact'. Please check the object provided and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Try + { + + $InputObject.defaultSecondary = $true + + $_PatchOp = NewObject -PatchOperation + $_PatchOp.op = 'replace' + $_PatchOp.path = "/contacts/{0}" -f $InputObject.contactKey + $_PatchOp.value = $InputObject + + Send-OVRequest -Uri $RemoteSupportUri -Method PATCH -Body $_PatchOp -Hostname $InputObject.ApplianceConnection | Wait-OVTaskComplete + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Remove-OVRemoteSupportContact +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "Default", SupportsShouldProcess, ConfirmImpact = 'High')] + [OutputType([HPEOneView.Appliance.TaskResource])] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = "Default")] + [ValidateNotNullorEmpty()] + [Alias ('Contact')] + [Object]$InputObject, + + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = "Default")] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not($PSBoundParameters['InputObject'])) + { + + $PipelineInput = $true + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + $_RemoteSupportContactsCol = [System.Collections.ArrayList]::new() + + } + + Process + { + + if ($InputObject -is [PSCustomObject]) + { + + "[{0}] Processing Pipeline input" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + "[{0}] Remote Support Contact Object provided: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject.name | Write-Verbose + + If ($InputObject.type -eq 'Contact') + { + + If (-not($InputObject.ApplianceConnection)) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.RemoteSupportContactException InvalidArgumentValue InvalidArgument "InputObject" -TargetType PSObject -Message "The InputObject object resource provided is missing the source ApplianceConnection property. Please check the object provided and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + [void]$_RemoteSupportContactsCol.Add($InputObject) + + } + + else + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.RemoteSupportContactException InvalidArgumentValue InvalidArgument "InputObject" -TargetType $InputObject.GetType().Name -Message "The InputObject object resource is not an expected type. The allowed resource category type is 'Contact'. Please check the object provided and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + else + { + + ForEach ($_appliance in $ApplianceConnection) + { + + "[{0}] Processing Appliance {1} (of {2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name, $ApplianceConnection.Count | Write-Verbose + + "[{0}] Processing Contact Name {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject | Write-Verbose + + Try + { + + $_Contact = Get-OVRemoteSupportContact -ApplianceConnection $_appliance | Where-Object firstName -eq $InputObject + + $_Contact | ForEach-Object { + + [void]$_RemoteSupportContactsCol.Add($_) + + } + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + } + + End + { + + "[{0}] Begin resource removal process." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + foreach ($_contact in $_RemoteSupportContactsCol) + { + + $Name = "{0} {1}" -f $_contact.firstName, $_contact.lastName + $RemoveMessage = "Remove Remote Support Contact '{0}'" -f $Name + + if ($_contact.default) + { + + $ExceptionMessage = "The Contact resource '{0}' is currently the default. The removal of the Default Contact is not supported. If you wish to remove this contact, please set another contact as the Default first." -f $Name + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.RemoteSupportContactException UnableToRemoveDefaultContact InvalidOperation "Contact" -TargetType 'PSObject' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + else + { + + if ($PSCmdlet.ShouldProcess($_contact.ApplianceConnection,$RemoveMessage)) + { + + Try + { + + Send-OVRequest -Uri $_contact.uri -Method DELETE -Hostname $_contact.ApplianceConnection -AddHeader @{'If-Match' = $_contact.eTag} | Wait-OVTaskComplete + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + elseif ($PSBoundParameters['WhatIf']) + { + + "[{0}] Caller passed -WhatIf Parameter." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + else + { + + "[{0}] Caller selected NO to confirmation prompt." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + } + + } + + } + +} + +function Get-OVRemoteSupportPartner +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "Default")] + Param + ( + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [ValidateNotNullorEmpty()] + [String]$Name, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + Process + { + + ForEach ($_appliance in $ApplianceConnection) + { + + $_uri = $RemoteSupportChannelPartnersUri + + Try + { + + $_resp = Send-OVRequest -Uri $_uri -Hostname $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if ($Name) + { + + [Array]$_resp.members = $_resp.members | Where-Object name -match $Name + + if ($_resp.members.count -eq 0) + { + + $ExceptionMessage = "Unable to locate {0} on Appliance Connection {1}." -f $Name, $_appliance.Name + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.RemoteSupportContactException RemoteSupportContactNotFound ObjectNotFound 'Name' -Message $ExceptionMessage + $PSCmdlet.WriteError($ErrorRecord) + + } + + } + + ForEach ($_rsPartner in $_resp.members) + { + + $_rsPartner.PSObject.TypeNames.Insert(0,'HPEOneview.Appliance.RemoteSupport.Partner') + + } + + $_resp.members + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function New-OVRemoteSupportPartner +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "Default")] + [OutputType([HPEOneView.Appliance.TaskResource])] + Param + ( + + [Parameter (Mandatory, ParameterSetName = "Default")] + [ValidateNotNullorEmpty()] + [String]$Name, + + [Parameter (Mandatory, ParameterSetName = "Default")] + [ValidateSet ('Support','Reseller')] + [String]$Type, + + [Parameter (Mandatory, ParameterSetName = "Default")] + [ValidateNotNullorEmpty()] + [Int]$PartnerId, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Switch]$Default, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + Process + { + + $_RemoteSupportPartnerObject = NewObject -RemoteSupportPartner + $_RemoteSupportPartnerObject.id = $PartnerId; + $_RemoteSupportPartnerObject.default = $Default.IsPresent; + $_RemoteSupportPartnerObject.partnerType = $Type.ToUpper() + + "[{0}] Validating PartnerID: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $PartnerId | Write-Verbose + + # Validate PartnerID + Try + { + + $_resp = Send-OVRequest -Uri $RemoteSupportChannelPartnersValidatorUri -Method POST -Body $PartnerId.ToString() -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + Try + { + + $_resp = Send-OVRequest -Uri $RemoteSupportChannelPartnersUri -Method POST -Body $_RemoteSupportPartnerObject -Hostname $ApplianceConnection | Wait-OVTaskComplete + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $_resp + + } + + End + { + + "Done." | Write-Verbose + + } + +} + +function Remove-OVRemoteSupportPartner +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "Default", SupportsShouldProcess, ConfirmImpact = 'High')] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = "Default")] + [ValidateNotNullorEmpty()] + [Alias ('Partner')] + [Object]$InputObject, + + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = "Default")] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not($PSBoundParameters['InputObject'])) + { + + $PipelineInput = $true + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + $_RemoteSupportPartnerCol = [System.Collections.ArrayList]::new() + $_TaskCollection = [System.Collections.ArrayList]::new() + + } + + Process + { + + if ($PipelineInput -or $InputObject -is [PSCustomObject]) + { + + "[{0}] Processing Pipeline input" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + "[{0}] Remote Support Contact Object provided: {1} ({2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject.name, $InputObject.uri | Write-Verbose + + If ($InputObject.type -eq 'ChannelPartner') + { + + If (-not($InputObject.ApplianceConnection)) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.RemoteSupportContactException InvalidArgumentValue InvalidArgument "InputObject" -TargetType PSObject -Message "The InputObject object resource provided is missing the source ApplianceConnection property. Please check the object provided and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + [void]$_RemoteSupportPartnerCol.Add($InputObject) + + } + + else + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.RemoteSupportContactException InvalidArgumentValue InvalidArgument "InputObject" -TargetType $InputObject.GetType().Name -Message "The InputObject object resource is not an expected type. The allowed resource category type is 'ChannelPartner'. Please check the object provided and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + else + { + + ForEach ($_appliance in $ApplianceConnection) + { + + "[{0}] Processing Appliance {1} (of {2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name, $ApplianceConnection.Count | Write-Verbose + + "[{0}] Processing Contact Name {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Contact | Write-Verbose + + Try + { + + $_Partner = Get-OVRemoteSupportPartner -Name $InputObject -ApplianceConnection $_appliance -ErrorAction Stop + + $_Partner | ForEach-Object { + + [void]$_RemoteSupportPartnerCol.Add($_) + + } + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + } + + End + { + + "[{0}] Begin resource removal process." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + foreach ($_partner in $_RemoteSupportPartnerCol) + { + + $RemoveMessage = "Remove Remote Support Channel Partner '{0}'" -f $_partner.Name + + if ($PSCmdlet.ShouldProcess($_partner.ApplianceConnection,$RemoveMessage)) + { + + Try + { + + Send-OVRequest -Uri $_partner.uri -Method DELETE -Hostname $_partner.ApplianceConnection -addHeader @{'If-Match' = $_partner.eTag} + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + elseif ($PSBoundParameters['WhatIf']) + { + + "[{0}] Caller passed -WhatIf Parameter." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + else + { + + "[{0}] Caller selected NO to confirmation prompt." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + } + + } + +} + +function Get-OVRemoteSupportSetting +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "Default" )] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = "Default")] + [ValidateNotNullorEmpty()] + [Object]$InputObject, + + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = "Default")] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not $PSBoundParameters['InputObject']) + { + + $PipelineInput = $true + + } + + else + { + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + } + + Process + { + + switch ($InputObject.category) + { + + $ResourceCategoryEnum.ServerHardware + { + + $_uri = '{0}/{1}' -f $RemoteSupportComputeSettingsUri, $InputObject.uuid + + } + + $ResourceCategoryEnum.Enclosure + { + + $_uri = '{0}/{1}' -f $RemoteSupportEnclosureSettingsUri, $InputObject.uuid + + } + + $ResourceCategoryEnum.Interconnect + { + + $_uri = '{0}/{1}' -f $RemoteSupportInterconnectSettingsUri, $InputObject.uri.Split('/')[-1] + + } + + $ResourceCategoryEnum.SasInterconnect + { + + $_uri = '{0}/{1}' -f $RemoteSupportSasInterconnectSettingsUri, $InputObject.uri.Split('/')[-1] + + } + + $ResourceCategoryEnum.RackManager + { + + $_uri = '{0}/{1}' -f $RemoteSupportRackManagerSettingsUri, $InputObject.uri.Split('/')[-1] + + } + + default + { + + # Unsupported + $ExceptionMessage = 'The {0} input object is an unsupported resource category type, "{1}". Only "server-hardware" or "enclosure" resources are supported.' -f $InputObject.category, $InputObject.name + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.RemoteSupportResourceException InvalidResourceObject InvalidArgument "InputObject" -TargetType 'PSObject' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + Try + { + + $_ResourceRemoteSupportSettings = Send-OVRequest -uri $_uri -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $_ResourceRemoteSupportSettings | Add-Member -NotePropertyName ResourceName -NotePropertyValue $InputObject.name + $_ResourceRemoteSupportSettings | Add-Member -NotePropertyName ResourceType -NotePropertyValue $InputObject.category + + $_ResourceRemoteSupportSettings.PSObject.TypeNames.Insert(0,'HPEOneView.RemoteSupport.ResourceSetting') + + $_ResourceRemoteSupportSettings + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Set-OVRemoteSupportSetting +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = 'Default')] + + Param + ( + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = 'Default')] + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = 'Disable')] + [ValidateNotNullorEmpty()] + [Object]$InputObject, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullorEmpty()] + [Object]$PrimaryContact, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullorEmpty()] + [Object]$SecondaryContact, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullorEmpty()] + [Object]$ServicePartner, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullorEmpty()] + [Object]$Reseller, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateSet ('PackagedSupport', 'SupportAgreement')] + [String]$ContractType, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullorEmpty()] + [String]$SupportID, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullorEmpty()] + [String]$NewSerialNumber, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullorEmpty()] + [String]$NewProductNumber, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullorEmpty()] + [Switch]$Enabled, + + [Parameter (Mandatory, ParameterSetName = 'Disable')] + [ValidateNotNullorEmpty()] + [Switch]$Disabled, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [Parameter (Mandatory = $false, ParameterSetName = 'Disable')] + [ValidateNotNullorEmpty()] + [Switch]$Async, + + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = 'Default')] + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = 'Disable')] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + Process + { + + $_RemoteSupportSettingsToSet = [System.Collections.ArrayList]::new() + + switch ($InputObject.category) + { + + $ResourceCategoryEnum.ServerHardware + { + + $_uri = '{0}/{1}' -f $RemoteSupportComputeSettingsUri, $InputObject.uuid + + } + + $ResourceCategoryEnum.Enclosure + { + + $_uri = '{0}/{1}' -f $RemoteSupportEnclosureSettingsUri, $InputObject.uuid + + } + + $ResourceCategoryEnum.Interconnect + { + + $_uri = '{0}/{1}' -f $RemoteSupportInterconnectSettingsUri, $InputObject.uri.Split('/')[-1] + + } + + $ResourceCategoryEnum.RackManager + { + + $_uri = '{0}/{1}' -f $RemoteSupportRackManagerSettingsUri, $InputObject.uri.Split('/')[-1] + + } + + default + { + + # Unsupported + $ExceptionMessage = 'The {0} input object is an unsupported resource category type, "{1}". Only "server-hardware" or "enclosure" resources are supported.' -f $InputObject.category, $InputObject.name + $ErrorRecord = New-ErrorRecord HPEOneView.InputObjectResourceException InvalidResourceObject InvalidArgument "InputObject" -TargetType $InputObject.GetType().Name -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + Switch ($PSBoundParameters.Keys) + { + + 'PrimaryContact' + { + + if ($PrimaryContact.Type -ne 'Contact') + { + + $ExceptionMessage = 'The PrimaryContact object is not a valid Remote Support Contact.' + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.RemoteSupportContactException InvalidPrimaryContact InvalidArgument "InputObject" -TargetType $PrimaryContact.GetType().Name -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + $_PrimaryContactOp = NewObject -PatchOperation + $_PrimaryContactOp.op = 'replace' + $_PrimaryContactOp.path = '/primaryContactUri' + $_PrimaryContactOp.value = $PrimaryContact.uri + + [Void]$_RemoteSupportSettingsToSet.Add($_PrimaryContactOp) + + } + + 'SecondaryContact' + { + + if ($SecondaryContact.Type -ne 'Contact') + { + + $ExceptionMessage = 'The SecondaryContact object is not a valid Remote Support Contact.' + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.RemoteSupportContactException InvalidSecondaryContact InvalidArgument "InputObject" -TargetType $SecondaryContact.GetType().Name -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + $_SecondaryContactOp = NewObject -PatchOperation + $_SecondaryContactOp.op = 'replace' + $_SecondaryContactOp.path = '/secondaryContactUri' + $_SecondaryContactOp.value = $SecondaryContact.uri + + [Void]$_RemoteSupportSettingsToSet.Add($_SecondaryContactOp) + + } + + 'Reseller' + { + + if ($Reseller.Type -ne 'ChannelPartner' -or $Reseller.partnerType -ne 'RESELLER') + { + + $ExceptionMessage = 'The Reseller object is not a valid Remote Support reseller partner.' + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.RemoteSupportPartnerException InvalidReseller InvalidArgument "InputObject" -TargetType $Reseller.GetType().Name -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + $_ResellerOp = NewObject -PatchOperation + $_ResellerOp.op = 'replace' + $_ResellerOp.path = '/salesChannelPartnerUri' + $_ResellerOp.value = $Reseller.uri + + [Void]$_RemoteSupportSettingsToSet.Add($_ResellerOp) + + } + + 'ServicePartner' + { + + if ($ServicePartner.Type -ne 'ChannelPartner' -or $ServicePartner.partnerType -ne 'SUPPORT') + { + + $ExceptionMessage = 'The Reseller object is not a valid Remote Support suport partner.' + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.RemoteSupportPartnerException InvalidServicePartner InvalidArgument "InputObject" -TargetType $ServicePartner.GetType().Name -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + $_ServicePartnerOp = NewObject -PatchOperation + $_ServicePartnerOp.op = 'replace' + $_ServicePartnerOp.path = '/supportChannelPartnerUri' + $_ServicePartnerOp.value = $ServicePartner.uri + + [Void]$_RemoteSupportSettingsToSet.Add($_ServicePartnerOp) + + } + + 'SupportID' + { + + $_SupportIDOp = NewObject -PatchOperation + $_SupportIDOp.op = 'replace' + $_SupportIDOp.path = '/entitlement' + $_SupportIDOp.value = [PSCustomOBject]@{ + + obligationType = $ContractType; + obligationId = $SupportID + + } + + [Void]$_RemoteSupportSettingsToSet.Add($_SupportIDOp) + + } + + 'NewSerialNumber' + { + + $_NewSerialNumberOp = NewObject -PatchOperation + $_NewSerialNumberOp.op = 'replace' + $_NewSerialNumberOp.path = '/enteredSerialNumber' + $_NewSerialNumberOp.value = $NewSerialNumber + + [Void]$_RemoteSupportSettingsToSet.Add($_NewSerialNumberOp) + + } + + 'NewProductNumber' + { + + $_NewProductNumberOp = NewObject -PatchOperation + $_NewProductNumberOp.op = 'replace' + $_NewProductNumberOp.path = '/enteredProductNumber' + $_NewProductNumberOp.value = $NewProductNumber + + [Void]$_RemoteSupportSettingsToSet.Add($_NewProductNumberOp) + + } + + } + + if ($PSBoundParameters['Enabled']) + { + + $_EnableOp = NewObject -PatchOperation + $_EnableOp.op = 'replace' + $_EnableOp.path = '/supportEnabled' + $_EnableOp.value = $true + + [Void]$_RemoteSupportSettingsToSet.Add($_EnableOp) + + } + + elseif ($PSBoundParameters['Disabled']) + { + + $_DisableOp = NewObject -PatchOperation + $_DisableOp.op = 'replace' + $_DisableOp.path = '/supportEnabled' + $_DisableOp.value = $false + + [Void]$_RemoteSupportSettingsToSet.Add($_DisableOp) + + } + + Try + { + + $_resp = Send-OVRequest -Uri $_uri -Method PATCH -Body $_RemoteSupportSettingsToSet -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if ($PSBoundParameters['Async']) + { + + $_resp + + } + + else + { + + $_resp | Wait-OVTaskComplete + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Set-OVRemoteSupportDataCollectionSchedule +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding ()] + Param + ( + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateSet ('AHS','Basic')] + [String]$Type, + + [Parameter (Mandatory, ParameterSetName = 'Default')] + [ValidateNotNullorEmpty()] + [DateTime]$DateTime, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullorEmpty()] + [Switch]$Async, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $_SchedulesToUpdate = [System.Collections.ArrayList]::new() + + } + + Process + { + + ForEach($_Appliance in $ApplianceConnection) + { + + # Get the default schedules on the appliance + Try + { + + $_Schedules = Send-OVRequest -Uri $RemoteSupportDataCollectionScheduleUri -Hostname $_Appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if (-not $PSBoundParameters['Type']) + { + + $_Type = 'AHS','Basic' + + } + + else + { + + $_Type = $Type + + } + + Switch ($_Type) + { + + 'AHS' + { + + $_schedule = $_Schedules.members | Where-Object serviceName -eq 'Active_Health_Service_Collection' + + "[{0}] Processing schedule: {1}({2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_schedule.scheduleName, $_schedule.serviceName | Write-Verbose + $_schedule.hourOfDay = [Int]$DateTime.Hour + $_schedule.minute = $DateTime.Minute + $_schedule.dayOfWeek = [Int]$DateTime.DayOfWeek + 1 # Needs to be a value of 1 through 7. Windows defaults to 0 - 6. + + $_PatchOperation = NewObject -PatchOperation + + $_PatchOperation.op = 'replace' + $_PatchOperation.path = '/schedules/{0}' -f $_schedule.taskKey + $_PatchOperation.value = $_schedule + + [void]$_SchedulesToUpdate.Add($_PatchOperation) + + } + + 'Basic' + { + + $_schedule = $_Schedules.members | Where-Object serviceName -eq 'Server_Basic_Configuration_Collection' + + "[{0}] Processing schedule: {1}({2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_schedule.scheduleName, $_schedule.serviceName | Write-Verbose + $_schedule.hourOfDay = [Int]$DateTime.Hour + $_schedule.minute = $DateTime.Minute + $_schedule.dayOfMonth = [Int]$DateTime.Day + + $_PatchOperation = NewObject -PatchOperation + + $_PatchOperation.op = 'replace' + $_PatchOperation.path = '/schedules/{0}' -f $_schedule.taskKey + $_PatchOperation.value = $_schedule + + [void]$_SchedulesToUpdate.Add($_PatchOperation) + + } + + } + + Try + { + + $_resp = Send-OVRequest -Uri $RemoteSupportUri -Method PATCH -Body $_SchedulesToUpdate -Hostname $_Appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if ($PSBoundParameters['Async']) + { + + $_resp + + } + + else + { + + $_resp | Wait-OVTaskComplete + + } + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Get-OVRemoteSupportDataCollectionSchedule +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdLetBinding (DefaultParameterSetName = "Default")] + Param + ( + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateSet ('AHS','Basic')] + [String]$Type, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + Process + { + + ForEach($_Appliance in $ApplianceConnection) + { + + # Get the default schedules on the appliance + Try + { + + $_Schedules = Send-OVRequest -Uri $RemoteSupportDataCollectionScheduleUri -Hostname $_Appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if (-not $PSBoundParameters['Type']) + { + + $_Type = 'AHS','Basic' + + } + + else + { + + $_Type = $Type + + } + + Switch ($_Type) + { + + 'AHS' + { + + $_Schedules.members | Where-Object serviceName -eq 'Active_Health_Service_Collection' | ForEach-Object { + + [HPEOneView.Appliance.RemoteSupport.Schedule]::new($_.scheduleName, + $_.repeatOption, + $_.hourOfDay, + $_.minute, + [DayOfWeek]$_.dayOfWeek, + $_.ApplianceConnection) + + } + + } + + 'Basic' + { + + $_Schedules.members | Where-Object serviceName -eq 'Server_Basic_Configuration_Collection' | ForEach-Object { + + [HPEOneView.Appliance.RemoteSupport.Schedule]::new($_.scheduleName, + $_.repeatOption, + $_.hourOfDay, + $_.minute, + $_.dayOfMonth, + $_.ApplianceConnection) + + } + + } + + } + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Start-OVRemoteSupportCollection +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdLetBinding ()] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline)] + [ValidateNotNullOrEmpty()] + [Object]$InputObject, + + [Parameter (Mandatory)] + [ValidateSet ('AHS', 'Basic')] + [String]$Type, + + [Parameter (Mandatory = $false)] + [ValidateNotNullorEmpty()] + [Switch]$Async, + + [Parameter (ValueFromPipelineByPropertyName, Mandatory = $false)] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $_SchedulesToUpdate = [System.Collections.ArrayList]::new() + + } + + Process + { + + $_DataCollection = [PSCustomObject]@{ + type = "CollectionType"; + collectionType = "AHS" + } + + switch ($InputObject.category) + { + + $ResourceCategoryEnum.Enclosure + { + + $_DataCollection.collectionType = 'Basic' + + $_Uri = '{0}?deviceID={1}&category={2}' -f $RemoteSupportDataCollectionsUri, $InputObject.uuid, $ResourceCategoryEnum.Enclosure + + } + + $ResourceCategoryEnum.ServerHardware + { + + $_DataCollection.collectionType = $RemoteSupportCollectionEnum[$Type] + + $_Uri = '{0}?deviceID={1}&category={2}' -f $RemoteSupportDataCollectionsUri, $InputObject.uuid, $ResourceCategoryEnum.ServerHardware + + } + + $ResourceCategoryEnum.Interconnect + { + + $_DataCollection.collectionType = 'Basic' + + $_Uri = '{0}?deviceID={1}&category={2}' -f $RemoteSupportDataCollectionsUri, $InputObject.uri.Split('/')[-1], $ResourceCategoryEnum.Interconnect + + } + + $ResourceCategoryEnum.RackManager + { + + $_DataCollection.collectionType = 'Basic' + + $_Uri = '{0}?deviceID={1}&category={2}' -f $RemoteSupportDataCollectionsUri, $InputObject.uri.Split('/')[-1], $ResourceCategoryEnum.RackManager + + } + + $ResourceCategoryEnum.ServerProfile + { + + if ($null -ne $InputObject.serverHardwareUri) + { + + $_DataCollection.collectionType = $RemoteSupportCollectionEnum[$Type] + + $_Uri = '{0}?deviceID={1}&category=server-hardware' -f $RemoteSupportDataCollectionsUri, $InputObject.uuid + + } + + else + { + + $ExceptionMessage = 'The {0} Server Profile resource is not assigned to a compute resource.' -f $InputObject.category, $InputObject.name + $ErrorRecord = New-ErrorRecord HPEOneView.InputObjectResourceException InvalidResourceObject InvalidArgument "InputObject" -TargetType 'PSObject' -Message $ExceptionMessage + $PSCmdlet.WriteError($ErrorRecord) + + } + + } + + default + { + + # Unsupported + $ExceptionMessage = 'The {0} input object is an unsupported resource category type, "{1}". Only "server-hardware", "server-profile" or "enclosure" resources are supported.' -f $InputObject.category, $InputObject.name + $ErrorRecord = New-ErrorRecord HPEOneView.InputObjectResourceException InvalidResourceObject InvalidArgument "InputObject" -TargetType $InputObject.GetType().Name -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + if ($_Uri) + { + + Try + { + + $_resp = Send-OVRequest -Uri $_Uri -Method POST -Body $_DataCollection -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if ($PSBoundParameters['Async']) + { + + $_resp + + } + + else + { + + $_resp | Wait-OVTaskComplete + + } + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Get-OVRemoteSupportEntitlementStatus +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdLetBinding (DefaultParameterSetName = "default")] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = "default")] + [ValidateNotNullOrEmpty()] + [Object]$InputObject, + + [Parameter (ValueFromPipelineByPropertyName, Mandatory = $false, ParameterSetName = "default")] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + "[{0}] Bound PS Parameters: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), ($PSBoundParameters | out-string) | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + + if (-not $PSBoundParameters['InputObject']) + { + + $PipelineInput = $True + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -gt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + } + + Process + { + + $_ResourcesToProcess = [System.Collections.ArrayList]::new() + + switch ($InputObject.category) + { + + $ResourceCategoryEnum.Enclosure + { + + "[{0}] Processing Enclosure: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject.name | Write-Verbose + + [void]$_ResourcesToProcess.Add($InputObject.PSObject.Copy()) + + } + + $ResourceCategoryEnum.LogicalEnclosure + { + + "[{0}] Processing Logical Enclosure: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject.name | Write-Verbose + + ForEach ($_Uri in $InputObject.enclosureUris) + { + + Try + { + + $_Resource = Send-OVRequest -Uri $_Uri -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + [void]$_ResourcesToProcess.Add($_Resource) + + } + + } + + $ResourceCategoryEnum.EnclosureGroup + { + + "[{0}] Processing Enclosure Group, and getting associated Logical Enclosures: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject.name | Write-Verbose + + $_Uri = '{0}?parentUri={1}&name=ENCLOSURE_GROUP_TO_LOGICAL_ENCLOSURE' -f $AssociationsUri, $InputObject.uri + + Try + { + + [Array]$_AssoiatedLEs = (Send-OVRequest -Uri $_Uri -Hostname $ApplianceConnection).members | ForEach-Object { Send-OVRequest $_.childUri -Hostname $_.ApplianceConnection} + + ForEach ($_Uri in $InputObject.enclosureUris) + { + + Try + { + + $_Resource = Send-OVRequest -Uri $_Uri -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + [void]$_ResourcesToProcess.Add($_Resource) + + } + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $ResourceCategoryEnum.ServerHardware + { + + "[{0}] Processing server hardware device: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject.name | Write-Verbose + + [void]$_ResourcesToProcess.Add($InputObject.PSObject.Copy()) + + } + + $ResourceCategoryEnum.ServerProfile + { + + "[{0}] Processing server profile: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject.name | Write-Verbose + + if ($Null -eq $InputObject.serverHardwareUri) + { + + "[{0}] Server Profile is currently unassigned." -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject.name | Write-Verbose + + } + + else + { + + Try + { + + $_Resource = Send-OVRequest -Uri $InputObject.serverHardwareUri -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + [void]$_ResourcesToProcess.Add($_Resource) + + } + + } + + $ResourceCategoryEnum.Interconnect + { + + "[{0}] Processing interconnect hardware device: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject.name | Write-Verbose + + $InputObject | Add-Member -NotePropertyName remoteSupportUri -NotePropertyValue $InputObject.remoteSupport.remoteSupportUri -Force + + [void]$_ResourcesToProcess.Add($InputObject.PSObject.Copy()) + + } + + default + { + + # Generae error of unsupported resource + $ExceptionMessage = 'The {0} input object is an unsupported resource category type, "{1}". Only "server-hardware"., "server-profile", "enclosure-group", "logical-enclosure" or "enclosure" resources are supported.' -f $InputObject.category, $InputObject.name + $ErrorRecord = New-ErrorRecord HPEOneView.InputObjectResourceException InvalidInputObjectResource InvalidArgument "InputObject" -TargetType 'String' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + ForEach ($_Resource in $_ResourcesToProcess) + { + + "[{0}] Getting Remote Support status for: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_Resource.name | Write-Verbose + + Try + { + + $_RemoteSupportStatus = Send-OVRequest -Uri $_Resource.remoteSupportUri -Hostname $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.RemoteSupportResourceException] + { + + $ExceptionMessage = "The device {0} is not eligible for Remote Support." -f $_Resource.name + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.RemoteSupportResourceException DeviceNotEligible InvalidOperation "Server" -Message $ExceptionMessage -InnerException $_.Exception.InnerException + $PSCmdlet.WriteError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if ($_RemoteSupportStatus.supportEnabled) + { + + "[{0}] Resource has Remote Support enabled, getting entitlement information." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $_ResourceEntitlementStatus = Send-OVRequest -Uri $_RemoteSupportStatus.entitlementUri -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if ($null -eq $_ResourceEntitlementStatus.obligationStartDate) + { + + [DateTime]$_ResourceEntitlementStatus.obligationStartDate = '01/01/1970' + + } + + if ($null -eq $_ResourceEntitlementStatus.obligationEndDate) + { + + [DateTime]$_ResourceEntitlementStatus.obligationEndDate = '01/01/1970' + + } + + if ($null -eq $_ResourceEntitlementStatus.offerStartDate) + { + + [DateTime]$_ResourceEntitlementStatus.offerStartDate = '01/01/1970' + + } + + if ($null -eq $_ResourceEntitlementStatus.offerEndDate) + { + + [DateTime]$_ResourceEntitlementStatus.offerEndDate = '01/01/1970' + + } + + # Get resource name + switch ($_Resource.type) + { + + 'server-hardware' + { + + if ($null -ne $_Resource.serverName) + { + + $_ResourceName = $_Resource.serverName + + } + + else + { + + $_ResourceName = $_Resource.name + + } + + } + + 'enclosures' + { + + $_ResourceName = $_Resource.name + + } + + } + + $_EntitlementStatus = [HPEOneView.RemoteSupport.ContractAndWarrantyStatus]::new($_ResourceName, + $_Uri, + $_Resource.serialNumber, + $_ResourceEntitlementStatus.entitlementPackage, + $_ResourceEntitlementStatus.entitlementStatus, + $_ResourceEntitlementStatus.offerStatus, + $_ResourceEntitlementStatus.coverageDays, + $_ResourceEntitlementStatus.coverageHoursDay1to5, + $_ResourceEntitlementStatus.coverageHoursDay6, + $_ResourceEntitlementStatus.coverageHoursDay7, + $_ResourceEntitlementStatus.responseTimeDay1to5, + $_ResourceEntitlementStatus.responseTimeDay6, + $_ResourceEntitlementStatus.responseTimeDay7, + [DateTime]$_ResourceEntitlementStatus.obligationStartDate, + [DateTime]$_ResourceEntitlementStatus.obligationEndDate, + [DateTime]$_ResourceEntitlementStatus.offerStartDate, + [DateTime]$_ResourceEntitlementStatus.offerEndDate, + $_ResourceEntitlementStatus.countryCode, + $_ResourceEntitlementStatus.obligationType, + $_ResourceEntitlementStatus.entitlementKey, + $_ResourceEntitlementStatus.obligationId, + $_ResourceEntitlementStatus.coversHolidays, + $_ResourceEntitlementStatus.isEntitled, + $_ResourceEntitlementStatus.responseTimeHolidays, + $_ResourceEntitlementStatus.explanation, + $_resourceEntitlementStatus.ApplianceConnection + ) + + } + + else + { + + "[{0}] Remote Support is disabled for the resource, returning ." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_EntitlementStatus = [HPEOneView.RemoteSupport.ContractAndWarrantyStatus]::new($_ResourceName, + $_Uri, + $_Resource.serialNumber, + $false, + 'INVALID', + $_Resource.ApplianceConnection + ) + + } + + $_EntitlementStatus + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Update-OVRemoteSupportEntitlement +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + # AllDevices is the default set name. Looking into why /RefreshState isn't a valid PATCH op + [CmdLetBinding (DefaultParameterSetName = "AllDevices")] + Param + ( + + # [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = "default")] + # [ValidateNotNullOrEmpty()] + # [Object]$InputObject, + + # [Parameter (Mandatory, ParameterSetName = "AllDevices")] + # [Switch]$AllDevices, + + # [Parameter (Mandatory = $false, ParameterSetName = "default")] + [Parameter (Mandatory = $false, ParameterSetName = "AllDevices")] + [Switch]$Async, + + # [Parameter (ValueFromPipelineByPropertyName, Mandatory = $false, ParameterSetName = "default")] + [Parameter (ValueFromPipelineByPropertyName, Mandatory = $false, ParameterSetName = "AllDevices")] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + "[{0}] Bound PS Parameters: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), ($PSBoundParameters | out-string) | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not $PSBoundParameters['InputObject']) + { + + $PipelineInput = $True + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -gt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + } + + Process + { + + $_OperationSplat = @{ + Method = "PATCH"; + Uri = $null + } + + if ($PSCmdlet.ParameterSetName = 'AllDevices') + { + + $_OperationSplat.Method = "POST" + $_OperationSplat.Uri = $RemoteSupportRefreshAllDeviceEntitlementUri + + } + + else + { + + $_Operation = NewObject -PatchOperation + $_Operation.op = 'replace' + $_Operation.path = '/refreshState' + $_Operation.value = "RefreshPending" + + [void]$_OperationSplat.Add("Body", $_Operation) + + switch ($InputObject.category) + { + + $ResourceCategoryEnum.ServerHardware + { + + $_OperationSplat.Uri = '{0}/{1}' -f $RemoteSupportComputeSettingsUri, $InputObject.uuid + + } + + $ResourceCategoryEnum.Enclosure + { + + $_OperationSplat.Uri = '{0}/{1}' -f $RemoteSupportEnclosureSettingsUri, $InputObject.uuid + + } + + $ResourceCategoryEnum.Interconnect + { + + $_OperationSplat.Uri = '{0}/{1}' -f $RemoteSupportEnclosureSettingsUri, $InputObject.uri.Split('/')[-1] + + } + + $ResourceCategoryEnum.RackManager + { + + $_OperationSplat.Uri = '{0}/{1}' -f $RemoteSupportRackManagerSettingsUri, $InputObject.uri.Split('/')[-1] + + } + + default + { + + # Unsupported + $ExceptionMessage = 'The {0} input object is an unsupported resource category type, "{1}". Only "server-hardware" or "enclosure" resources are supported.' -f $InputObject.category, $InputObject.name + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.RemoteSupportResourceException InvalidResourceObject InvalidArgument "InputObject" -TargetType 'PSObject' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + } + + try + { + + $_Resp = Send-OVRequest @_OperationSplat -Hostname $ApplianceConnection + + } + + catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if ($PSBoundParameters['Async']) + { + + $_Resp + + } + + else + { + + Try + { + + $_Resp | Wait-OVTaskComplete + + } + + Catch + { + + $PSCmdlet.ThrowTerninatingError($_) + + } + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Get-OVRemoteSupportDefaultSite +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding ()] + Param + ( + + [Parameter (Mandatory = $false)] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $_connection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $_connection -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $defaultSiteCollection = [System.Collections.ArrayList]::new() + + } + + Process + { + + ForEach($_Connection in $ApplianceConnection) + { + + Try + { + + $_defaultSite = Send-OVRequest $RemoteSupportDefaultSitesUri -appliance $_Connection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $_defaultSite.PSObject.TypeNames.Insert(0,'HPEOneview.Appliance.RemoteSupport.DefaultSite') + + [void]$defaultSiteCollection.Add($_defaultSite) + + } + + } + + End + { + + return $defaultSiteCollection + + } + +} + +function Set-OVRemoteSupportDefaultSite +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "Default" )] + Param + ( + + [Parameter (Mandatory, ParameterSetName = "Default")] + [ValidateNotNullorEmpty()] + [Alias ('a1')] + [String]$AddressLine1, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [ValidateNotNullorEmpty()] + [Alias ('a2')] + [String]$AddressLine2, + + [Parameter (Mandatory, ParameterSetName = "Default")] + [ValidateNotNullorEmpty()] + [String]$City, + + [Parameter (Mandatory, ParameterSetName = "Default")] + [ValidateNotNullorEmpty()] + [Alias ('Province')] + [String]$State, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [ValidateNotNullorEmpty()] + [String]$PostalCode, + + [Parameter (Mandatory, ParameterSetName = "Default")] + [ValidateNotNullorEmpty()] + [String]$Country, + + [Parameter (Mandatory, ParameterSetName = "Default")] + [ValidateNotNullorEmpty()] + [String]$TimeZone, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $_connection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $_connection -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $defaultSiteCollection = [System.Collections.ArrayList]::new() + + } + + Process + { + + ForEach($_Connection in $ApplianceConnection) + { + + Try + { + + $_DefaultSite = Send-OVRequest -uri $RemoteSupportDefaultSitesUri -Hostname $_Connection + $_method = 'PUT' + $_uri = $_DefaultSite.uri + + + } + + Catch + { + + if ([RegEx]::Match($_.FullyQualifiedErrorId, 'ResourceNotFound', $RegExInsensitiveFlag).Success) + { + + $_method = 'POST' + $_uri = $RemoteSupportDefaultSitesUri + $_DefaultSite = NewObject -RemoteSupportSite + + } + + else + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $_DefaultSite.streetAddress1 = $AddressLine1 + if ($PSBoundParameters['AddressLine2']) { $_DefaultSite.streetAddress2 = $AddressLine2 } + $_DefaultSite.city = $City + $_DefaultSite.provinceState = $State + $_DefaultSite.countryCode = $Country + if ($PSBoundParameters['PostalCode']) { $_DefaultSite.postalCode = $PostalCode } + $_DefaultSite.timeZone = $TimeZone + + Try + { + + $_resp = Send-OVRequest -method $_method -uri $_uri -Body $_defaultSite -Hostname $_Connection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $_resp.PSObject.TypeNames.Insert(0,'HPEOneview.Appliance.RemoteSupport.DefaultSite') + + $_resp + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Test-OVRemoteSupportEvent +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "Default" )] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = "Default")] + [ValidateNotNullorEmpty()] + [Object]$InputObject, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [ValidateNotNullorEmpty()] + [Switch]$CreateTestCase, + + [Parameter (Mandatory = $false)] + [Switch]$Async, + + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = "Default")] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + Process + { + + if ($InputObject.category -ne $ResourceCategoryEnum.ServerHardware) + { + + + $ExceptionMessage = "The specified '{0}' InputObject parameter value is not supported. Only server hardware is supported." -f $InputObject.name + $ErrorRecord = New-ErrorRecord HPEOneView.InputObjectResourceException InvalidInputObjectResource InvalidArgument "InputObject" -TargetType $InputObject.GetType().Name -Message $ExceptionMessage + $PSCmdlet.WriteError($ErrorRecord) + + } + + else + { + + $_NewTestEvent = NewObject -RemoteSupportTestEvent + + $_NewTestEvent.createCase = $PSBoundParameters['CreateTestCase'].IsPresent + + $_uri = "{0}?deviceID={1}&category={2}" -f $RemoteSupportEventsUri, $InputObject.uuid, $InputObject.category + + Write-Warning "Requesting a test event may take up to 20 minutes and will send data back to Hewlett Packard Enterprise." + + Try + { + + $_TaskResponse = Send-OVRequest -Uri $_uri -Method POST -Body $_NewTestEvent -Appliance $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if (-not $PSBoundParameters['Async']) + { + + $_TaskResponse = Wait-OVTaskComplete -InputObject $_TaskResponse + + } + + $_TaskResponse + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Get-OVBaseline +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "ISOFileName" )] + Param + ( + + [Parameter (Mandatory = $false, ParameterSetName = "ISOFileName")] + [ValidateNotNullOrEmpty()] + [Alias ('isoFileName','FileName')] + [Object]$File, + + [Parameter (Mandatory, ParameterSetName = "BaselineName")] + [Alias ('name')] + [ValidateNotNullOrEmpty()] + [String]$SppName, + + [Parameter (Mandatory = $false, ParameterSetName = "BaselineName")] + [ValidateNotNullOrEmpty()] + [String]$Version, + + [Parameter (Mandatory = $false, ParameterSetName = "HotFixesOnly")] + [Switch]$HotfixesOnly, + + [Parameter (Mandatory = $false, ParameterSetName = "ISOFileName")] + [Parameter (Mandatory = $false, ParameterSetName = "BaselineName")] + [Parameter (Mandatory = $false, ParameterSetName = "HotFixesOnly")] + [ValidateNotNullOrEmpty()] + [Object]$Scope = "AllResourcesInScope", + + [Parameter (Mandatory = $false, ParameterSetName = "ISOFileName")] + [Parameter (Mandatory = $false, ParameterSetName = "BaselineName")] + [Parameter (Mandatory = $false, ParameterSetName = "HotFixesOnly")] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $BaselineCollection = [System.Collections.ArrayList]::new() + + } + + Process + { + + ForEach($_Connection in $ApplianceConnection) + { + + $_Query = [System.Collections.ArrayList]::new() + + # Handle default cause of AllResourcesInScope + if ($Scope -eq 'AllResourcesInScope') + { + + "[{0}] Processing AllResourcesInScope." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_Scopes = $_Connection.ActivePermissions | Where-Object Active + + # If one scope contains 'AllResources' ScopeName "tag", then all resources should be returned regardless. + if ($_Scopes | Where-Object ScopeName -eq 'AllResources') + { + + $_ScopeNames = [String]::Join(', ', ($_Scopes | Where-Object ScopeName -eq 'AllResources').ScopeName) + + "[{0}] Scope(s) {1} is set to 'AllResources'. Will not add scope to URI query parameter." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_ScopeNames | Write-Verbose + + } + + # Process ApplianceConnection ActivePermissions collection + else + { + + Try + { + + $_ScopeQuery = Join-Scope $_Scopes + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + [Void]$_Query.Add(("({0})" -f $_ScopeQuery)) + + } + + } + + elseif ($Scope | Where-Object ScopeName -eq 'AllResources') + { + + $_ScopeNames = [String]::Join(', ', ($_Scopes | Where-Object ScopeName -eq 'AllResources').ScopeName) + + "[{0}] Scope(s) {1} is set to 'AllResources'. Will not add scope to URI query parameter." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_ScopeNames | Write-Verbose + + } + + elseif ($Scope -eq 'AllResources') + { + + "[{0}] Requesting scope 'AllResources'. Will not add scope to URI query parameter." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_ScopeNames | Write-Verbose + + } + + else + { + + Try + { + + $_ScopeQuery = Join-Scope $Scope + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + [Void]$_Query.Add(("({0})" -f $_ScopeQuery)) + + } + + switch ($PSCmdlet.ParameterSetName) + { + + "BaselineName" + { + + "[{0}] SppName Parameter provided: $($SppName)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if ($SppName.Contains('*')) + { + + [Void]$_Query.Add(("fwbaseline_name%3A{0}" -f $SppName.Replace("*", "%2A"))) + + } + + else + { + + [Void]$_Query.Add(("fwbaseline_name:'{0}'" -f $SppName)) + + } + + if ($Version) + { + + "[{0}] Version Parameter provided: $($version)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + [Void]$_Query.Add(("fwbaseline_version:'{0}'" -f $Version)) + + } + + } + + "ISOFileName" + { + + if ($File) + { + + if ($File.EndsWith('.exe') -or $File.EndsWith('.scexe') -or $File.EndsWith('.rpm') -or $File.EndsWith('.zip') -or $File.EndsWith('.fwpkg')) + { + + "[{0}] Looking for hotfix file" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if ($File.Contains('*')) + { + + [Void]$_Query.Add(("fwbaseline_fileName%3A{0}" -f $File.Replace("*", "%2A"))) + + } + + else + { + + [Void]$_Query.Add(("fwbaseline_fileName:'{0}'" -f $File)) + + } + + } + + else + { + + "[{0}] Looking for Baseline ISO file" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not $File.EndsWith('iso')) + { + + $File += '.iso' + + } + + # Replace any preceeding period with an underscore. + $_File = [RegEx]::Replace($File, '\.(?!iso|exe|scexe|rpm|zip)', '_') + + if ($_File.Contains('*')) + { + + [Void]$_Query.Add(("fwbaseline_isoFileName%3A{0}" -f $_File.Replace("*", "%2A"))) + + } + + else + { + + [Void]$_Query.Add(("fwbaseline_isoFileName:'{0}'" -f $_File)) + + } + + } + + } + + } + + 'HotfixesOnly' + { + + [Void]$_Query.Add("fwbaseline_bundleType:Hotfix") + + } + + default + { + + "[{0}] No Parameter provided. Looking for all SPP Baselines." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + } + + # Build the final URI + $_uri = '{0}?category=firmware-drivers&sort=name:asc&query={1}' -f $IndexUri, [String]::Join(' AND ', $_Query.ToArray()) + + Try + { + + $_BundlesFromIndexCol = Get-AllIndexResources -Uri $_uri -ApplianceConnection $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if (-not $_BundlesFromIndexCol) + { + + if ($PSBoundParameters['File']) + { + + $ExceptionMessage = "The Baseline resource name '{0}' was not found on '{1}' appliance." -f $File, $_Connection.Name + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.BaselineResourceException BaselineResourceNotFound ObjectNotFound 'File' -Message $ExceptionMessage + $PSCmdlet.WriteError($ErrorRecord) + + } + + elseif ($PSBoundParameters['SppName'] -and -not $PSBoundParameters['Version']) + { + + $ExceptionMessage = "The Baseline name '{0}' was not found on '{1}' appliance." -f $SppName, $_Connection.Name + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.BaselineResourceException BaselineResourceNotFound ObjectNotFound 'SppName' -Message $ExceptionMessage + $PSCmdlet.WriteError($ErrorRecord) + + } + + elseif ($PSBoundParameters['Version']) + { + + $ExceptionMessage = "The Baseline name '{0}' version '{1}' was not found on '{2}' appliance." -f $SppName, $Version, $_Connection.Name + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.BaselineResourceException BaselineResourceNotFound ObjectNotFound 'SppName' -Message $ExceptionMessage + $PSCmdlet.WriteError($ErrorRecord) + + } + + } + + # foreach ($_baseline in $_baselines.members) + foreach ($_baseline in $_BundlesFromIndexCol) + { + + # Inject repository location as a property, should not cause issues with other API calls with the resource + # $_Locations = [System.Collections.ArrayList]::new() + $_Locations = [System.Collections.Generic.List[String]]::new() + + ForEach ($_Location in ($_baseline.locations.PSObject.Members | Where-Object { $_.MemberType -eq 'NoteProperty'})) + { + + [void]$_Locations.Add($_Location.Value) + + } + + # $_baseline.locations = [String]::Join(', ', $_Locations.ToArray()) + + $_FwComponentsList = [System.Collections.Generic.List[HPEOneView.Appliance.Baseline+FwComponent]]::new() + + ForEach ($_Component in $_baseline.fwComponents) + { + + if ($_baseline.state -eq 'AddFailed') + { + + $_ComponentVersion = "0.0" + + } + + else + { + + $_ComponentVersion = $_Component.componentVersion + + } + + $_FwComponentsList.Add(([HPEOneView.Appliance.Baseline+FwComponent]::new($_Component.name, + $_ComponentVersion, + $_Component.fileName, + $_Component.swKeyNameList))) + + } + + $_HotFixes = [System.Collections.Generic.List[HPEOneView.Appliance.Baseline+Hotfix]]::new() + + ForEach ($_Hotfix in $_baseline.hotfixes) + { + + if ($_baseline.state -eq 'AddFailed') + { + + $_ReleaseDate = "01/01/1900" + + } + + else + { + + $_ReleaseDate = $_Hotfix.releaseDate + + } + + $_HotFixes.Add(([HPEOneView.Appliance.Baseline+HotFix]::new($_Hotfix.hotfixName, + $_ReleaseDate, + $_Hotfix.resourceId))) + } + + $_ParentBundle = $null + + if ($null -ne $_baseline.parentBundle) + { + + if ($_baseline.state -eq 'AddFailed') + { + + $_ReleaseDate = "01/01/1900" + $_Version = "0.0" + + } + + else + { + + $_ReleaseDate = $_baseline.parentBundle.releaseDate + $_Version = $_baseline.parentBundle.version + + } + + $_ParentBundle = [HPEOneView.Appliance.Baseline+ParentBaseline]::new($_baseline.parentBundle.parentBundleName, + $_ReleaseDate, + $_Version) + + } + + $_SupportedOsList = [System.Collections.Generic.List[String]]::new() + + ForEach ($_SupportedOS in $_baseline.supportedOSList) + { + + $_SupportedOsList.Add($_SupportedOS) + + } + + switch ($_baseline.bundleType) + { + + {'Custom', 'SPP', 'ServicePack' -contains $_} + { + + if ($_baseline.state -eq 'AddFailed') + { + + $_ReleaseDate = "01/01/1900" + $_Version = '0.0' + + } + + else + { + + $_ReleaseDate = $_baseline.releaseDate + $_Version = $_baseline.version + + } + + [HPEOneView.Appliance.Baseline]::new($_baseline.name, + $_baseline.description, + $_baseline.status, + $_Version, + $_ReleaseDate, + $_baseline.bundleType, + $_baseline.bundleSize, + $_baseline.resourceId, + $_baseline.uuid, + $_baseline.xmlKeyName, + $_baseline.isoFileName, + $_baseline.baselineShortName, + $_SupportedOsList, + $_baseline.supportedLanguages, + $_FwComponentsList, + $_baseline.state, + $_baseline.hpsumVersion, + $_ParentBundle, + $_HotFixes, + $_Locations, + $null, + $_baseline.uri, + $_baseline.eTag, + $_baseline.created, + $_baseline.modified, + $_baseline.resourceState, + $_baseline.scopesUri, + $_baseline.applianceConnection) + + } + + 'Hotfix' + { + + if ($_baseline.state -eq 'AddFailed') + { + + $_ReleaseDate = "01/01/1900" + $_Version = '0.0' + + } + + else + { + + $_ReleaseDate = $_baseline.releaseDate + $_Version = $_baseline.version + + } + + [HPEOneView.Appliance.BaselineHotfix]::new($_baseline.name, + $_baseline.description, + $_baseline.status, + $_Version, + $_ReleaseDate, + $_baseline.bundleType, + $_baseline.bundleSize, + $_baseline.resourceId, + $_baseline.uuid, + $_baseline.xmlKeyName, + $_baseline.isoFileName, + $_baseline.baselineShortName, + $_SupportedOsList, + $_baseline.supportedLanguages, + $_FwComponentsList, + $_baseline.state, + $_baseline.hpsumVersion, + $_ParentBundle, + $_HotFixes, + $_Locations, + $null, + $_baseline.uri, + $_baseline.eTag, + $_baseline.created, + $_baseline.modified, + $_baseline.resourceState, + $_baseline.scopesUri, + $_baseline.applianceConnection, + $_baseline.signatureFileName) + + } + + } + + } + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Add-OVBaseline +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding ()] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline)] + [ValidateScript({Test-Path $_})] + [Alias ('sppFile')] + [Object]$File, + + [Parameter (Mandatory = $false)] + [ValidateScript({Test-Path $_})] + [Object]$CompSigFile, + + [Parameter (Mandatory = $false)] + [ValidateNotNullOrEmpty()] + [HPEOneView.Appliance.ScopeCollection]$Scope, + + [Parameter (Mandatory = $false)] + [Switch]$UseInvokeWebRequest, + + [Parameter (Mandatory = $false)] + [Switch]$Async, + + [Parameter (Mandatory = $false)] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not($PSBoundParameters['File'])) + { + + $PipelineInput = $True + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + $TaskCollection = [System.Collections.ArrayList]::new() + + } + + Process + { + + if (-not(Test-Path $File -PathType Leaf)) + { + + $ExceptionMessage = "The baseline file '{0}' was not found. Please check the path and filename." -f $File.Name + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.BaselineResourceException BaselineFileNotFound ObjectNotFound 'File' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + if ($File -isnot [System.IO.FileInfo]) + { + + $File = Get-ChildItem -Path $File + + } + + if ($PSBoundParameters['CompSigFile']) + { + + $_c = 0 + + ForEach ($_CompSigFile in $CompSigFile) + { + + if ($_CompSigFile -isnot [System.IO.FileInfo]) + { + + $CompSigFile[$_c] = Get-ChildItem -Path $_CompSigFile + + } + + if ($_CompSigFile.Length -le 0) + { + + $ExceptionMessage = "The CompSigFile resource '{0}' file size is 0." -f $_CompSigFile.Name + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.BaselineResourceException ResourceCannotBeZero InvalidArgument 'CompSigFile' -TargetType 'System.IO.FileInfo' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + $_c++ + + } + + } + + if ($File.Length -le 0) + { + + $ExceptionMessage = "The File resource '{0}' file size is 0." -f $File.Name + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.BaselineResourceException ResourceCannotBeZero InvalidArgument 'File' -TargetType 'System.IO.FileInfo' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + ForEach ($_appliance in $ApplianceConnection) + { + + $_BaselineExists = $null + + "[{0}] Processing Appliance $($_appliance.Name)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + # Check if the Baseline exists already, instead of waiting for filetransfer to finish + "[{0}] Checking if Baseline exists" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $_BaselineExists = Get-OVBaseline -FileName ($File.BaseName.Replace('.','_') + $File.Extension) -ApplianceConnection $_appliance -ErrorAction SilentlyContinue + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if (-not $_BaselineExists) + { + + # Start upload file + Try + { + + $_Params = @{ + URI = $ApplianceFwBundlesUri; + File = $File.FullName; + ApplianceConnection = $_appliance + } + + if ($PSBoundParameters['Scope']) + { + + $_sb = [System.Collections.ArrayList]::new() + + ForEach ($_Scope in $Scope) + { + + "[{0}] Adding resource to Scope: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_Scope.Name | Write-Verbose + + [void]$_sb.Add($_Scope.Uri) + + } + + $_ScopeHttpHeader = @{'initialScopeUris' = [String]::Join(', ', $_sb.ToArray())} + + $_Params.Add('AddHeader', $_ScopeHttpHeader) + + } + + if ($PSBoundParameters['UseInvokeWebRequest'] -and -not $PSBoundParameters['CompSigFile']) + { + + Write-Warning "Using the -UseInvokeWebRequest switch parameter will not display progress. Please wait while the baseline file is uploaded..." + + Try + { + + $FieldName = 'file' + $ContentType = 'application/octet-stream' + + $FileStream = [System.IO.FileStream]::new($File, [System.IO.FileMode]::Open) + $FileHeader = [System.Net.Http.Headers.ContentDispositionHeaderValue]::new('form-data') + $FileHeader.Name = $FieldName + $FileHeader.FileName = $File.FullName + $FileContent = [System.Net.Http.StreamContent]::new($FileStream) + $FileContent.Headers.ContentDisposition = $FileHeader + $FileContent.Headers.ContentType = [System.Net.Http.Headers.MediaTypeHeaderValue]::Parse($ContentType) + $MultipartContent = [System.Net.Http.MultipartFormDataContent]::new() + $MultipartContent.Add($FileContent) + + # Add the headers, which do not belong in the FileContent object + $Headers = @{ + "auth" = $_appliance.SessionID; + "X-API-Version" = 3800; + "uploadfilename" = $File.Name + } + + $_Uri = "https://{0}{1}" -f $_appliance, $ApplianceFwBundlesUri + + $_UploadResp = Invoke-WebRequest -Body $MultipartContent -Method 'POST' -Uri $_Uri -Headers $Headers -ConnectionTimeoutSeconds 1200000 -SkipCertificateCheck + + if ($_UploadResp.StatusCode -ne 202) + { + + $ExceptionMessage = "The file upload operation failed with a status code of {0}, and exception message {1}" -f $_UploadResp.StatusCode, $_UploadResp.Content + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.BaselineResourceException InvalidFileUploadOperation InvalidOperation 'File' -TargetType 'System.IO.FileInfo' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + $AddTask = Send-OVRequest -Uri $_UploadResp.Headers['Location'][0] -ApplianceConnection $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + else + { + + Try + { + + $AddTask = Upload-File @_Params + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + if ((-not $PSBoundParameters['Async'] -and $PSBoundParameters['CompSigFile']) -or (-not $PSBoundParameters['Async'])) + { + + "[{0}] Response is a task resource, calling Wait-OVTaskComplete" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $AddTask = $AddTask | Wait-OVTaskComplete + + } + + if ($PSBoundParameters['CompSigFile']) + { + + ForEach ($_CompSigFile in $CompSigFile) + { + + "[{0}] Adding CompSig file to appliance: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_CompSigFile.Name | Write-Verbose + + $uploadCompSigTask = Upload-File -Uri ($ApplianceFwCompSigUri -f $_CompSigFile.Name) -File $_CompSigFile.FullName -ApplianceConnection $_appliance + + if ($uploadCompSigTask.tastState -eq 'Error') + { + + $ExceptionMessage = "{0}" -f $uploadCompSigTask.taskErrors.message + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.BaselineResourceException InvalidCompSigFileUploadOperation InvalidOperation 'CompSigFile' -TargetType 'System.IO.FileInfo' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + } + + $AddTask + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + elseif ($_BaselineExists) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.BaselineResourceException BaselineResourceAlreadyExists ResourceExists 'File' -Message ("The Baseline '{0}' is already present on the appliance. Please upload a different baseline." -f $File.Name) + $PSCmdlet.WriteError($ErrorRecord) + + } + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Save-OVBaseline +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding ()] + Param + ( + + [Parameter (Mandatory)] + [ValidateNotNullOrEmpty()] + [Object]$InputObject, + + [Parameter (Mandatory)] + [ValidateScript ({Test-Path $_})] + [System.IO.FileSystem]$Path, + + [Parameter (Mandatory = $false)] + [ValidateNotNullOrEmpty()] + [HPEOneView.Appliance.ScopeCollection[]]$Scope, + + [Parameter (Mandatory = $false)] + [Switch]$Async, + + [Parameter (Mandatory = $false)] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not($PSBoundParameters['File'])) + { + + $PipelineInput = $True + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + $TaskCollection = [System.Collections.ArrayList]::new() + + } + + Process + { + + if (-not(Test-Path $File -PathType Leaf)) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.BaselineResourceException BaselineFileNotFound ObjectNotFound 'File' -Message ("The baseline file '{0}' was not found. Please check the path and filename." -f $File.Name) + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + if ($File -isnot [System.IO.FileInfo]) + { + + $File = Get-ChildItem -Path $File + + } + + if ($File.Length -le 0) + { + + $ExceptionMessage = ("The File resource '{0}' file size is 0." -f $File.Name) + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.BaselineResourceException ResourceCannotBeZero InvalidArgument 'File' -TargetType 'System.IO.FileInfo' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + ForEach ($_appliance in $ApplianceConnection) + { + + $_BaselineExists = $null + + "[{0}] Processing Appliance $($_appliance.Name)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + # Check if the Baseline exists already, instead of waiting for filetransfer to finish + "[{0}] Checking if Baseline exists" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $_BaselineExists = Get-OVBaseline -FileName ($File.BaseName.Replace('.','_') + $File.Extension) -ApplianceConnection $_appliance -ErrorAction SilentlyContinue + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if (-not $_BaselineExists) + { + + # Start upload file + Try + { + + $_Params = @{ + URI = $ApplianceFwBundlesUri; + File = $File.FullName; + ApplianceConnection = $_appliance + } + + if ($PSBoundParameters['Scope']) + { + + $_sb = [System.Collections.ArrayList]::new() + + ForEach ($_Scope in $Scope) + { + + "[{0}] Adding resource to Scope: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_Scope.Name | Write-Verbose + + [void]$_sb.Add($_Scope.Uri) + + } + + $_ScopeHttpHeader = @{'initialScopeUris' = [String]::Join(', ', $_sb.ToArray())} + + $_Params.Add('AddHeader', $_ScopeHttpHeader) + + } + + $task = Upload-File @_Params + + if (-not($PSBoundParameters['Async'])) + { + + "[{0}] Response is a task resource, calling Wait-OVTaskComplete" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $task = $task | Wait-OVTaskComplete + + } + + $Task + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + elseif ($_BaselineExists) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.BaselineResourceException BaselineResourceAlreadyExists ResourceExists 'File' -Message ("The Baseline '{0}' is already present on the appliance. Please upload a different baseline." -f $File.Name) + $PSCmdlet.WriteError($ErrorRecord) + + } + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function New-OVCustomBaseline +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding ()] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline)] + [ValidateNotNullorEmpty()] + [Object]$SourceBaseline, + + [Parameter (Mandatory)] + [Array]$Hotfixes, + + [Parameter (Mandatory)] + [String]$BaselineName, + + [Parameter (Mandatory = $false)] + [Switch]$Async, + + [Parameter (Mandatory = $false)] + [ValidateNotNullOrEmpty()] + [HPEOneView.Appliance.ScopeCollection[]]$Scope, + + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName)] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not($PSBoundParameters['SourceBaseline'])) + { + + $PipelineInput = $True + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + $TaskCollection = [System.Collections.ArrayList]::new() + + } + + Process + { + + $_CustomBaseline = NewObject -CustomBaseline + + # Validate Source Baseline + switch ($SourceBaseline.GetType().Name) + { + + 'PSCustomObject' + { + + if ($SourceBaseline.category -ne $ResourceCategoryEnum.Baseline) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.BaselineResourceException InvalidBaselineResource InvalidArgument 'SourceBaseline' -TargetType 'PSObject' -Message "The provided SourceBaseline object is not the required category, 'firmware-drivers'. Please correct the input Parameter." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + "[{0}] Baseline Object Provided" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + "[{0}] Baseline Name: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $SourceBaseline.shortName | Write-Verbose + "[{0}] Baseline URI: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $SourceBaseline.uri | Write-Verbose + + } + + 'String' + { + + "[{0}] Baseline Name Provided: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(),$SourceBaseline | Write-Verbose + + # Get Source Baseline from Baseline Name + Try + { + + $BaselineParamName = $SourceBaseline.Clone() + $SourceBaseline = Get-OVBaseline -SppName $SourceBaseline -ApplianceConnection $ApplianceConnection -ErrorAction SilentlyContinue + + If (-not $SourceBaseline) + { + + $ExceptionMessage = "The provided SourceBaseline '{0}' was not found." -f $BaselineParamName + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.BaselineResourceException BaselineResourceNotFound ObjectNotFound 'SourceBaseline' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + # Loop through Hotfixes + ForEach ($_HotFix in $Hotfixes) + { + + switch ($_HotFix.GetType().Name) + { + + 'PSCustomObject' + { + + if ($_HotFix.category -ne $ResourceCategoryEnum.Baseline -and $_HotFix.bundleType -ne 'Hotfix') + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.BaselineResourceException InvalidBaselineResource InvalidArgument 'Hotfixes' -TargetType 'PSObject' -Message "The provided Hotfix object is not the required category and type. Only 'firmware-drivers' category and 'Hotfix' type are allowed. Please correct the input Parameter." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + "[{0}] Hotfix baseline object provided" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + "[{0}] Hotfix baseline Name: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(),$_HotFix.shortName | Write-Verbose + "[{0}] Hotfix baseline URI: {1}" -f $MyInvocation.InvocationName.ToString(),$_HotFix.uri | Write-Verbose + + } + + 'String' + { + + "[{0}] Hotfix Name Provided: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_HotFix | Write-Verbose + + # Get Source Baseline from Baseline Name + Try + { + + $_HotFixName = $_HotFix.Clone() + $_HotFix = Get-OVBaseline -File $_HotFix -ApplianceConnection $ApplianceConnection -ErrorAction SilentlyContinue + + If (-not $_HotFix) + { + + $ExceptionMessage = "The provided Hotfix '{0}' was not found." -f $_HotFixName + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.BaselineResourceException BaselineResourceNotFound ObjectNotFound 'Hotfixes' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + [void]$_CustomBaseline.hotfixUris.Add($_HotFix.uri) + + } + + $_CustomBaseline.baselineUri = $SourceBaseline.uri + $_CustomBaseline.customBaselineName = $BaselineName + + $_Params = @{ + URI = $ApplianceFwBundlesUri; + Method = 'POST'; + Body = $_CustomBaseline; + Hostname = $ApplianceConnection.Name + } + + if ($PSBoundParameters['Scope']) + { + + $_sb = [System.Collections.ArrayList]::new() + + ForEach ($_Scope in $Scope) + { + + "[{0}] Adding to Scope: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_Scope.Name | Write-Verbose + + [void]$_sb.Add($_Scope.Uri) + + } + + $_ScopeHttpHeader = @{'initialScopeUris' = [String]::Join(', ', $_sb.ToArray())} + + $_Params.Add('AddHeader', $_ScopeHttpHeader) + + } + + # Post the new object to the appliance + Try + { + + $_Resp = Send-OVRequest -Uri $ApplianceFwDriversUri -Method POST -Body $_CustomBaseline -Hostname $ApplianceConnection.Name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if (-not($PSBoundParameters['Async'])) + { + + $_Resp | Wait-OVTaskComplete + + } + + else + { + + $_Resp + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString() | Write-Verbose + + } + +} + +function Restore-OVCustomBaseline +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding ()] + Param + ( + + [Parameter (Mandatory = $False)] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $_TaskCollection = [System.Collections.ArrayList]::new() + $_BaselineCollection = [System.Collections.ArrayList]::new() + + } + + Process + { + + ForEach ($_appliance in $ApplianceConnection) + { + + "[{0}] Processing Appliance $($_appliance.Name) (of $($ApplianceConnection.Count))" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + "[{0}] Getting all baseline resources" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $_baselineresources = Send-OVRequest $ApplianceFwBundlesUri -Hostname $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + foreach ($_baseline in ($_baselineresources.members | Where-Object bundleType -eq 'Custom' -and state -eq 'Removed')) + { + + $_CustomBaselineRestore = NewObject -CustomBaselineRestore + + $_CustomBaselineRestore.baselineUri = $_baseline.uri + $_CustomBaselineRestore.customBaselineName = $_baseline.name + + "[{0}] Looking up Associations for '$($_baseline.name) [$($_baseline.uuid)]' custom baseline." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + $_uri = '{0}?parentUri={1}' -f $AssociationsUri, $_baseline.uri + + $_baselineassociations = Send-OVRequest -Uri $_uri -Hostname $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + foreach ($_association in $_baselineassociations.members) + { + + "[{0}] Adding '$($_association.childUri)' to object collection." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + [void]$_CustomBaselineRestore.hotfixUris.Add($_association.childUri) + + } + + "[{0}] Sending request to recreate '$_CustomBaselineRestore.customBaselineName' custom baseline." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $_resp = Send-OVRequest -Uri $ApplianceFwBundlesUri -Body $_CustomBaselineRestore -Hostname $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + [void]$_TaskCollection.Add($_resp) + + } + + } + + } + + End + { + + "[{0}] done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Return $_TaskCollection + + } + + +} + +function Remove-OVBaseline +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "default", SupportsShouldProcess, ConfirmImpact = 'High')] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline)] + [ValidateNotNullOrEmpty()] + [Alias ("b",'Baseline')] + [Object]$InputObject, + + [Parameter (Mandatory = $false, ValueFromPipeline)] + [Switch]$Force, + + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName)] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not($PSBoundParameters['InputObject'])) + { + + $PipelineInput = $True + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + } + + Process + { + + if ($PipelineInput -or $InputObject -is [PSCustomObject]) + { + + "[{0}] Processing Pipeline input" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + "[{0}] Baseline provided: {1} ({2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject.Name, $InputObject.uri | Write-Verbose + + If ($InputObject.category -eq $ResourceCategoryEnum.Baseline) + { + + If (-not($InputObject.ApplianceConnection)) + { + + $ExceptionMessage = "The Baseline resource provided is missing the source ApplianceConnection property. Please check the object provided and try again." + $ErrorRecord = New-ErrorRecord InvalidOperationException InvalidArgumentValue InvalidArgument "InputObject:$($InputObject.Name)" -TargetType PSObject -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + elseif ($InputObject -is [PSCustomObject] -and $InputObject.category -ne $ResourceCategoryEnum.Baseline) + { + + $ExceptionMessage = "The Baseline resource is not an expected category type [{0}]. Allowed resource category type is '{01}'. Please check the object provided and try again." -f $InputObject.category, $ResourceCategoryEnum.Baseline + $ErrorRecord = New-ErrorRecord InvalidOperationException InvalidArgumentValue InvalidArgument "InputObject:$($InputObject.Name)" -TargetType PSObject -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + if ($PSCmdlet.ShouldProcess($InputObject.ApplianceConnection, ("remove baseline '{0}'" -f $InputObject.Name))) + { + + "[{0}] Removing Baseline '{1}' from appliance '{2}'." -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject.name, $InputObject.ApplianceConnection | Write-Verbose + + $_Uri = $InputObject.Uri.ToString() + + if ($Force) + { + + $_Uri += '?force=true' + + } + + Try + { + + Send-OVRequest -Uri $_Uri -Method DELETE -Hostname $InputObject.ApplianceConnection -AddHeader @{'If-Match' = $InputObject.eTag } + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + elseif ($PSBoundParameters['WhatIf']) + { + + "[{0}] WhatIf Parameter was passed." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Get-OVBaselineRepository +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding ()] + Param + ( + + [Parameter (Mandatory = $False)] + [ValidateNotNullOrEmpty()] + [String]$Name, + + [Parameter (Mandatory = $False)] + [ValidateSet ('Internal', 'External')] + [String]$Type, + + [Parameter (Mandatory = $False)] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + Process + { + + ForEach ($_appliance in $ApplianceConnection) + { + + "[{0}] Processing Appliance {1} (of {2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name, $ApplianceConnection.Count | Write-Verbose + + "[{0}] Getting baseline repo information resources" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_Uri = '{0}?sort=name:asc' -f $ApplianceRepositoriesUri + + if ($Name) + { + + $_Uri += "&filter=name EQ '{0}'" -f $Name + + } + + if ($Type) + { + + $_Uri += "&filter=repositoryType EQ '{0}'" -f $RepositoryType[$Type] + + } + + Try + { + + $_BaselineRepos = Send-OVRequest -Uri $_Uri -Hostname $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if ($Name -and $_BaselineRepos.Count -eq 0) + { + + $ExceptionMessage = "The specified '{0}' baseline repository resource was not found on '{1}' appliance connection. Please check the name and try again." -f $Name, $_appliance.Name + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.BaselineRepositoryResourceException BaselineRepositoryResourceNotFound ObjectNotFound "Name" -Message $ExceptionMessage + $PSCmdlet.WriteError($ErrorRecord) + + } + + else + { + + ForEach ($_RepoEntry in $_BaselineRepos.members) + { + + $_RepoEntry.PSObject.TypeNames.Insert(0,'HPEOneview.Appliance.BaselineRepository') + + $_RepoEntry + + } + + } + + } + + } + + End + { + + "[{0}] done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function New-OVExternalRepository +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdLetBinding (DefaultParameterSetName = 'Default')] + Param + ( + + [Parameter (Mandatory, ParameterSetName = 'Default')] + [Parameter (Mandatory, ParameterSetName = 'PSCredentials')] + [ValidateNotNullorEmpty()] + [String]$Name, + + [Parameter (Mandatory, ParameterSetName = 'Default')] + [Parameter (Mandatory, ParameterSetName = 'PSCredentials')] + [String]$Hostname, + + [Parameter (Mandatory, ParameterSetName = 'Default')] + [Parameter (Mandatory, ParameterSetName = 'PSCredentials')] + [String]$Directory, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [Parameter (Mandatory = $false, ParameterSetName = 'PSCredentials')] + [String]$NFSPath, + + [Parameter (Mandatory, ParameterSetName = 'PSCredentials')] + [PSCredential]$Credential, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [String]$Username, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [SecureString]$Password, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [Parameter (Mandatory = $false, ParameterSetName = 'PSCredentials')] + [Switch]$Http, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [Parameter (Mandatory = $false, ParameterSetName = 'PSCredentials')] + [String]$Certificate, + + [Parameter (Mandatory = $false,ParameterSetName = 'Default')] + [Parameter (Mandatory = $false,ParameterSetName = 'PSCredentials')] + [Switch]$Async, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [Parameter (Mandatory = $false, ParameterSetName = 'PSCredentials')] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + # Valiate NFSPath parameter + if ($PSBoundParameters['NFSPath'] -and -not $NFSPathRegEx.Match($NFSPath).Success) + { + + $ExceptionMessage = 'NFSPath parameter value "{0}" is not a valid NFS path. Please ensure the format follows "server:/path1" or "server.fqdn:/path".' -f $NFSPath + $ErrorRecord = New-ErrorRecord HPEOneView.Library.ParameterValidationException InvalidParameter InvalidArgument 'NFSPath' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + Process + { + + if (-not $PSBoundParameters['Password'] -and $PSBoundParameters['Username'] -and $PSCmdlet.ParameterSetName -eq 'Default') + { + + [SecureString]$Password = read-host -AsSecureString "Password" + $_DecryptPassword = [Runtime.InteropServices.Marshal]::PtrToStringBSTR([Runtime.InteropServices.Marshal]::SecureStringToBSTR($Password)) + + } + + elseif ($Password -is [SecureString] -and $PSCmdlet.ParameterSetName -eq 'Default') + { + + $_DecryptPassword = [Runtime.InteropServices.Marshal]::PtrToStringBSTR([Runtime.InteropServices.Marshal]::SecureStringToBSTR($Password)) + + } + + elseif ($PSCmdlet.ParameterSetName -eq 'Default') + { + + $_DecryptPassword = "$Password" + + } + + elseif ($PSBoundParameters['Credential']) + { + + $Username = $Credential.UserName + $_DecryptPassword = [Runtime.InteropServices.Marshal]::PtrToStringBSTR([Runtime.InteropServices.Marshal]::SecureStringToBSTR($Credential.Password)) + + } + + $_ExternalRepository = NewObject -ExternalRepository + + $_Protocol = 'https' + + if ($PSBoundParameters['Http']) + { + + "[{0}] Setting protocol to HTTP." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_Protocol = 'http' + + } + + if ($PSBoundParameters['Certificate']) + { + + # Validate the certificate, and that it isn't expired. + [Security.Cryptography.X509Certificates.X509Certificate2]$Cert = [System.Convert]::FromBase64String($Certificate.Replace('-----BEGIN CERTIFICATE-----',$null).Replace('-----END CERTIFICATE-----',$null)) + + $chain = [System.Security.Cryptography.X509Certificates.X509Chain]::new() + $chain.build($Cert) + + ForEach ($status in $chain.ChainStatus) + { + + "[{0}] Cert chain status: {1} ({2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $status.Status, $status.StatusInformation | Write-Verbose + + if ($status.Status -eq 'NotTimeValid') + { + + $ExceptionMessage = "The provided certificate is expired. The NotAfter property is '{0}'." -f $Cert.NotAfter + $ErrorRecord = New-ErrorRecord HPEOneView.Library.ParameterValidationException InvalidInputObjectParameter InvalidOperation 'Certificate' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + } + + if ($PSBoundParameters['NFSPath']) + { + + "[{0}] Adding NFSPath: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $NFSPath | Write-Verbose + + $_ExternalRepository.nfsFolderPath = $NFSPath + + } + + $_ExternalRepository.repositoryName = $Name + $_ExternalRepository.userName = $Username + $_ExternalRepository.password = $_DecryptPassword + $_ExternalRepository.repositoryURI = '{0}://{1}/{2}' -f $_Protocol, $Hostname, $Directory + $_ExternalRepository.base64Data = $Certificate + + # Post the new object to the appliance + Try + { + + $_Resp = Send-OVRequest -Uri $ApplianceRepositoriesUri -Method POST $_ExternalRepository -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if (-not($PSBoundParameters['Async'])) + { + + $_Resp | Wait-OVTaskComplete + + } + + else + { + + $_Resp + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString() | Write-Verbose + + } + +} + +function Set-OVExternalRepository +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdLetBinding (DefaultParameterSetName = "Default", SupportsShouldProcess, ConfirmImpact = 'High')] + Param + ( + + [Parameter (Mandatory, ParameterSetName = "Default", ValueFromPipeline)] + [Parameter (Mandatory, ParameterSetName = "PSCredentials", ValueFromPipeline)] + [ValidateNotNullOrEmpty()] + [Object]$InputObject, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [Parameter (Mandatory = $false, ParameterSetName = 'PSCredentials')] + [ValidateNotNullorEmpty()] + [String]$Name, + + [Parameter (Mandatory = $false, ParameterSetName = 'PSCredentials')] + [PSCredential]$Credential, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [String]$Username, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [SecureString]$Password, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [Parameter (Mandatory = $false, ParameterSetName = 'PSCredentials')] + [String]$Certificate, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [Parameter (Mandatory = $false, ParameterSetName = 'PSCredentials')] + [String]$NFSPath, + + [Parameter (Mandatory = $false,ParameterSetName = 'Default')] + [Parameter (Mandatory = $false,ParameterSetName = 'PSCredentials')] + [Switch]$Async, + + [Parameter (Mandatory = $false, ParameterSetName = "default", ValueFromPipelineByPropertyName)] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not $PSBoundParameters['InputObject']) + { + + $PipelineInput = $true + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + # Valiate NFSPath parameter + if ($PSBoundParameters['NFSPath'] -and -not $NFSPathRegEx.Match($NFSPath).Success) + { + + $ExceptionMessage = 'NFSPath parameter value "{0}" is not a valid NFS path. Please ensure the format follows "server:/path1" or "server.fqdn:/path".' -f $NFSPath + $ErrorRecord = New-ErrorRecord HPEOneView.Library.ParameterValidationException InvalidParameter InvalidArgument 'NFSPath' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + Process + { + + if ($InputObject.category -ne $ResourceCategoryEnum.RepositoryManager) + { + + $ExceptionMessage = "The specified '{0}' InputObject parameter value is not supported." -f $InputObject.name + $ErrorRecord = New-ErrorRecord HPEOneView.InputObjectResourceException InvalidInputObjectResource InvalidArgument "InputObject" -TargetType $InputObject.GetType().Name -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + if ($InputObject.repositoryType -eq 'FirmwareInternalRepo') + { + + $ExceptionMessage = "The specified '{0}' InputObject parameter value is an Internal Baseline Repository. Only External repositories can be removed." -f $InputObject.name + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.BaselineRepositoryResourceException InvalidInputObjectResource InvalidArgument "InputObject" -TargetType $InputObject.GetType().Name -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + $_PatchOpertation = [System.Collections.ArrayList]::new() + + switch ($PSBoundParameters.Keys) + { + + 'Name' + { + + "[{0}] Updating repository name: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Name | Write-Verbose + + $_UpdatedInputObject = NewObject -PatchOperation + $_UpdatedInputObject.op = 'replace' + $_UpdatedInputObject.path = '/repositoryName' + $_UpdatedInputObject.value = $Name + + [void]$_PatchOpertation.Add($_UpdatedInputObject) + + } + + 'Certificate' + { + + "[{0}] Updating repository HTTPS certificate." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_UpdatedInputObject = NewObject -PatchOperation + $_UpdatedInputObject.op = 'replace' + $_UpdatedInputObject.path = '/base64Data' + $_UpdatedInputObject.value = $Certificate + + [void]$_PatchOpertation.Add($_UpdatedInputObject) + + } + + 'Credential' + { + + "[{0}] Updating repository credentials with PSCredential object." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $Username = $Credential.UserName + $_DecryptPassword = [Runtime.InteropServices.Marshal]::PtrToStringBSTR([Runtime.InteropServices.Marshal]::SecureStringToBSTR($Credential.Password)) + + $_UpdatedInputObject = NewObject -PatchOperation + $_UpdatedInputObject.op = 'replace' + $_UpdatedInputObject.path = '/userName' + $_UpdatedInputObject.value = $Username + + [void]$_PatchOpertation.Add($_UpdatedInputObject) + + $_UpdatedInputObject = NewObject -PatchOperation + $_UpdatedInputObject.op = 'replace' + $_UpdatedInputObject.path = '/password' + $_UpdatedInputObject.value = $_DecryptPassword + + [void]$_PatchOpertation.Add($_UpdatedInputObject) + + } + + 'Username' + { + + "[{0}] Updating repository username." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_UpdatedInputObject = NewObject -PatchOperation + $_UpdatedInputObject.op = 'replace' + $_UpdatedInputObject.path = '/userName' + $_UpdatedInputObject.value = $Username + + [void]$_PatchOpertation.Add($_UpdatedInputObject) + + } + + 'Password' + { + + "[{0}] Updating repository password." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_DecryptPassword = [Runtime.InteropServices.Marshal]::PtrToStringBSTR([Runtime.InteropServices.Marshal]::SecureStringToBSTR($Password)) + + $_UpdatedInputObject = NewObject -PatchOperation + $_UpdatedInputObject.op = 'replace' + $_UpdatedInputObject.path = '/password' + $_UpdatedInputObject.value = $_DecryptPassword + + [void]$_PatchOpertation.Add($_UpdatedInputObject) + + } + + 'NFSPath' + { + + "[{0}] Updating NFSPath: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $NFSPath | Write-Verbose + + $_UpdatedInputObject = NewObject -PatchOperation + $_UpdatedInputObject.op = 'replace' + $_UpdatedInputObject.path = '/nfsFolderPath' + $_UpdatedInputObject.value = $NFSPath + + [void]$_PatchOpertation.Add($_UpdatedInputObject) + + } + + } + + if ($PSCmdlet.ShouldProcess($InputObject.Name, ("Modify repository from appliance {0}" -f $InputObject.ApplianceConnection))) + { + + Try + { + + $_Resp = Send-OVRequest -Uri $InputObject.uri -Method PATCH -Body $_UpdatedInputObject -AddHeader @{'If-Match' = $InputObject.eTag} -Hostname $InputObject.ApplianceConnection + + if (-not $PSBoundParameters['Async']) + { + + $_Resp | Wait-OVTaskComplete + + } + + else + { + + $_Resp + + } + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + elseif ($PSBoundParameters['WhatIf']) + { + + "[{0}] Caller passed -WhatIf Parameter." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + else + { + + "[{0}] Caller selected NO to confirmation prompt." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Update-OVExternalRepository +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdLetBinding (DefaultParameterSetName = "Default", SupportsShouldProcess, ConfirmImpact = 'High')] + Param + ( + + [Parameter (Mandatory, ParameterSetName = "Default", ValueFromPipeline)] + [ValidateNotNullOrEmpty()] + [Object]$InputObject, + + [Parameter (Mandatory = $false,ParameterSetName = 'Default')] + [Switch]$Async, + + [Parameter (Mandatory = $false, ParameterSetName = "default", ValueFromPipelineByPropertyName)] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not $PSBoundParameters['InputObject']) + { + + $PipelineInput = $true + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + } + + Process + { + + if ($InputObject.category -ne $ResourceCategoryEnum.RepositoryManager) + { + + $ExceptionMessage = "The specified '{0}' InputObject parameter value is not supported." -f $InputObject.name + $ErrorRecord = New-ErrorRecord HPEOneView.InputObjectResourceException InvalidInputObjectResource InvalidArgument "InputObject" -TargetType $InputObject.GetType().Name -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + if ($InputObject.repositoryType -eq 'FirmwareInternalRepo') + { + + $ExceptionMessage = "The specified '{0}' InputObject parameter value is an Internal Baseline Repository. Only External repositories can be removed." -f $InputObject.name + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.BaselineRepositoryResourceException InvalidInputObjectResource InvalidArgument "InputObject" -TargetType $InputObject.GetType().Name -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + $_RefreshRepositoryOperation = NewObject -PatchOperation + $_RefreshRepositoryOperation.op = 'replace' + $_RefreshRepositoryOperation.path = '/refreshState' + $_RefreshRepositoryOperation.value = 'RefreshPending' + + if ($PSCmdlet.ShouldProcess($InputObject.Name, ("Refresh repository on appliance {0}" -f $InputObject.ApplianceConnection))) + { + + Try + { + + $_Resp = Send-OVRequest -Uri $InputObject.uri -Method PATCH -Body $_RefreshRepositoryOperation -Hostname $InputObject.ApplianceConnection + + if (-not $PSBoundParameters['Async']) + { + + $_Resp | Wait-OVTaskComplete + + } + + else + { + + $_Resp + + } + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + elseif ($PSBoundParameters['WhatIf']) + { + + "[{0}] Caller passed -WhatIf Parameter." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + else + { + + "[{0}] Caller selected NO to confirmation prompt." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Remove-OVExternalRepository +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdLetBinding (DefaultParameterSetName = "Default", SupportsShouldProcess, ConfirmImpact = 'High')] + Param + ( + + [Parameter (Mandatory, ParameterSetName = "Default", ValueFromPipeline)] + [ValidateNotNullOrEmpty()] + [Object]$InputObject, + + [Parameter (Mandatory = $false,ParameterSetName = 'Default')] + [Switch]$Force, + + [Parameter (Mandatory = $false,ParameterSetName = 'Default')] + [Switch]$Async, + + [Parameter (Mandatory = $false, ParameterSetName = "Default", ValueFromPipelineByPropertyName)] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not $PSBoundParameters['InputObject']) + { + + $PipelineInput = $true + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + } + + Process + { + + if ($InputObject.category -ne $ResourceCategoryEnum.RepositoryManager) + { + + $ExceptionMessage = "The specified '{0}' InputObject parameter value is not supported." -f $InputObject.name + $ErrorRecord = New-ErrorRecord HPEOneView.InputObjectResourceException InvalidInputObjectResource InvalidArgument "InputObject" -TargetType $InputObject.GetType().Name -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + if ($InputObject.repositoryType -eq 'FirmwareInternalRepo') + { + + $ExceptionMessage = "The specified '{0}' InputObject parameter value is an Internal Baseline Repository. Only External repositories can be removed." -f $InputObject.name + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.BaselineRepositoryResourceException InvalidInputObjectResource InvalidArgument "InputObject" -TargetType $InputObject.GetType().Name -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + $_uri = $InputObject.Uri.ToString() + + if ($PSCmdlet.ShouldProcess($InputObject.Name, ("Remove repository from appliance {0}" -f $InputObject.ApplianceConnection))) + { + + if ($Force) + { + + $_uri += '?force=true' + + } + + Try + { + + $_resp = Send-OVRequest -Uri $_uri -Method DELETE -AddHeader @{'If-Match' = $InputObject.eTag } -Hostname $InputObject.ApplianceConnection + + if (-not $PSBoundParameters['Async']) + { + + $_resp | Wait-OVTaskComplete + + } + + else + { + + $_resp + + } + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + elseif ($PSBoundParameters['WhatIf']) + { + + "[{0}] Caller passed -WhatIf Parameter." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + else + { + + "[{0}] Caller selected NO to confirmation prompt." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function New-OVSupportDump +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "values")] + Param + ( + + [Parameter (Mandatory = $false, ValueFromPipeline = $false, ParameterSetName = "values")] + [Parameter (Mandatory = $false, ValueFromPipeline = $false, ParameterSetName = "Advanced")] + [Parameter (Mandatory = $false, ValueFromPipeline = $false, ParameterSetName = "Object")] + [Alias ("save", "Location")] + [String]$Path = (get-location).Path, + + [Parameter (Mandatory, ValueFromPipeline = $false, ParameterSetName = "values")] + [Parameter (Mandatory, ValueFromPipeline = $false, ParameterSetName = "Advanced")] + [Parameter (Mandatory, ValueFromPipeline = $false, ParameterSetName = "Object")] + [ValidateSet ("Appliance", "LE", "LogicalEnclosure")] + [String]$Type, + + [Parameter (Mandatory = $false, ValueFromPipeline = $false, ParameterSetName = "values")] + [Switch]$Encrypted, + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = "Object")] + [Alias ('liobject','li','name', 'LogicalEnclosure')] + [object]$InputObject, + + [Parameter (Mandatory = $false, ParameterSetName = "Object")] + [Switch]$ExcludeApplianceSupportDump, + + [Parameter (Mandatory = $false, ParameterSetName = "Advanced")] + [Switch]$AdvancedSupportDump, + + [Parameter (Mandatory = $false, ParameterSetName = "Advanced")] + [Switch]$CiDebugLogs, + + [Parameter (Mandatory = $false, ParameterSetName = "Advanced")] + [Switch]$CiRequestLogs, + + [Parameter (Mandatory = $false, ParameterSetName = "Advanced")] + [Switch]$JettyLogs, + + [Parameter (Mandatory = $false, ParameterSetName = "Advanced")] + [Switch]$ApacheLogs, + + [Parameter (Mandatory = $false, ParameterSetName = "Advanced")] + [Switch]$AHSLogsForComposer, + + [Parameter (Mandatory = $false, ParameterSetName = "Advanced")] + [Switch]$AlertLogs, + + [Parameter (Mandatory = $false, ParameterSetName = "Advanced")] + [Switch]$CiDbLogs, + + [Parameter (Mandatory = $false, ParameterSetName = "Advanced")] + [Switch]$FLMLogs, + + [Parameter (Mandatory = $false, ParameterSetName = "Advanced")] + [Switch]$LicenseManagerLogs, + + [Parameter (Mandatory = $False, ValueFromPipelineByPropertyName, ParameterSetName = "values")] + [Parameter (Mandatory = $False, ValueFromPipelineByPropertyName, ParameterSetName = "Advanced")] + [Parameter (Mandatory = $False, ValueFromPipelineByPropertyName, ParameterSetName = "Object")] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not($PSBoundParameters["InputObject"]) -and $PSCmdlet.ParameterSetName -eq "Object") + { + + $PipelineInput = $true + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + # Validate the path exists. If not, create it. + "[{0}] Validating '{1}' exists" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Path | Write-Verbose + + if (-not(Test-Path $Path)) + { + + "[{0}] '{1}' Directory does not exist. Creating directory..." -f $MyInvocation.InvocationName.ToString().ToUpper(), $Path | Write-Verbose + + New-Item -ItemType Directory -path $Path + + } + + } + + Process + { + + if ($PipelineInput -or 'LE', 'LogicalEnclosure' -contains $Type) + { + + if ($null -eq $InputObject) + { + + $ExceptionMessage = "The support dump request is LogicalEnclosure. The InputObject parameter must be supplied with a logical enclosure resource." + $ErrorRecord = New-ErrorRecord InvalidOperationException InvalidInputObjectParameterValue InvalidArgument 'InputObject' -TargetType 'InputObject' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + "[{0}] Pipeline object: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject.name | Write-Verbose + + # Validate input object is a Logical Interconnect resource + if ($InputObject.category -ne $ResourceCategoryEnum.LogicalEnclosure) + { + + $ExceptionMessage = "The InputObject parameter value is invalid. Resource category provided '{0}', expected '{1}'. Please check the value and try again." -f$InputObject.category, $ResourceCategoryEnum.LogicalEnclosure + $ErrorRecord = New-ErrorRecord InvalidOperationException InvalidInputObjectParameterValue InvalidArgument 'InputObject' -TargetType $InputObject.GetType().Name -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + $Request = [PSCustomObject]@{ + excludeApplianceDump = $false + errorCode = $InputObject.name + } + + if ($PSBoundParameters.Keys -contains 'ExcludeApplianceSupportDump') + { + + $Request.excludeApplianceDump = [bool]$ExcludeApplianceSupportDump + + } + + $targetURI = $InputObject.Uri.ToString() + "/support-dumps" + + "[{0}] Request : $($request | out-string) " -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + "[{0}] URI: $($targetURI)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + # Send the request + Write-Host "Please wait while the Support Dump is generated. This can take a few minutes..." + + Try + { + + $resp = Send-OVRequest -Uri $targetUri -Method POST -Body $Request -Hostname $InputObject.ApplianceConnection + + # Wait for the parent task to complete + $FinalTask = Wait-OVTaskComplete -InputObject $resp.parentTaskUri #-verbose:$true + + # Get the original returned task to validate it is complete + $resp = Wait-OVTaskComplete -InputObject $resp #-verbose:$true + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + # Get the file to download from the task + $DownloadLocation = $Resp.associatedResource.resourceUri + + # Now that the Support Dump has been created, download the file + Try + { + + Download-File -Uri $DownloadLocation -ApplianceConnection $InputObject.ApplianceConnection -SaveLocation $Path + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + else + { + + ForEach ($_appliance in $ApplianceConnection) + { + + #Build the request and specify the target URI. Do not change errorCode value. + "[{0}] Requesting Appliance Support Dump..." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $request = [PSCustomObject]@{ + + errorCode = "CI"; + encrypt = [Bool]$Encrypted.IsPresent; + flags =@{ + saveToUSB = $false; + deleteDump = $true; + advancedSupportDump = $false + }; + dump = 'support' + group = [System.Collections.ArrayList]::new() + } + + if ($PSBoundParameters.Keys -contains 'AdvancedSupportDump' -and $AdvancedSupportDump) + { + + $request.flags.advancedSupportDump = [Bool]$AdvancedSupportDump + + if ($PSBoundParameters['CiDebugLogs']) + { + + "[{0}] Adding CiDebugLogs to request." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + [void]$request.group.Add("ciDebug logs") + + } + + if ($PSBoundParameters['CiRequestLogs']) + { + + "[{0}] Adding CiRequestLogs to request." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + [void]$request.group.Add("ciRequest logs") + + } + + if ($PSBoundParameters['JettyLogs']) + { + + "[{0}] Adding JettyLogs to request." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + [void]$request.group.Add("Jetty log files") + + } + + if ($PSBoundParameters['ApacheLogs']) + { + + "[{0}] Adding ApacheLogs to request." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + [void]$request.group.Add("Apache logs") + + } + + if ($PSBoundParameters['AHSLogsForComposer']) + { + + "[{0}] Adding AHSLogsForComposer to request." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + [void]$request.group.Add("AHS logs for the composer") + + } + + if ($PSBoundParameters['AlertLogs']) + { + + "[{0}] Adding AlertLogs to request." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + [void]$request.group.Add("Alerts logs") + + } + + if ($PSBoundParameters['CiDbLogs']) + { + + "[{0}] Adding CiDbLogs to request." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + [void]$request.group.Add("cidb logs") + + } + + if ($PSBoundParameters['FLMLogs']) + { + + "[{0}] Adding FLMLogs to request." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + [void]$request.group.Add("FLM logs") + + } + + if ($PSBoundParameters['LicenseManagerLogs']) + { + + "[{0}] Adding LicenseManagerLogs to request." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + [void]$request.group.Add("License mgr logs") + + } + + } + + $targetURI = $ApplianceSupportDumpUri + + # Send the request + Write-Host "Please wait while the Support Dump is generated. This can take a few minutes..." + + Try + { + + $resp = Send-OVRequest -Uri $targetUri -Method POST -Body $Request -Hostname $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + # Now that the Support Dump has been requested, download the file + Try + { + + Download-File $resp.uri $_appliance.Name $Path + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + } + + End + { + + "Done." | Write-Verbose + + } + +} + +function Get-OVAutomaticBackupConfig +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "default")] + Param + ( + + [Parameter (Mandatory = $false)] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $_AutoBackupStatusCollection = [System.Collections.ArrayList]::new() + + } + + Process + { + + ForEach ($_appliance in $ApplianceConnection) + { + + "[{0}] Processing '{1}' Appliance (of {2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name, $ApplianceConnection.Count | Write-Verbose + + Try + { + + $_AutomaticBackup = Send-OVRequest -Uri $ApplianceAutoBackupConfUri -Hostname $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $_AutomaticBackup.PSObject.TypeNames.Insert(0,'HPEOneview.Appliance.AutomaticBackupConfig') + + [void]$_AutoBackupStatusCollection.Add($_AutomaticBackup) + + + } + + } + + End + { + + Return $_AutoBackupStatusCollection + + } + +} + +function Set-OVAutomaticBackupConfig +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdLetBinding (DefaultParameterSetName = 'Default', SupportsShouldProcess, ConfirmImpact = 'High')] + Param + ( + + [Parameter (Mandatory, ParameterSetName = 'Default')] + [ValidateNotNullorEmpty()] + [String]$Hostname, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullorEmpty()] + [int]$Port = 22, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullorEmpty()] + [String]$Directory, + + [Parameter (Mandatory, ParameterSetName = 'Default')] + [ValidateNotNullorEmpty()] + [String]$Username, + + [Parameter (Mandatory, ParameterSetName = 'Default')] + [ValidateNotNullorEmpty()] + [SecureString]$Password, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullorEmpty()] + [String]$HostSSHKey, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateSet ('SCP','SFTP')] + [String]$Protocol = 'SCP', + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateSet ('Daily','Weekly')] + [String]$Interval, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullorEmpty()] + [Array]$Days, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateScript ({[RegEx]::IsMatch($_,"([01]?[0-9]|2[0-3]):[0-5][0-9]")})] + [String]$Time, + + [Parameter (Mandatory, ParameterSetName = "Default")] + [ValidateNotNullorEmpty()] + [SecureString]$Passphrase, + + [Parameter (Mandatory, ParameterSetName = 'Disable')] + [Switch]$Disabled, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [Parameter (Mandatory = $false, ParameterSetName = 'Disable')] + [Switch]$Async, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [Parameter (Mandatory = $false, ParameterSetName = 'Disable')] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $_AutoBackupStatusCollection = [System.Collections.ArrayList]::new() + + } + + Process + { + + ForEach ($_appliance in $ApplianceConnection) + { + + $_resp = $null + + "[{0}] Processing '{1}' Appliance (of {2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name, $ApplianceConnection.Count | Write-Verbose + + Try + { + + $_AutomaticBackupStatus = Send-OVRequest -Uri $ApplianceAutoBackupConfUri -Hostname $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $_AutoBackupConfig = NewObject -AutoBackupConfig + + $_AutoBackupConfig.eTag = $_AutomaticBackupStatus.eTag + + if ($PSBoundParameters['Disabled']) + { + + $_AutomaticBackupStatus.enabled = $false + + } + + else + { + + if ($PSBoundParameters['HostSSHKey']) + { + + "[{0}] Caller provided manual host SSH key." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not $HostSSHKey.StartsWith('ssh-rsa')) + { + + $_ExceptionMessage = 'The provided HostSSHKey is not a valid OpenSSL RSA key.' + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AutomatedBackupConfigException InvalidedHostSSHRsaKey InvalidArgument 'HostSSHKey' -Message $_ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + $_AutoBackupConfig.remoteServerPublicKey = ($HostSSHKey | Out-String) + + } + + else + { + + "[{0}] Caller did not provide manual host SSH key. Using appliance to get host key." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $_uri = "{0}/{1}?port={2}" -f $ApplianceAutoBackupHostKeyUri, $Hostname, $Port + + $_HostSSHKey = Send-OVRequest -Uri $_uri -Hostname $_appliance + + "[{0}] Retrieved public key from remote server: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_HostSSHKey.remoteServerPublicKey | Write-Verbose + + $_AutoBackupConfig.remoteServerPublicKey = $_HostSSHKey.remoteServerPublicKey + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $_AutoBackupConfig.remoteServerDir = $Directory + $_AutoBackupConfig.remoteServerName = $Hostname + + $_AutoBackupConfig.userName = $Username + $_AutoBackupConfig.password = [Runtime.InteropServices.Marshal]::PtrToStringBSTR([Runtime.InteropServices.Marshal]::SecureStringToBSTR($Password)) + + if ($PSBoundParameters['Protocol']) + { + + $_AutoBackupConfig.protocol = $Protocol + + } + + else + { + + $_AutoBackupConfig.protocol = $_AutomaticBackupStatus.Protocol + + } + + if ($PSBoundParameters['Interval']) + { + + $_AutoBackupConfig.scheduleInterval = $Interval.ToUpper() + + } + + else + { + + $_AutoBackupConfig.scheduleInterval = $_AutomaticBackupStatus.scheduleInterval + + } + + if ($PSBoundParameters['Days'] -and $PSBoundParameters['Interval'] -eq 'Weekly') + { + + ForEach ($_day in $Days) + { + + [void]$_AutoBackupConfig.scheduleDays.Add($DayOfWeekEnum.$_day.ToUpper()) + + } + + } + + else + { + + $_AutoBackupConfig.scheduleDays = $_AutomaticBackupStatus.scheduleDays + + } + + if ($PSBoundParameters['Time']) + { + + $_AutoBackupConfig.scheduleTime = $Time + + } + + else + { + + $_AutoBackupConfig.scheduleTime = $_AutomaticBackupStatus.scheduleTime + + } + + if ($PSBoundParameters['Passphrase']) + { + + $_DecryptedPassphrase = [Runtime.InteropServices.Marshal]::PtrToStringBSTR([Runtime.InteropServices.Marshal]::SecureStringToBSTR($Passphrase)) + + $_AutoBackupConfig | Add-Member -NotePropertyName "passphrase" -NotePropertyValue $_DecryptedPassphrase + + } + + } + + # Prompt the user if they really want to disable Automatic Backups + if ($PSBoundParameters['Disabled']) + { + + if ($PSCmdlet.ShouldProcess($_appliance.Name,'disable automatic backup schedule on appliance')) + { + + Try + { + + $_resp = Send-OVRequest -Uri $ApplianceAutoBackupConfUri -Method PUT -Body $_AutomaticBackupStatus -Hostname $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + elseif ($PSBoundParameters['WhatIf']) + { + + "[{0}] User provided -WhatIf switch." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + else + { + + "[{0}] User cancelled or stated 'No'." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Return + + } + + } + + else + { + + "[{0}] Sending request" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $_resp = Send-OVRequest -Uri $ApplianceAutoBackupConfUri -Method PUT -Body $_AutoBackupConfig -Hostname $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + if ($PSBoundParameters['Async']) + { + + $_resp + + } + + else + { + + $_resp | Wait-OVTaskComplete + + } + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Get-OVBackup +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "default")] + Param + ( + + [Parameter (Mandatory = $false, ParameterSetName = "default")] + [DateTime]$Before, + + [Parameter (Mandatory = $false, ParameterSetName = "default")] + [DateTime]$After, + + [Parameter (Mandatory = $false, ParameterSetName = "default")] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + # Validate the path exists. If not, create it. + if ($PSBoundParameters['Location'] -and -not(Test-Path $Location)) + { + + "[{0}] Directory does not exist. Creating directory..." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + New-Item $Location -itemtype directory + + } + + $_BackupFileStatusCollection = [System.Collections.ArrayList]::new() + + } + + Process + { + + ForEach ($_appliance in $ApplianceConnection) + { + + "[{0}] Processing '{1}' Appliance (of {2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name, $ApplianceConnection.Count | Write-Verbose + + Try + { + + $_Backups = Send-OVRequest -Uri $ApplianceBackupUri -Hostname $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if ($PSBoundParameters['Before']) + { + + $_Backups.members | Where-Object { [DateTime]$_.created -le $Before.ToUniversalTime() } + + } + + elseif ($PSBoundParameters['After']) + { + + $_Backups.members | Where-Object { [DateTime]$_.created -ge $After.ToUniversalTime() } + + } + + else + { + + $_Backups.members + + } + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Save-OVBackup +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "default")] + Param + ( + + [Parameter (Mandatory = $false, ParameterSetName = "default")] + [ValidateNotNullOrEmpty()] + [Alias ("save")] + [String]$Location = (get-location).Path, + + [Parameter (Mandatory, ParameterSetName = "SaveRemoteOnly")] + [Switch]$SaveRemoteOnly, + + [Parameter (Mandatory = $false, ParameterSetName = "default")] + [Parameter (Mandatory = $false, ParameterSetName = "SaveRemoteOnly")] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + # Validate the path exists. If not, create it. + if ($PSBoundParameters['Location'] -and -not(Test-Path $Location)) + { + + "[{0}] Directory does not exist. Creating directory..." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + New-Item $Location -itemtype directory | Out-Null + + } + + } + + Process + { + + ForEach ($_appliance in $ApplianceConnection) + { + + "[{0}] Processing '{1}' Appliance (of {2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name, $ApplianceConnection.Count | Write-Verbose + + # Check to see if Automatic Backup is set on the appliance. + Try + { + + $_AutomaticBackup = Send-OVRequest -Uri $ApplianceAutoBackupConfUri -Hostname $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + "[{0}] Getting appliance created backup file" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $_CurrentBackup = Send-OVRequest -Uri $ApplianceBackupUri -Hostname $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if ($_CurrentBackup.Count -eq 0) + { + + "[{0}] Appliance does not contain a backup file. Generate non-terminating error." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $ExceptionMessage = 'No backup files were found on "{0}" appliance.' -f $_appliance + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.ApplianceBackupException EmptyBackupFileList ObjectNotFound ApplianceConnection -Message $ExceptionMessage + $PSCmdlet.WriteError($ErrorRecord) + + } + + else + { + + ForEach ($_BackupToDownload in $_CurrentBackup.members) + { + + if ($_AutomaticBackup.enabled -and $PSBoundParameters['SaveRemoteOnly']) + { + + "[{0}] Appliance supports remtoe backups. Saving backup file to remote location: {1}/{2}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_AutomaticBackup.remoteServerName, $_AutomaticBackup.remoteServerDir | Write-Verbose + + Try + { + + Send-OVRequest -Uri $_BackupToDownload.saveUri -Method PUT -Hostname $_BackupToDownload.ApplianceConnection | Wait-OVTaskComplete + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + else + { + + Try + { + + $_Results = Download-File $_BackupToDownload.downloadUri $_appliance $Location + + [System.IO.FileInfo]$_Results.file + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + } + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function New-OVBackup +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "default")] + Param + ( + + [Parameter (Mandatory = $false, ParameterSetName = "default")] + [ValidateNotNullOrEmpty()] + [Alias ("save")] + [String]$Location = (get-location).Path, + + [Parameter (Mandatory, ParameterSetName = "default")] + [ValidateNotNullOrEmpty()] + [SecureString]$Passphrase, + + [Parameter (Mandatory = $false, ParameterSetName = "default")] + [Switch]$Force, + + [Parameter (Mandatory = $false, ParameterSetName = "default")] + [Switch]$Async, + + [Parameter (Mandatory = $false, ParameterSetName = "default")] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + # Validate the path exists. If not, create it. + if ($PSBoundParameters['Location'] -and -not(Test-Path $Location)) + { + + "[{0}] Directory does not exist. Creating directory..." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + New-Item $Location -itemtype directory + + } + + $_BackupFileStatusCollection = [System.Collections.ArrayList]::new() + + } + + Process + { + + ForEach ($_appliance in $ApplianceConnection) + { + + $_DecryptedPassphrase = [Runtime.InteropServices.Marshal]::PtrToStringBSTR([Runtime.InteropServices.Marshal]::SecureStringToBSTR($Passphrase)) + + "[{0}] Processing '{1}' Appliance (of {2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name, $ApplianceConnection.Count | Write-Verbose + + # Check to see if Automatic Backup is set on the appliance. + Try + { + + $_AutomaticBackup = Send-OVRequest -Uri $ApplianceAutoBackupConfUri -Hostname $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + "[{0}] Please wait while the appliance backup is generated. This can take a few minutes..." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $_Params = @{ + Uri = $ApplianceBackupUri; + Method = "POST"; + Hostname = $_appliance + } + + if ($PSBoundParameters['Passphrase']) + { + + $_DecryptedPassphrase = [Runtime.InteropServices.Marshal]::PtrToStringBSTR([Runtime.InteropServices.Marshal]::SecureStringToBSTR($Passphrase)) + + $_Params.Add("AddHeader", @{Passphrase = $_DecryptedPassphrase}) + + } + + $_taskStatus = Send-OVRequest @_Params | Wait-OVTaskComplete -timeout (New-Timespan -minutes 45) + + "[{0}] Response: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $($_taskStatus | out-string) | Write-Verbose + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + # Something happened with creating the backup. Throw an error. + If ($_taskStatus.taskState -ne "Completed") + { + + $ExceptionMessage = 'The backup task did not complete successfully. {0}' -f $_taskStatus.taskErrors.recommendedActions + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.ApplianceBackupException BackupTaskFailed InvalidResult ApplianceConnection -Message $ExceptionMessage + $PSCmdlet.WriteError($ErrorRecord) + + } + + else + { + + # Get the backup file URI to download + Try + { + + $_backupObject = Send-OVRequest -Uri $_taskStatus.associatedResource.resourceUri -Hostname $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + # If no automatic backup is configured, then download + if (-not($_AutomaticBackup.enabled) -or $PSBoundParameters['Force']) + { + + "[{0}] Backup File URI: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_backupObject.downloadUri | Write-Verbose + + "[{0}] Downloading to: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Location | Write-Verbose + + Try + { + + $_resp = Download-File $_backupObject.downloadUri $_appliance $Location + + [void]$_BackupFileStatusCollection.Add([System.IO.FileInfo]$_resp.file) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + else + { + + "[{0}] Created backup will be saved to remote location: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_AutomaticBackup.remoteServerName | Write-Verbose + + Try + { + + $_resp = Send-OVRequest -Uri $_backupObject.saveUri -Method PUT -Hostname $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if (-not($PSboundParameters['Async'])) + { + + "[{0}] Monitoring remote save operation." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $_resp = Wait-OVTaskComplete $_resp + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + [void]$_BackupFileStatusCollection.Add($_resp) + + } + + } + + } + + } + + End + { + + Return $_BackupFileStatusCollection + + } + +} + +function New-OVRestore +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdLetBinding (DefaultParameterSetName = "default", SupportsShouldProcess, ConfirmImpact = 'High')] + Param + ( + + [Parameter (Mandatory, ParameterSetName = "default")] + [ValidateNotNullOrEmpty()] + [Alias ("File")] + [String]$FileName, + + [Parameter (Mandatory, ParameterSetName = "default")] + [ValidateNotNullOrEmpty()] + [SecureString]$Passphrase, + + [Parameter (Mandatory = $false, ParameterSetName = "default")] + [ValidateNotNullOrEmpty()] + [Object]$EncryptionKey, + + [Parameter (Mandatory = $false, ParameterSetName = "default")] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $_ApplianceStatus = [System.Collections.ArrayList]::new() + + } + + Process + { + + ForEach ($_appliance in $ApplianceConnection) + { + + "[{0}] Processing '{1}' Appliance (of {2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name, $ApplianceConnection.Count | Write-Verbose + + # Validate the path exists. If not, create it. + if (-not(Test-Path $FileName)) + { + + "[{0}] Backup file specified does not exist." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.RestoreException BackupFileNotFound ObjectNotFound 'FileName' -Message "'$FileName' was not found. Please check the directory and/or name and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + if ($PSCmdlet.ShouldProcess($_appliance, ('restore backup {0} to appliance' -f $FileName.FullName))) + { + + # Send the request + "[{0}] Please wait while the appliance backup is uploaded. This can take a few minutes..." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $resp = Upload-File -Uri $ApplianceRestoreRepoUri $FileName -Hostname $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if ($resp.backupType -eq 'UPLOADED' -and $resp.status -eq 'SUCCEEDED') + { + + "[{0}] Sending request to restore appliance" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_restoreObject = [PSCustomObject]@{ + + type = "RESTOREV1000"; + uriOfBackupToRestore = $resp.uri; + applianceEncryptionKey = $null + + } + + # Add Passphrase support + if ($PSBoundParameters['Passphrase']) + { + + $_DecryptedPassphrase = [Runtime.InteropServices.Marshal]::PtrToStringBSTR([Runtime.InteropServices.Marshal]::SecureStringToBSTR($Passphrase)) + + $_restoreObject.Add("passphrase", $_DecryptedPassphrase) + + } + + # EncryptionKey is for Composer data at rest encryption + if ($PSBoundParameters['EncryptionKey'] -and $ApplianceConnection.ApplianceType -ne 'Composer') + { + + $ExceptionMessage = 'The ApplianceConnection {0} is not a Synergy Composer. Data at rest encryption is only supported with HPE Synergy Composer appliances, not Virtual Machine Appliance types.' -f $ApplianceConnection.Name + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.ComposerNodeException InvalidOperation InvalidOperation 'ApplianceConnection' -Message $ExceptionMessage + $PSCmdlet.WriteError($ErrorRecord) + + } + + elseif ($PSBoundParameters['EncryptionKey']) + { + + # File object from Get-ChildItem or DIR + if ($EncryptionKey -is [System.IO.FileInfo]) + { + + try + { + + $AllString = [System.IO.File]::ReadAllText($EncryptionKey) | ConvertFrom-Json + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $_restoreObject.applianceEncryptionKey = $AllString.applianceEncryptionKey + + } + + # String value + else + { + + $_restoreObject.applianceEncryptionKey = $EncryptionKey + + } + + } + + elseif (-not $PSBoundParameters['EncryptionKey'] -and $_appliance.ApplianceType -eq 'Composer') + { + + # Check to see if data at rest encryption is enabled + Try + { + + $DataAtRestConfig = Send-OVRequest -Uri $ApplianceDataAtRestConfigUri -Hostname $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if ($DataAtRestConfig.secureDataAtRest) + { + + # Get the appliance encrpytion key + Try + { + + $_restoreObject.applianceEncryptionKey = (Send-OVRequest -Uri $ApplianceEncryptionKeyUri -Hostname $_appliance).applianceEncryptionKey + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + Try + { + + $_restoreStatus = Send-OVRequest -Uri $ApplianceRestoreUri -Method POST -Body $_restoreObject -Hostname $_appliance + + Write-warning "Appliance restore in progress. All users are now logged off." + + } + + Catch + { + + # Need to handle when the encryption key is not accepted by the API and need to generate a different error + if ([RegEx]::Match($_.FullyQualifiedErrorId, 'AEK_VALIDATION_FAILED', $RegExInsensitiveFlag).Success -and -not $PSBoundParameters['EncryptionKey']) + { + + # // TODO: Update exception class + $ExceptionMessage = "The provided backup contains a different encryptione key than what the appliance is configured with. Please provide the encryption key file by using the -EncryptionKey parameter." + $ErrorRecord = New-ErrorRecord HPEOneView.SanManagerResourceException InvalidEncryptionKey InvalidOperation 'EncryptionKey' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + else + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $sw = [System.Diagnostics.Stopwatch]::StartNew() + + While ($_restoreStatus.status -eq "IN_PROGRESS") + { + + $_statusMessage = "{0} {1}% [{2}min {3}sec]" -f $ApplianceUpdateProgressStepEnum[$_restoreStatus.progressStep],$_restoreStatus.percentComplete, $sw.Elapsed.Minutes, $sw.Elapsed.Seconds + + # Handle the call from -Verbose so Write-Progress does not get borked on display. + if ($PSBoundParameters['Verbose'] -or $VerbosePreference -eq 'Continue') + { + + "[{0}] - $_statusMessage" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + else + { + + Write-Progress -id 1 -activity "Restoring Appliance Backup $($_restoreStatus.id)" -status $_statusMessage -percentComplete $_restoreStatus.percentComplete + + } + + Try + { + + $_restoreStatus = Send-OVRequest $_restoreStatus.uri -Hostname $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } # Until ($restoreStatus.percentComplete -eq 100 -or $restoreStatus -ne "IN_PROGRESS") + + $sw.Stop() + + "[{0}] - Operation took $($sw.elapsed.minutes)min $($sw.elapsed.seconds)sec" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Write-Progress -id 1 -activity "Restoring Appliance Backup $($_restoreStatus.id)" -status $_statusMessage -Completed + + Write-warning "Appliance restore in has completed for $($_appliance.Name). Address Pool ranges will need to be re-enabled, and verify the managed or monitored resources do not need a refresh." + + } + + else + { + + Send-OVRequest -Uri $resp.taskUri -Hostname + } + + [void]$_ApplianceStatus.Add($_restoreStatus) + + } + + } + + } + + End + { + + Return $_ApplianceStatus + + } + +} + +function Download-File +{ + + <# + + .DESCRIPTION + Helper function to download files from appliance. + + .Parameter uri + The location where the Support Dump or backup will be downloaded from + + .Parameter SaveLocation + The full path to where the Support Dump or backup will be saved to. This path will not be validated in this helper function + + .Parameter ApplianceConnection + The Appliance Connection Object, Name or ConnectionID + + .INPUTS + None. You cannot pipe objects to this cmdlet. + + .OUTPUTS + Downloads the requested file using net.WebRequest + + .EXAMPLE + PS C:\> Download-File /rest/appliance/support-dumps/ci5P01AB76-CI-2013_09_04-04_52_00.014786.sdmp -ApplianceConnection MyAppliance.domain.com c:\temp + + #> + + [CmdletBinding ()] + Param + ( + + [Parameter (Mandatory)] + [ValidateNotNullOrEmpty()] + [String]$uri, + + [Parameter (Mandatory)] + [ValidateNotNullorEmpty()] + [object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default), + + [Parameter (Mandatory)] + [Alias ("save")] + [ValidateNotNullOrEmpty()] + [String]$SaveLocation + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection -is [HPEOneView.Appliance.Connection] -or $ApplianceConnection -is [HPEOneView.Library.ApplianceConnection] ) -and (-not($ApplianceConnection -is [System.String]))) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException InvalidApplianceConnectionDataType InvalidArgument 'ApplianceConnection' -Message 'The specified ApplianceConnection Parameter is not type [HPEOneView.Appliance.Connection] or [System.String]. Please correct this value and try again.' + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection.Count -gt 1) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException MultipleApplianceConnections InvalidArgument 'ApplianceConnection' -Message 'The specified ApplianceConnection Parameter contains multiple Appliance Connections. This CMDLET only supports 1 Appliance Connection in the ApplianceConnect Parameter value. Please correct this and try again.' + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -TargetType $ApplianceConnection.GetType().Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + Process + { + + $_downloadfilestatus = NewObject -DownloadFileStatus + + $fsCreate = [System.IO.FileAccess]::Create + $fsWrite = [System.IO.FileAccess]::Write + + "[{0}] Download URI: $uri" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + # [System.Net.ServicePointManager]::UseNagleAlgorithm = $false + [System.Net.httpWebRequest]$_fileDownload = RestClient GET $uri $ApplianceConnection.Name + $_fileDownload.Headers.Item('Accept-Encoding') = 'gzip, deflate' + $_fileDownload.accept = "application/zip,application/octet-stream,*/*" + $_fileDownload.Headers.Item("auth") = $ApplianceConnection.SessionID + + $i = 0 + + ForEach ($_h in $_fileDownload.Headers) + { + + $_HeaderValue = $_fileDownload.Headers[$i] + + if ("Password", "Passphrase" -contains $_h.key) + { + + $_HeaderValue = "********REDACTED********" + + } + + "[{0}] Request Header $($i): $($_h) = $_HeaderValue" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $i++ + + } + + "[{0}] Request: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_fileDownload | Write-Verbose + + Try + { + + # Get response + "[{0}] Getting response" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + [Net.httpWebResponse]$_rs = $_fileDownload.GetResponse() + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + Finally + { + + if ($rs) + { + + $_rs.Close() + + } + + } + + # Display the response status if verbose output is requested + "[{0}] Response Status: $([Int]$_rs.StatusCode) $($_rs.StatusDescription)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $i = 0 + + ForEach ($_h in $_rs.Headers) + { + + "[{0}] Response Header $($i): $($_h) = $($_rs.Headers[$i])" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $i++ + + } + + # Request is a redirect to download file contained in the response headers + if (-not [String]::IsNullOrEmpty($_rs.Headers["File-Name"])) + { + + "[{0}] Filename from 'File-Name' HTTP header" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_fileName = $_rs.Headers["File-Name"] + + } + + elseif (($_rs.headers["Content-Disposition"]) -and ($_rs.headers["Content-Disposition"].StartsWith("attachment; filename="))) + { + + "[{0}] Filename from 'Content-Disposition' HTTP header" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_fileName = ($_rs.headers["Content-Disposition"].SubString(21)) -replace "`"","" + + } + + # Detect if the download is a Support Dump or Appliance Backup + elseif ($uri.Contains("/rest/backups/archive")) + { + + "[{0}] Filename from URI as it is a backup file." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + # Need to get the Appliance file name + $_fileName = $uri.split("/") + + $_fileName = $_fileName[-1] + ".bkp" + + } + + else + { + + "[{0}] Filename from URI." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + # Need to get the Support Dump file name + $_fileName = $uri.split("/") + + $_fileName = $ApplianceConnection.Name + "_" + $_fileName[-1] + + } + + if ($_rs.headers['Content-Length']) + { + + [int64]$_fileSize = $_rs.headers['Content-Length'] + Write-Verbose ('*****Filesize from Header: {0}' -f $_fileSize) + + } + + elseif ($_rs.ContentLength) + { + + [int64]$_fileSize = $_rs.ContentLength + Write-Verbose ('*****Filesize from ContentLength: {0}' -f $_fileSize) + + } + + "[{0}] Filename: $($_fileName)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + "[{0}] Filesize: $($_fileSize)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if($_rs.StatusCode -eq 200) + { + + Try + { + + # Read from response and write to file + $_stream = $_rs.GetResponseStream() + + # Define buffer and buffer size WAS AT 8MB. This caused perf issue with .NetCore 3 StreamReader until changed to 4MB? + [int]$ByteSize = 4096 + Write-Verbose ('Creating Buffer of size: {0}MB' -f ((1024 * $ByteSize) / 1MB)) + [byte[]]$_buffer = [byte[]]::new(1024 * $ByteSize) + [Int] $_bytesRead = 0 + + Write-Verbose ('Buffer size: {0}' -f $_buffer.length) + + # This is used to keep track of the file upload progress. + $_numBytesRead = 0 + $_numBytesWrote = 0 + + "[{0}] Saving to $($saveLocation)\$($_fileName)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_fs = [IO.FileStream]::new(($saveLocation + "\" + $_fileName), [System.IO.FileMode]::Create) + + # Throughput Stopwatch + $_sw = [System.Diagnostics.StopWatch]::new() + $_progresssw = [System.Diagnostics.StopWatch]::new() + $_sw.Start() + $_progresssw.Start() + + while (($_bytesRead = $_stream.Read($_buffer, 0, $_buffer.Length)) -gt 0) + { + + # Write from buffer to file + $_fs.Write($_buffer, 0, $_bytesRead) + + # Keep track of bytes written for progress meter + $_total += $_bytesRead + + # Elapsed time to calculate throughput + $_transferrate = ($_total / $_sw.Elapsed.TotalSeconds) / 1MB + + # Use the Write-Progress cmd-let to show the progress of uploading the file. + [Int]$_percent = (($_total / $_fileSize) * 100) + + $_status = '{0:0}MB of {1:0}MB @ {2:N2}MB/s' -f ($_total / 1MB), ($_fileSize / 1MB), $_transferrate + + # Handle the call from -Verbose so Write-Progress does not get borked on display. + if ($PSBoundParameters['Verbose'] -or $VerbosePreference -eq 'Continue') + { + + if ($_progresssw.Elapsed.TotalMilliseconds -ge 500) + { + + "[{0}] Skipping Write-Progress display." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + "[{0}] Downloading file: $_fileName, status: $_status, Percent: $_percent" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_progresssw.Restart() + + } + + } + + else + { + + if ($_progresssw.Elapsed.TotalMilliseconds -ge 500) + { + + Write-Progress -id 0 -Activity "Downloading file $_fileName" -Status $_status -percentComplete $_percent + + $_progresssw.Restart() + + } + + } + + } # While ($_bytesRead -gt 0) + + Write-Progress -id 0 -Activity "Downloading file $_fileName" -Completed + + "[{0}] File saved to $($saveLocation)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_downloadfilestatus.status = 'Completed' + $_downloadfilestatus.file = "$saveLocation\$_fileName" + $_downloadfilestatus.ApplianceConnection = $ApplianceConnection.Name + + Return $_downloadfilestatus + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + finally + { + + # Clean up our work + if ($_stream) { $_stream.Close() } + if ($_rs) { $_rs.Close() } + if ($_fs) { $_fs.Close() } + + } + + } + + else + { + + # Clean up + if ($_rs) { $_rs.Close() } + if ($_fs) { $_fs.Close() } + + Throw 'Unhandled download exception' + + } + + } + +} + +function Upload-File +{ + + <# + + .SYNOPSIS + Upload a file to the appliance. + + .DESCRIPTION + This cmdlet will upload a file to the appliance that can accepts file uploads (SPP firmware bundle, Appliance Restore, and Appliance Updates.) + + .Parameter URI + Location where to upload file to. + + .Parameter File + Full path to the file to be uploaded. + + .Parameter AddHeader + Provide a Hashtable of additional HTTP headers to include + + .Parameter ApplianceConnection + Appliance Connection + + .INPUTS + None. You cannot pipe objects to this cmdlet. + + .OUTPUTS + Write-Progress + The progress of uploading the file to the appliance. + + .LINK + Add-OVBaseline + + .LINK + New-OVRestore + + .EXAMPLE + PS C:\> Upload-File "/rest/firmware-bundles" "C:\Users\me\Documents\SPP2012060B.2012_0525.1.iso" + + Upload a new SPP into the appliance. + + .EXAMPLE + PS C:\> Upload-File "/rest/restores" "C:\Users\me\Documents\appliance.bak" + + Upload a backup file to restore in the appliance. + + #> + + [CmdletBinding ()] + + Param + ( + + [Parameter (Mandatory)] + [ValidateNotNullOrEmpty()] + [Alias ('u')] + [String]$uri, + + [Parameter (Mandatory)] + [Alias ('f')] + [ValidateScript( {Test-Path $_})] + [System.IO.FileInfo]$File, + + [Parameter (Mandatory = $false)] + [ValidateNotNullorEmpty()] + [Object]$AddHeader, + + [Parameter (Mandatory = $false)] + [ValidateSet ('PUT', 'POST')] + [String]$Method = 'POST', + + [Parameter (Mandatory = $false)] + [Alias ('Hostname')] + [ValidateNotNullorEmpty()] + [object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + "[{0}] Bound PS Parameters: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), ($PSBoundParameters | out-string) | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection -is [HPEOneView.Appliance.Connection]) -and (-not($ApplianceConnection -is [System.String]))) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException InvalidApplianceConnectionDataType InvalidArgument 'ApplianceConnection' -Message 'The specified ApplianceConnection Parameter is not type [HPEOneView.Appliance.Connection] or [System.String]. Please correct this value and try again.' + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection.Count -gt 1) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException MultipleApplianceConnections InvalidArgument 'ApplianceConnection' -Message 'The specified ApplianceConnection Parameter contains multiple Appliance Connections. This CMDLET only supports 1 Appliance Connection in the ApplianceConnect Parameter value. Please correct this and try again.' + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -TargetType $ApplianceConnection.GetType().Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + Process + { + + $fs = [IO.FileStream]::new($File.FullName, $FSOpenMode, $FSRead) + [void]$fs.FlushAsync() + + "[{0}] Uploading {1} file to appliance, this may take a few minutes..." -f $MyInvocation.InvocationName.ToString().ToUpper(), $File.FullName | Write-Verbose + + try + { + + # $uri = "{0}?uploadfilename={1}" -f $uri, $File.Name + $url = "https://{0}/{1}?uploadfilename={2}" -f $ApplianceConnection, $uri, $File.Name + + $_DispositionContentType = "application/octet-stream" + + if ($File.Extension -eq '.crl') + { + + $_DispositionContentType = "application/pkix-crl" + + "[{0}] Setting HttpWebRequest body encoding to 'ISO-8859-1': {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), [Bool]$_encoding | Write-Verbose + + } + + "[{0}] Setting Disposition Content-Type to: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_DispositionContentType | Write-Verbose + + [System.Net.HttpWebRequest]$uploadRequest = RestClient $Method $uri -Appliance $ApplianceConnection.Name + + $LF = [System.Environment]::NewLine + $boundary = "-----------------------" + [DateTime]::Now.Ticks.ToString("x") + $beginBoundary = "--" + $boundary + "$LF" + $disposition = 'Content-Disposition: form-data; name="file"; filename="{1}"{0}Content-Type: {2}{0}{0}' -f $LF, $File.Name, $_DispositionContentType + $endBoundary = "$LF--" + $boundary + "--$LF" + [byte[]]$BoundaryBytes = [System.Text.Encoding]::UTF8.GetBytes($beginBoundary) + [byte[]]$ContentDispBytes = [System.Text.Encoding]::UTF8.GetBytes($disposition) + [byte[]]$EndBoundaryBytes = [System.Text.Encoding]::UTF8.GetBytes($endBoundary) + $_ContentLength = $BoundaryBytes.length + $ContentDispBytes.length + $File.Length + $EndBoundaryBytes.Length + + $uploadRequest.Timeout = 1200000 + $uploadRequest.ContentType = "multipart/form-data; boundary={0}" -f $boundary + $uploadRequest.Headers.Item("auth") = $ApplianceConnection.SessionID + $uploadRequest.Headers.Item("uploadfilename") = $File.Name + $uploadRequest.AllowWriteStreamBuffering = $false # DO NOT CHANGE THIS VALUE. MUST BE $FALSE + $uploadRequest.SendChunked = $false # DO NOT CHANGE THIS VALUE. MUST BE $FALSE + $uploadRequest.ContentLength = $_ContentLength + + ForEach ($_Header in $AddHeader) + { + + $uploadRequest.Headers.($_Header.Name) = $_Header.Value + + } + + "[{0}] Request: POST {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $uri | Write-Verbose + + $i = 0 + + foreach ($h in $uploadRequest.Headers) + { + + "[{0}] Request Header ({1}) {2} : {3}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $i, $h, $uploadRequest.Headers[$i] | Write-Verbose + + $i++ + + } + + $rs = $uploadRequest.GetRequestStream() + + [void]$rs.FlushAsync() + + [byte[]]$readbuffer = [byte[]]::new(4096 * 1024) + $rs.write($BoundaryBytes, 0, $BoundaryBytes.Length); + $rs.write($ContentDispBytes, 0, $ContentDispBytes.Length); + + # This is used to keep track of the file upload progress. + $numBytesToRead = $fs.Length + [int64]$_numBytesRead = 0 + + if ($PSBoundParameters['Verbose'] -or $VerbosePreference -eq 'Continue') + { + + "[{0}] Skipping Write-Progress display." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + $_sw = [System.Diagnostics.Stopwatch]::StartNew() + $_progresssw = [System.Diagnostics.Stopwatch]::StartNew() + + while ($bytesRead = $fs.Read($readbuffer, 0, $readbuffer.length)) + { + + $rs.write($readbuffer, 0, $bytesRead) + + # Keep track of where we are at clearduring the read operation + $_numBytesRead += $bytesRead + + # Flush the buffer every 200ms and 1MB written? + if ($_progresssw.Elapsed.TotalMilliseconds -ge 200 -and $_numBytesRead % 100mb -eq 0) + { + + "[{0}] Flushing request stream." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + [void]$rs.flush() + + } + + # Use the Write-Progress cmd-let to show the progress of uploading the file. + [Int]$_percent = [math]::floor(($_numBytesRead / $fs.Length) * 100) + + # Elapsed time to calculat throughput + [Int]$_elapsed = $_sw.ElapsedMilliseconds / 1000 + + if ($_elapsed -ne 0 ) + { + + [single]$_transferrate = [Math]::Round(($_numBytesRead / $_elapsed) / 1mb) + + } + + else + { + + [single]$_transferrate = 0.0 + + } + + $status = "({0:0}MB of {1:0}MB transferred @ {2}MB/s) Completed {3}%" -f ($_numBytesRead / 1MB), ($numBytesToRead / 1MB), $_transferrate, $_percent + + # Handle the call from -Verbose so Write-Progress does not get borked on display. + if ($PSBoundParameters['Verbose'] -or $VerbosePreference -eq 'Continue') + { + + "[{0}] Uploading file {1}, status: {2}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $File.Name, $status | Write-Verbose + + } + + else + { + + if ($_progresssw.Elapsed.TotalMilliseconds -ge 500) + { + + if ($_numBytesRead % 1mb -eq 0) + { + + Write-Progress -activity "Upload File" -status ("Uploading '{0}'" -f $File.Name) -CurrentOperation $status -PercentComplete $_percent + + } + + } + + } + + } + + "[{0}] Finalizing upload." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $fs.close() + + "[{0}] Sending end boundary to complete the multipart form data transfer." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $rs.write($EndBoundaryBytes, 0, $EndBoundaryBytes.Length) + + $_FinalTransferLength = $_numBytesRead + $BoundaryBytes.Length + $ContentDispBytes.Length + $EndBoundaryBytes.Length + + "[{0}] Total bytes transferred: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_FinalTransferLength | Write-Verbose + "[{0}] Total bytes transferred equal content-length: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), ($_FinalTransferLength -eq $uploadRequest.ContentLength) | Write-Verbose + + "[{0}] Closing streams." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $rs.close() + + $_sw.stop() + $_sw.Reset() + + Write-Progress -activity "Upload File" -status ("Uploading '{0}'" -f $File.Name) -Complete + + } + + catch [System.Exception] + { + + Write-Verbose "Exception caught while uploading file." + + Write-Verbose ("Exception: {0}" -f $_.Exception.Message) + Write-Verbose ("InnerException: {0}" -f $_.Exception.InnerException.Message) + + if ($fs) + { + + $fs.close() + + } + + if ($_sw.IsRunning) + { + + $_sw.Stop() + $_sw.Reset() + + } + + # Dispose if still exist + if ($rs) + { + + $rs.close() + + } + + $PSCmdlet.ThrowTerminatingError($_) + + } + + try + { + + "[{0}] Upload Request completed." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if ($PSBoundParameters['Verbose'] -or $VerbosePreference -eq 'Continue') + { + + "[{0}] Waiting for completion response from appliance." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + else + { + + Write-Progress -activity "Upload File" -status ("Uploading '{0}'" -f $File.Name) -CurrentOperation "Waiting for completion response from appliance." -percentComplete $_percent + + } + + [Net.httpWebResponse]$WebResponse = $uploadRequest.getResponse() + + "[{0}] Response Status: ({1}) {2}" -f $MyInvocation.InvocationName.ToString().ToUpper(), [Int]$WebResponse.StatusCode, $WebResponse.StatusDescription | Write-Verbose + + $uploadResponseStream = $WebResponse.GetResponseStream() + + # Read the response & convert to JSON + $reader = [System.IO.StreamReader]::new($uploadResponseStream) + $responseJson = $reader.ReadToEnd() + + $uploadResponse = ConvertFrom-Json $responseJson + + $uploadResponseStream.Close() + + # need to parse the output to know when the upload is truly complete + "[{0}] Response: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), ($uploadResponse | out-string) | Write-Verbose + + $i = 0 + + foreach ($h in $WebResponse.Headers) + { + + "[{0}] Response Header {1}: {2} = {3}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $i, $h, $WebResponse.Headers[$i] | Write-Verbose + + $i++ + + } + + $uploadRequest = $Null + + Write-Progress -activity "Upload File" -CurrentOperation "Uploading $Filename " -Completed + + } + + catch [Net.WebException] + { + + if ($null -ne $_.Exception.Response) + { + + "[{0}] WebException caught. Getting exception response from API." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + # Need to see if Response is not empty + + $sr = [IO.StreamReader]::new($_.Exception.Response.GetResponseStream()) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $errorObject = $sr.readtoEnd() | ConvertFrom-Json + + "[{0}] Error Response from API: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), ($errorObject | Out-String) | Write-Verbose + + # dispose if still exist + if ($rs) + { + + $rs.close() + + } + + if ($fs) + { + + $fs.close() + + } + + $sr.close() + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.UploadFileException $errorObject.ErrorCode InvalidResult 'Upload-File' -Message $errorObject.Message -InnerException $_.Exception + + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + else + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + End + { + + if ($uploadResponseStream) + { + + $uploadResponseStream.Close() + + } + + # Handle file uploads that generate task resource (i.e. Upload SPP Baseline) + if ($uploadResponse.category -eq $ResourceCategoryEnum.Task) + { + + "[{0}] Response is a task resource" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $uploadResponse | ForEach-Object { $_.PSObject.TypeNames.Insert(0, "HPEOneview.Appliance.TaskResource") } + + Add-Member -InputObject $uploadResponse -NotePropertyName ApplianceConnection -NotePropertyValue ([HPEOneView.Library.ApplianceConnection]::new($ApplianceConnection.Name, $ApplianceConnection.ConnectionId)) -Force + + return $uploadResponse + + } + + elseif ($null -ne $WebResponse.Headers) + { + + if ($WebResponse.Headers['Location']) + { + + try + { + + "[{0}] Response is a task resource provided by HTTP Location header." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $uri = $WebResponse.Headers['Location'] + + $taskResource = Send-OVRequest -Uri $uri -Hostname $ApplianceConnection.Name + + Return $taskResource + + } + + catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + else + { + + "[{0}] Response does not contain any HTTP headers or task location. Returning API response body." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + return $uploadResponse + + } + + } + + } + +} + +function Get-OVScmbCertificates +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = 'default')] + Param + ( + + [Parameter (Mandatory = $false, ParameterSetName = "default")] + [Parameter (Mandatory = $false, ParameterSetName = "convert")] + [ValidateNotNullOrEmpty()] + [Alias ("save")] + [String]$Location = ($pwd).path, + + [Parameter (Mandatory = $false, ParameterSetName = "convert")] + [ValidateNotNullOrEmpty()] + [Alias ("pfx")] + [Switch]$ConvertToPFx, + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = "convert")] + [ValidateNotNullOrEmpty()] + [SecureString]$Password, + + [Parameter (Mandatory = $false, ParameterSetName = "default")] + [Parameter (Mandatory = $false, ParameterSetName = "convert")] + [Switch]$InstallApplianceRootCA, + + [Parameter (Mandatory = $false, ParameterSetName = "default")] + [Parameter (Mandatory = $false, ParameterSetName = "convert")] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $TaskCollection = [System.Collections.ArrayList]::new() + + # Validate the path exists. If not, create it. + if (-not(Test-Path $Location)) + { + + "[{0}] Directory does not exist. Creating directory..." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + New-Item -path $Location -ItemType Directory + + } + + } + + Process + { + + ForEach ($_appliance in $ApplianceConnection) + { + + "[{0}] Processing '{1}' appliance connection (of {2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name, $ApplianceConnection.count | Write-Verbose + + # Appliance CA + $caFile = '{0}\{1}_ca.cer' -f $Location, $_appliance.Name + + # Appliance Public Key + $publicKeyFile = '{0}\{1}_cert.cer' -f $Location, $_appliance.Name + + # Rabbit Client Private Key + $privateKeyFile = '{0}\{1}_privateKey.key' -f $Location, $_appliance.Name + + # Check to see if the Rabbit client cert was already created + Try + { + + $_keys = Send-OVRequest -Uri $ApplianceRabbitMQKeyPairUri -Hostname $_appliance.Name + + } + + Catch [HPEOneView.ResourceNotFoundException] + { + + "[{0}] RabbitMQ SSL cert key pair does not exist." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $_rabbitbody = NewObject -RabbitmqCertReq + + # Generate the client private key request + # "[{0}] Body: $($_rabbitbody | Format-List * )" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Send-OVRequest -Uri $ApplianceScmbRabbitmqUri -Method POST -Body $_rabbitbody -Hostname $_appliance.Name | Wait-OVTaskComplete | Out-Null + + # Retrieve generated keys + $_keys = Send-OVRequest -Uri $ApplianceRabbitMQKeyPairUri -Hostname $_appliance.Name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + try + { + + New-Item $PrivateKeyFile -type file -force -value $_keys.base64SSLKeyData + + $PrivateKeyFile = [System.IO.FileInfo]$PrivateKeyFile + + "[{0}] Created rabbitmq_readonly user Private Key: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $PrivateKeyFile.Name | Write-Verbose + + } + + catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + try + { + + New-Item $PublicKeyFile -type file -force -value $_keys.base64SSLCertData + + $PublicKeyFile = [System.IO.FileInfo]$PublicKeyFile + + "[{0}] Created rabbitmq_readonly user Public Key: {0}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $PublicKeyFile.FullName | Write-Verbose + + } + + catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + If ($PSBoundParameters['ConvertToPFx']) + { + + Try + { + + ConvertTo-Pfx -PrivateKeyFile $PrivateKeyFile -PublicKeyFile $PublicKeyFile -Password $Password + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + try + { + + $_Resp = Send-OVRequest -Uri $ApplianceInternalCertificateAuthority -Hostname $_appliance.Name + + $_ca = $_Resp.members[0].certificateDetails.base64Data + + New-Item $caFile -type file -force -value $_ca + + "[{0}] Created {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $caFile | Write-Verbose + + } + + catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if ($PSBoundParameters['InstallApplianceRootCA']) + { + + # Get certificate + [Security.Cryptography.X509Certificates.X509Certificate2]$Cert = [System.Convert]::FromBase64String($_ca.Replace('-----BEGIN CERTIFICATE-----',$null).Replace('-----End CERTIFICATE-----',$null)) + + $StoreScope = "CurrentUser" + $StoreName = "Root" + + # Save to users Trusted Root Authentication Hosts store + $store = [System.Security.Cryptography.X509Certificates.X509Store]::new($StoreName, $StoreScope) + + $store.Open([System.Security.Cryptography.X509Certificates.OpenFlags]::ReadWrite) + + try + { + + "[{0}] Attempting to add cert to store" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $store.Add($cert) + $store.Close() + + "[{0}] Cert added successfully" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + catch + { + + $store.Close() + + $PSCmdlet.ThrowTerminatingError($_.Exception) + + } + + } + + } + + } + +} + +function ConvertTo-Pfx +{ + + # Modified from Script provided by Vadims Padans (https://www.sysadmins.lv/blog-en/how-to-convert-pem-to-x509certificate2-in-powershell-revisited.aspx) + + [CmdletBinding ()] + Param + ( + + [Parameter (Mandatory)] + [System.IO.FileSystemInfo]$PrivateKeyFile, + + [Parameter (Mandatory)] + [System.IO.FileSystemInfo]$PublicKeyFile, + + [Parameter (Mandatory)] + [SecureString]$Password + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + } + + Process + { + + function __normalizeAsnInteger ($array) + { + + $padding = $array.Length % 8 + + if ($padding) + { + + $array = $array[$padding..($array.Length - 1)] + + } + + [array]::Reverse($array) + + [Byte[]]$array + + } + + function __extractCert([String]$Text) + { + + $keyFlags = [Security.Cryptography.X509Certificates.X509KeyStorageFlags]::Exportable + + $matches = [RegEx]::Match($Text, "(?msx).*-{5}BEGIN\sCERTIFICATE-{5}(.+)-{5}End\sCERTIFICATE-{5}", $RegExInsensitiveFlag) #| Out-Null + + $RawData = [Convert]::FromBase64String($matches.groups[1].value.split(' ')) + + try + { + + [Security.Cryptography.X509Certificates.X509Certificate2]::new($RawData, $null, $keyFlags) + + } + + catch + { + + throw "The data is not valid security certificate." + + } + + Write-Debug "X.509 certificate is correct." + + } + + # returns [byte[]] + function __composePRIVATEKEYBLOB($modulus, $PublicExponent, $PrivateExponent, $Prime1, $Prime2, $Exponent1, $Exponent2, $Coefficient) + { + + Write-Debug "Calculating key length." + + $bitLen = "{0:X4}" -f $($modulus.Length * 8) + + Write-Debug "Key length is $($modulus.Length * 8) bits." + + # Change from Invoke-Expression due to security "issues" and guidance from MS + # [byte[]]$bitLen1 = Invoke-Expression 0x$([Int]$bitLen.Substring(0,2)) + [byte[]]$bitLen1 = '0x{0}' -f [Int]$bitLen.Substring(0,2) + # [byte[]]$bitLen2 = Invoke-Expression 0x$([Int]$bitLen.Substring(2,2)) + [byte[]]$bitLen2 = '0x{0}' -f [Int]$bitLen.Substring(2,2) + [Byte[]]$PrivateKey = 0x07,0x02,0x00,0x00,0x00,0x24,0x00,0x00,0x52,0x53,0x41,0x32,0x00 + [Byte[]]$PrivateKey = $PrivateKey + $bitLen1 + $bitLen2 + $PublicExponent + ,0x00 + $modulus + $Prime1 + $Prime2 + $Exponent1 + $Exponent2 + $Coefficient + $PrivateExponent + + Return $PrivateKey + + } + + # returns RSACryptoServiceProvider for dispose purposes + function __attachPrivateKey($_Cert, [Byte[]]$PrivateKey) + { + + $cspParams = [Security.Cryptography.CspParameters]::new() + + $cspParams.ProviderName = $ProviderName + $cspParams.KeyContainerName = "pspki-" + [Guid]::NewGuid().ToString() + $cspParams.KeyNumber = 1 # AT_KEYEXCHANGE + + $rsa = [Security.Cryptography.RSACryptoServiceProvider]::new($cspParams) + + $rsa.ImportCspBlob($PrivateKey) + + # This is here due to .NetCore changes to the X509Certificate2 API. The PrivateKey property cannot be set, and getter is only available for backwards compat. (https://github.com/dotnet/runtime/issues/27346) + if ($PSVersionTable.PSEdition -eq "Core") + { + + "Using alternate dotnetcore method to attaching private key to cert." | Write-Debug + [void][Reflection.Assembly]::Load("System.Security.Cryptography.X509Certificates") + $script:Cert = [System.Security.Cryptography.X509Certificates.RSACertificateExtensions]::CopyWithPrivateKey($_Cert, $rsa) + + } + + else + { + + "Using dotnet framework standard method to attach private key to cert." | Write-Debug + + $Cert.PrivateKey = $rsa + + } + + "Cert has private key: {0}" -f $script:Cert.HasPrivateKey | Write-Debug + + Return $rsa + + } + + # returns Asn1Reader + function __decodePkcs1($base64) + { + + Write-Debug "Processing PKCS#1 RSA KEY module." + + # $asn = [SysadminsLV.Asn1Parser.Asn1Reader]::new($null,[Convert]::FromBase64String($base64)) + $asn = [SysadminsLV.Asn1Parser.Asn1Reader]::new([Convert]::FromBase64String($base64)) + + if ($asn.Tag -ne 48) {throw "The data is invalid."} + + Return $asn + + } + + # returns Asn1Reader + function __decodePkcs8($base64) + { + + Write-Debug "Processing PKCS#8 Private Key module." + + $asn = [SysadminsLV.Asn1Parser.Asn1Reader]::new($null,[Convert]::FromBase64String($base64)) + + if ($asn.Tag -ne 48) {throw "The data is invalid."} + + # version + if (!$asn.MoveNext()) {throw "The data is invalid."} + + # algorithm identifier + if (!$asn.MoveNext()) {throw "The data is invalid."} + + # octet string + if (!$asn.MoveNextCurrentLevel()) {throw "The data is invalid."} + if ($asn.Tag -ne 4) {throw "The data is invalid."} + if (!$asn.MoveNext()) {throw "The data is invalid."} + + Return $asn + + } + + $PfxFileName = $PrivateKeyFile.FullName.Replace(".key",".pfx") + + # Merge Public and Private Key file contents together + [String]$PrivateKeyFileContents = [System.IO.File]::ReadAllLines($PrivateKeyFile.FullName) + [String]$CertFileContents = [System.IO.File]::ReadAllLines($PublicKeyFile.FullName) + + Write-Debug "Extracting certificate information..." + + $script:Cert = __extractCert $CertFileContents # Validate PEM certificate + + $matches = [RegEx]::Match($PrivateKeyFileContents, "(?msx).*-{5}BEGIN\sRSA\sPRIVATE\sKEY-{5}(.+)-{5}End\sRSA\sPRIVATE\sKEY-{5}", $RegExInsensitiveFlag) + $asn = __decodePkcs1 $matches.groups[1].value.split(' ') + + # private key version + if (!$asn.MoveNext()) {throw "The data is invalid."} + + # modulus n + if (!$asn.MoveNext()) {throw "The data is invalid."} + + $modulus = __normalizeAsnInteger $asn.GetPayload() + Write-Debug "Modulus length: $($modulus.Length)" + + # public exponent e + if (!$asn.MoveNext()) {throw "The data is invalid."} + + # public exponent must be 4 bytes exactly. + $PublicExponent = if ($asn.GetPayload().Length -eq 3) + { + + ,0 + $asn.GetPayload() + + } + + else + { + + $asn.GetPayload() + + } + + Write-Debug "PublicExponent length: $($PublicExponent.Length)" + + # private exponent d + if (!$asn.MoveNext()) {throw "The data is invalid."} + $PrivateExponent = __normalizeAsnInteger $asn.GetPayload() + Write-Debug "PrivateExponent length: $($PrivateExponent.Length)" + + # prime1 p + if (!$asn.MoveNext()) {throw "The data is invalid."} + $Prime1 = __normalizeAsnInteger $asn.GetPayload() + Write-Debug "Prime1 length: $($Prime1.Length)" + + # prime2 q + if (!$asn.MoveNext()) {throw "The data is invalid."} + $Prime2 = __normalizeAsnInteger $asn.GetPayload() + Write-Debug "Prime2 length: $($Prime2.Length)" + + # exponent1 d mod (p-1) + if (!$asn.MoveNext()) {throw "The data is invalid."} + $Exponent1 = __normalizeAsnInteger $asn.GetPayload() + Write-Debug "Exponent1 length: $($Exponent1.Length)" + + # exponent2 d mod (q-1) + if (!$asn.MoveNext()) {throw "The data is invalid."} + $Exponent2 = __normalizeAsnInteger $asn.GetPayload() + Write-Debug "Exponent2 length: $($Exponent2.Length)" + + # coefficient (inverse of q) mod p + if (!$asn.MoveNext()) {throw "The data is invalid."} + $Coefficient = __normalizeAsnInteger $asn.GetPayload() + Write-Debug "Coefficient length: $($Coefficient.Length)" + + # creating Private Key BLOB structure + $PrivateKey = __composePRIVATEKEYBLOB $modulus $PublicExponent $PrivateExponent $Prime1 $Prime2 $Exponent1 $Exponent2 $Coefficient + + # Region key attach and export routine + $rsaKey = __attachPrivateKey $Cert $PrivateKey + + "Cert has private key still: {0}" -f $Cert.HasPrivateKey | Write-Debug + + $pfxBytes = $Cert.Export([System.Security.Cryptography.X509Certificates.X509ContentType]::Pfx, $Password) + [System.IO.File]::WriteAllBytes($PfxFileName, $pfxBytes) + + $rsaKey.Dispose() + [System.IO.FileInfo]$PfxFileName + + "[{0}] Created PFX certificate: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $PfxFileName | Write-Verbose + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Remove-OVScmbCertificate +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdLetBinding (DefaultParameterSetName = "Default", SupportsShouldProcess, ConfirmImpact = 'High')] + Param + ( + + [Parameter (Mandatory = $false, ParameterSetName = "default")] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + Process + { + + ForEach ($_appliance in $ApplianceConnection) + { + + "[{0}] Processing '{1}' appliance connection (of {2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name, $ApplianceConnection.count | Write-Verbose + + Try + { + + $_keys = Send-OVRequest -Uri $ApplianceRabbitMQKeyPairUri -Hostname $_appliance + + } + + Catch [HPEOneView.ResourceNotFoundException] + { + + $ExceptionMessage = 'The SCMB certificate key pair has not bee generated on the appliance "{0}". Please use Get-OVScmbCertificates to generate a new certificate key pair.' -f $_appliance.Name + $ErrorRecord = New-ErrorRecord HPEOneView.ResourceNotFoundException ResourceNotFound ObjectNotFound "ScmbCertifcateKeyPait" -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if ($PSCmdlet.ShouldProcess($_appliance.Name, "Remove SCMB (RabbitMQ) rabbit_readonly user certificates")) + { + + Try + { + + Send-OVRequest -Uri $ApplianceRabbitMQKeyPairCertUri -Method DELETE -Hostname $_appliance -AddHeader @{'if-match' = "*"} + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + Finally + { + + + } + + } + + elseif ($PSBoundParameters['WhatIf']) + { + + "[{0}] Caller passed -WhatIf Parameter." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + else + { + + "[{0}] Caller selected NO to confirmation prompt." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Import-OVSslCertificate +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding ()] + + Param + ( + + [Parameter (ValueFromPipeline, Mandatory = $false)] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not($PSBoundParameters['ApplianceConnection'])) + { + + $PipelineInput = $True + + } + + } + + Process + { + + ForEach ($_appliance in $ApplianceConnection) + { + + if ($_appliance -is [HPEOneView.Appliance.Connection]) + { + + $_appliance = $_appliance.Name + + } + + "[{0}] Processing Appliance '{1}' (of {2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance, $ApplianceConnection.Count | Write-Verbose + + try + { + + "[{0}] Getting response" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + [System.Net.HttpWebRequest]$WebRequest = [System.Net.HttpWebRequest]::Create("https://$_appliance") + + $WebRequest.ServerCertificateValidationCallback = { $True } + + $Response = $WebRequest.GetResponse() + + } + + catch [Net.WebException] + { + + if (-not($WebRequest.Connection) -and ([Int]$Response.StatusCode -eq 0)) + { + + Write-Error $_.Exception.Message -Category ObjectNotFound -ErrorAction Stop + + } + + } + + finally + { + + # Close the response connection, as it is no longer needed, and will cause problems if left open. + if ($Response) + { + + "[{0}] Closing response connection" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $Response.Close() + + } + + $Response.Dispose() + + } + + if ($null -ne $WebRequest.ServicePoint.Certificate) + { + + # Get certificate + $Cert = [Security.Cryptography.X509Certificates.X509Certificate2]$WebRequest.ServicePoint.Certificate + + $StoreScope = "CurrentUser" + $StoreName = "Root" + + # Save to users Trusted Root Authentication Hosts store + $store = [System.Security.Cryptography.X509Certificates.X509Store]::new($StoreName, $StoreScope) + + $store.Open([System.Security.Cryptography.X509Certificates.OpenFlags]::ReadWrite) + + try + { + + "[{0}] Attempting to add cert to store" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $store.Add($cert) + $store.Close() + + "[{0}] Cert added successfully" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + catch + { + + $store.Close() + # Write-Error $_.Exception.Message -Category InvalidResult -ErrorAction Stop + $PSCmdlet.ThrowTerminatingError($_.Exception) + + } + + } + + } + + } + + End + { + + Write-Warning "Please note that the Subject Alternate Name (SAN) must match that of the Appliance hostname you use to connect to your appliance. If it does not, an SSL connection failure will occur. When creating a CSR on the appliance, make sure to include the additional FQDN and IP address(es) in the Alternative Name field." + + } + +} + +function Restart-OVAppliance +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (SupportsShouldProcess, ConfirmImpact = 'High')] + Param + ( + + [Parameter (ValueFromPipeline, Mandatory = $false)] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not($PSBoundParameters['ApplianceConnection'])) + { + + $PipelineInput = $True + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + $TaskCollection = [System.Collections.ArrayList]::new() + + } + + Process + { + + if (-not($ApplianceConnection)) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + ForEach ($_appliance in $ApplianceConnection) + { + + "[{0}] Processing Appliance '$($_appliance.Name)' (of $($ApplianceConnection.Count))" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + "[{0}] Appliance Restart being request." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + "[{0}] Presenting confirmation prompt." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if ($PSCmdlet.ShouldProcess(("Restart appliance {0}" -f $_appliance.Name),"WARNING: Restarting the appliance will cause all users to be disconnected and all ongoing tasks to be interrupted.",('Perform operation "Restart appliance" on target "{0}"?' -f $_appliance.Name))) + { + + "[{0}] User confirmed appliance shutdown." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + + $_resp = Send-OVRequest -uri $script:applianceRebootUri -method POST -Hostname $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + elseif ($PSBoundParameters['Whatif']) + { + + "[{0}] User passed -WhatIf." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + else + { + + "[{0}] User cancelled shutdown request." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + } + + } + + End + { + + Return $TaskCollection + + } + +} + +function Stop-OVAppliance +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (SupportsShouldProcess, ConfirmImpact = 'High')] + Param + ( + + [Parameter (ValueFromPipeline, Mandatory = $false)] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not $PSBoundParameters['ApplianceConnection']) + { + + $PipelineInput = $True + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + $TaskCollection = [System.Collections.ArrayList]::new() + + } + + Process + { + + ForEach ($_appliance in $ApplianceConnection) + { + + "[{0}] Processing Appliance '$($_appliance.Name)' (of $($ApplianceConnection.Count))" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + "[{0}] Appliance SHUTDOWN being requested..." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + "[{0}] Presenting confirmation prompt." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if ($PSCmdlet.ShouldProcess(("Shutdown appliance {0}" -f $_appliance.Name),"WARNING: Shutdown of the appliance will cause all users to be disconnected and all ongoing tasks to be interrupted.",('Perform operation "Shutdown appliance" on target "{0}"?' -f $_appliance.Name))) + { + + "[{0}] User confirmed appliance shutdown." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $_resp = Send-OVRequest -uri $applianceShutDownUri POST -Hostname $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + [void]$TaskCollection.Add($_resp) + + } + + elseif ($PSBoundParameters['Whatif']) + { + + "[{0}] User passed -WhatIf." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + else + { + + "[{0}] User cancelled shutdown request." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + } + + } + + End + { + + Return $TaskCollection + + } + +} + +function New-OVApplianceDataAtRestEncryptionKey +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "default")] + Param + ( + + [Parameter (Mandatory = $false, ParameterSetName = "default")] + [ValidateNotNullOrEmpty()] + [String]$Location, + + [Parameter (Mandatory = $false, ParameterSetName = "default")] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + # Validate the path exists. If not, create it. + if ($PSBoundParameters['Location'] -and -not(Test-Path $Location)) + { + + "[{0}] Directory does not exist. Creating directory..." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + New-Item $Location -itemtype directory + + } + + } + + Process + { + + ForEach ($_appliance in $ApplianceConnection) + { + + "[{0}] Processing '{1}' Appliance (of {2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name, $ApplianceConnection.Count | Write-Verbose + + if ($_appliance.ApplianceType -ne 'Composer') + { + + $ExceptionMessage = 'The ApplianceConnection {0} is not a Synergy Composer, which does not support Enclosure Discovery to create an Enclosure Group.' -f $_appliance + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.ComposerNodeException InvalidOperation InvalidOperation 'ApplianceConnection' -Message $ExceptionMessage + $PSCmdlet.WriteError($ErrorRecord) + + } + + else + { + + '[{0}] Generting new encryption key from appliance.' -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + Try + { + + $NewEncryptionKey = Send-OVRequest -Uri $ApplianceDataAtRestEncryptionKeyGenUri -Method POST -ApplianceConnection $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + '[{0}] User provided new passphrase to generate new encryption key.' -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $Body = @{ + keyId = $NewEncryptionKey.keyId; + applianceEncryptionKey = $NewEncryptionKey.applianceEncryptionKey + } + + Try + { + + $resp = Send-OVRequest -Uri $ApplianceEncryptionKeyUri -Method PUT -Body $Body -ApplianceConnection $_appliance | Wait-OVTaskComplete + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if ($PSBoundParameters[$Location]) + { + + $_filename = "{0}\{1}_ApplianceEncryptionKey_{2}.aek" -f $Location, $_appliance.Name.Replace(".", '_'), [DateTime]::now.ToString("yyyy-MM-dd") + + [System.IO.File]::WriteAllText($_filename, ($resp | ConvertTo-Json)) + + [System.IO.FileInfo]$_filename + + } + + else + { + + Write-Warning "If data at rest encryption is enabled, and you can not saved the encryption key file, you risk losing the ability to restore from backup. Please use the Save-OVApplianceDataAtRestEncryptionKey Cmdlet to save the encryption key file to a safe and secure place." + + $resp + + } + + } + + } + + End + { + + '[{0}] Done.' -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Save-OVApplianceDataAtRestEncryptionKey +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "default")] + Param + ( + + [Parameter (Mandatory = $false, ParameterSetName = "default")] + [ValidateNotNullOrEmpty()] + [Alias ("save")] + [String]$Location = (get-location).Path, + + [Parameter (Mandatory = $false, ParameterSetName = "default")] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + # Validate the path exists. If not, create it. + if ($PSBoundParameters['Location'] -and -not(Test-Path $Location)) + { + + "[{0}] Directory does not exist. Creating directory..." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + New-Item $Location -itemtype directory + + } + + } + + Process + { + + ForEach ($_appliance in $ApplianceConnection) + { + + "[{0}] Processing '{1}' Appliance (of {2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name, $ApplianceConnection.Count | Write-Verbose + + if ($_appliance.ApplianceType -ne 'Composer') + { + + $ExceptionMessage = 'The ApplianceConnection {0} is not a Synergy Composer, which does not support Enclosure Discovery to create an Enclosure Group.' -f $_appliance + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.ComposerNodeException InvalidOperation InvalidOperation 'ApplianceConnection' -Message $ExceptionMessage + $PSCmdlet.WriteError($ErrorRecord) + + } + + else + { + + # Get encryption key file from API + Try + { + + $_ApplianceEncryptionKeyFile = Download-File -Uri $ApplianceEncryptionKeyUri -SaveLocation $Location -ApplianceConnection $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + [System.IO.FileInfo]$_ApplianceEncryptionKeyFile.file + + } + + } + + } + + End + { + + '[{0}] Done.' -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Get-OVApplianceDataAtRestEncryption +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "default")] + Param + ( + + [Parameter (Mandatory = $false, ParameterSetName = "default")] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + Process + { + + ForEach ($_appliance in $ApplianceConnection) + { + + "[{0}] Processing '{1}' Appliance (of {2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name, $ApplianceConnection.Count | Write-Verbose + + if ($_appliance.ApplianceType -ne 'Composer') + { + + $ExceptionMessage = 'The ApplianceConnection {0} is not a Synergy Composer, which does not support Enclosure Discovery to create an Enclosure Group.' -f $_appliance + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.ComposerNodeException InvalidOperation InvalidOperation 'ApplianceConnection' -Message $ExceptionMessage + $PSCmdlet.WriteError($ErrorRecord) + + } + + else + { + + Try + { + + "[{0}] Getting current data at rest encryption." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + Send-OVRequest -Uri $ApplianceDataAtRestConfigUri -ApplianceConnection $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + } + + End + { + + '[{0}] Done.' -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Enable-OVApplianceDataAtRestEncryption +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "default", SupportsShouldProcess, ConfirmImpact = 'High')] + Param + ( + + [Parameter (Mandatory = $false, ParameterSetName = "default")] + [ValidateNotNullOrEmpty()] + [Alias ("save")] + [String]$Location = (get-location).Path, + + [Parameter (Mandatory = $false, ParameterSetName = "default")] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + # Validate the path exists. If not, create it. + if ($PSBoundParameters['Location'] -and -not(Test-Path $Location)) + { + + "[{0}] Directory does not exist. Creating directory..." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + New-Item $Location -itemtype directory + + } + + } + + Process + { + + ForEach ($_appliance in $ApplianceConnection) + { + + "[{0}] Processing '{1}' Appliance (of {2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name, $ApplianceConnection.Count | Write-Verbose + + if ($_appliance.ApplianceType -ne 'Composer') + { + + $ExceptionMessage = 'The ApplianceConnection {0} is not a Synergy Composer, which does not support Enclosure Discovery to create an Enclosure Group.' -f $_appliance + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.ComposerNodeException InvalidOperation InvalidOperation 'ApplianceConnection' -Message $ExceptionMessage + $PSCmdlet.WriteError($ErrorRecord) + + } + + else + { + + $Message = "Enable '{0}' appliance data at rest encryption" -f $_appliance + + if ($PSCmdlet.ShouldProcess($_appliance, $Message)) + { + + # Download and save encryption key file to $Location + Try + { + + "[{0}] Saving encryption key file from appliance to {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name, $Location | Write-Verbose + $_ApplianceEncryptionKeyFile = Download-File -Uri $ApplianceEncryptionKeyUri -SaveLocation $Location -ApplianceConnection $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + Try + { + + "[{0}] Reading saved encryption key file from from {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_ApplianceEncryptionKeyFile | Write-Verbose + $_FileContents = ([System.IO.File]::ReadAllText($_ApplianceEncryptionKeyFile)) | ConvertFrom-Json + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + # Build new object to enable, which reads the file, to then provide applianceEncryptionKey and keyId values + + $ConfigureSDAREncryption = NewObject -SecureDataAtRestEncryption + + $ConfigureSDAREncryption.secureDataAtRest = $true + $ConfigureSDAREncryption.applianceEncryptionKey = $_FileContents.applianceEncryptionKey + $ConfigureSDAREncryption.keyId = $_FileContents.keyId + + Try + { + + "[{0}] Attempting to enable data at rest encryption." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + Send-OVRequest -Uri $ApplianceDataAtRestConfigUri -Method PUT -Body $ConfigureSDAREncryption -ApplianceConnection $_appliance | Wait-OVTaskComplete + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + } + + } + + End + { + + '[{0}] Done.' -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Disable-OVApplianceDataAtRestEncryption +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "default", SupportsShouldProcess, ConfirmImpact = 'High')] + Param + ( + + [Parameter (Mandatory = $false, ParameterSetName = "default")] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + Process + { + + ForEach ($_appliance in $ApplianceConnection) + { + + "[{0}] Processing '{1}' Appliance (of {2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name, $ApplianceConnection.Count | Write-Verbose + + if ($_appliance.ApplianceType -ne 'Composer') + { + + $ExceptionMessage = 'The ApplianceConnection {0} is not a Synergy Composer, which does not support Enclosure Discovery to create an Enclosure Group.' -f $_appliance + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.ComposerNodeException InvalidOperation InvalidOperation 'ApplianceConnection' -Message $ExceptionMessage + $PSCmdlet.WriteError($ErrorRecord) + + } + + else + { + + Write-Warning "When disabled, the appliance encryption key, used to encrypt credentials and other private information, is stored on the appliance hard drive making this information vulnerable if the drive is stolen. This setting also controls whether the key is included in backups." + + $Message = "Disable '{0}' appliance data at rest encryption" -f $_appliance + + if ($PSCmdlet.ShouldProcess($_appliance, $Message)) + { + + $ConfigureSDAREncryption = NewObject -SecureDataAtRestEncryption + + Try + { + + "[{0}] Attempting to disable data at rest encryption." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + Send-OVRequest -Uri $ApplianceDataAtRestConfigUri -Method PUT -Body $ConfigureSDAREncryption -ApplianceConnection $_appliance | Wait-OVTaskComplete + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + } + + } + + End + { + + '[{0}] Done.' -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Get-OVFirmwareBundleUpdateSchedule +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = 'Default')] + Param + ( + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneView.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneView.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneView.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + Process + { + + Try + { + + $ApplianceUpdateScheduleConfig = Send-OVRequest -Uri $ApplianceUpdateScheduleUri -Hostname $ApplianceConnection + + } + + catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if ($ApplianceUpdateScheduleConfig.state -eq [HPEOneView.Appliance.StateEnum]::DISABLED) + { + + Return [HPEOneView.Appliance.FirmwareBundleUpdateSchedule]::new($ApplianceUpdateScheduleConfig.state, + $ApplianceUpdateScheduleConfig.etag, + $ApplianceUpdateScheduleConfig.created, + $ApplianceUpdateScheduleConfig.frequencyInWeeks, + $ApplianceUpdateScheduleConfig.ApplianceConnection) + + } + + else + { + + Return [HPEOneView.Appliance.FirmwareBundleUpdateSchedule]::new($ApplianceUpdateScheduleConfig.state, + $ApplianceUpdateScheduleConfig.etag, + $ApplianceUpdateScheduleConfig.created, + $ApplianceUpdateScheduleConfig.modified, + $ApplianceUpdateScheduleConfig.frequencyInWeeks, + $ApplianceUpdateScheduleConfig.scheduleFrequency, + $ApplianceUpdateScheduleConfig.scheduleDay, + $ApplianceUpdateScheduleConfig.scheduleTimeUTC, + $ApplianceUpdateScheduleConfig.lastSuccessfulCheck, + $ApplianceUpdateScheduleConfig.ApplianceConnection) + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Get-OVFirmwareBundleUpdate +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = 'Default')] + Param + ( + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [Switch]$GetLatestUpdates, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneView.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneView.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneView.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + Process + { + + # If user passes -GetLatestUpdates switch, this will be a different API call and require a PATCH operation to $ApplianceUpdateScheduleUri + if ($PSBoundParameters['GetLatestUpdates'].IsPresent) + { + + Try + { + + $_CheckForUpdatesOperation = NewObject -PatchOperation + $_CheckForUpdatesOperation.op = 'replace' + $_CheckForUpdatesOperation.path = '/state' + $_CheckForUpdatesOperation.value = $ApplianceUpdateScheduleStateEnum.CheckForUpdates + + $AvailableUpdates = Send-OVRequest -Method PATCH -Uri $ApplianceUpdateScheduleUri -Body $_CheckForUpdatesOperation -Hostname $ApplianceConnection -OverrideContentType "application/json" | Wait-OVTaskComplete + + } + + catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + Try + { + + $AvailableUpdates = Send-OVRequest -Uri $ApplianceAvailableUpdatesUri -Hostname $ApplianceConnection + + } + + catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + ForEach ($AvailableUpdate in $AvailableUpdates) + { + + # $AvailableUpdate.PSObject.TypeNames.Insert(0, "HPEOneView.Appliance.ApplianceAvailableUpdates") + $AvailableUpdate.PSObject.TypeNames.Insert(0, "HPEOneView.Appliance.FirmwareBundleUpdate") + $AvailableUpdate | Add-Member -NotePropertyName Supplements -NotePropertyValue ([System.Collections.ArrayList]::new()) + + ForEach ($Supplement in $AvailableUpdate.servicePackData.supplements) + { + + [void]$AvailableUpdate.Supplements.Add([Version]$Supplement.version) + + } + + $AvailableUpdate + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Set-OVFirmwareBundleUpdateSchedule +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = 'Default', SupportsShouldProcess, ConfirmImpact = 'High')] + Param + ( + + [Parameter (Mandatory, ParameterSetName = 'Disable')] + [Switch]$Disabled, + + [Parameter (Mandatory, ParameterSetName = 'Manual')] + [Switch]$ManualInterval, + + [Parameter (Mandatory, ParameterSetName = 'Default')] + [Switch]$WeeklyInterval, + + [Parameter (Mandatory, ParameterSetName = 'Default')] + [ValidateRange(1, 52)] + [Int]$Weeks, + + [Parameter (Mandatory, ParameterSetName = 'Default')] + [String]$Day, + + [Parameter (Mandatory, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [Timespan]$Time, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [Parameter (Mandatory = $false, ParameterSetName = 'Manual')] + [String]$ActivationKey, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [Parameter (Mandatory = $false, ParameterSetName = 'Disable')] + [Parameter (Mandatory = $false, ParameterSetName = 'Manual')] + [Switch]$Async, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [Parameter (Mandatory = $false, ParameterSetName = 'Disable')] + [Parameter (Mandatory = $false, ParameterSetName = 'Manual')] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneView.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneView.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneView.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $_ApplianceSchedulesToUpdate = [System.Collections.ArrayList]::new() + + } + + Process + { + + if ($PSBoundParameters['Disabled'].IsPresent) + { + + $_Operation = "Disable" + + $_UpdateApplianceScheduleSettings = NewObject -PatchOperation + $_UpdateApplianceScheduleSettings.op = 'replace' + $_UpdateApplianceScheduleSettings.path = '/state' + $_UpdateApplianceScheduleSettings.value = $ApplianceUpdateScheduleStateEnum.Disabled.ToLower() + + [void]$_ApplianceSchedulesToUpdate.Add($_UpdateApplianceScheduleSettings) + + } + + else + { + + $_Operation = "Enable/Update" + + $_UpdateApplianceScheduleSettings = NewObject -PatchOperation + $_UpdateApplianceScheduleSettings.op = 'replace' + $_UpdateApplianceScheduleSettings.path = '/state' + $_UpdateApplianceScheduleSettings.value = $ApplianceUpdateScheduleStateEnum.Enabled.ToLower() + + [void]$_ApplianceSchedulesToUpdate.Add($_UpdateApplianceScheduleSettings) + + if ($PSBoundParameters['ManualInterval'].IsPresent) + { + + $_UpdateApplianceScheduleSettings = NewObject -PatchOperation + $_UpdateApplianceScheduleSettings.op = 'replace' + $_UpdateApplianceScheduleSettings.path = '/scheduleFrequency' + $_UpdateApplianceScheduleSettings.value = $ApplianceUpdateScheduleIntervalEnum['Manual'].ToUpper() + + [void]$_ApplianceSchedulesToUpdate.Add($_UpdateApplianceScheduleSettings) + + } + + elseif ($PSBoundParameters['WeeklyInterval'].IsPresent) + { + + $_UpdateApplianceScheduleSettings = NewObject -PatchOperation + $_UpdateApplianceScheduleSettings.op = 'replace' + $_UpdateApplianceScheduleSettings.path = '/scheduleFrequency' + $_UpdateApplianceScheduleSettings.value = $ApplianceUpdateScheduleIntervalEnum['Weekly'].ToUpper() + + [void]$_ApplianceSchedulesToUpdate.Add($_UpdateApplianceScheduleSettings) + + } + + Switch ($PSBoundParameters.Keys) + { + + 'Weeks' + { + + $_UpdateApplianceScheduleSettings = NewObject -PatchOperation + $_UpdateApplianceScheduleSettings.op = 'replace' + $_UpdateApplianceScheduleSettings.path = '/frequencyInWeeks' + $_UpdateApplianceScheduleSettings.value = $Weeks.ToString() + + [void]$_ApplianceSchedulesToUpdate.Add($_UpdateApplianceScheduleSettings) + + } + + 'Day' + { + + $_UpdateApplianceScheduleSettings = NewObject -PatchOperation + $_UpdateApplianceScheduleSettings.op = 'replace' + $_UpdateApplianceScheduleSettings.path = '/scheduleDay' + $_UpdateApplianceScheduleSettings.value = $ApplianceUpdateScheduleDayEnum.$Day.ToUpper() + + [void]$_ApplianceSchedulesToUpdate.Add($_UpdateApplianceScheduleSettings) + + } + + 'Time' + { + + # Convert $Time to UTC formatted string" + $CurrentDate = [datetime]::Today + $dt = [DateTime]::new($currentDate.Year, $currentDate.Month, $currentDate.Day, $Time.Hours, $Time.Minute, 0) + $ConvertedTime = [TimeZoneInfo]::ConvertTimeToUtc($dt).TimeOfDay + + $_UpdateApplianceScheduleSettings = NewObject -PatchOperation + $_UpdateApplianceScheduleSettings.op = 'replace' + $_UpdateApplianceScheduleSettings.path = '/scheduleTimeUTC' + $_UpdateApplianceScheduleSettings.value = "{0:00}:{1:00}" -f $ConvertedTime.Hours, $ConvertedTime.Minutes + + [void]$_ApplianceSchedulesToUpdate.Add($_UpdateApplianceScheduleSettings) + + } + + 'ActivationKey' + { + + $_UpdateApplianceScheduleSettings = NewObject -PatchOperation + $_UpdateApplianceScheduleSettings.op = 'replace' + $_UpdateApplianceScheduleSettings.path = '/icmToken' + $_UpdateApplianceScheduleSettings.value = $ActivationKey + + [void]$_ApplianceSchedulesToUpdate.Add($_UpdateApplianceScheduleSettings) + + } + + + } + + } + + $ShouldProcessMessage = "{0} appliance schedule?" -f $_Operation + + if ($PSCmdlet.ShouldProcess($ShouldProcessMessage)) + { + + Try + { + + # Need to override ContentType as the URI doesn't support application/json-patch+json type. + $Responce = Send-OVRequest -Uri $ApplianceUpdateScheduleUri -Method PATCH -Body $_ApplianceSchedulesToUpdate -Hostname $ApplianceConnection -OverrideContentType "application/json" + + if ($PSBoundParameters['Async'].IsPresent) + { + + $Responce + + } + + else + { + + $Responce | Wait-OVTaskComplete + } + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + elseif ($PSBoundParameters['WhatIf']) + { + + "[{0}] Caller passed -WhatIf Parameter." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + else + { + + "[{0}] Caller selected NO to confirmation prompt." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +####################################################### +# Facilities: +# + +function Get-OVRack +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = 'Default')] + Param + ( + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [String]$Name, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [ValidateNotNullOrEmpty()] + [Object]$Datacenter, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneView.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneView.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneView.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $_RackCol = [System.Collections.ArrayList]::new() + + } + + Process + { + + $_uri = "{0}?category=racks" -f $IndexUri + + if ($PSBoundParameters['Datacenter']) + { + + $_uri = "{0}?parentUri={1}&name=DATACENTER_TO_PHYSICAL_OBJECT" -f $AssociationsUri, $Datacenter.uri + + } + + ForEach ($_appliance in $ApplianceConnection) + { + + '[{0}] Processing "{1}" appliance connection.' -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name | Write-Verbose + + try + { + + [Array]$_ResourcesFromIndexCol = Get-AllIndexResources -Uri $_uri -ApplianceConnection $_appliance + + } + + catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + If ($PSBoundParameters['Name']) + { + + $_ResourcesFromIndexCol = $_ResourcesFromIndexCol | Where-Object name -eq $Name + + } + + if ($_ResourcesFromIndexCol.count -eq 0 -and $Name) + { + + $ExceptionMessage = 'The "{0}" rack was not found on {1}. Please check the name and try again.' -f $Name, $_appliance.Name + $ErrorRecord = New-ErrorRecord HPEOneView.ResourceNotFoundException ObjectNotFound ObjectNotFound 'Name' -Message $ExceptionMessage + $PSCmdlet.WriteError($ErrorRecord) + + } + + ForEach ($_rack in $_ResourcesFromIndexCol) + { + + $_rack.PSObject.TypeNames.Insert(0,'HPEOneView.Facilities.Rack') + + $_rack + + } + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function New-OVRack +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = 'Default')] + Param + ( + + [Parameter (Mandatory, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [String]$Name, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [Int]$ThermalLimit, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [String]$SerialNumber, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [String]$PartNumber, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [String]$Model, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateRange(305, 1829)] + [Int]$Depth, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateRange(1867, 3048)] + [Int]$Height, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [Int]$UHeight, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateRange(305, 1829)] + [Int]$Width, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + Process + { + + $_Rack = NewObject -Rack + $_Rack.name = $Name + + Switch ($PSBoundParameters.Keys) + { + + 'ThermalLimit' + { + + $_Rack.thermalLimit = $ThermalLimit + + } + + 'SerialNumber' + { + + $_Rack.serialNumber = $SerialNumber + + } + + 'PartNumber' + { + + $_Rack.partNumber = $PartNumber + + } + + 'Model' + { + + $_Rack.model = $Model + + } + + 'UHeight' + { + + $_Rack.uHeight = $UHeight + + } + + 'Width' + { + + $_Rack.width = $Width + + } + + 'Depth' + { + + $_Rack.depth = $Depth + + } + + } + + if ($PSBoundParameters['Height']) + { + + $_Rack.height = $Height + + } + + else + { + + $_Rack.height = [Math]::Round($UHeight * 44.45) + + } + + Try + { + + Send-OVRequest -Uri $DataCenterRacksUri -Method POST -Body $_Rack -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Set-OVRack +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = 'Default')] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [Object]$InputObject, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [String]$Name, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [Int]$ThermalLimit, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [String]$SerialNumber, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [String]$PartNumber, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [String]$Model, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateRange(305, 1829)] + [Int]$Depth, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateRange(1867, 3048)] + [Int]$Height, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [Int]$UHeight, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateRange(305, 1829)] + [Int]$Width, + + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not $PSBoundParameters['InputObject']) + { + + $PipelineInput = $true + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + } + + Process + { + + # Validate the Inputobject is a Rack + if ($InputObject.category -ne $ResourceCategoryEnum.Rack) + { + + $ExceptionMessage = 'The InputObject is not a valid Rack object.' + $ErrorRecord = New-ErrorRecord HPEOneView.InputObjectResourceException InvalidParameter InvalidArgument 'InputObject' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + $_Rack = $InputObject.PSObject.Copy() + + Switch ($PSBoundParameters.Keys) + { + + 'Name' + { + + $_Rack.name = $Name + + } + + 'ThermalLimit' + { + + $_Rack.thermalLimit = $ThermalLimit + + } + + 'SerialNumber' + { + + $_Rack.serialNumber = $SerialNumber + + } + + 'PartNumber' + { + + $_Rack.partNumber = $PartNumber + + } + + 'Model' + { + + $_Rack.model = $Model + + } + + 'UHeight' + { + + $_Rack.uHeight = $UHeight + + # Adjust the Height for the rack based on the UHeight provided here. + if (-not $PSBoundParameters['Height']) + { + + $_Rack.height = [Math]::Round($UHeight * 44.45) + + } + + } + + 'Width' + { + + $_Rack.width = $Width + + } + + 'Depth' + { + + $_Rack.depth = $Depth + + } + + 'Height' + { + + $_Rack.height = $Height + + # Adjust the uHeight for the rack based on the Height provided here. + if (-not $PSBoundParameters['UHeight']) + { + + $_Rack.uHeight = [Math]::Round($Height / 44.45) + + } + + } + + } + + Try + { + + Send-OVRequest -Uri $_Rack.uri -Method PUT -Body $_Rack -Hostname $_Rack.ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +Function Add-OVResourceToRack +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = 'Default')] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = 'Default')] + [ValidateNotNullorEmpty()] + [Object]$InputObject, + + [Parameter (Mandatory, ParameterSetName = 'Default')] + [ValidateNotNullorEmpty()] + [Object]$Rack, + + [Parameter (Mandatory, ParameterSetName = 'Default')] + [ValidateNotNullorEmpty()] + [Int]$ULocation, + + [Parameter (Mandatory = $false, ValueFromPipelinebyPropertyName, ParameterSetName = 'Default')] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not $InputObject) + { + + $PipelineInput - $True + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + $_Collection = [System.Collections.ArrayList]::new() + + } + + Process + { + + if ($Rack.category -ne $ResourceCategoryEnum.Rack) + { + + $ExceptionMessage = 'The Rack is not a valid Rack object.' + $ErrorRecord = New-ErrorRecord HPEOneView.RackResourceException InvalidParameter InvalidArgument 'Rack' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + # Get the most current version of the object + Try + { + + $Rack = Send-OVRequest -Uri $Rack.uri -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + switch ($InputObject.category) + { + + 'server-hardware' + { + + $_RelativeOrder = 0 + [Int]$_UHeight = $InputObject.formFactor.Replace('U',$null) + + } + + 'unmanaged-devices' + { + + $_RelativeOrder = 0 + [Int]$_UHeight = $InputObject.height + + } + + 'enclosures' + { + + $_RelativeOrder = -1 + [Int]$_UHeight = 10 + + } + + # Unsupported type + default + { + + $ExceptionMessage = 'The resource {0} you are attempting to associate with the Rack {1} is not a supported object.' -f $InputObject.name, $Rack.name + $ErrorRecord = New-ErrorRecord HPEOneView.RackResourceException InvalidParameter InvalidArgument 'InputObject' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + if (($ULocation + $_UHeight - 1) -le 0) + { + + $ExceptionMessage = 'The resource {0} you are attempting to associate with the Rack {1} at {2} U location is not valid. The device is {3} Rack Units in size and cannot fit at {2} U rack position.' -f $InputObject.name, $Rack.name, $_UHeight, $ULocation + $ErrorRecord = New-ErrorRecord HPEOneView.RackResourceException InvalidParameter InvalidArgument 'Rack' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + $_RackItem = NewObject -RackItem + $_RackItem.mountUri = $InputObject.Uri.ToString() + $_RackItem.relativeOrder = $_RelativeOrder + $_RackItem.topUSlot = $ULocation + $_UHeight - 1 + $_RackItem.uHeight = $_UHeight + + $_OriginalRackContents = [Array]$Rack.rackMounts.Clone() + $Rack.rackMounts = [System.Collections.ArrayList]::new() + + $_OriginalRackContents | ForEach-Object { [void]$Rack.rackMounts.Add($_) } + [void]$Rack.rackMounts.Add($_RackItem) + + Try + { + + Send-OVRequest -Uri $Rack.uri -Method PUT -Body $Rack -AddHeader @{'If-Match' = $Rack.eTag} -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Get-OVRackMember +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = 'Default')] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [Object]$InputObject, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [String]$Name, + + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not($PSBoundParameters['InputObject'])) + { + + $PipelineInput = $true + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + $_RackCol = [System.Collections.ArrayList]::new() + $_TaskCollection = [System.Collections.ArrayList]::new() + + } + + Process + { + + if ($InputObject -is [PSCustomObject]) + { + + "[{0}] Rack Object provided: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject.name | Write-Verbose + + If ('racks' -contains $InputObject.category) + { + + If (-not($InputObject.ApplianceConnection)) + { + + $ErrorRecord = New-ErrorRecord HPEOneView.RackResourceException InvalidArgumentValue InvalidArgument "InputObject" -TargetType PSObject -Message "The InputObject object resource provided is missing the source ApplianceConnection property. Please check the object provided and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + else + { + + $ErrorRecord = New-ErrorRecord HPEOneView.RackResourceException InvalidArgumentValue InvalidArgument "InputObject" -TargetType $InputObject.GetType().Name -Message "The InputObject object resource is not an expected type. The allowed resource category type is 'racks'. Please check the object provided and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + "[{0}] Get most current Rack object version" -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject | Write-Verbose + + Try + { + + $InputObject = Send-OVRequest -Uri $InputObject.uri -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + else + { + + "[{0}] Processing Rack Name {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject | Write-Verbose + + Try + { + + $InputObject = Get-OVRack -Name $InputObject -ApplianceConnection $ApplianceConnection -ErrorAction Stop + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + # Get list of rack mounted objects to then either return to the caller or search for specific resource name + ForEach ($_RackItem in $InputObject.rackMounts) + { + + Try + { + + $_RackItemObject = Send-OVRequest -Uri $_RackItem.mountUri -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + switch ($_RackItemObject.category) + { + + 'server-hardware' + { + + $_Model = $_RackItemObject.model + [Int]$_UHeight = $_RackItemObject.formFactor.Replace('U',$null) + + } + + 'unmanaged-devices' + { + + $_Model = $_RackItemObject.model + [Int]$_UHeight = $_RackItemObject.height + + } + + 'enclosures' + { + + $_Model = $_RackItemObject.enclosureModel + [Int]$_UHeight = 10 + + } + + } + + $_RackULocation = $_RackItem.topUSlot - $_UHeight + 1 + + Try + { + + $_RackMember = [HPEOneView.Facilities.RackMember]::new($_RackItemObject.name, $_Model, $_UHeight, $_RackULocation, $_RackItemObject.uri, $InputObject.name, $InputObject.uri, $_RackItemObject.ApplianceConnection) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + [void]$_RackCol.Add($_RackMember) + + } + + if ($Name) + { + + $_RackCol = $_RackCol | Where-Object { $_.Name -match $Name } + + if (-not $_RackCol) + { + + $ExceptionMessage = 'The "{0}" rack member was not found in {1}. Please check the name and try again.' -f $Name, $InputObject.name + $ErrorRecord = New-ErrorRecord HPEOneView.ResourceNotFoundException ObjectNotFound ObjectNotFound 'Name' -Message $ExceptionMessage + $PSCmdlet.WriteError($ErrorRecord) + + } + + } + + $_RackCol + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Set-OVRackMemberLocation +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = 'Default')] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [HPEOneView.Facilities.RackMember]$InputObject, + + [Parameter (Mandatory, ParameterSetName = 'Default')] + [ValidateNotNullorEmpty()] + [Int]$ULocation, + + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not($PSBoundParameters['InputObject'])) + { + + $PipelineInput = $true + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + $_RackCol = [System.Collections.ArrayList]::new() + $_TaskCollection = [System.Collections.ArrayList]::new() + + } + + Process + { + + "[{0}] RackMember Object provided: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject.name | Write-Verbose + + If (-not($InputObject.ApplianceConnection)) + { + + $ErrorRecord = New-ErrorRecord HPEOneView.RackResourceException InvalidArgumentValue InvalidArgument "InputObject" -TargetType PSObject -Message "The InputObject object resource provided is missing the source ApplianceConnection property. Please check the object provided and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + # Get Rack from member + Try + { + + $Rack = Send-OVRequest -Uri $InputObject.RackUri -Hostname $InputObject.ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + ($Rack.rackMounts | Where-Object mountUri -eq $InputObject.Uri).topUSlot = ($ULocation + $InputObject.UHeight - 1) + + Try + { + + Send-OVRequest -Uri $Rack.uri -Method PUT -Body $Rack -Hostname $Rack.ApplianceConnection | Out-Null + + Get-OVRackMember -InputObject $Rack -Name $InputObject.Name -ErrorAction Stop + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Remove-OVRackMember +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "Default", SupportsShouldProcess, ConfirmImpact = 'High')] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = "Default")] + [ValidateNotNullorEmpty()] + [HPEOneView.Facilities.RackMember]$InputObject, + + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = "Default")] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not($PSBoundParameters['InputObject'])) + { + + $PipelineInput = $true + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + $_RackCol = [System.Collections.ArrayList]::new() + $_TaskCollection = [System.Collections.ArrayList]::new() + + } + + Process + { + + "[{0}] Begin resource removal process." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $RemoveMessage = "Remove Rack member '{0}'" -f $InputObject.Name + + if ($PSCmdlet.ShouldProcess($InputObject.RackName, $RemoveMessage)) + { + + Try + { + + # Get Rack resource object, which is what needs to be modified. + $Rack = Send-OVRequest -Uri $InputObject.RackUri -Hostname $InputObject.ApplianceConnection + + [Array]$Rack.rackMounts = $Rack.rackMounts | Where-Object mountUri -ne $InputObject.Uri + + Send-OVRequest -Uri $Rack.uri -Method PUT -Body $Rack -Hostname $Rack.ApplianceConnection -addHeader @{'If-Match' = $Rack.eTag} + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + elseif ($PSBoundParameters['WhatIf']) + { + + "[{0}] Caller passed -WhatIf Parameter." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + else + { + + "[{0}] Caller selected NO to confirmation prompt." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Remove-OVRack +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "Default", SupportsShouldProcess, ConfirmImpact = 'High')] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = "Default")] + [ValidateNotNullorEmpty()] + [Object]$InputObject, + + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = "Default")] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not($PSBoundParameters['InputObject'])) + { + + $PipelineInput = $true + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + $_RackCol = [System.Collections.ArrayList]::new() + $_TaskCollection = [System.Collections.ArrayList]::new() + + } + + Process + { + + if ($InputObject -is [PSCustomObject]) + { + + "[{0}] Processing Pipeline input" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + "[{0}] Rack Object provided: {1} ({2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject.name, $InputObject.uri | Write-Verbose + + If ('racks' -contains $InputObject.category) + { + + If (-not($InputObject.ApplianceConnection)) + { + + $ErrorRecord = New-ErrorRecord HPEOneView.RackResourceException InvalidArgumentValue InvalidArgument "InputObject" -TargetType PSObject -Message "The InputObject object resource provided is missing the source ApplianceConnection property. Please check the object provided and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + [void]$_RackCol.Add($InputObject) + + } + + else + { + + $ErrorRecord = New-ErrorRecord HPEOneView.RackResourceException InvalidArgumentValue InvalidArgument "InputObject" -TargetType $InputObject.GetType().Name -Message "The InputObject object resource is not an expected type. The allowed resource category type is 'racks'. Please check the object provided and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + else + { + + For ($c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + "[{0}] Processing Appliance {1} (of {2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $ApplianceConnection[$c].Name, $ApplianceConnection.Count | Write-Verbose + + "[{0}] Processing DataCenter Name {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject | Write-Verbose + + Try + { + + $_Racks = Get-OVRack -Name $InputObject -ApplianceConnection $ApplianceConnection[$c] + + $_Racks | ForEach-Object { + + [void]$_RackCol.Add($_) + + } + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + } + + End + { + + "[{0}] Begin resource removal process." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + foreach ($_rack in $_RackCol) + { + + $RemoveMessage = "Remove Rack '{0}'" -f $_rack.Name + + if ($PSCmdlet.ShouldProcess($_rack.ApplianceConnection,$RemoveMessage)) + { + + Try + { + + Send-OVRequest -Uri $_rack.uri -Method DELETE -Hostname $_rack.ApplianceConnection -addHeader @{'If-Match' = $_rack.eTag} + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + elseif ($PSBoundParameters['WhatIf']) + { + + "[{0}] Caller passed -WhatIf Parameter." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + else + { + + "[{0}] Caller selected NO to confirmation prompt." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + } + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Get-OVDataCenter +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = 'Default')] + Param + ( + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [String]$Name, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $_DCCol = [System.Collections.ArrayList]::new() + + } + + Process + { + + $uri = $DataCentersUri.Clone() + + if ($Name) + { + + $method = 'EQ' + + if ($Name.Contains('*')) + { + + $method = 'matches' + + } + + $uri = "{0}?filter=name {1} '{2}'" -f $uri, $method, $Name.Replace('*','%25').Replace('?','%26') + + } + + ForEach ($_appliance in $ApplianceConnection) + { + + '[{0}] Processing "{1}" appliance connection.' -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name | Write-Verbose + + try + { + + $Resp = Send-OVRequest -Uri $uri -Hostname $_appliance + + } + + catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if ($Resp.count -eq 0 -and $Name) + { + + $ExceptionMessage = 'The "{0}" datacenter was not found on {1}. Please check the name and try again.' -f $Name, $_appliance.Name + $ErrorRecord = New-ErrorRecord HPEOneView.ResourceNotFoundException ObjectNotFound ObjectNotFound 'Name' -Message $ExceptionMessage + $PSCmdlet.WriteError($ErrorRecord) + + } + + else + { + + Try + { + + $RemoteSupportConfigured = Send-OVRequest -Uri $RemoteSupportConfigUri -Hostname $_appliance.Name + + } + + catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + ForEach ($member in $resp.members) + { + + if ($RemoteSupportConfigured.enableRemoteSupport) + { + + '[{0}] Appliance has Remote Support enabled. Collecting DataCenter location and contact information.' -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name | Write-Verbose + + Try + { + + $_DCRemoteSupportLocation = Send-OVRequest -uri $member.remoteSupportUri -Hostname $_appliance.Name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $member | Add-Member -NotePropertyName RemoteSupportLocation -NotePropertyValue $_DCRemoteSupportLocation + + } + + $member.PSObject.TypeNames.Insert(0,'HPEOneView.Facilities.DataCenter') + + $member + + } + + } + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function New-OVDataCenter +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = 'Default')] + Param + ( + + [Parameter (Mandatory, ParameterSetName = 'Default')] + [Parameter (Mandatory, ParameterSetName = 'RemoteSupport')] + [ValidateNotNullOrEmpty()] + [String]$Name, + + [Parameter (Mandatory, ParameterSetName = 'Default')] + [Parameter (Mandatory, ParameterSetName = 'RemoteSupport')] + [ValidateNotNullOrEmpty()] + [Float]$Width, + + [Parameter (Mandatory, ParameterSetName = 'Default')] + [Parameter (Mandatory, ParameterSetName = 'RemoteSupport')] + [ValidateNotNullOrEmpty()] + [Float]$Depth, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [Parameter (Mandatory = $false, ParameterSetName = 'RemoteSupport')] + [Switch]$Millimeters, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [Parameter (Mandatory = $false, ParameterSetName = 'RemoteSupport')] + [ValidateNotNullOrEmpty()] + [Int]$ElectricalDerating = 20, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [Parameter (Mandatory = $false, ParameterSetName = 'RemoteSupport')] + [ValidateSet ('NaJp', 'Custom', 'None')] + [String]$ElectricalDeratingType = 'NaJp', + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [Parameter (Mandatory = $false, ParameterSetName = 'RemoteSupport')] + [ValidateNotNullOrEmpty()] + [Int]$DefaultVoltage = 220, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [Parameter (Mandatory = $false, ParameterSetName = 'RemoteSupport')] + [ValidateNotNullOrEmpty()] + [String]$Currency = 'USD', + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [Parameter (Mandatory = $false, ParameterSetName = 'RemoteSupport')] + [ValidateNotNullOrEmpty()] + [Float]$PowerCosts, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [Parameter (Mandatory = $false, ParameterSetName = 'RemoteSupport')] + [ValidateNotNullOrEmpty()] + [Int]$CoolingCapacity, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [Parameter (Mandatory = $false, ParameterSetName = 'RemoteSupport')] + [ValidateNotNullOrEmpty()] + [Float]$CoolingMultiplier = 1.5, + + [Parameter (Mandatory = $false, ParameterSetName = 'RemoteSupport')] + [ValidateNotNullOrEmpty()] + [Object]$PrimaryContact, + + [Parameter (Mandatory = $false, ParameterSetName = 'RemoteSupport')] + [ValidateNotNullOrEmpty()] + [Object]$SecondaryContact, + + [Parameter (Mandatory = $false, ParameterSetName = 'RemoteSupport')] + [ValidateNotNullOrEmpty()] + [String]$Address1, + + [Parameter (Mandatory = $False, ParameterSetName = 'RemoteSupport')] + [ValidateNotNullOrEmpty()] + [String]$Address2, + + [Parameter (Mandatory = $false, ParameterSetName = 'RemoteSupport')] + [ValidateNotNullOrEmpty()] + [String]$City, + + [Parameter (Mandatory = $false, ParameterSetName = 'RemoteSupport')] + [ValidateNotNullOrEmpty()] + [String]$State, + + [Parameter (Mandatory = $false, ParameterSetName = 'RemoteSupport')] + [ValidateNotNullOrEmpty()] + [String]$PostCode, + + [Parameter (Mandatory = $false, ParameterSetName = 'RemoteSupport')] + [ValidateNotNullOrEmpty()] + [String]$Country, + + [Parameter (Mandatory = $false, ParameterSetName = 'RemoteSupport')] + [ValidateNotNullOrEmpty()] + [String]$TimeZone, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [Parameter (Mandatory = $false, ParameterSetName = 'RemoteSupport')] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $_ApplianceRemoteSupportCol = [System.Collections.ArrayList]::new() + + } + + Process + { + + $RemoteSupportStatus = $null + + if ($PSCmdlet.ParameterSetName -eq 'RemoteSupport') + { + + "[{0}] Validate Remote Support is configured on the appliance." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $RemoteSupportStatus = Send-OVRequest -Uri $RemoteSupportConfigUri -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if (-not $RemoteSupportStatus.enableRemoteSupport) + { + + "[{0}] Remote Support is not enabled and configured on the appliance. Generate non-terminating error." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $ExceptionMessage = 'Remote Support is not configured on the appliance, {0}. In order to set the Remote Support location for the DataCenter, Remote SUpport must be enabledon the appliance. Either enable Remote Support or do not attempt to set the Data Center location until Remote Support has been anabled on the appliance.' -f $ApplianceConnection.Name + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.RemoteSupportException RemoteSupportNotEnabled InvalidOperation 'ApplianceConnect' -Message $ExceptionMessage + $PSCmdlet.WriteError($ErrorRecord) + + } + + else + { + + "[{0}] Remote Support is enabled and configured on the appliance. Will set Data Center RS location." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_DataCenterAddressPatchOp = [System.Collections.ArrayList]::new() + + switch ($PSBoundParameters.Keys) + { + + 'Address1' + { + + $_PatchOperation = NewObject -PatchOperation + $_PatchOperation.op = 'replace' + $_PatchOperation.path = '/streetAddress1' + $_PatchOperation.value = $Address1 + + [void]$_DataCenterAddressPatchOp.Add($_PatchOperation) + + } + + 'Address2' + { + + $_PatchOperation = NewObject -PatchOperation + $_PatchOperation.op = 'replace' + $_PatchOperation.path = '/streetAddress2' + $_PatchOperation.value = $Address2 + + [void]$_DataCenterAddressPatchOp.Add($_PatchOperation) + + } + + 'City' + { + + $_PatchOperation = NewObject -PatchOperation + $_PatchOperation.op = 'replace' + $_PatchOperation.path = '/city' + $_PatchOperation.value = $City + + [void]$_DataCenterAddressPatchOp.Add($_PatchOperation) + + } + + 'State' + { + + $_PatchOperation = NewObject -PatchOperation + $_PatchOperation.op = 'replace' + $_PatchOperation.path = '/provinceState' + $_PatchOperation.value = $State + + [void]$_DataCenterAddressPatchOp.Add($_PatchOperation) + + } + + 'PostCode' + { + + $_PatchOperation = NewObject -PatchOperation + $_PatchOperation.op = 'replace' + $_PatchOperation.path = '/postalCode' + $_PatchOperation.value = $PostCode + + [void]$_DataCenterAddressPatchOp.Add($_PatchOperation) + + } + + 'Country' + { + + $_PatchOperation = NewObject -PatchOperation + $_PatchOperation.op = 'replace' + $_PatchOperation.path = '/countryCode' + $_PatchOperation.value = $Country + + [void]$_DataCenterAddressPatchOp.Add($_PatchOperation) + + } + + 'TimeZone' + { + + $_PatchOperation = NewObject -PatchOperation + $_PatchOperation.op = 'replace' + $_PatchOperation.path = '/timeZone' + $_PatchOperation.value = $TimeZone + + [void]$_DataCenterAddressPatchOp.Add($_PatchOperation) + + } + + 'PrimaryContact' + { + + if ($PrimaryContact.Type -ne 'Contact') + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.RemoteSupportContactException InvalidArgumentValue InvalidArgument "PrimaryContact" -TargetType PSObject -Message "The PrimaryContact object resource provided is not a Remote Support Contact. Please use the Get-OVRemoteSupportContact Cmdlet to get a valid contact object." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + $_PatchOperation = NewObject -PatchOperation + $_PatchOperation.op = 'replace' + $_PatchOperation.path = '/primaryContactUri' + $_PatchOperation.value = $PrimaryContact.uri + + [void]$_DataCenterAddressPatchOp.Add($_PatchOperation) + + } + + 'SecondaryContact' + { + + if ($SecondaryContact.Type -ne 'Contact') + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.RemoteSupportContactException InvalidArgumentValue InvalidArgument "SecondaryContact" -TargetType PSObject -Message "The SecondaryContact object resource provided is not a Remote Support Contact. Please use the Get-OVRemoteSupportContact Cmdlet to get a valid contact object." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + $_PatchOperation = NewObject -PatchOperation + $_PatchOperation.op = 'replace' + $_PatchOperation.path = '/secondaryContactUri' + $_PatchOperation.value = $SecondaryContact.uri + + [void]$_DataCenterAddressPatchOp.Add($_PatchOperation) + + } + + } + + if ($PrimaryContact.uri -eq $SecondaryContact.uri) + { + + "[{0}] Primary and Secondary Contact are the same. Must be uniquel; generating terminating error." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $ExceptionMessage = "Both the PrimaryContact and SecondaryContact objects are the same. Please specify unique Primary and Secondary contacts." + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.RemoteSupportContactException InvalidArgumentValue InvalidArgument "PrimaryContact" -TargetType PSObject -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + } + + if (-not $Millimeters.IsPresent) + { + + # Convert from Feet to Millimeters + $Width = [Math]::Round($Width * .3048 * 1000, 2) + $Depth = [Math]::Round($Depth * .3048 * 1000, 2) + + } + + $NewDataCenter = NewObject -DataCenter + + $NewDataCenter.name = $Name + + Switch ($PSBoundParameters.Keys) + { + + 'CoolingCapacity' + { + + $NewDataCenter.coolingCapacity = $CoolingCapacity + + } + + 'PowerCosts' + { + + $NewDataCenter.costPerKilowattHour = $PowerCosts + + } + + 'Currency' + { + + $NewDataCenter.currency = $Currency + + } + + 'ElectricalDeratingType' + { + + $NewDataCenter.deratingType = $ElectricalDeratingType + + } + + 'ElectricalDerating' + { + + $NewDataCenter.deratingPercentage = $ElectricalDerating + + } + + 'DefaultVoltage' + { + + $NewDataCenter.defaultPowerLineVoltage = $DefaultVoltage + + } + + 'CoolingMultiplier' + { + + $NewDataCenter.coolingMultiplier = $CoolingMultiplier + + } + + 'Width' + { + + $NewDataCenter.width = $Width + + } + + 'Depth' + { + + $NewDataCenter.depth = $Depth + + } + + } + + # Create DC + Try + { + + $Resp = Send-OVRequest -Uri $DataCentersUri -Method POST -Body $NewDataCenter -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + # Update Remote Support DC if needed + if ($_DataCenterAddressPatchOp.Count -gt 0) + { + + "[{0}] Modifying datacenter Remote Support location to the specified value." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $_UpdateDCLocationResults = Send-OVRequest -Uri $Resp.remoteSupportUri -Method PATCH -Body $_DataCenterAddressPatchOp -Hostname $ApplianceConnection | Wait-OVTaskComplete + + if ($_UpdateDCLocationResults.taskState -ne 'Completed') + { + + $ExceptionMessage = 'Updating the datacenter with the specified location did not complete successfully with: {0}' -f [String]::Join(' ', $_UpdateDCLocationResults.taskErrors) + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.RemoteSupportException InvalidOperation InvalidOperation 'ApplianceConnect' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Send-OVRequest -Uri $Resp.uri -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + else + { + + $Resp + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Add-OVRackToDataCenter +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = 'Default')] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = 'Default')] + [ValidateNotNullorEmpty()] + [Object]$InputObject, + + [Parameter (Mandatory, ParameterSetName = 'Default')] + [ValidateNotNullorEmpty()] + [Object]$DataCenter, + + [Parameter (Mandatory, ParameterSetName = 'Default')] + [ValidateNotNullorEmpty()] + [Int]$X, + + [Parameter (Mandatory, ParameterSetName = 'Default')] + [ValidateNotNullorEmpty()] + [Int]$Y, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [Switch]$Millimeters, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateRange(0,360)] + [Int]$Rotate = 0, + + [Parameter (Mandatory = $false, ValueFromPipelinebyPropertyName, ParameterSetName = 'Default')] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not $InputObject) + { + + $PipelineInput - $True + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + $_Collection = [System.Collections.ArrayList]::new() + + } + + Process + { + + if ($InputObject.category -ne $ResourceCategoryEnum.Rack) + { + + $ExceptionMessage = 'The InputObject is not a valid Rack object.' + $ErrorRecord = New-ErrorRecord HPEOneView.RackResourceException InvalidParameter InvalidArgument 'InputObject' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + if ($DataCenter.category -ne $ResourceCategoryEnum.Datacenter) + { + + $ExceptionMessage = 'The DataCenter is not a valid data center object.' + $ErrorRecord = New-ErrorRecord HPEOneView.DatacenterResourceException InvalidParameter InvalidArgument 'DataCenter' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + # Get the most current version of the object + Try + { + + $DataCenter = Send-OVRequest -Uri $DataCenter.uri -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $_DataCenterToUpdate = $DataCenter.PSObject.Copy() + + $_UpdatedAssociations = $_DataCenterToUpdate.contents + + $_DataCenterToUpdate.contents = [System.Collections.ArrayList]::new() + $_UpdatedAssociations | ForEach-Object { [void]$_DataCenterToUpdate.contents.Add($_) } + + if (-not $Millimeters.IsPresent) + { + + # Convert from Feet to Millimeters + $X = [Math]::Round([Int]$X * .3048 * 1000, 2) + $Y = [Math]::Round([Int]$Y * .3048 * 1000, 2) + + } + + $_NewDCItem = NewObject -DataCenterItem + $_NewDCItem.resourceUri = $InputObject.Uri.ToString() + $_NewDCItem.rotation = $Rotate + $_NewDCItem.x = $X + $_NewDCItem.y = $y + + [void]$_DataCenterToUpdate.contents.Add($_NewDCItem) + + Try + { + + Send-OVRequest -Uri $DataCenter.uri -Method PUT -Body ($_DataCenterToUpdate | Select-Object * -Exclude RemoteSupportLocation) -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Set-OVDataCenterRemoteSupport +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = 'Default')] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [Object]$InputObject, + + [Parameter (Mandatory = $False, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [Object]$PrimaryContact, + + [Parameter (Mandatory = $False, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [Object]$SecondaryContact, + + [Parameter (Mandatory = $False, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [String]$Address1, + + [Parameter (Mandatory = $False, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [String]$Address2, + + [Parameter (Mandatory = $False, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [String]$City, + + [Parameter (Mandatory = $False, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [String]$State, + + [Parameter (Mandatory = $False, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [String]$PostCode, + + [Parameter (Mandatory = $False, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [String]$Country, + + [Parameter (Mandatory = $False, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [String]$TimeZone, + + [Parameter (Mandatory = $False, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [Switch]$Async, + + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = 'Default')] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not($PSBoundParameters['InputObject'])) + { + + $PipelineInput = $true + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + $_ApplianceRemoteSupportCol = [System.Collections.ArrayList]::new() + + } + + Process + { + + if ($InputObject -is [PSCustomObject]) + { + + "[{0}] Processing Pipeline input" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + "[{0}] Remote Support Contact Object provided: {1} ({2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject.name, $InputObject.uri | Write-Verbose + + If ('datacenters' -contains $InputObject.category) + { + + If (-not($InputObject.ApplianceConnection)) + { + + $ErrorRecord = New-ErrorRecord HPEOneView.DataCenterResourceException InvalidArgumentValue InvalidArgument "InputObject" -TargetType PSObject -Message "The InputObject object resource provided is missing the source ApplianceConnection property. Please check the object provided and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + else + { + + $ErrorRecord = New-ErrorRecord HPEOneView.DataCenterResourceException InvalidArgumentValue InvalidArgument "InputObject" -TargetType $InputObject.GetType().Name -Message "The InputObject object resource is not an expected type. The allowed resource category type is 'DataCenters'. Please check the object provided and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + else + { + + Try + { + + $InputObject = Get-OVDataCenter -Name $InputObject -ApplianceConnection $ApplianceConnection -ErrorAction Stop + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $RemoteSupportStatus = $null + + "[{0}] Validate Remote Support is configured on the appliance." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $RemoteSupportStatus = Send-OVRequest -Uri $RemoteSupportConfigUri -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if (-not $RemoteSupportStatus.enableRemoteSupport) + { + + "[{0}] Remote Support is not enabled and configured on the appliance. Generate non-terminating error." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $ExceptionMessage = 'Remote Support is not configured on the appliance, {0}. In order to set the Remote Support location for the DataCenter, Remote SUpport must be enabledon the appliance. Either enable Remote Support or do not attempt to set the Data Center location until Remote Support has been anabled on the appliance.' -f $ApplianceConnection.Name + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.RemoteSupportException RemoteSupportNotEnabled InvalidOperation 'ApplianceConnect' -Message $ExceptionMessage + $PSCmdlet.WriteError($ErrorRecord) + + } + + else + { + + "[{0}] Remote Support is enabled and configured on the appliance. Will set Data Center RS location." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_DataCenterAddressPatchOp = [System.Collections.ArrayList]::new() + + switch ($PSBoundParameters.Keys) + { + + 'Address1' + { + + $_PatchOperation = NewObject -PatchOperation + $_PatchOperation.op = 'replace' + $_PatchOperation.path = '/streetAddress1' + $_PatchOperation.value = $Address1 + + [void]$_DataCenterAddressPatchOp.Add($_PatchOperation) + + } + + 'Address2' + { + + $_PatchOperation = NewObject -PatchOperation + $_PatchOperation.op = 'replace' + $_PatchOperation.path = '/streetAddress2' + $_PatchOperation.value = $Address2 + + [void]$_DataCenterAddressPatchOp.Add($_PatchOperation) + + } + + 'City' + { + + $_PatchOperation = NewObject -PatchOperation + $_PatchOperation.op = 'replace' + $_PatchOperation.path = '/city' + $_PatchOperation.value = $City + + [void]$_DataCenterAddressPatchOp.Add($_PatchOperation) + + } + + 'State' + { + + $_PatchOperation = NewObject -PatchOperation + $_PatchOperation.op = 'replace' + $_PatchOperation.path = '/provinceState' + $_PatchOperation.value = $State + + [void]$_DataCenterAddressPatchOp.Add($_PatchOperation) + + } + + 'PostCode' + { + + $_PatchOperation = NewObject -PatchOperation + $_PatchOperation.op = 'replace' + $_PatchOperation.path = '/postalCode' + $_PatchOperation.value = $PostCode + + [void]$_DataCenterAddressPatchOp.Add($_PatchOperation) + + } + + 'Country' + { + + $_PatchOperation = NewObject -PatchOperation + $_PatchOperation.op = 'replace' + $_PatchOperation.path = '/countryCode' + $_PatchOperation.value = $Country + + [void]$_DataCenterAddressPatchOp.Add($_PatchOperation) + + } + + 'TimeZone' + { + + $_PatchOperation = NewObject -PatchOperation + $_PatchOperation.op = 'replace' + $_PatchOperation.path = '/timeZone' + $_PatchOperation.value = $TimeZone + + [void]$_DataCenterAddressPatchOp.Add($_PatchOperation) + + } + + 'PrimaryContact' + { + + if ($PrimaryContact.Type -ne 'Contact') + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.RemoteSupportContactException InvalidArgumentValue InvalidArgument "PrimaryContact" -TargetType PSObject -Message "The PrimaryContact object resource provided is not a Remote Support Contact. Please use the Get-OVRemoteSupportContact Cmdlet to get a valid contact object." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + $_PatchOperation = NewObject -PatchOperation + $_PatchOperation.op = 'replace' + $_PatchOperation.path = '/primaryContactUri' + $_PatchOperation.value = $PrimaryContact.uri + + [void]$_DataCenterAddressPatchOp.Add($_PatchOperation) + + } + + 'SecondaryContact' + { + + if ($SecondaryContact.Type -ne 'Contact') + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.RemoteSupportContactException InvalidArgumentValue InvalidArgument "SecondaryContact" -TargetType PSObject -Message "The SecondaryContact object resource provided is not a Remote Support Contact. Please use the Get-OVRemoteSupportContact Cmdlet to get a valid contact object." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + $_PatchOperation = NewObject -PatchOperation + $_PatchOperation.op = 'replace' + $_PatchOperation.path = '/secondaryContactUri' + $_PatchOperation.value = $SecondaryContact.uri + + [void]$_DataCenterAddressPatchOp.Add($_PatchOperation) + + } + + } + + if (($PSBoundParameters['PrimaryContact'] -or $PSBoundParameters['SecondaryContact']) -and $PrimaryContact.uri -eq $SecondaryContact.uri) + { + + "[{0}] Primary and Secondary Contact are the same. Must be unique; generating terminating error." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $ExceptionMessage = "Both the PrimaryContact and SecondaryContact objects are the same. Please specify unique Primary and Secondary contacts." + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.RemoteSupportContactException InvalidArgumentValue InvalidArgument "PrimaryContact" -TargetType PSObject -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + # Update Remote Support DC if needed + if ($_DataCenterAddressPatchOp.Count -gt 0) + { + + "[{0}] Modifying datacenter Remote Support location to the specified value." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $_UpdateDCLocationResults = Send-OVRequest -Uri $InputObject.remoteSupportUri -Method PATCH -Body $_DataCenterAddressPatchOp -Hostname $ApplianceConnection + + if (-not $Async.IsPresent) + { + + $_UpdateDCLocationResults = $_UpdateDCLocationResults | Wait-OVTaskComplete + + if ($_UpdateDCLocationResults.taskState -ne 'Completed') + { + + $ExceptionMessage = 'Updating the datacenter with the specified location did not complete successfully with: {0}' -f [String]::Join(' ', $_UpdateDCLocationResults.taskErrors) + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.RemoteSupportException InvalidOperation InvalidOperation 'ApplianceConnect' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + $_UpdateDCLocationResults + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + else + { + + "[{0}] Nothing to do." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Set-OVDataCenter +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = 'Default')] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [Object]$InputObject, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [String]$Name, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [Float]$Width, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [Float]$Depth, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [Switch]$Millimeters, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [Int]$ElectricalDerating, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateSet ('NaJp', 'Custom', 'None')] + [String]$ElectricalDeratingType, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [Int]$DefaultVoltage, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [String]$Currency, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [Float]$PowerCosts, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [Int]$CoolingCapacity, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [Float]$CoolingMultiplier, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not($PSBoundParameters['InputObject'])) + { + + $PipelineInput = $true + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + $_ApplianceRemoteSupportCol = [System.Collections.ArrayList]::new() + + } + + Process + { + + if ($InputObject -is [PSCustomObject]) + { + + "[{0}] Processing Pipeline input" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + "[{0}] Remote Support Contact Object provided: {1} ({2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject.name, $InputObject.uri | Write-Verbose + + If ('datacenters' -contains $InputObject.category) + { + + If (-not($InputObject.ApplianceConnection)) + { + + $ErrorRecord = New-ErrorRecord HPEOneView.DataCenterResourceException InvalidArgumentValue InvalidArgument "InputObject" -TargetType PSObject -Message "The InputObject object resource provided is missing the source ApplianceConnection property. Please check the object provided and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + else + { + + $ErrorRecord = New-ErrorRecord HPEOneView.DataCenterResourceException InvalidArgumentValue InvalidArgument "InputObject" -TargetType $InputObject.GetType().Name -Message "The InputObject object resource is not an expected type. The allowed resource category type is 'DataCenters'. Please check the object provided and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + else + { + + Try + { + + $InputObject = Get-OVDataCenter -Name $InputObject -ApplianceConnection $ApplianceConnection -ErrorAction Stop + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $_DataCenterObject = $InputObject.PSObject.Copy() + + switch ($PSBoundParameters.Keys) + { + + 'Name' + { + + $_DataCenterObject.name = $Name + + } + + 'Width' + { + + if (-not $Millimeters.IsPresent) + { + + # Convert from Feet to Millimeters + $Width = [Math]::Round($Width * .3048 * 1000, 2) + + } + + $_DataCenterObject.width = $Width + + } + + 'Depth' + { + + if (-not $Millimeters.IsPresent) + { + + # Convert from Feet to Millimeters + $Depth = [Math]::Round($Depth * .3048 * 1000, 2) + + } + + $_DataCenterObject.depth = $Depth + + } + + 'ElectricalDerating' + { + + if ($PSBoundParameters['ElectricalDeratingType'] -ne 'Custom') + { + + $ExceptionMessage = 'The ElectricalDerating paraemter was used with a custom value, without providing the ElectricalDeratingType parameter. ElectricalDerating will not be set to the value.' + $ErrorRecord = New-ErrorRecord HPEOneView.DataCenterResourceException InvalidParameter InvalidArgument 'ElectricalDerating' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + else + { + + $_DataCenterObject.deratingPercentage = $ElectricalDerating + + } + + } + + 'ElectricalDeratingType' + { + + if ($PSBoundParameters['ElectricalDerating'] -eq 'Custom' -and (-not $PSBoundParameters['ElectricalDerating'])) + { + + $ExceptionMessage = 'The ElectricalDeratingType paraemter is set to "Custom" without providing the ElectricalDerating parameter. ElectricalDeratingType will not be set to the value.' + $ErrorRecord = New-ErrorRecord HPEOneView.DataCenterResourceException InvalidParameter InvalidArgument 'ElectricalDeratingType' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + else + { + + $_DataCenterObject.deratingType = $ElectricalDeratingType + + $NeedToUpdateTwice = $false + + if ($ElectricalDeratingType -eq 'Custom') + { + + $NeedToUpdateTwice = $true + + } + + } + + } + + 'DefaultVoltage' + { + + $_DataCenterObject.defaultPowerLineVoltage = $DefaultVoltage + + } + + 'Currency' + { + + $_DataCenterObject.currency = $Currency + + } + + 'PowerCosts' + { + + $_DataCenterObject.costPerKilowattHour = $PowerCosts + + } + + 'CoolingCapacity' + { + + $_DataCenterObject.coolingCapacity = $CoolingCapacity + + } + + 'CoolingMultiplier' + { + + $_DataCenterObject.coolingMultiplier = $CoolingMultiplier + + } + + } + + Try + { + + $Resp = Send-OVRequest -Uri $_DataCenterObject.uri -Method PUT -Body ($_DataCenterObject | Select-Object * -Exclude RemoteSupportLocation) -Hostname $_DataCenterObject.ApplianceConnection + + if ($NeedToUpdateTwice) + { + + "[{0}] Need to update the DC object again in order to set deratingPercentage custom value" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $resp.deratingPercentage = $ElectricalDerating + + $Resp = Send-OVRequest -Uri $Resp.uri -Method PUT -Body ($Resp | Select-Object * -Exclude RemoteSupportLocation) -Hostname $Resp.ApplianceConnection + + } + + $Resp + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Remove-OVDataCenter +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "Default", SupportsShouldProcess, ConfirmImpact = 'High')] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = "Default")] + [ValidateNotNullorEmpty()] + [Object]$InputObject, + + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = "Default")] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not($PSBoundParameters['InputObject'])) + { + + $PipelineInput = $true + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + $_DataCenterCol = [System.Collections.ArrayList]::new() + $_TaskCollection = [System.Collections.ArrayList]::new() + + } + + Process + { + + if ($InputObject -is [PSCustomObject]) + { + + "[{0}] Processing Pipeline input" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + "[{0}] Datacenter Object provided: {1} ({2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject.name, $InputObject.uri | Write-Verbose + + If ('datacenters' -contains $InputObject.category) + { + + If (-not($InputObject.ApplianceConnection)) + { + + $ErrorRecord = New-ErrorRecord HPEOneView.DataCenterResourceException InvalidArgumentValue InvalidArgument "InputObject" -TargetType PSObject -Message "The InputObject object resource provided is missing the source ApplianceConnection property. Please check the object provided and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + [void]$_DataCenterCol.Add($InputObject) + + } + + else + { + + $ErrorRecord = New-ErrorRecord HPEOneView.DataCenterResourceException InvalidArgumentValue InvalidArgument "InputObject" -TargetType $InputObject.GetType().Name -Message "The InputObject object resource is not an expected type. The allowed resource category type is 'DataCenters'. Please check the object provided and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + else + { + + For ($c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + "[{0}] Processing Appliance {1} (of {2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $ApplianceConnection[$c].Name, $ApplianceConnection.Count | Write-Verbose + + "[{0}] Processing DataCenter Name {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject | Write-Verbose + + Try + { + + $_DataCenter = Get-OVDataCenter -Name $InputObject -ApplianceConnection $ApplianceConnection[$c] + + $_DataCenter | ForEach-Object { + + [void]$_DataCenterCol.Add($_) + + } + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + } + + End + { + + "[{0}] Begin resource removal process." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + foreach ($_dc in $_DataCenterCol) + { + + $RemoveMessage = "Remove DataCenter '{0}'" -f $_dc.Name + + if ($PSCmdlet.ShouldProcess($_dc.ApplianceConnection,$RemoveMessage)) + { + + Try + { + + $resp = Send-OVRequest $_dc.uri DELETE -Hostname $_dc.ApplianceConnection -addHeader @{'If-Match' = $_dc.eTag} + $resp | Add-Member -NotePropertyName ResourceName -NotePropertyValue $_dc.Name + $resp + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + elseif ($PSBoundParameters['WhatIf']) + { + + "[{0}] Caller passed -WhatIf Parameter." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + else + { + + "[{0}] Caller selected NO to confirmation prompt." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + } + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +####################################################### +# Server Hardware and Enclosures: +# + +function Get-OVServerNTPConfiguration +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "Default")] + Param + ( + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + "[{0}] Bound PS Parameters: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), ($PSBoundParameters | out-string) | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -TargetType $InputObject.ApplianceConnection.GetType().Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + Process + { + + $_uri = $ApplianceGlobalSettingsUri + '/appliance/global/ServerManagementProcessorNtpSource' + + # BY DEFAULT THE URI WILL NOT EXIST, RESULTING IN DEFAULT APPLIANCE SOURCE + # NEED TO HANDLE HTTP404 error for this + Try + { + + $_config = Send-OVRequest -Uri $_uri -Hostname $ApplianceConnection + + $_TimeConfigPolicy = [HPEOneView.Appliance.GlobalSetting]::new($_config.name, + $_config.value, + $_config.eTag, + $_config.created, + $_config.modified, + $_config.group, + $_config.settingCategory, + $_config.uri, + $_config.ApplianceConnection) + + if ($_TimeConfigPolicy.Value -eq $NTPSourceEnum.External) + { + + # Get timelocale to get appliance configured NTP servers + Try + { + + $_applianceDateTimeLocaleConfig = Send-OVRequest -Uri $ApplianceDateTimeUri -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $_TimeConfigPolicy | Add-Member -NotePropertyName NTPServers -NotePropertyValue $_applianceDateTimeLocaleConfig.ntpServers + + } + + $_TimeConfigPolicy + + } + + # Default + Catch [HPEOneView.ResourceNotFoundException] + { + + "[{0}] Global-setting URI not found. Likely default, so returning default value." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + # Global-setting does not exist, must be set to default + [HPEOneView.Appliance.GlobalSetting]::new('ServerManagementProcessorNtpSource', + $NTPSourceEnum.ServerDefault, + [DateTime]::now, + [DateTime]::now, + [DateTime]::now, + 'global', + 'global-settings', + $_uri, + ([HPEOneView.Library.ApplianceConnection]::new($ApplianceConnection.Name, $ApplianceConnnection.ConnectionId))) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Set-OVServerNTPConfiguration +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "Default")] + Param + ( + + [Parameter (Mandatory, ParameterSetName = "Default")] + [Switch]$SyncWithAppliance, + + [Parameter (Mandatory, ParameterSetName = "SyncWithNTP")] + [Switch]$SyncWithNTP, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Parameter (Mandatory = $false, ParameterSetName = "SyncWithNTP")] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + "[{0}] Bound PS Parameters: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), ($PSBoundParameters | out-string) | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -TargetType $InputObject.ApplianceConnection.GetType().Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + Process + { + + $_uri = $ApplianceGlobalSettingsUri + '/appliance/global/ServerManagementProcessorNtpSource' + $_method = "PUT" + + Try + { + + $_serverTimePolicyConfig = Send-OVRequest -Uri $_uri -Hostname $ApplianceConnection + + } + + # Default + Catch [HPEOneView.ResourceNotFoundException] + { + + "[{0}] Global-setting URI not found. Likely default, so returning default value." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_serverTimePolicyConfig = NewObject -GlobalSetting + + $_serverTimePolicyConfig.name = 'ServerManagementProcessorNtpSource' + + $_uri = $ApplianceGlobalSettingsUri + $_method = "POST" + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + switch ($PSBoundParameters.Keys) + { + + 'SyncWithAppliance' + { + + "[{0}] Will sync with appliance." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + $_serverTimePolicyConfig.value = $NTPSourceEnum.Appliance + + } + + 'SyncWithNTP' + { + + "[{0}] Will sync with external NTP servers." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + $_serverTimePolicyConfig.value = $NTPSourceEnum.External + + } + + } + + Try + { + + $_resp = Send-OVRequest -Uri $_uri -Method $_method -Body $_serverTimePolicyConfig -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $_UpdatedTimeConfigPolicy = [HPEOneView.Appliance.GlobalSetting]::new($_resp.name, + $_resp.value, + $_resp.eTag, + $_resp.created, + $_resp.modified, + $_resp.group, + $_resp.settingCategory, + $_resp.uri, + $_resp.ApplianceConnection) + + if ($_UpdatedTimeConfigPolicy.Value -eq $NTPSourceEnum.External) + { + + # Get timelocale to get appliance configured NTP servers + Try + { + + $_applianceDateTimeLocaleConfig = Send-OVRequest -Uri $ApplianceDateTimeUri -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $_UpdatedTimeConfigPolicy | Add-Member -NotePropertyName NTPServers -NotePropertyValue $_applianceDateTimeLocaleConfig.ntpServers + + } + + $_UpdatedTimeConfigPolicy + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Enable-OVMaintenanceMode +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "Default", SupportsShouldProcess, ConfirmImpact = 'High')] + Param + ( + + [Parameter (ValueFromPipeline, Mandatory, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [Alias('Server')] + [Object]$InputObject, + + [Parameter (Mandatory = $False, ParameterSetName = "Default")] + [Switch]$Async, + + [Parameter (ValueFromPipelineByPropertyName, Mandatory = $false, ParameterSetName = "Default")] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + "[{0}] Bound PS Parameters: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), ($PSBoundParameters | out-string) | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not $PSBoundParameters['InputObject']) + { + + $PipelineInput = $true + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + if (-not($InputObject -is [PSCustomObject]) -or (-not($InputObject.ApplianceConnection))) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException InvalidApplianceConnectionDataType InvalidArgument 'InputObject' -TargetType 'PSObject' -Message "The specified 'InputObject' is not an object or is missing the 'ApplianceConnection' property. Please correct this value and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -TargetType $InputObject.ApplianceConnection.GetType().Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + } + + Process + { + + $_ResourcesToProcess = $null + $ShouldProcessMessage = "enable maintenance mode for server hardware" + + # Process inputobject if server hardware or profile + Switch ($InputObject.category) + { + + $ResourceCategoryEnum.ServerProfile + { + + "[{0}] Server profile provided by caller: {1} ({2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject.name, $InputObject.uri | Write-Verbose + + if ([String]::IsNullOrEmpty($InputObject.serverHardwareUri)) + { + + $ExceptionMessage = "The InputObject resource '{0}' is not assigned to a server hardware resource." -f $InputObject.name + $ErrorRecord = New-ErrorRecord InvalidOperationException InvalidInputObjectParameterValue InvalidArgument 'InputObject' -TargetType $InputObject.GetType().Name -Message $ExceptionMessage + $PSCmdlet.WriteError($ErrorRecord) + + } + + else + { + + "[{0}] Getting associated server hardware resource." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $_ResourcesToProcess = Send-OVRequest -Uri $InputObject.serverHardwareUri -Hostname $InputObject.ApplianceConnection + + } + + Catch + { + + $PSCMdlet.ThrowTerminatingError($_) + + } + + $ShouldProcessMessage += " (assocaited with {0} server profile)" -f $InputObject.name + + } + + } + + $ResourceCategoryEnum.ServerHardware + { + + "[{0}] Server hardware provided by caller: {1} ({2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject.name, $InputObject.uri | Write-Verbose + + $_ResourcesToProcess = $InputObject.PSObject.Copy() + + } + + # Unsupported resource type + default + { + + if ($InputObject -is [HPEOneView.Appliance.ScopeCollection]) + { + + # Process the scope, looking for server hardware and add them to a collection + $_ResourcesToProcess = [System.Collections.ArrayList]::new() + + ForEach ($input in ($InputObject.Members | Where-Object { 'ServerHardware', 'ServerProfile' -contains $_.Type })) + { + + switch ($input.Type) + { + + 'ServerHardware' + { + + "[{0}] Adding {1} resource found within scope to collection: {2} ({3})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $input.Type, $input.name, $input.uri | Write-Verbose + + [void]$_ResourcesToProcess.Add($input) + + } + + 'ServerProfile' + { + + "[{0}] Getting associated server hardware resource from profile, {1} ({2})." -f $MyInvocation.InvocationName.ToString().ToUpper(), $input.name, $input.uri | Write-Verbose + + Try + { + + $_Uri = '{0}?category=server-hardware&userQuery="serverProfileUri EQ {1}"' -f $IndexUri, $input.uri + + $_AssociatedServerhardware = (Send-OVRequest -Uri $_Uri -Hostname $InputObject.ApplianceConnection).Members + + } + + Catch + { + + $PSCMdlet.ThrowTerminatingError($_) + + } + + if ($_AssociatedServerhardware.Count -eq 0) + { + + "[{0}] Server profile {1} ({2}) is not assigned to a server hardware resource. Skipping." -f $MyInvocation.InvocationName.ToString().ToUpper(), $input.name, $input.uri | Write-Verbose + + } + + # If resource isn't already added to the collection, add it. Otherwise, skip. + elseif ($_AssociatedServerhardware.Count -ne 0 -and -not ($_ResourcesToProcess | ? uri -eq $_AssociatedServerhardware.uri)) + { + + "[{0}] Adding server hardware resource found within scope to collection: {1} ({2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_AssociatedServerhardware.name, $_AssociatedServerhardware.uri | Write-Verbose + + [void]$_ResourcesToProcess.Add($_AssociatedServerhardware) + + } + + elseif ($_ResourcesToProcess | ? uri -eq $_AssociatedServerhardware.uri) + { + + "[{0}] Associated server hardware resource already exists in the collection: {1} ({2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_AssociatedServerhardware.name, $_AssociatedServerhardware.uri | Write-Verbose + + } + + } + + default + { + + "[{0}] Not adding {1} resource found within scope: {2} ({3})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $input.Type, $input.name, $input.uri | Write-Verbose + + } + + } + + } + + # If no server hardware, do nothing + if ($_ResourcesToProcess.Count -eq 0) + { + + "[{0}] No server hardware found within the collection." -f $MyInvocation.InvocationName.ToString().ToUpper(), $input.name, $input.uri | Write-Verbose + + } + + } + + else + { + + $ExceptionMessage = "The InputObject resource '{0}' is not a server hardware or server profile resource." -f $InputObject.name + $ErrorRecord = New-ErrorRecord InvalidOperationException InvalidInputObjectParameterValue InvalidArgument 'InputObject' -TargetType $InputObject.GetType().Name -Message $ExceptionMessage + $PSCmdlet.WriteError($ErrorRecord) + + } + + } + + } + + ForEach ($_ResourceToProcess in $_ResourcesToProcess) + { + + # Report the user the sever hardware resource is already in MM + if ($_ResourceToProcess.maintenanceMode) + { + + $ExceptionMessage = "The InputObject resource '{0}' server hardware resource is already in maintenance mode." -f $InputObject.name + $ErrorRecord = New-ErrorRecord InvalidOperationException InvalidInputObjectParameterValue InvalidArgument 'InputObject' -TargetType $InputObject.GetType().Name -Message $ExceptionMessage + $PSCmdlet.WriteError($ErrorRecord) + + } + + else + { + + Write-Warning ("Enabling maintenance mode will prevent this appliance from sending any email notifications related to server hardware {0} and its associated profile. Maintenance mode will not affect normal server or profile operations." -f $_ResourceToProcess.name) + + if ($null -ne $_ResourceToProcess -and $PSCmdlet.ShouldProcess($_ResourceToProcess.name, $ShouldProcessMessage)) + { + + "[{0}] Putting server hardware resource {1} into maintenance mode." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_ResourceToProcess.name | Write-Verbose + + $_PatchOperation = NewObject -PatchOperation + + $_PatchOperation.op = 'replace' + $_PatchOperation.path = "/maintenanceMode" + $_PatchOperation.value = $true + + Try + { + + $resp = Send-OVRequest -Uri $_ResourceToProcess.uri -Method PATCH -Body $_PatchOperation -Hostname $ApplianceConnection.Name -AddHeader @{'if-match' = $_ResourceToProcess.eTag} + + if ($PSBoundParameters['Async']) + { + + $resp + + } + + else + { + + $resp | Wait-OVTaskComplete + + } + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Disable-OVMaintenanceMode +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "Default", SupportsShouldProcess, ConfirmImpact = 'High')] + Param + ( + + [Parameter (ValueFromPipeline, Mandatory, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [Alias('Server')] + [Object]$InputObject, + + [Parameter (Mandatory = $False, ParameterSetName = "Default")] + [Switch]$Async, + + [Parameter (ValueFromPipelineByPropertyName, Mandatory = $false, ParameterSetName = "Default")] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + "[{0}] Bound PS Parameters: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), ($PSBoundParameters | out-string) | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not $PSBoundParameters['InputObject']) + { + + $PipelineInput = $true + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + if (-not($InputObject -is [PSCustomObject]) -or (-not($InputObject.ApplianceConnection))) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException InvalidApplianceConnectionDataType InvalidArgument 'InputObject' -TargetType 'PSObject' -Message "The specified 'InputObject' is not an object or is missing the 'ApplianceConnection' property. Please correct this value and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -TargetType $InputObject.ApplianceConnection.GetType().Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + } + + Process + { + + $_ResourceToProcess = $null + $ShouldProcessMessage = "disable maintenance mode for server hardware" + + # Process inputobject if server hardware, profile or scope + Switch ($InputObject.category) + { + + $ResourceCategoryEnum.ServerProfile + { + + "[{0}] Server profile provided by caller: {1} ({2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject.name, $InputObject.uri | Write-Verbose + + if ([String]::IsNullOrEmpty($InputObject.serverHardwareUri)) + { + + $ExceptionMessage = "The InputObject resource '{0}' is not assigned to a server hardware resource." -f $InputObject.name + $ErrorRecord = New-ErrorRecord InvalidOperationException InvalidInputObjectParameterValue InvalidArgument 'InputObject' -TargetType $InputObject.GetType().Name -Message $ExceptionMessage + $PSCmdlet.WriteError($ErrorRecord) + + } + + else + { + + "[{0}] Getting associated server hardware resource." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $_ResourcesToProcess = Send-OVRequest -Uri $InputObject.serverHardwareUri -Hostname $InputObject.ApplianceConnection + + } + + Catch + { + + $PSCMdlet.ThrowTerminatingError($_) + + } + + $ShouldProcessMessage += " (assocaited with {0} server profile)" -f $InputObject.name + + } + + } + + $ResourceCategoryEnum.ServerHardware + { + + "[{0}] Server hardware provided by caller: {1} ({2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject.name, $InputObject.uri | Write-Verbose + + $_ResourcesToProcess = $InputObject.PSObject.Copy() + + } + + # Unsupported resource type + default + { + + if ($InputObject -is [HPEOneView.Appliance.ScopeCollection]) + { + + # Process the scope, looking for server hardware and add them to a collection + $_ResourcesToProcess = [System.Collections.ArrayList]::new() + + ForEach ($input in ($InputObject.Members | Where-Object { 'ServerHardware', 'ServerProfile' -contains $_.Type })) + { + + switch ($input.Type) + { + + 'ServerHardware' + { + + "[{0}] Adding {1} resource found within scope to collection: {2} ({3})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $input.Type, $input.name, $input.uri | Write-Verbose + + Try + { + + $_ServerResource = Send-OVRequest -Uri $input.uri -Hostname $InputObject.ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + [void]$_ResourcesToProcess.Add($_ServerResource) + + } + + 'ServerProfile' + { + + "[{0}] Getting associated server hardware resource from profile, {1} ({2})." -f $MyInvocation.InvocationName.ToString().ToUpper(), $input.name, $input.uri | Write-Verbose + + Try + { + + $_Uri = '{0}?category=server-hardware&userQuery="serverProfileUri EQ {1}"' -f $IndexUri, $input.uri + + $_AssociatedServerhardware = (Send-OVRequest -Uri $_Uri -Hostname $InputObject.ApplianceConnection).Members + + $_AssociatedServerhardware | Add-Member -NotePropertyName maintenanceMode -NotePropertyValue $_AssociatedServerhardware.attributes.maintenanceMode + + } + + Catch + { + + $PSCMdlet.ThrowTerminatingError($_) + + } + + if ($_AssociatedServerhardware.Count -eq 0) + { + + "[{0}] Server profile {1} ({2}) is not assigned to a server hardware resource. Skipping." -f $MyInvocation.InvocationName.ToString().ToUpper(), $input.name, $input.uri | Write-Verbose + + } + + # If resource isn't already added to the collection, add it. Otherwise, skip. + elseif ($_AssociatedServerhardware.Count -ne 0 -and -not ($_ResourcesToProcess | ? uri -eq $_AssociatedServerhardware.uri)) + { + + "[{0}] Adding server hardware resource found within scope to collection: {1} ({2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_AssociatedServerhardware.name, $_AssociatedServerhardware.uri | Write-Verbose + + [void]$_ResourcesToProcess.Add($_AssociatedServerhardware) + + } + + elseif ($_ResourcesToProcess | ? uri -eq $_AssociatedServerhardware.uri) + { + + "[{0}] Associated server hardware resource already exists in the collection: {1} ({2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_AssociatedServerhardware.name, $_AssociatedServerhardware.uri | Write-Verbose + + } + + } + + default + { + + "[{0}] Not adding {1} resource found within scope: {2} ({3})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $input.Type, $input.name, $input.uri | Write-Verbose + + } + + } + + } + + # If no server hardware, do nothing + if ($_ResourcesToProcess.Count -eq 0) + { + + "[{0}] No server hardware found within the collection." -f $MyInvocation.InvocationName.ToString().ToUpper(), $input.name, $input.uri | Write-Verbose + + } + + } + + else + { + + $ExceptionMessage = "The InputObject resource '{0}' is not a server hardware or server profile resource." -f $InputObject.name + $ErrorRecord = New-ErrorRecord InvalidOperationException InvalidInputObjectParameterValue InvalidArgument 'InputObject' -TargetType $InputObject.GetType().Name -Message $ExceptionMessage + $PSCmdlet.WriteError($ErrorRecord) + + } + + } + + } + + ForEach ($_ResourceToProcess in $_ResourcesToProcess) + { + + # Report the user the sever hardware resource is already in MM + if (-not $_ResourceToProcess.maintenanceMode) + { + + "[{0}] Server hardware is not in maintenance. Nothing to do." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + # Prompt user for confirmation + else + { + + Write-Warning "Disabling maintenance mode will cause email notifications to return to normal." + + if ($null -ne $_ResourceToProcess -and $PSCmdlet.ShouldProcess($_ResourceToProcess.name, $ShouldProcessMessage)) + { + + "[{0}] Putting server hardware resource {1} into maintenance mode." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_ResourceToProcess.name | Write-Verbose + + $_PatchOperation = NewObject -PatchOperation + + $_PatchOperation.op = 'replace' + $_PatchOperation.path = "/maintenanceMode" + $_PatchOperation.value = $false + + Try + { + + $resp = Send-OVRequest -Uri $_ResourceToProcess.uri -Method PATCH -Body $_PatchOperation -Hostname $ApplianceConnection.Name -AddHeader @{'if-match' = $_ResourceToProcess.eTag} + + if ($PSBoundParameters['Async']) + { + + $resp + + } + + else + { + + $resp | Wait-OVTaskComplete + + } + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + + } + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Get-OVServer +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "Default")] + Param + ( + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [ValidateNotNullOrEmpty()] + [String]$Name, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [ValidateNotNullOrEmpty()] + [String]$SerialNumber, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [ValidateNotNullOrEmpty()] + [String]$ServerName, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [ValidateSet ('Critical', 'Warning', 'OK', 'Unknown', 'Disabled')] + [String[]]$Status, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Switch]$NoProfile, + + [Parameter (Mandatory = $false, ValueFromPipeline, ParameterSetName = "Default")] + [Alias ('ServerHardwareType','ServerProfileTemplate')] + [ValidateNotNullOrEmpty()] + [object]$InputObject, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [ValidateNotNullOrEmpty()] + [Bool]$MaintenanceMode, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [ValidateNotNullOrEmpty()] + [String]$Label, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [ValidateNotNullOrEmpty()] + [String]$Query, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [ValidateNotNullOrEmpty()] + [Int]$Count, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [ValidateNotNullOrEmpty()] + [Object]$Scope = "AllResourcesInScope", + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + Process + { + + ForEach ($_appliance in $ApplianceConnection) + { + + "[{0}] Processing appliance {1} (of {2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name, $ApplianceConnection.Count | Write-Verbose + + $_Query = [System.Collections.ArrayList]::new() + + # Handle default cause of AllResourcesInScope + if ($Scope -eq 'AllResourcesInScope') + { + + "[{0}] Processing AllResourcesInScope." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_Scopes = $_appliance.ActivePermissions | Where-Object Active + + # If one scope contains 'AllResources' ScopeName "tag", then all resources should be returned regardless. + if ($_Scopes | Where-Object ScopeName -eq 'AllResources') + { + + $_ScopeNames = [String]::Join(', ', ($_Scopes | Where-Object ScopeName -eq 'AllResources').ScopeName) + + "[{0}] Scope(s) {1} is set to 'AllResources'. Will not add scope to URI query parameter." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_ScopeNames | Write-Verbose + + } + + # Process ApplianceConnection ActivePermissions collection + else + { + + Try + { + + $_ScopeQuery = Join-Scope $_Scopes + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + [Void]$_Query.Add(("({0})" -f $_ScopeQuery)) + + } + + } + + elseif ($Scope | Where-Object ScopeName -eq 'AllResources') + { + + $_ScopeNames = [String]::Join(', ', ($_Scopes | Where-Object ScopeName -eq 'AllResources').ScopeName) + + "[{0}] Scope(s) {1} is set to 'AllResources'. Will not add scope to URI query parameter." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_ScopeNames | Write-Verbose + + } + + elseif ($Scope -eq 'AllResources') + { + + "[{0}] Requesting scope 'AllResources'. Will not add scope to URI query parameter." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_ScopeNames | Write-Verbose + + } + + else + { + + Try + { + + $_ScopeQuery = Join-Scope $Scope + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + [Void]$_Query.Add(("({0})" -f $_ScopeQuery)) + + } + + if ($ServerName) + { + + if ($ServerName.Contains('*')) + { + + [Void]$_Query.Add(("serverName%3A%2A{0}" -f $ServerName.Replace("*", "%2A").Replace(" ", "?"))) + + } + + else + { + + [Void]$_Query.Add(("serverName:'{0}'" -f $ServerName)) + + } + + } + + if ($Name) + { + + if ($Name.Contains('*')) + { + + [Void]$_Query.Add(("name%3A{0}" -f $Name.Replace("*", "%2A").Replace(',','%2C').Replace(" ", "?"))) + + } + + else + { + + [Void]$_Query.Add(("name:'{0}'" -f $Name)) + + } + + } + + if ($SerialNumber) + { + + if ($Name.Contains('*')) + { + + [Void]$_Query.Add(("serialNumber%3A{0}" -f $SerialNumber.Replace("*", "%2A").Replace(',','%2C').Replace(" ", "?"))) + + } + + else + { + + [Void]$_Query.Add(("serialNumber:'{0}'" -f $SerialNumber)) + + } + + } + + if ($PSBoundParameters.Keys -Contains 'MaintenanceMode') + { + + [Void]$_Query.Add(("maintenanceMode:'{0}'" -f $MaintenanceMode)) + + } + + if ($Label) + { + + [Void]$_Query.Add(("labels:'{0}'" -f $Label)) + + } + + if ($Status) + { + + $_StatusQuery = [System.Collections.ArrayList]::new() + + ForEach ($_status in $Status) + { + + [Void]$_StatusQuery.Add(("status:'{0}'" -f $_status)) + + } + + [void]$_Query.Add([String]::Join(' OR ', $_StatusQuery.ToArray())) + + } + + if ($PSBoundParameters['Query']) + { + + [Void]$_Query.Add($Query) + + } + + $_Count = $null + + if ($PSBoundParameters['Count']) + { + + $_Count = "&count=$Count" + + } + + $_Category = 'category=server-hardware' + + # Build the final URI + $_uri = '{0}?{1}{2}&sort=name:asc&query={3}' -f $IndexUri, [String]::Join('&', $_Category), $_Count, [String]::Join(' AND ', $_Query.ToArray()) + + Try + { + + [Array]$_ResourcesFromIndexCol = Get-AllIndexResources -Uri $_uri -ApplianceConnection $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + # Filter collection for resources without profile assigned + if ($PSBoundParameters['NoProfile']) + { + + "[{0}] Filtering for server hardware with no assigned profiles." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_ResourcesFromIndexCol = $_ResourcesFromIndexCol | Where-Object { $null -eq $_.serverProfileUri } + + } + + # Filter collection for resources that match the SHT of inputobject provided + if ($InputObject) + { + + switch ($InputObject.category) + { + + $ResourceCategoryEnum.ServerProfileTemplate + { + + $_FilterProperty = "serverHardwareTypeUri" + + $_FilterUri = $InputObject.serverHardwareTypeUri + + } + + $ResourceCategoryEnum.ServerProfile + { + + $_FilterProperty = "serverProfileUri" + + $_FilterUri = $InputObject.Uri.ToString() + + } + + $ResourceCategoryEnum.ServerHardwareType + { + + $_FilterProperty = "serverHardwareTypeUri" + + $_FilterUri = $InputObject.Uri.ToString() + + } + + default + { + + if ([RegEx]::Match($InputObject.PSObject.properties, 'category', $RegExInsensitiveFlag).Success) + { + + $InputObjectName = $InputObject.name.Clone() + + } + + else + { + + $InputObjectName = $InputObject.Clone() + + } + + $ExceptionMessage = "The provided InputObject parameter value, '{0}', is not a supported resource type. Only server profile template or server hardware type resources are supported. Please check the value, and try again." -f $InputObjectName + $ErrorRecord = New-ErrorRecord HPEOneView.InputObjectResourceException InvalidInputObject InvalidArgument 'InputObject' -TargetType 'PSObject' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + "FilterProperty: {0}" -f $_FilterProperty | Write-Verbose + "FilterUri: {0}" -f $_FilterUri | Write-Verbose + + $_ResourcesFromIndexCol = $_ResourcesFromIndexCol | Where-Object { $_.$_FilterProperty -eq $_FilterUri } + + } + + # if ($Count) + # { + + # $_ResourcesFromIndexCol = $_ResourcesFromIndexCol | Select-Object -First $Count + + # } + + + if ($_ResourcesFromIndexCol.count -eq 0 -and $Name) + { + + $ExceptionMessage = "Server Hardware '{0}' not found on '{1}' appliance connection. Please check the name again, and try again." -f $Name, $_appliance.Name + $ErrorRecord = New-ErrorRecord HPEOneView.ServerHardwareResourceException ServerHardwareResourceNotFound ObjectNotFound 'Name' -Message $ExceptionMessage + $PSCmdlet.WriteError($ErrorRecord) + + } + + if ($_ResourcesFromIndexCol.count -eq 0 -and $ServerName) + { + + $ExceptionMessage = "Server Hardware OS Server Name '{0}' not found on '{1}' appliance connection. Please check the name again, and try again." -f $ServerName, $_appliance.Name + $ErrorRecord = New-ErrorRecord HPEOneView.ServerHardwareResourceException ServerHardwareResourceNotFound ObjectNotFound 'ServerName' -Message $ExceptionMessage + $PSCmdlet.WriteError($ErrorRecord) + + } + + else + { + + ForEach ($s in ($_ResourcesFromIndexCol | Sort-Object name)) + { + + "[{0}] Returning {1} ({2}) server from API." -f $MyInvocation.InvocationName.ToString().ToUpper(), $s.name, $s.uri | Write-Verbose + + $s.PSObject.TypeNames.Insert(0,'HPEOneView.ServerHardare') + + $s + + } + + } + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Get-OVIloSso +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "Default")] + Param + ( + + [Parameter (ValueFromPipeline, Mandatory, ParameterSetName = 'Default')] + [Parameter (ValueFromPipeline, Mandatory, ParameterSetName = 'IloRestSession')] + [ValidateNotNullOrEmpty()] + [Alias('Server')] + [Object]$InputObject, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [Switch]$RemoteConsoleOnly, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [Parameter (Mandatory = $false, ParameterSetName = 'IloRestSession')] + [Switch]$IloRestSession, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [Parameter (Mandatory = $false, ParameterSetName = 'IloRestSession')] + [Switch]$SkipCertificateCheck, + + [Parameter (ValueFromPipelineByPropertyName, Mandatory = $false, ParameterSetName = "Default")] + [Parameter (ValueFromPipelineByPropertyName, Mandatory = $false, ParameterSetName = "IloRestSession")] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + "[{0}] Bound PS Parameters: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), ($PSBoundParameters | out-string) | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not $PSBoundParameters['InputObject']) + { + + $PipelineInput = $true + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + if (-not($InputObject -is [PSCustomObject]) -or (-not($InputObject.ApplianceConnection))) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException InvalidApplianceConnectionDataType InvalidArgument 'InputObject' -TargetType 'PSObject' -Message "The specified 'InputObject' is not an object or is missing the 'ApplianceConnection' property. Please correct this value and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -TargetType $InputObject.ApplianceConnection.GetType().Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + $colStatus = [System.Collections.ArrayList]::new() + + } + + Process + { + + if (-not($PipelineInput) -and (-not($InputObject -is [PSCustomObject]))) + { + + $ExceptionMessage = "The specified 'InputObject' is not an object. Please correct this value and try again." + $ErrorRecord = New-ErrorRecord HPEOneView.ServerResourceException InvalidServerObject InvalidArgument 'InputObject' -TargetType $InputObject.GetType().Name -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + if ('server-hardware',$ResourceCategoryEnum.ServerProfile -notcontains $InputObject.category) + { + + $ExceptionMessage = "The specified 'InputObject' is not a Server or Server Profile object. Please correct this value and try again." + $ErrorRecord = New-ErrorRecord HPEOneView.ServerResourceException InvalidObject InvalidArgument 'InputObject' -TargetType $InputObject.GetType().Name -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + if ($InputObject.category -eq $ResourceCategoryEnum.ServerProfile ) + { + + "[{0}] Server Profile was provided." -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject.name | Write-Verbose + $_uri = $InputObject.serverHardwareUri + + # get server hardware from resource + try + { + + $_Server = Send-OVRequest -Uri $_uri -Hostname $InputObject.ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + else + { + + "[{0}] Server Hardware was provided." -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject.name | Write-Verbose + $_uri = $InputObject.Uri.ToString() + + $_Server = $InputObject + + } + + if ($PSBoundParameters['RemoteConsoleOnly']) + { + + $_uri = $_uri + '/remoteConsoleUrl' + + } + + else + { + + $_uri = $_uri + '/iloSsoUrl' + + } + + "[{0}] Processing {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject.name | Write-Verbose + + Try + { + + $_ssoresp = Send-OVRequest -URI $_uri -Hostname $InputObject.ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if (-not $PSBoundParameters['IloRestSession']) + { + + "[{0}] Returning iLO SSO Session" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_ssoresp + + } + + else + { + + "[{0}] Generating and returning iLO REST/RedFish SSO Session object" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_IgnoredCertValidationCallBack = $false + + Try + { + + $CookieContainer = [System.Net.CookieContainer]::new() + + [System.Net.HttpWebRequest]$WebRequest = [System.Net.HttpWebRequest]::Create($_ssoresp.iloSsoUrl) + $WebRequest.CookieContainer = $CookieContainer + $WebRequest.Accept = 'application/json, *.*' + + if ($PSBoundParameters['SkipCertificateCheck']) + { + + "[{0}] Caller requested to skip certificate validation for endpoint." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + # Need to detect the powershell version. This only works with Windows PowerShell (aka PowerShell 5.x) + if ($PSEdition -ne 'Core') + { + + "[{0}] Not PowerShell Core 'edition'." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $WebRequest.ServerCertificateValidationCallback = { $True } + + } + + else + { + + "[{0}] PowerShell Core 'edition'." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + # There is no override ServicePointManager.ServerCertificateValidationCallback policy, need to set it as the caller asked to SkipCertificateCheck + if ($null -eq [System.Net.ServicePointManager]::ServerCertificateValidationCallback) + { + + "[{0}] ServicePointManager.ServerCertificateValidationCallback is null, setting to 'true' to override." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + [System.Net.ServicePointManager]::ServerCertificateValidationCallback = [HPEOneView.PKI.SslValidation]::CertificateValidationCallBack + + # Flag variable used to reset when we are done. + $_IgnoredCertValidationCallBack = $true + + } + + else + { + + "[{0}] ServicePointManager.ServerCertificateValidationCallback is not null, another policy already exists." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + } + + } + + "[{0}] Getting Redfish SessionID token from iLO, {1}." -f $MyInvocation.InvocationName.ToString().ToUpper(), ([URI]$_ssoresp.iloSsoUrl).Host | Write-Verbose + + $Response = $WebRequest.GetResponse() + $Response.Close() + $Response.Dispose() + + "[{0}] Getting Redfish SessionID token from cookies." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + $SessionID = $CookieContainer.GetCookieHeader($_ssoresp.iloSsoUrl) + + if ($_IgnoredCertValidationCallBack) + { + + [System.Net.ServicePointManager]::ServerCertificateValidationCallback = $null + + } + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + "[{0}] Building iLO Session Object." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + switch ($_Server.mpModel) + { + + default + { + + $_RootUri = "https://{0}/redfish/v1" -f ([URI]$_ssoresp.iloSsoUrl).Host + + } + + 'iLO4' + { + + $_RootUri = "https://{0}/rest/v1" -f ([URI]$_ssoresp.iloSsoUrl).Host + + } + + } + + $IloSession = NewObject -IloRestSession + $IloSession.RootUri = $_RootUri + $IloSession.'X-Auth-Token' = $SessionID.Replace('sessionKey=',$null) + + $IloSession + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Add-OVServer +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "Managed", SupportsShouldProcess, ConfirmImpact = 'High')] + Param + ( + + [Parameter (ValueFromPipeline, Mandatory, ParameterSetName = "Monitored")] + [Parameter (ValueFromPipeline, Mandatory, ParameterSetName = "Managed")] + [ValidateNotNullOrEmpty()] + [String]$Hostname, + + [Parameter (Mandatory = $false, ParameterSetName = "Monitored")] + [Parameter (Mandatory = $false, ParameterSetName = "Managed")] + [Obsolete()] + [ValidateNotNullOrEmpty()] + [String]$Username, + + [Parameter (Mandatory = $false, ParameterSetName = "Monitored")] + [Parameter (Mandatory = $false, ParameterSetName = "Managed")] + [Obsolete()] + [ValidateNotNullOrEmpty()] + [Object]$Password, + + [Parameter (Mandatory = $false, ParameterSetName = "Monitored")] + [Parameter (Mandatory = $false, ParameterSetName = "Managed")] + [ValidateNotNullOrEmpty()] + [PSCredential]$Credential, + + [Parameter (Mandatory = $false, ParameterSetName = "Managed")] + [ValidateSet ("OneView", "OneViewNoiLO")] + [String]$LicensingIntent = 'OneView', + + [Parameter (Mandatory, ParameterSetName = "Monitored")] + [Switch]$Monitored, + + [Parameter (Mandatory = $false, ParameterSetName = "Managed")] + [Parameter (Mandatory = $false, ParameterSetName = "Monitored")] + [ValidateNotNullOrEmpty()] + [HPEOneView.Appliance.ScopeCollection[]]$Scope, + + [Parameter (Mandatory = $False, ParameterSetName = "Monitored")] + [Parameter (Mandatory = $False, ParameterSetName = "Managed")] + [Switch]$Async, + + [Parameter (Mandatory = $False, ParameterSetName = "Monitored")] + [Parameter (Mandatory = $False, ParameterSetName = "Managed")] + [ValidateNotNullorEmpty()] + [object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + if ($PSBoundParameters['Credential']) + { + + $_Username = $Credential.Username + $_Password = [Runtime.InteropServices.Marshal]::PtrToStringBSTR([Runtime.InteropServices.Marshal]::SecureStringToBSTR($Credential.Password)) + + } + + elseif ($PSBoundParameters['Username']) + { + + Write-Warning "The -Username and -Password parameters are being deprecated. Please transition your scripts to using the -Credential parameter." + + $_Username = $Username.clone() + + if (-not $PSBoundParameters['Password']) + { + + $ExceptionMessage = "The -Username parameter requires the -Password parameter. Or please use the -Credential parameter instead." + $ErrorRecord = New-ErrorRecord HPEOneView.Library.UnsupportedArgumentException MissingRequiredPasswordParameter InvalidOperation 'Password' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + if ($Password -is [SecureString]) + { + + $_Password = [Runtime.InteropServices.Marshal]::PtrToStringBSTR([Runtime.InteropServices.Marshal]::SecureStringToBSTR($Password)) + + } + + else + { + + $_Password = $Password.Clone() + + } + + } + + elseif (-not $PSBoundParameters['Credential'] -and -not $PSBoundParameters['Username']) + { + + $ExceptionMessage = "This Cmdlet requires credentials to the target resource. Please provide either the -Username and -Password, or -Credential parameters." + $ErrorRecord = New-ErrorRecord HPEOneView.Library.UnsupportedArgumentException MissingRequiredPasswordParameter InvalidOperation 'Authentication' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + Process + { + + # New Server Resource Object + $_server = NewObject -ServerImport + $_server.hostname = $Hostname; + $_server.username = $_Username; + $_server.password = $_Password; + $_server.licensingIntent = $LicensingIntent; + + if ([Bool]$Monitored) + { + + $_server.licensingIntent = "OneViewStandard" + $_server.configurationState = "Monitored" + + } + + else + { + + $_server.configurationState = "Managed" + + } + + if ($PSBoundParameters['Scope']) + { + + ForEach ($_Scope in $Scope) + { + + "[{0}] Adding resource to Scope: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_Scope.Name | Write-Verbose + + [void]$_server.initialScopeUris.Add($_Scope.Uri) + + } + + } + + "[{0}] Sending request to add server resource {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Hostname | Write-Verbose + + Try + { + + $task = Send-OVRequest -Uri $ServerHardwareUri -Method POST -Body $_server -Hostname $ApplianceConnection.Name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + "[{0}] Initial task response: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), ($resp | out-string) | Write-Verbose + + Try + { + + $resp = Wait-OVTaskStart $task + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + "[{0}] Second task response: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), ($resp | out-string) | Write-Verbose + + # Check to see if the task errored, which should be in the Task Validation stage + if ($resp.taskState -ne "Running") + { + + if (($resp.taskState -eq "Error") -and ($resp.stateReason -eq "ValidationError")) + { + + "[{0}] Task error found: {1}, {2}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $resp.taskState, $resp.stateReason | Write-Verbose + + # TaskErrors should contain only a single value, so we will force pick the first one. + $errorMessage = $resp.taskerrors[0] + + switch ($errorMessage.errorCode) + { + + {[RegEx]::Match($_, "SERVER_ALREADY_*", $RegExInsensitiveFlag).Success } + { + + # Support different external manager process + if ([Uri]::IsWellFormedUriString($errorMessage.data.managementUrl, [System.UriKind]::Absolute)) + { + + $externalManagerType = $errorMessage.data.managementProduct + + $externalManagerIP = $errorMessage.data.managementUrl.Replace("https://","") + + Try + { + + $externalManagerFQDN = [System.Net.DNS]::GetHostByAddress($externalManagerIP) + + } + + Catch + { + + "[{0}] Unable to resolve IP Address to DNS A Record." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + $externalManagerFQDN = [PSCustomObject]@{HostName = 'UnknownFqdn'; Aliases = @(); AddressList = @($externalManagerIP.Clone())} + + } + + "[{0}] Found server '{1}' is already being managed by {2} at {3}." -f $MyInvocation.InvocationName.ToString().ToUpper(), $Hostname, $externalManagerType, $externalManagerIP | Write-Verbose + "[{0}] {1} resolves to {2}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $externalManagerIP, $($externalManagerFQDN | out-string) | Write-Verbose + + write-warning ("Server '{0}' is already being managed by {1} at {2} ({3})." -f $hostname, $externalManagerType, $externalManagerIP, $($externalManagerFQDN | out-string)) + + if ($PSCmdlet.ShouldProcess($hostname,("force add server that is already managed/monitored by {0} at {1} ({2})" -f $externalManagerType, $externalManagerIP, $externalManagerFQDN.HostName))) + { + + "[{0}] Server was claimed and user chose YES to force add." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_server | Add-Member -NotePropertyName force -NotePropertyValue $true -force | out-null + + Try + { + + $resp = Send-OVRequest -Uri $ServerHardwareUri -Method POST -Body $_server -Hostname $ApplianceConnection.Name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + else + { + + if ($PSBoundParameters['whatif'].ispresent) + { + + write-warning "-WhatIf was passed, would have force added '$hostname' server to appliance." + + $resp = $null + + } + + else + { + + # If here, user chose "No", End Processing + write-warning "Not importing server, $hostname." + + $resp = $Null + + } + + } + + } + + # Device is already added to appliance as Monitored or Managed resource + else + { + + "[{0}] Device alerady exists." -f $MyInvocation.InvocationName.ToString().ToUpper(), $resp.taskState, $resp.stateReason | Write-Verbose + + $_EmbeddedJson = ([Regex]::Match($errorMessage.message, "\{.*\}")).value | ConvertFrom-Json + + if ([String]::IsNullOrEmpty($_EmbeddedJson) -and -not [String]::IsNullOrEmpty($errorMessage.data.uri)) + { + + # Get the server hardware in $errorMessage.data.uri + Try + { + + $_Server = (Send-OVRequest -Uri $errorMessage.data.uri -Hostname $ApplianceConnection).name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + elseif ([String]::IsNullOrEmpty($errorMessage.data.uri)) + { + + $_Server = $_EmbeddedJson + + } + + else + { + + $_Server = $Hostname + + } + + # Throw exception that resource is already managed by the appliance as $Server.name + "[{0}] Generating error: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), ($errorMessage.message) | Write-Verbose + + $ExceptionMessage = '"The server hardware has already been added as "{0}". {1} If the server is orphaned, use Remove-OVServer -Force Cmdlet, and then try your add again.' -f $_Server, [String]::Join(' ', $errorMessage.recommendedActions) + $ErrorRecord = New-ErrorRecord HPEOneView.ServerHardwareResourceException ServerResourceExists ResourceExists 'Hostname' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + "INVALID_ADDR" + { + + "[{0}] Generating error: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), ($errorMessage.message) | Write-Verbose + $ExceptionMessage = '{0} {1}' -f $errorMessage.message, $errorMessage.recommendedActions + $ErrorRecord = New-ErrorRecord HPEOneView.ServerHardwareResourceException ServerResourceNotFound ObjectNotFound 'Hostname' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + } + + } + + if (-not($PSBoundParameters['Async'])) + { + + $resp | Wait-OVTaskComplete + + } + + else + { + + $resp + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Remove-OVServer +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (SupportsShouldProcess, ConfirmImpact = 'High')] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline)] + [ValidateNotNullOrEmpty()] + [Alias ("uri","name","Server")] + [object]$InputObject, + + [Parameter (Mandatory = $false)] + [Switch]$Force, + + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName)] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not($PSBoundParameters['InputObject'])) + { + + $PipelineInput = $True + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + $_ServersToRemoveCol = [System.Collections.ArrayList]::new() + $_TaskCollection = [System.Collections.ArrayList]::new() + + } + + Process + { + + if ($PipelineInput -or $InputObject -is [PSCustomObject]) + { + + "[{0}] Processing pipeline input objects." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if ($InputObject.category -ne $ResourceCategoryEnum.ServerHardware) + { + + $ErrorRecord = New-ErrorRecord HPEOneView.ServerHardwareResourceException UnsupportedResourceCategory InvalidArgument 'InputObject' -TargetType 'PSObject' -Message "The provided Server object {$($InputObject.name)} is an unsupported object category, '$($InputObject.category)'. Only 'server-hardware' category objects are supported. please check the Parameter value and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + # Throw error that you cannot remove a BL server + if ($null -ne $InputObject.locationUri -and [RegEx]::Match($InputObject.model,'BL|WS|SY').Success) + { + + $ErrorRecord = New-ErrorRecord HPEOneView.ServerHardwareResourceException CannotRemoveBLServerTypes InvalidOperation 'InputObject' -TargetType 'PSObject' -Message "The provided Server object {$($InputObject.name)} cannot be removed from the appliance, as it is a WS/BL server class. If you wish to remove a WS/BL server from the appliance, you either physically remove the server from the enclosure or remove the enclosure from the appliance. Please check the Parameter value and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + [void]$_ServersToRemoveCol.Add($InputObject) + + } + + Else + { + + ForEach ($_appliance in $ApplianceConnection) + { + + "[{0}] Processing {1} appliance connection (of {2})." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name, $ApplianceConnection.Count | Write-Verbose + + Try + { + + "[{0}] Getting '{1}' server from Get-OVServer." -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject | Write-Verbose + + $_InputObject = Get-OVServer -Name $InputObject -ApplianceConnection $_appliance -ErrorAction SilentlyContinue + + [void]$_ServersToRemoveCol.Add($_InputObject) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + } + + End + { + + "[{0}] Processing {1} Server object resources to remove." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_ServersToRemoveCol.count | Write-Verbose + + # Process Storage Resources + ForEach ($_server in $_ServersToRemoveCol) + { + + if ($PSCmdlet.ShouldProcess($_server.ApplianceConnection,"Remove Server resource '$($_server.name)' from appliance")) + { + + "[{0}] Removing Server resource '{1}' from appliance '{2}'." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_server.name, $_server.ApplianceConnection | Write-Verbose + + $_Uri = $_server.uri.Clone() + + if ($PSboundParameters['force']) + { + + $_Uri += "?force=true" + + } + + Try + { + + Send-OVRequest -Uri $_Uri -Method DELETE -AddHeader @{'If-Match' = $_server.eTag } -Hostname $_server.ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + elseif ($PSBoundParameters['WhatIf']) + { + + "[{0}] WhatIf Parameter was passed." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + } + + } + +} + +function Start-OVServer +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding ()] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline)] + [ValidateNotNullOrEmpty()] + [Alias('Server')] + [object]$InputObject, + + [Parameter (Mandatory = $false)] + [Switch]$Async, + + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName)] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not($PSBoundParameters['InputObject'])) + { + + $PipelineInput = $True + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + $_PowerControl = 'MomentaryPress' + $_PowerState = 'On' + + $_ServerPowerControlCol = [System.Collections.ArrayList]::new() + + } + + Process + { + + # Checking if the input is PSCustomObject, and the category type is server-profiles, which could be passed via pipeline input + if (($InputObject -is [System.Management.Automation.PSCustomObject]) -and $InputObject.category -ieq "server-hardware") + { + + "[{0}] Server is a Server Device object: $($InputObject.name)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_uri = $InputObject.Uri.ToString() + + } + + # Checking if the input is PSCustomObject, and the category type is server-hardware, which would be passed via pipeline input + elseif (($InputObject -is [System.Management.Automation.PSCustomObject]) -and ($InputObject.category -ieq $ResourceCategoryEnum.ServerProfile ) -and ($InputObject.serverHardwareUri)) + { + + "[{0}] Server is a Server Profile object: $($InputObject.name)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + "[{0}] Getting server hardware device assigned to Server Profile." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_uri = $InputObject.serverHardwareUri + + } + + else + { + + if (-not($InputObject.serverHardwareUri)) + { + + $ErrorRecord = New-ErrorRecord InvalidOperationException ServerProfileUnassigned InvalidArgument 'InputObject' -TargetType $InputObjectServer.GetType().Name -Message "The Server Profile '$($InputObject.name)' is unassigned. This cmdlet only supports Server Profiles that are assigned to Server Hardware resources. Please check the input object and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + else + { + + $ErrorRecord = New-ErrorRecord InvalidOperationException InvalidArgumentValue InvalidArgument 'InputObject' -TargetType $InputObject.GetType().Name -Message "The Parameter 'InputObject' value is invalid. Please validate the 'Server' Parameter value you passed and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + # Validate the server power state and lock + Try + { + + $_serverObj = Send-OVRequest $_uri -appliance $ApplianceConnection.Name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + # Need to add confirm prompt here. + if (($_serverObj.powerState -ine $_PowerState -and (-not($_serverObj.powerLock)))) + { + + "[{0}] Set Server '{1}' to desired Power State '{2}'." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_serverObj.name, $_PowerState | Write-Verbose + + $_uri = $_serverObj.uri + "/powerState" + + $body = [pscustomobject]@{ + + powerState = $_PowerState; + powerControl = $_PowerControl + + } + + Try + { + + $_resp = Send-OVRequest $_uri PUT $body -Hostname $_serverObj.ApplianceConnection + + if (-not($PSBoundParameters['Async'])) + { + + $_resp = Wait-OVTaskComplete $_resp + + } + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + [void]$_ServerPowerControlCol.Add($_resp) + + } + + else + { + + $_Message = $null + + if ($serverPowerState.powerState -ieq $_PowerState) + { + + $_Message = "Requested Power State '{0}' is the same value as the current Server Power State '{0}'. " -f $_PowerState + + } + + if ($serverPowerState.powerLock) + { + + $_Message += "Server is currently under Power Lock." + + } + + if ($errorMessage) + { + + $_ErrorRecord = New-ErrorRecord HPEOneView.InvalidServerPowerControlException InvalidServerPowerControlOpertion InvalidOperation 'Server' -TargetType 'PSObject' $_Message + $PSCmdlet.WriteError($_ErrorRecord) + + } + + } + + } + + End + { + + Return $_ServerPowerControlCol + + } + +} + +function Stop-OVServer +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (SupportsShouldProcess, ConfirmImpact = 'High', DefaultParameterSetName = 'Default')] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = 'Default')] + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = 'Force')] + [ValidateNotNullOrEmpty()] + [Alias('Server')] + [object]$InputObject, + + [Parameter (Mandatory, ParameterSetName = 'Force')] + [Switch]$Force, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [Parameter (Mandatory = $false, ParameterSetName = 'Force')] + [Switch]$Async, + + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = 'Default')] + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = 'Force')] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not($PSBoundParameters['InputObject'])) + { + + $PipelineInput = $True + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + $_PowerControl = if ($PSBoundParameters['Force']) + { + + 'PressAndHold' + + } + + else + { + + 'MomentaryPress' + + } + + $_PowerState = 'Off' + + $_ServerPowerControlCol = [System.Collections.ArrayList]::new() + + } + + Process + { + + # Checking if the input is PSCustomObject, and the category type is server-profiles, which could be passed via pipeline input + if (($InputObject -is [System.Management.Automation.PSCustomObject]) -and ($InputObject.category -ieq "server-hardware")) + { + + "[{0}] Server is a Server Device object: $($InputObject.name)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_uri = $InputObject.Uri.ToString() + + } + + # Checking if the input is PSCustomObject, and the category type is server-hardware, which would be passed via pipeline input + elseif (($InputObject -is [System.Management.Automation.PSCustomObject]) -and ($InputObject.category -ieq $ResourceCategoryEnum.ServerProfile) -and ($InputObject.serverHardwareUri)) + { + + "[{0}] Server is a Server Profile object: $($InputObject.name)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + "[{0}] Getting server hardware device assigned to Server Profile." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_uri = $InputObject.serverHardwareUri + + } + + else + { + + if (-not($InputObject.serverHardwareUri)) + { + + $ErrorRecord = New-ErrorRecord InvalidOperationException ServerProfileUnassigned InvalidArgument 'InputObject' -TargetType $InputObject.GetType().Name -Message "The Server Profile '$($InputObject.name)' is unassigned. This cmdlet only supports Server Profiles that are assigned to Server Hardware resources. Please check the input object and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + else + { + + $ErrorRecord = New-ErrorRecord InvalidOperationException InvalidArgumentValue InvalidArgument 'InputObject' -TargetType $InputObject.GetType().Name -Message "The Parameter 'InputObject' value is invalid. Please validate the 'Server' Parameter value you passed and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + # Validate the server power state and lock + Try + { + + $_serverObj = Send-OVRequest $_uri -appliance $ApplianceConnection.Name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + # Need to add confirm prompt here. + if (($_serverObj.powerState -ine $_PowerState -and (-not($_serverObj.powerLock)))) + { + + if ($PSCmdlet.ShouldProcess($_serverObj.name,'Poweroff server resource')) + { + + "[{0}] Set Server '{1}' to desired Power State '{2}'." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_serverObj.name, $_PowerState | Write-Verbose + + $_uri = $_serverObj.uri + "/powerState" + + $body = [pscustomobject]@{ + + powerState = $_PowerState; + powerControl = $_PowerControl + + } + + Try + { + + $_resp = Send-OVRequest -uri $_uri -method PUT -Body $body -Hostname $_serverObj.ApplianceConnection + + if (-not($PSBoundParameters['Async'])) + { + + $_resp = Wait-OVTaskComplete -InputObject $_resp + + } + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $_resp + + } + + elseif ($PSBoundParameters['WhatIf']) + { + + "[{0}] -WhatIf scenario." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + else + { + + "[{0}] User cancelled oepration by choosing No." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + } + + else + { + + $_Message = $null + + if ($serverPowerState.powerState -ieq $_PowerState) + { + + $_Message = "Requested Power State '{0}' is the same value as the current Server Power State '{0}'. " -f $_PowerState + + } + + if ($serverPowerState.powerLock) + { + + $_Message += "Server is currently under Power Lock." + + } + + if ($errorMessage) + { + + $_ErrorRecord = New-ErrorRecord HPEOneView.InvalidServerPowerControlException InvalidServerPowerControlOpertion InvalidOperation 'Server' -TargetType 'PSObject' $_Message + $PSCmdlet.WriteError($_ErrorRecord) + + } + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Restart-OVServer +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (SupportsShouldProcess, ConfirmImpact = 'High', DefaultParameterSetName = 'Default')] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = 'Default')] + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = 'ColdBoot')] + [ValidateNotNullOrEmpty()] + [object]$Server, + + [Parameter (Mandatory, ParameterSetName = 'ColdBoot')] + [Switch]$ColdBoot, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [Parameter (Mandatory = $false, ParameterSetName = 'ColdBoot')] + [Switch]$Async, + + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = 'Default')] + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = 'ColdBoot')] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not($PSBoundParameters['Server'])) + { + + $PipelineInput = $True + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + $_PowerControl = if ($PSBoundParameters['ColdBoot']) + { + + 'ColdBoot' + + } + + else + { + + 'Reset' + + } + + $_PowerState = 'On' + + $_ServerPowerControlCol = [System.Collections.ArrayList]::new() + + } + + Process + { + + # Checking if the input is PSCustomObject, and the category type is server-profiles, which could be passed via pipeline input + if (($server -is [System.Management.Automation.PSCustomObject]) -and ($server.category -ieq "server-hardware")) + { + + "[{0}] Server is a Server Device object: $($server.name)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_uri = $server.uri + + } + + # Checking if the input is PSCustomObject, and the category type is server-hardware, which would be passed via pipeline input + elseif (($server -is [System.Management.Automation.PSCustomObject]) -and ($server.category -ieq $ResourceCategoryEnum.ServerProfile) -and ($server.serverHardwareUri)) + { + + "[{0}] Server is a Server Profile object: $($server.name)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + "[{0}] Getting server hardware device assigned to Server Profile." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_uri = $server.serverHardwareUri + + } + + else + { + + if (-not($server.serverHardwareUri)) + { + + $ErrorRecord = New-ErrorRecord InvalidOperationException ServerProfileUnassigned InvalidArgument 'Server' -TargetType $Server.GetType().Name -Message "The Server Profile '$($Server.name)' is unassigned. This cmdlet only supports Server Profiles that are assigned to Server Hardware resources. Please check the input object and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + else + { + + $ErrorRecord = New-ErrorRecord InvalidOperationException InvalidArgumentValue InvalidArgument 'Server' -TargetType $Server.GetType().Name -Message "The Parameter 'Server' value is invalid. Please validate the 'Server' Parameter value you passed and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + # Validate the server power state and lock + Try + { + + $_serverObj = Send-OVRequest $_uri -appliance $ApplianceConnection.Name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + # Need to add confirm prompt here. + if (($_serverObj.powerState -ine 'Off' -and (-not($_serverObj.powerLock)))) + { + + if ($PSCmdlet.ShouldProcess($_serverObj.name,'Restart server resource')) + { + + "[{0}] Set Server '{1}' to desired Power State '{2}'." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_serverObj.name, $_PowerState | Write-Verbose + + $_uri = $_serverObj.uri + "/powerState" + + $body = [pscustomobject]@{ + + powerState = $_PowerState; + powerControl = $_PowerControl + + } + + Try + { + + $_resp = Send-OVRequest $_uri PUT $body -Hostname $_serverObj.ApplianceConnection + + if (-not($PSBoundParameters['Async'])) + { + + $_resp = Wait-OVTaskComplete $_resp + + } + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + [void]$_ServerPowerControlCol.Add($_resp) + + } + + elseif ($PSBoundParameters['WhatIf']) + { + + "[{0}] -WhatIf scenario." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + else + { + + "[{0}] User cancelled oepration by choosing No." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + } + + else + { + + $_Message = $null + + if ($serverPowerState.powerState -ieq $_PowerState) + { + + $_Message = "Requested Power State '{0}' is the same value as the current Server Power State '{0}'. " -f $_PowerState + + } + + if ($serverPowerState.powerLock) + { + + $_Message += "Server is currently under Power Lock." + + } + + if ($errorMessage) + { + + $_ErrorRecord = New-ErrorRecord HPEOneView.InvalidServerPowerControlException InvalidServerPowerControlOpertion InvalidOperation 'Server' -TargetType 'PSObject' $_Message + $PSCmdlet.WriteError($_ErrorRecord) + + } + + } + + } + + End + { + + Return $_ServerPowerControlCol + + } + +} + +function Set-OVServerPower +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (SupportsShouldProcess, ConfirmImpact = 'High')] + [Obsolete()] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline)] + [ValidateNotNullOrEmpty()] + [Alias ("name","uri","serverUri")] + [object]$Server, + + [Parameter (Mandatory = $false)] + [Alias ('PowerState')] + [ValidateSet ("On", "Off")] + [String]$State = "On", + + [Parameter (Mandatory = $false)] + [ValidateSet ("PressAndHold", "MomentaryPress", "ColdBoot", "Reset")] + [String]$powerControl = "MomentaryPress", + + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName)] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + Write-Warning "This Cmdlet has been deprecated. Please use either Start-OVServer, Stop-OVServer or Restart-OVServer." + + } + +} + +function Get-OVServerOneTimeBoot +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding ()] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline)] + [ValidateNotNullOrEmpty()] + [Alias ("Server")] + [object]$InputObject, + + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName)] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not($PSBoundParameters['InputObject'])) + { + + $PipelineInput = $True + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + } + + Process + { + + if ($ResourceCategoryEnum.ServerProfile, $ResourceCategoryEnum.ServerHardware -notcontains $InputObject.category) + { + + $ExceptionMessage = "The InputObject resource '{0}' is not a server hardware or server profile resource." -f $InputObject.name + $ErrorRecord = New-ErrorRecord InvalidOperationException InvalidInputObjectParameterValue InvalidArgument 'InputObject' -TargetType $InputObject.GetType().Name -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + if ($ResourceCategoryEnum.ServerProfile -eq $InputObject.category) + { + + "[{0}] InputObject is a server profile resource." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + "[{0}] Resource assigned to server hardware: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), [String]::IsNullOrEmpty($InputObject.serverHardwareUri) | Write-Verbose + + if ([String]::IsNullOrEmpty($InputObject.serverHardwareUri)) + { + + $ExceptionMessage = "The InputObject server profile resource '{0}' is not assigned to a server hardware resource." -f $InputObject.name + $ErrorRecord = New-ErrorRecord InvalidOperationException InvalidInputObjectParameterValue InvalidArgument 'InputObject' -TargetType $InputObject.GetType().Name -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + else + { + + Try + { + + $_ObjectToProcess = Send-OVRequest -Uri $InputObject.serverHardwareUri -Hostname $InputObject.ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + $_ObjectToProcess = $InputObject.PSObject.Copy() + + } + + $_OneTimeBootSetting = $ServerHardwareOneTimeBootEnum.($_ObjectToProcess.oneTimeBoot) + + [HPEOneView.Servers.ServerHardware+OneTimeBoot]::new($_ObjectToProcess.name, + [HPEOneView.Servers.OneTimeBootEnum]::$_OneTimeBootSetting, + $_ObjectToProcess.uri, + $_ObjectToProcess.ApplianceConnection) + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Set-OVServerOneTimeBoot +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (SupportsShouldProcess, ConfirmImpact = 'High')] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline)] + [ValidateNotNullOrEmpty()] + [Alias ("Server")] + [object]$InputObject, + + [Parameter (Mandatory)] + [ValidateSet ('Normal', 'PXE', 'HardDisk', 'CD', 'USB')] + [String]$Setting, + + [Parameter (Mandatory = $false)] + [Alias ('PowerState')] + [Switch]$PowerOn, + + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName)] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not($PSBoundParameters['InputObject'])) + { + + $PipelineInput = $True + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + } + + Process + { + + if ($ResourceCategoryEnum.ServerProfile, $ResourceCategoryEnum.ServerHardware -notcontains $InputObject.category) + { + + $ExceptionMessage = "The InputObject resource '{0}' is not a server hardware or server profile resource." -f $InputObject.name + $ErrorRecord = New-ErrorRecord InvalidOperationException InvalidInputObjectParameterValue InvalidArgument 'InputObject' -TargetType $InputObject.GetType().Name -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + if ($ResourceCategoryEnum.ServerProfile -eq $InputObject.category) + { + + "[{0}] InputObject is a server profile resource." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + "[{0}] Resource assigned to server hardware: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), [String]::IsNullOrEmpty($InputObject.serverHardwareUri) | Write-Verbose + + if ([String]::IsNullOrEmpty($InputObject.serverHardwareUri)) + { + + $ExceptionMessage = "The InputObject server profile resource '{0}' is not assigned to a server hardware resource." -f $InputObject.name + $ErrorRecord = New-ErrorRecord InvalidOperationException InvalidInputObjectParameterValue InvalidArgument 'InputObject' -TargetType $InputObject.GetType().Name -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + else + { + + Try + { + + $_ObjectToProcess = Send-OVRequest -Uri $InputObject.serverHardwareUri -Hostname $InputObject.ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + $_ObjectToProcess = $InputObject.PSObject.Copy() + + } + + $_PatchOperation = [System.Collections.ArrayList]::new() + + $_PatchOp = NewObject -PatchOperation + $_PatchOp.op = 'replace' + $_PatchOp.path = '/oneTimeBoot' + $_PatchOp.value = $ServerHardwareOneTimeBootEnum.$Setting + + [void]$_PatchOperation.Add($_PatchOp) + + if ($PSBoundParameters['PowerOn']) + { + + # Validate the server is powreed off + if ($_ObjectToProcess.powerState -ne 'Off' -and -not $_ObjectToProcess.powerLock) + { + + $ExceptionMessage = 'The server "{0}" is both not currently powered off and power control is locked. Please wait until the currently running task releases power lock status. In order to set the server to power on, it must first be powered off using Stop-OVServer.' -f $_ObjectToProcess.name + $_ErrorRecord = New-ErrorRecord HPEOneView.InvalidServerPowerControlException InvalidServerPowerControlOpertion InvalidOperation 'InputObject' -TargetType 'PSObject' $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($_ErrorRecord) + + } + + elseif ($_ObjectToProcess.powerState -ne 'Off') + { + + $ExceptionMessage = 'The server "{0}" is not currently powered off. In order to set the server to power on, it must first be powered off using Stop-OVServer.' -f $_ObjectToProcess.name + $_ErrorRecord = New-ErrorRecord HPEOneView.InvalidServerPowerControlException InvalidServerPowerControlOpertion InvalidOperation 'InputObject' -TargetType 'PSObject' $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($_ErrorRecord) + + } + + $_PatchOp = NewObject -PatchOperation + $_PatchOp.op = 'replace' + $_PatchOp.path = '/powerState' + $_PatchOp.value = @{powerState = "On"; powerControl = "MomentaryPress"} + + [void]$_PatchOperation.Add($_PatchOp) + + } + + if ($PSCmdlet.ShouldProcess($_ObjectToProcess.name,'Restart server resource')) + { + + "[{0}] Set Server '{1}' to desired Power State '{2}'." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_serverObj.name, $_PowerState | Write-Verbose + + $_uri = $_ObjectToProcess.uri + $_eTag = $_ObjectToProcess.eTag + + Try + { + + $_resp = Send-OVRequest -Uri $_uri -Method PATCH -Body $_PatchOperation -Hostname $_ObjectToProcess.ApplianceConnection -AddHeader @{'If-Match' = $_eTag} + + if (-not $PSBoundParameters['Async']) + { + + $_resp = Wait-OVTaskComplete $_resp + + } + + $_resp + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + elseif ($PSBoundParameters['WhatIf']) + { + + "[{0}] -WhatIf scenario." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + else + { + + "[{0}] User cancelled oepration by choosing No." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + } + + End + { + + Return $_ServerPowerControlCol + + } + +} + +function Update-OVServerFirmware +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "Default")] + param + ( + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = "Default")] + [Alias("Server", "ServerHardware", "ServerProfile")] + [ValidateNotNullOrEmpty()] + [Object]$InputObject, + + [Parameter (Mandatory, ParameterSetName = "Default")] + [ValidateNotNullOrEmpty()] + [Object]$Baseline, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [ValidateNotNullOrEmpty()] + [Version]$PatchLevel, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [ValidateSet ('LowerThanBaseline', 'NotEqualToBaseline')] + [String]$FirmwareInstallationPolicy = 'LowerThanBaseline', + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Alias ('FirmwareMode')] + [ValidateSet ('FirmwareOnly', 'FirmwareAndSoftware', 'FirmwareOffline', 'FirmwareAndOSDrivers', 'FirmwareOnlyOfflineMode')] + [String]$FirmwareInstallMode = 'FirmwareAndSoftware', + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Switch]$ReinstallFirmware, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Switch]$Async, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [ValidateNotNullOrEmpty()] + [Alias ("Appliance")] + [Object]$ApplianceConnection = ($ConnectedSessions | Where-Object Default) + + ) + + Begin + { + + "[{0}] Bound PS Parameters: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(),($PSBoundParameters | out-string) | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not($ConnectedSessions)) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command agian." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -gt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + Process + { + + $_CompliancePreview = [System.Collections.ArrayList]::new() + + if ($InputObject.category -ne $ResourceCategoryEnum.ServerHardware) + { + + $ExceptionMessage = "The provided InputObject is not a server hardware resource." + $ErrorRecord = New-ErrorRecord HPEOneView.Library.ParameterValidationException InvalidInputObjectParameter InvalidOperation 'InputObject' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + # This policy setting is only supported with Gen10 and newer platforms + if (-not [enum]::IsDefined([FirmwarePolicyGenerationSupportEnum], $InputObject.generation.Replace(" ", $null))) + { + + $ExceptionMessage = "Firmware installation without server profile is only available with Gen10 and newer platforms. It is not supported with '{0}' server generation." -f $InputObject.generation + $ErrorRecord = New-ErrorRecord HPEOneView.ServerHardwareResourceException InvalidFirmwareInstallPolicy InvalidArgument 'FirmwareInstallationPolicy' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + $FoundPatchLevel = $null + + # Validate Patch level + if ($PSBoundParameters['PatchLevel']) + { + + $FoundPatchLevel = $Baseline.servicePackData.supplements | ? { [version]$_.version -eq $patchlevel } + + if (-not $FoundPatchLevel) + { + + $ExceptionMessage = "The provided Patch Level '{0}' is not found in the firmware baseline." -f $PatchLevel + $ErrorRecord = New-ErrorRecord HPEOneView.ServerHardwareResourceException InvalidPatchLevel InvalidArgument 'PatchLevel' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + switch ($Inputobject.category) + { + + $ResourceCategoryEnum.ServerHardware + { + + "[{0}] InputObject is a server hardware resource." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + # Check if the server hardware resource contains an iLO Advanced license or HPE OneView Advanced, generate terminating error if not + if (('OneViewNoiLO', 'OneView' -Contains $InputObject.licensingIntent) -or ($InputObject.licensingIntent -eq "OneViewStandard" -and $InputObject.mpLicenseType -eq "iLO Advanced")) + { + + # Check if the server is powered off + if ($InputObject.powerState -ne "Off" -and 'FirmwareOnly', 'FirmwareOffline' -contains $FirmwareInstallMode) + { + + $ExceptionMessage = "The provided server resource {0} is not powered off. Server power state must be off before attempting to install an offline firmware bundle." -f $InputObject.name + $ErrorRecord = New-ErrorRecord HPEOneView.ServerHardwareResourceException InvalidPowerState InvalidOperation 'InputObjectS' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + if (-not [String]::IsNullOrEmpty($InputObject.serverProfileUri)) + { + + $ExceptionMessage = "The provided server resource {0} has a server profile assigned. Deploying a firmware bundle must be installed using the assigned server profile." -f $InputObject.name + $ErrorRecord = New-ErrorRecord HPEOneView.ServerHardwareResourceException InvalidServerProfile InvalidOperation 'InputObjectS' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + "[{0}] Firmware Baseline: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Baseline | Write-Verbose + + $_ServerFirmwareInstallOp = NewObject -InstallServerFirmware + + $_ServerFirmwareInstallOp.forceApplyFirmware = $PSBoundParameters['ReinstallFirmware'] + $_ServerFirmwareInstallOp.firmwareInstallType = $ServerProfileFirmwareControlModeEnum[$FirmwareInstallMode] + $_ServerFirmwareInstallOp.installationPolicy = $FirmwareInstallationPolicy + + if ($PSBoundParameters['PatchLevel']) + { + + $_PatchLevel = "{0:0000}.{1:00}.{2:00}.{3:00}" -f $PatchLevel.Major, $PatchLevel.Minor, $PatchLevel.Build, $PatchLevel.Revision + $_ServerFirmwareInstallOp | Add-Member -NotePropertyName patchLevel -NotePropertyValue $_PatchLevel + + } + + # We are expecting the SPP or Update object that contains the URI. + if ($ResourceCategoryEnum.Baseline, $ResourceCategoryEnum.Updates -contains $Baseline.category) + { + + $_ServerFirmwareInstallOp.baselineUri = $baseline.uri + + } + + else + { + + $ExceptionMessage = "An invalid parameter value for Baseline was provided. Only objects from Get-OVBaseline are supported." + $ErrorRecord = New-ErrorRecord HPEOneView.Library.ParameterValidationException InvalidBaselineParameter InvalidOperation 'Baseline' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + $_PatchOp = NewObject -PatchOperation + $_PatchOp.op = "replace" + $_PatchOp.value = $_ServerFirmwareInstallOp + + $_uri = "{0}/firmware/settings" -f $InputObject.uri + + $_Method = "PATCH" + + } + + # No proper license, generate terminating error + else + { + + $ExceptionMessage = 'Firmware installation without server profile requires an iLO Advanced with HPE OneView Standard, or HPE OneView Advanced license. Server "{0}" HPE OneView license type is "{1}", and iLO license is "{2}".' -f $InputObject.name, $InputObject.licensingIntent, $InputObject.mpLicenseType + $ErrorRecord = New-ErrorRecord HPEOneView.ServerHardwareResourceException InvalidFirmwareInstallPolicy InvalidArgument 'FirmwareInstallationPolicy' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + $ResourceCategoryEnum.ServerProfile + { + + "[{0}] InputObject is a server profile resource." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + "[{0}] server profile name: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Inputobject.name | Write-Verbose + "[{0}] server profile uri: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Inputobject.uri | Write-Verbose + + $_PatchOp = $InputObject.PSObject.Copy() + + $_PatchOp.firmware.forceApplyFirmware = $PSBoundParameters['ReinstallFirmware'] + $_PatchOp.firmware.firmwareInstallType = $ServerProfileFirmwareControlModeEnum[$FirmwareInstallMode] + $_PatchOp.firmware.installationPolicy = $FirmwareInstallationPolicy + + if ($PSBoundParameters['PatchLevel']) + { + + $_PatchLevel = "{0:0000}.{1:00}.{2:00}.{3:00}" -f $PatchLevel.Major, $PatchLevel.Minor, $PatchLevel.Build, $PatchLevel.Revision + $_PatchOp.firmware | Add-Member -NotePropertyName patchLevel -NotePropertyValue $_PatchLevel + + } + + # We are expecting the SPP or Update object that contains the URI. + if ($ResourceCategoryEnum.Baseline, $ResourceCategoryEnum.Updates -contains $Baseline.category) + { + + $_PatchOp.firmware.baselineUri = $baseline.uri + + } + + else + { + + $ExceptionMessage = "An invalid parameter value for Baseline was provided. Only objects from Get-OVBaseline are supported." + $ErrorRecord = New-ErrorRecord HPEOneView.Library.ParameterValidationException InvalidBaselineParameter InvalidOperation 'Baseline' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + $_uri = $InputObject.serverHardwareUri + $_Method = "PUT" + + } + + } + + Try + { + + $Task = Send-OVRequest -Uri $_uri -Method $_Method -Body $_PatchOp -ApplianceConnection $InputObject.ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if ($PSBoundParameters['Async']) + { + + $Task + + } + + else + { + + $Task | Wait-OVTaskComplete + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Add-OVRackManager +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "Default")] + param + ( + + [Parameter (Mandatory, ParameterSetName = "Default")] + [Alias("Name")] + [String]$ComputerName, + + [Parameter (Mandatory, ParameterSetName = "Default")] + [PSCredential]$Credential, + + [Parameter (ParameterSetName = "Default", Mandatory = $false)] + [ValidateNotNullOrEmpty()] + [HPEOneView.Appliance.ScopeCollection[]]$Scope, + + [Parameter (ParameterSetName = "Default", Mandatory = $false)] + [Switch]$Async, + + [Parameter (ParameterSetName = "Default", Mandatory = $false)] + [Switch]$Force, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [ValidateNotNullOrEmpty()] + [Alias ("Appliance")] + [Object]$ApplianceConnection = ($ConnectedSessions | Where-Object Default) + + ) + + Begin + { + + "[{0}] Bound PS Parameters: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(),($PSBoundParameters | out-string) | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not($ConnectedSessions)) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command agian." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -gt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + Process + { + + if ($PSBoundParameters["Scope"]) + { + + $_InitialScopeUris = [System.Collections.Generic.List[String]]::new() + + ForEach ($_Scope in $Scope) + { + + "[{0}] Adding resource to Scope: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_Scope.Name | Write-Verbose + + $_InitialScopeUris.Add($_Scope.Uri) + + } + + } + + $_Import = NewObject -AddRackManager + + $_Import.hostname = $ComputerName; + $_Import.username = $Credential.Username; + $_Import.password = [Runtime.InteropServices.Marshal]::PtrToStringBSTR([Runtime.InteropServices.Marshal]::SecureStringToBSTR($Credential.Password)); + $_Import.force = $Force.IsPresent + + Try + { + + $_resp = Send-OVRequest -Uri $RackManagerUri -Method POST -Body $_Import -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if (-not $Async.IsPresent) + { + + $_resp | Wait-OVTaskComplete + + } + + else + { + + $_resp + + } + + } + + end + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Get-OVRackManager +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = 'Default')] + param + ( + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [String]$Name, + + [Parameter (ParameterSetName = 'Default', Mandatory = $false)] + [ValidateNotNullOrEmpty()] + [String]$Label, + + [Parameter (ParameterSetName = 'Default', Mandatory = $false)] + [ValidateNotNullOrEmpty()] + [Object]$Scope = "AllResourcesInScope", + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = ($ConnectedSessions | Where-Object Default) + + ) + + Begin + { + + "[{0}] Bound PS Parameters: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(),($PSBoundParameters | out-string) | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not($ConnectedSessions)) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command agian." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -gt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $_CollectionName = [System.Collections.ArrayList]::new() + + } + + Process + { + + ForEach ($_appliance in $ApplianceConnection) + { + + "[{0}] Processing appliance {1} (of {2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name, $ApplianceConnection.Count | Write-Verbose + + $_Query = [System.Collections.ArrayList]::new() + + # Handle default cause of AllResourcesInScope + if ($Scope -eq 'AllResourcesInScope') + { + + "[{0}] Processing AllResourcesInScope." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_Scopes = $_appliance.ActivePermissions | Where-Object Active + + # If one scope contains 'AllResources' ScopeName "tag", then all resources should be returned regardless. + if ($_Scopes | Where-Object ScopeName -eq 'AllResources') + { + + $_ScopeNames = [String]::Join(', ', ($_Scopes | Where-Object ScopeName -eq 'AllResources').ScopeName) + + "[{0}] Scope(s) {1} is set to 'AllResources'. Will not add scope to URI query parameter." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_ScopeNames | Write-Verbose + + } + + # Process ApplianceConnection ActivePermissions collection + else + { + + Try + { + + $_ScopeQuery = Join-Scope $_Scopes + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + [Void]$_Query.Add(("({0})" -f $_ScopeQuery)) + + } + + } + + elseif ($Scope | Where-Object ScopeName -eq 'AllResources') + { + + $_ScopeNames = [String]::Join(', ', ($_Scopes | Where-Object ScopeName -eq 'AllResources').ScopeName) + + "[{0}] Scope(s) {1} is set to 'AllResources'. Will not add scope to URI query parameter." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_ScopeNames | Write-Verbose + + } + + elseif ($Scope -eq 'AllResources') + { + + "[{0}] Requesting scope 'AllResources'. Will not add scope to URI query parameter." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_ScopeNames | Write-Verbose + + } + + else + { + + Try + { + + $_ScopeQuery = Join-Scope $Scope + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + [Void]$_Query.Add(("({0})" -f $_ScopeQuery)) + + } + + if ($Name) + { + + "[{0}] Filtering for Name: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Name | Write-Verbose + + if ($Name.Contains('*')) + { + + "[{0}] Filtering for Name: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Name | Write-Verbose + + [Void]$_Query.Add(("name%3A{0}" -f $Name.Replace("*", "%2A").Replace(',','%2C').Replace(" ", "?"))) + + } + + else + { + + [Void]$_Query.Add(("name:'{0}'" -f $Name)) + + } + + } + + if ($Label) + { + + [Void]$_Query.Add(("labels:'{0}'" -f $Label)) + + } + + $_Category = 'category={0}' -f $ResourceCategoryEnum.RackManager + + # Build the final URI + $_uri = '{0}?{1}&sort=name:asc&query={2}' -f $IndexUri, [String]::Join('&', $_Category), [String]::Join(' AND ', $_Query.ToArray()) + + Try + { + + [Array]$_ResourcesFromIndexCol = Get-AllIndexResources -Uri $_uri -ApplianceConnection $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if($_ResourcesFromIndexCol.Count -eq 0 -and $Name) + { + + "[{0}] Rack manager Resource Name '{1}' was not found on appliance {2}. Generate Error." -f $MyInvocation.InvocationName.ToString().ToUpper(), $Name, $_appliance.Name | Write-Verbose + + $ExceptionMessage = "The specified Rack manager '{0}' was not found on '{1}' appliance connection. Please check the name again, and try again." -f $Name, $_appliance.Name + $ErrorRecord = New-ErrorRecord HPEOneView.RackManagerResourceException RackManagerResourceNotFound ObjectNotFound "Name" -Message $ExceptionMessage + + $PSCmdlet.WriteError($ErrorRecord) + + } + + else + { + + ForEach ($_member in $_ResourcesFromIndexCol) + { + + # Get Chassis subresource + Try + { + + $_ChassisResourceCol = [System.Collections.Generic.List[HPEOneView.Servers.Chassis]]::new() + + ForEach ($_chassis in $_member.subResources.chassis.data) + { + + $_ChassisResourceCol.Add(([HPEOneView.Servers.Chassis]::new($_chassis.name, + $_chassis.model, + $_chassis.partNumber, + $_chassis.chassisType, + $_chassis.serialNumber, + $_chassis.uPosition, + $_chassis.status, + $_chassis.state, + ('{0}/{1}' -f $RackManagerUri, $_chassis.rackManagerId), + $_chassis.partitionName, + $_chassis.physicalLocationString, + ('{0}/{1}' -f $ServerFirmwareUri, $_chassis.partitionUuid), + $_chassis.uri, + $_chassis.ApplianceConnection))) + + } + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + # Get Partition subresources + Try + { + + $_PartitionResourcesCol = [System.Collections.Generic.List[HPEOneView.Servers.Partition]]::new() + + ForEach ($_partition in $_member.subResources.partitions.data) + { + + # Look in the fwInventories collection for the Partition Name to get the firmware version installed + $_PartitionFirmware = $_member.subResources.fwInventories.data | ? name -eq $_partition.name + + $_PartitionResourcesCol.Add(([HPEOneView.Servers.Partition]::new($_partition.name, + $_partition.powerState, + $_partition.state, + $_partition.status, + $_partition.partitionId, + $_partition.chassisCount, + $_partition.totalPartitionMemoryGB, + $_partition.totalProcessorCount, + $_partition.coreCountPerProcessor, + $_PartitionFirmware.currentVersion, + $_partition.redfishUri, + ('{0}/{1}' -f $RackManagerUri, $_partition.rackManagerId), + $_partition.serverHardwareUri, + $_partition.uri, + $_partition.ApplianceConnection))) + + } + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + # Get Managers subresources + Try + { + + $_ChassisManagerResources = Send-OVRequest -Uri $_member.subResources.managers.uri -Hostname $ApplianceConnection + + $_ChassisManagerResourcesCol = [System.Collections.Generic.List[HPEOneView.Servers.Manager]]::new() + + ForEach ($_manager in $_ChassisManagerResources.members) + { + + $_ChassisManagerResourcesCol.Add(([HPEOneView.Servers.Manager]::new($_manager.name, + $_manager.fwVersion, + $_manager.ipv4Address, + $_manager.ipv6Address, + $_manager.hostname, + $_manager.managerType, + $_manager.model, + $_manager.status, + $_manager.state, + $_manager.uPosition, + ('{0}/{1}' -f $RackManagerUri, $_manager.rackManagerId), + $_manager.serialNumber, + $_manager.partNumber, + $_manager.uri, + $_manager.ApplianceConnection))) + + } + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $_SubResources = [HPEOneView.Servers.SubResources]::new($_ChassisResourceCol, $_PartitionResourcesCol, $_ChassisManagerResourcesCol) + + [HPEOneView.Servers.RackManager]::new($_member.name, + $_member.serialNumber, + $_member.partNumber, + $_member.licensingIntent, + $_member.etag, + $_member.state, + $_member.status, + $_member.model, + $_member.location, + $_member.refreshState, + $_member.remoteSupportUri, + $_member.uri, + $_member.created, + $_member.modified, + $_SubResources, + $_member.ApplianceConnection) + + } + + } + + } + + } + + end + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Update-OVRackManager +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = 'Default')] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = 'Default')] + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = 'RefreshWithCredentials')] + [ValidateNotNullOrEmpty()] + [Alias ("name",'Server')] + [HPEOneView.Servers.RackManager[]]$InputObject, + + [Parameter (Mandatory, ParameterSetName = "RefreshWithCredentials")] + [String]$Hostname, + + [Parameter (Mandatory, ParameterSetName = "RefreshWithCredentials")] + [PSCredential]$Credential, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [Parameter (Mandatory = $false, ParameterSetName = 'RefreshWithCredentials')] + [Switch]$Force, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [Parameter (Mandatory = $false, ParameterSetName = 'RefreshWithCredentials')] + [Switch]$Async, + + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = 'Default')] + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = 'DefRefreshWithCredentialsault')] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not($PSBoundParameters['InputObject'])) + { + + "[{0}] Server object provided by pipeline." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $PipelineInput = $True + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + } + + Process + { + + "[{0}] Rackmanager: {1} ({2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject.Name, $InputObject.Uri | Write-Verbose + + "[{0}] Rackmanager State: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject.State | Write-Verbose + "[{0}] Rackmanager Status: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject.Status | Write-Verbose + + $_body = @{ + op = "RefreshRackManagerOp"; + isforce = $Force.IsPresent; + hostname = $null; + username = $null; + password = $null; + } + + if ($InputObject.State -ieq 'Unmanaged' -and $InputObject.refreshState -ieq 'RefreshFailed') + { + + if (-not $PSBoundParameters['Credential']) + { + + $ExceptionMessage = "The appliance can no longer communicate with '{0}' resource, and requires valid Credentials." -f $InputObject.name + $ErrorRecord = New-ErrorRecord HPEOneView.Library.UnsupportedArgumentException MissingRequiredUsernameParameter InvalidOperation 'Credential' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + if (-not $PSBoundParameters['Hostname']) + { + + $ExceptionMessage = "The appliance can no longer communicate with '{0}' resource, and requires a Hostname/IPAddress." -f $InputObject.name + $ErrorRecord = New-ErrorRecord HPEOneView.Library.UnsupportedArgumentException MissingRequiredHostnameParameter InvalidOperation 'Hostname' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + $_body.hostname = $Hostname + $_body.username = $Credential.Username + $_body.password = [Runtime.InteropServices.Marshal]::PtrToStringBSTR([Runtime.InteropServices.Marshal]::SecureStringToBSTR($Credential.Password)) + + } + + Try + { + + $_resp = Send-OVRequest -Uri $InputObject.Uri -Method PATCH -Body $_body -Hostname $InputObject.ApplianceConnection -AddHeader @{'If-Match' = $InputObject.ETag} + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if ($PSBoundParameters['Async']) + { + + $_resp + + } + + else + { + + $_resp | Wait-OVTaskComplete + + } + + } + + End + { + + '[{0}] Done.' -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Remove-OVRackManager +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (SupportsShouldProcess, ConfirmImpact = 'High')] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline)] + [ValidateNotNullOrEmpty()] + [Alias ("uri","name","Server")] + [HPEOneView.Servers.RackManager]$InputObject, + + [Parameter (Mandatory = $false)] + [Switch]$Force, + + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName)] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not($PSBoundParameters['InputObject'])) + { + + $PipelineInput = $True + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + } + + Process + { + + "[{0}] Processing RackManager: {1} ({2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject.Name, $InputObject.Uri | Write-Verbose + + $_RemoveMessage = "remove '{0}' rack manager resource" -f $InputObject.Name + + if ($PSCmdlet.ShouldProcess($InputObject.ApplianceConnection, $_RemoveMessage)) + { + + "[{0}] Removing rack manager resource '{1}' from appliance '{2}'." -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject.name, $InputObject.ApplianceConnection | Write-Verbose + + $_Uri = $InputObject.Uri.ToString() + + if ($PSboundParameters['Force']) + { + + $_Uri += "?force=true" + + } + + Try + { + + Send-OVRequest -Uri $_Uri -Method DELETE -AddHeader @{'If-Match' = $InputObject.eTag } -Hostname $InputObject.ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + elseif ($PSBoundParameters['WhatIf']) + { + + "[{0}] WhatIf Parameter was passed." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Update-OVServer +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = 'Default')] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = 'Default')] + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = 'RefreshWithCredentials')] + [ValidateNotNullOrEmpty()] + [Alias ("name",'Server')] + [object]$InputObject, + + [Parameter (Mandatory = $false, ParameterSetName = "RefreshWithCredentials")] + [String]$Hostname, + + [Parameter (Mandatory, ParameterSetName = "RefreshWithCredentials")] + [ValidateNotNullOrEmpty()] + [PSCredential]$Credential, + + [Parameter (Mandatory = $false, ParameterSetName = "RefreshWithCredentials")] + [Switch]$Force, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [Parameter (Mandatory = $false, ParameterSetName = 'RefreshWithCredentials')] + [Switch]$Async, + + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = 'Default')] + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = 'RefreshWithCredentials')] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not($PSBoundParameters['InputObject'])) + { + + "[{0}] Server object provided by pipeline." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $PipelineInput = $True + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + } + + Process + { + + # Validate input object type + # Checking if the input is System.String and is NOT a URI + if (($InputObject -is [String]) -and (-not($InputObject.StartsWith($ServerHardwareUri)))) + { + + "[{0}] Server is a Server Name: $($InputObject)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + "[{0}] Getting Server from Name" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $_InputObject = Get-OVServer -Name $InputObject -ErrorAction Stop -ApplianceConnection $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + # Checking if the input is System.String and IS a URI + elseif (($InputObject -is [String]) -and ($InputObject.StartsWith($ServerHardwareUri))) + { + + "[{0}] Server is a Server device URI: $($InputObject)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $_InputObject = Send-OVRequest -Uri $InputObject -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + # Checking if the input is PSCustomObject, and the category type is server-profiles, which could be passed via pipeline input + elseif (($InputObject -is [System.Management.Automation.PSCustomObject]) -and ($InputObject.category -ieq "server-hardware")) + { + + "[{0}] Server is a Server Device object: $($InputObject.name)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_InputObject = $InputObject.PSObject.Copy() + + } + + # Checking if the input is PSCustomObject, and the category type is server-hardware, which would be passed via pipeline input + elseif (($InputObject -is [System.Management.Automation.PSCustomObject]) -and ($InputObject.category -ieq $ResourceCategoryEnum.ServerProfile)) + { + + "[{0}] Server is a Server Profile object: $($InputObject.name)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + "[{0}] Getting server hardware device assigned to Server Profile." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($InputObject.serverHardwareUri)) + { + + $ExceptionMessage = "The Server Profile '{0}' is unassigned. This cmdlet only supports Server Profiles that are assigned to Server Hardware resources. Please check the input object and try again." -f $InputObject.name + $ErrorRecord = New-ErrorRecord InvalidOperationException ServerProfileUnassigned InvalidArgument 'InputObject' -TargetType $InputObject.GetType().Name -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Try + { + + $_InputObject = Send-OVRequest -Uri $InputObject.serverHardwareUri -Hostname $ApplianceConnection.Name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + else + { + + $ExceptionMessage = "The Parameter 'InputObject' value is invalid. Please validate the 'InputObject' Parameter value you passed and try again." + $ErrorRecord = New-ErrorRecord InvalidOperationException InvalidArgumentValue InvalidArgument 'InputObject' -TargetType $InputObject.GetType().Name -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + "[{0}] Refreshing Server Hardware device: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_InputObject.name | Write-Verbose + + $_uri = $_InputObject.uri + "/refreshState" + + $_body = @{ + + refreshState = 'RefreshPending' + + } + + if (($_InputObject.state -ieq 'Unmanaged' -and $_InputObject.stateReason -ieq 'Unconfigured') -or $Force) + { + + if (-not $PSBoundParameters['Credential']) + { + + $ExceptionMessage = "The appliance can no longer communicate with {0} server hardware, and requires valid Credentials." -f $_InputObject.name + $ErrorRecord = New-ErrorRecord HPEOneView.Library.UnsupportedArgumentException MissingRequiredUsernameParameter InvalidOperation 'Enclosure' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + if (-not $PSBoundParameters['Hostname']) + { + + "[{0}] Caller did not supply Hostname. Attempting to locate a valid address to use." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + [Object]$IPAddress = $null + + # Test for FQDN + if (([Regex]::Match($_InputObject.mpHostInfo.mpHostName, $FQDNRegex)).Success -or ([ipaddress]::TryParse($_InputObject.mpHostInfo.mpHostName, [ref]$IPAddress) -and $IPAddress.Address -ne "0.0.0.0")) + { + + "[{0}] Found valid FQDN or IP Address in mpHostName value." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $Hostname = $_InputObject.mpHostInfo.mpHostName + + } + + # First find the IPv4 Address and use if available + elseif ($IPAddress = $_InputObject.mpHostInfo.mpIpAddresses | ? { ([ipaddress]$_.address).AddressFamily.Equals([System.Net.Sockets.AddressFamily]::InterNetwork) -and $_.address -ne '0.0.0.0' }) + { + + "[{0}] Found valid IPv4 Address in mpIpAddresses collection." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + # Only get the IPv4 Address + $Hostname = $IPAddress.address + + } + + # if the appliance type is Composer, use the Link Local address? + elseif (($ConnectedSessions | ? ConnectionID -eq $ApplianceConnection.ConnectionID).ApplianceType -eq 'Composer') + { + + "[{0}] Synergy composer. Attempting to use IPv6 Link Local Address from mpIpAddresses collection." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $Hostname = ($_InputObject.mpHostInfo.mpIpAddresses | ? { $_.type -eq 'LinkLocal' -and ([ipaddress]$_.address).AddressFamily.Equals([System.Net.Sockets.AddressFamily]::InterNetworkv6) }).address + + } + + # try to use the IPv6 address found? + else + { + + "[{0}] Attempting to use first IPv6 non-Link Local Address from mpIpAddresses collection." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $Hostname = ($_InputObject.mpHostInfo.mpIpAddresses | ? { $_.type -ne 'LinkLocal' -and ([ipaddress]$_.address).AddressFamily.Equals([System.Net.Sockets.AddressFamily]::InterNetworkv6) } | Select -First 1).address + + } + + "[{0}] Will use hostname value: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Hostname | Write-Verbose + + } + + $_body.Add('hostname', $Hostname) + $_body.Add('username', $Credential.Username) + $_body.Add('password', [Runtime.InteropServices.Marshal]::PtrToStringBSTR([Runtime.InteropServices.Marshal]::SecureStringToBSTR($Credential.Password))) + + } + + Try + { + + $_resp = Send-OVRequest -Uri $_uri -Method PUT -Body $_body -Hostname $_InputObject.ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if ($PSBoundParameters['Async']) + { + + $_resp + + } + + else + { + + $_resp | Wait-OVTaskComplete + + } + + } + + End + { + + '[{0}] Done.' -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Update-OVServerHardwareLicenseIntent +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = 'Default')] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [Alias ("name",'Server')] + [Object]$InputObject, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [Switch]$Async, + + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not($PSBoundParameters['InputObject'])) + { + + "[{0}] Server object provided by pipeline." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $PipelineInput = $True + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + } + + Process + { + + # Validate input object type + # Checking if the input is System.String and is NOT a URI + if (($InputObject -is [String]) -and (-not($InputObject.StartsWith($ServerHardwareUri)))) + { + + "[{0}] Server is a Server Name: $($InputObject)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + "[{0}] Getting Server from Name" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $_InputObject = Get-OVServer -Name $InputObject -ErrorAction Stop -ApplianceConnection $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + # Checking if the input is System.String and IS a URI + elseif (($InputObject -is [String]) -and ($InputObject.StartsWith($ServerHardwareUri))) + { + + "[{0}] Server is a Server device URI: $($InputObject)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $_InputObject = Send-OVRequest -Uri $InputObject -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + # Checking if the input is PSCustomObject, and the category type is server-profiles, which could be passed via pipeline input + elseif (($InputObject -is [System.Management.Automation.PSCustomObject]) -and ($InputObject.category -ieq $ResourceCategoryEnum.ServerHardware)) + { + + "[{0}] Server is a Server Device object: $($InputObject.name)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_InputObject = $InputObject.PSObject.Copy() + + } + + # Checking if the input is PSCustomObject, and the category type is server-hardware, which would be passed via pipeline input + elseif (($InputObject -is [System.Management.Automation.PSCustomObject]) -and ($InputObject.category -ieq $ResourceCategoryEnum.ServerProfile)) + { + + "[{0}] Server is a Server Profile object: $($InputObject.name)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + "[{0}] Getting server hardware device assigned to Server Profile." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($InputObject.serverHardwareUri)) + { + + $ExceptionMessage = "The Server Profile '{0}' is unassigned. This cmdlet only supports Server Profiles that are assigned to Server Hardware resources. Please check the input object and try again." -f $InputObject.name + $ErrorRecord = New-ErrorRecord InvalidOperationException ServerProfileUnassigned InvalidArgument 'InputObject' -TargetType $InputObject.GetType().Name -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Try + { + + $_InputObject = Send-OVRequest -Uri $InputObject.serverHardwareUri -Hostname $ApplianceConnection.Name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + else + { + + $ExceptionMessage = "The Parameter 'InputObject' value is invalid. Please validate the 'InputObject' Parameter value you passed and try again." + $ErrorRecord = New-ErrorRecord InvalidOperationException InvalidArgumentValue InvalidArgument 'InputObject' -TargetType $InputObject.GetType().Name -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + # If server is not Managed, generate error + if ($_InputObject.state -eq "Monitored") + { + + $ExceptionMessage = "The provided server hardware resource {0} is a Monitored resource. This Cmdlet only supports Managed server hardware." -f $_InputObject.name + $ErrorRecord = New-ErrorRecord HPEOneView.ServerHardwareResourceException UnsupportedResourceState InvalidArgument 'InputObject' -TargetType $_InputObject.GetType().Name -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + "[{0}] Checking Server Hardware if it is licensed." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_Uri = "/rest/licenses?filter=nodeId EQ '{0}'" -f $_InputObject.uuid + + # The licensing intent of the server is changed, and if a license of the intended type is available, + # it is applied to the server. Once licensed, the only permitted change is an upgrade from "OneViewNoiLO" to "OneView". + # The server must be unlicensed and managed in order to be able to update the licensing intent. + # [ + # { "op": "replace", "path": "/licensingIntent", "value": "OneView"} + # ] + + + Try + { + + $_IsLicensed = Send-OVRequest -Uri $_uri -Hostname $_InputObject.ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + # server is already licensed. generate an error + if ($_IsLicensed.members[0].licenseType -ne 'Unlicensedproduct' -and + $_IsLicensed.members[0].product -eq 'HPE OneView Advanced') + { + + $ExceptionMessage = "The provided server hardware resource {0} is a Monitored resource. This Cmdlet only supports updating the license allocation policy (intent) from 'HPE OneView Advanced without iLO Advanced' to 'HPE OneView Advanced'." -f $_InputObject.name + $ErrorRecord = New-ErrorRecord HPEOneView.ServerHardwareResourceException UnsupportedLicenseStateChange InvalidOperation 'InputObject' -TargetType $_InputObject.GetType().Name -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + $_PatchOperation = NewObject -PatchOperation + + $_PatchOperation.op = "replace" + $_PatchOperation.path = "/licensingIntent" + $_PatchOperation.value = "OneView" + + $_uri = $_InputObject.uri + + Try + { + + $_resp = Send-OVRequest -Uri $_uri -Method PATCH -Body $_PatchOperation -Hostname $_InputObject.ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if ($PSBoundParameters['Async']) + { + + $_resp + + } + + else + { + + $_resp | Wait-OVTaskComplete + + } + + } + + End + { + + '[{0}] Done.' -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Get-OVMigratableServer +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = 'Default')] + Param + ( + + [Parameter (Mandatory, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [Object]$Hostname, + + [Parameter (Mandatory, ParameterSetName = 'Default')] + [PSCredential]$Credential, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + Process + { + + "[{0}] Processing '{1}' Appliance" -f $MyInvocation.InvocationName.ToString().ToUpper(), $ApplianceConnection | Write-Verbose + + $RemoteApplianceConnect = [ServerMigrationConnectApplianceCredentials]::New($Hostname, $Credential) + + Try + { + + $Resp = Send-OVRequest -Uri $MigratableServersUri -Method POST -Body $RemoteApplianceConnect -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + # Generate error no available migratable servers + if ($Resp.serverHardware.Count -eq 0) + { + + "[{0}] No migratable servers available from {1}." -f $MyInvocation.InvocationName.ToString().ToUpper(), $Hostname | Write-Verbose + + $ExceptionMessage = "The source appliance {0} has no migratable server hardware." -f $Hostname + $ErrorRecord = New-ErrorRecord HPEOneView.ServerHardwareResourceException MigratableServerResourceNotFound ObjectNotFound "Hostname" -Message $ExceptionMessage + $PSCmdlet.WriteError($ErrorRecord) + + } + + else + { + + ForEach ($MigratableServer in $Resp.serverHardware) + { + + "[{0}] Returning '{1}' ({2}) object." -f $MyInvocation.InvocationName.ToString().ToUpper(), $MigratableServer.name, $MigratableServer.uri | Write-Verbose + + [HPEOneView.Servers.MigratableServer]::new($MigratableServer.uri, + $MigratableServer.status, + $MigratableServer.name, + $MigratableServer.model, + $MigratableServer.serverProfileUri, + $MigratableServer.serverProfileStatus, + $MigratableServer.serverProfileName, + $MigratableServer.serverProfileDescription, + $Hostname) + + } + + } + + } + + End + { + + '[{0}] Done.' -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + +} + +function Invoke-OVMigrateServer +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = 'Default', SupportsShouldProcess, ConfirmImpact = 'High')] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [HPEOneView.Servers.MigratableServer[]]$InputObject, + + [Parameter (Mandatory, ParameterSetName = 'Default')] + [PSCredential]$Credential, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [Switch]$Async, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + if ($PSBoundParameters['InputObject']) + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + } + + Process + { + + "[{0}] Processing '{1}' Appliance" -f $MyInvocation.InvocationName.ToString().ToUpper(), $ApplianceConnection | Write-Verbose + + Write-Warning "Do not perform any operations on the migrating server hardware, server profile, or any referenced resources (networks, storage, firmware bundles, remote support configuration, etc.) while the migration is in progress." + + ForEach ($ServerToMigrate in $InputObject) + { + + $MigrateServer = [ServerMigration]::new($ServerToMigrate.Uri, $ServerToMigrate.ApplianceConnection, $Credential) + + $ShouldProcessMessage = "migrate from {0} to {1}" -f $Hostname, $ApplianceConnection + + if ($PSCmdlet.ShouldProcess($ServerToMigrate.name, $ShouldProcessMessage)) + { + + "[{0}] Sending request to {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $ShouldProcessMessage | Write-Verbose + + Try + { + + $_task = Send-OVRequest -Uri $ServerMigrationUri -Method POST -Body $MigrateServer -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if (-not $PSBoundParameters['Async']) + { + + $_task | Wait-OVTaskComplete + + } + + else + { + + $_task + + } + + } + + elseif ($PSBoundParameters['WhatIf']) + { + + "[{0}] User included -WhatIf." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + else + { + + "[{0}] User cancelled." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + } + + } + + End + { + + '[{0}] Done.' -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Get-OVEnclosureGroup +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding ()] + Param + ( + + [Parameter (Mandatory = $false)] + [ValidateNotNullorEmpty()] + [String]$Name, + + [Parameter (Mandatory = $false)] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default), + + [Parameter (Mandatory = $false)] + [Alias ("x", "export")] + [ValidateScript({split-path $_ | Test-Path})] + [String]$exportFile + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $EGCollection = [System.Collections.ArrayList]::new() + + } + + Process + { + + ForEach ($_appliance in $ApplianceConnection) + { + + # Display obselete message if the connection is a VM, not Synergy + [ObsoleteMessage]::Write($_appliance) + + "[{0}] Processing '{1}' Appliance (of {2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name, $ApplianceConnection.Count | Write-Verbose + + if ($PSboundParameters['name']) + { + + "[{0}] Enclosure Group name provided: '$name'" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $name = $name -replace ("[*]","%25") -replace ("[&]","%26") + + $uri = $enclosureGroupsUri + "?filter=name matches '$name'" + + } + + else + { + + "[{0}] No Enclosure Group name provided. Looking for all Enclosure Group resources." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $uri = $enclosureGroupsUri + + } + + Try + { + + $enclGrps = Send-OVRequest $uri -Hostname $_appliance + + } + + Catch + { + + "[{0}] API Error Caught: $($_.Exception.Message)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if ($enclGrps.count -eq 0 -and $name) + { + + "[{0}] Enclosure Group '$name' resource not found. Generating error" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $ExceptionMessage = "The specified Enclosure Group '{0}' was not found on '{1}'. Please check the name and try again." -f $Name, $_appliance.Name + $ErrorRecord = New-ErrorRecord InvalidOperationException EnclosureGroupNotFound ObjectNotFound 'Name' -Message $ExceptionMessage + $PSCmdlet.WriteError($ErrorRecord) + + } + + elseif ($enclGrps.count -eq 0) + { + + "[{0}] No Enclosure Group resources found." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + else + { + + "[{0}] Found $($enclGrps.count) Enclosure Group resources." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $enclGrps.members | ForEach-Object { + + $_.PSObject.TypeNames.Insert(0,'HPEOneView.EnclosureGroup') + + [void]$EGCollection.Add($_) + + } + + } + + } + + + } + + End + { + + "[{0}] Done. $($enclGrps.count) enclosure group(s) found." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if ($exportFile) + { + + $enclGrps.members | convertto-json -Depth 99 | Set-Content -Path $exportFile -force -encoding UTF8 + + } + + else + { + + Return $EGCollection + + } + + } + +} + +function New-OVEnclosureGroup +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = 'Default')] + Param + ( + + [Parameter (Mandatory, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [String]$Name, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateRange(1,5)] + [Int]$EnclosureCount = 1, + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [Alias ('logicalInterconnectGroupUri','logicalInterconnectGroup')] + [object]$LogicalInterconnectGroupMapping, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateSet ('RedundantPowerFeed','RedundantPowerSupply', IgnoreCase = $false)] + [String]$PowerRedundantMode = "RedundantPowerFeed", + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateSet ('AddressPool', 'DHCP', 'External')] + [String]$IPv4AddressType = 'DHCP', + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [Alias ('AddressPool')] + [ValidateNotNullOrEmpty()] + [Object]$IPv4AddressRange, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateSet ('AddressPool', 'DHCP', 'External')] + [String]$IPv6AddressType = 'DHCP', + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [Object]$IPv6AddressRange, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateSet ('None', 'Internal', 'External')] + [String]$DeploymentNetworkType = 'None', + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [object]$DeploymentNetwork, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = 'ImportFile')] + [HPEOneView.Appliance.ScopeCollection[]]$Scope, + + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = 'Default')] + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = 'ImportFile')] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default), + + [Parameter (Mandatory, ParameterSetName = "ImportFile")] + [ValidateNotNullOrEmpty()] + [Alias ("i", "import")] + [String]$ImportFile + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Resolved Parameter Set Name: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $PSCmdlet.ParameterSetName | Write-Verbose + + if (-not($PSBoundParameters['LogicalInterconnectGroupMapping'])) + { + + $PipelineInput = $true + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + $_EnclosureGroupCreateResults = [System.Collections.ArrayList]::new() + + } + + Process + { + + if ($PSCmdlet.ParameterSetName -eq 'importFile') + { + + $_EnclosureGroup = (Get-Content $ImportFile).ToString() + + "[{0}] Enclosure Group object: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_EnclosureGroup | Write-Verbose + + Try + { + + $resp = Send-OVRequest -Uri $enclosureGroupsUri -Method POST -Body $_EnclosureGroup -Hostname $ApplianceConnection.Name + + $resp.PSObject.TypeNames.Insert(0,'HPEOneView.EnclosureGroup') + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + else + { + + $_EnclosureGroup = NewObject -SynergyEnclosureGroup + $_EnclosureGroup.name = $Name + $_EnclosureGroup.powerMode = $PowerRedundantMode + + "[{0}] Processing Synergy LIG(s)." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_c = 0 + + # Explicit Mapping with Hashtable + if ($LogicalInterconnectGroupMapping -is [System.Collections.IEnumerable] -and $LogicalInterconnectGroupMapping -isnot [String]) + { + + # Loop through LIGs to build EG Interconnect Bay Mapping + foreach ($_FrameLig in $LogicalInterconnectGroupMapping.GetEnumerator()) + { + + if (($_FrameLig -is [System.Collections.IEnumerable] -and $_FrameLig -isnot [String] -and $_FrameLig -isnot [Array]) -or ($_FrameLig -is [System.Collections.DictionaryEntry])) + { + + $_FrameLigIndex = $_FrameLig.Key.ToLower().TrimStart('frameenclosure') + + $_FrameLig = $_FrameLig.Value + + '[{0}] Frame LIG Index ID: {1}' -f $MyInvocation.InvocationName.ToString().ToUpper(), $_FrameLigIndex | Write-Verbose + + } + + ForEach ($_LigEntry in $_FrameLig) + { + + '[{0}] Processing LIG: {1}' -f $MyInvocation.InvocationName.ToString().ToUpper(), $_LigEntry.name | Write-Verbose + + if (('sas-logical-interconnect-groups' -eq $_LigEntry.category) -or ('-1' -contains $_LigEntry.enclosureIndexes)) + { + + '[{0}] Frame LIG is either Natasha or Carbon, storing EnclosureIndexID from FrameLigIndex: {1}' -f $MyInvocation.InvocationName.ToString().ToUpper(), $_FrameLigIndex | Write-Verbose + + $_EnclosureIndexID = $_FrameLigIndex + + } + + else + { + + $_EnclosureIndexID = $null + + } + + if ('logical-interconnect-groups','sas-logical-interconnect-groups' -notcontains $_LigEntry.category) + { + + $Message = "The provided Logical Interconnect Group value for Bay {0} is not a valid Logical Interconnect Group Object {1}." -f $_LigEntry.Name, $_LigEntry.Value.category + $ErrorRecord = New-ErrorRecord InvalidOperationException InvalidLogicalInterconnectGroupCategory InvalidType 'LogicalInterconnectGroupMapping' -TargetType 'PSObject' -Message $Message + + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + if ($_LigEntry.enclosureType -NotMatch 'SY') + { + + $Message = "The provided Logical Interconnect Group {0} is modeled for the HPE BladeSystem C7000 enclosure type. Please provide a Synergy Logical Interconnect Grou presource, and try again." -f $_LigEntry.name + $ErrorRecord = New-ErrorRecord InvalidOperationException InvalidLogicalInterconnectGroupCategory InvalidType 'LogicalInterconnectGroupMapping' -TargetType 'PSObject' -Message $Message + + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + # Loop through InterconnectMapTemplate Entries + ForEach ($_InterconnectMapTemplate in $_LigEntry.interconnectMapTemplate.interconnectMapEntryTemplates) + { + + # Detect I3S setting in the Uplink Sets of the LIG + if (-not $_I3SSettingsFound) + { + + $_I3SSettingsFound = $_LigEntry.uplinkSets | Where-Object ethernetNetworkType -eq 'ImageStreamer' + + } + + $_InterconnectBayMapping = NewObject -InterconnectBayMapping + + $_InterconnectBayMapping.enclosureIndex = if (-not $_EnclosureIndexID) { $_InterconnectMapTemplate.enclosureIndex } else { $_EnclosureIndexID } + $_InterconnectBayMapping.interconnectBay = ($_InterconnectMapTemplate.logicalLocation.locationEntries | Where-Object type -eq 'Bay').relativeValue + $_InterconnectBayMapping.logicalInterconnectGroupUri = $_LigEntry.uri + + # If LIG is not present in the EG interconnectBayMapping + if ((Compare-Object $_EnclosureGroup.interconnectBayMappings -DifferenceObject $_InterconnectBayMapping -Property enclosureIndex,interconnectBay,logicalInterconnectGroupUri -IncludeEqual).SideIndicator -notcontains '==') + { + + '[{0}] Mapping Frame {1} Bay {2} -> {3} ({4})' -f $MyInvocation.InvocationName.ToString().ToUpper(), $_InterconnectBayMapping.enclosureIndex, $_InterconnectBayMapping.interconnectBay, $_LigEntry.Name, $_LigEntry.uri | Write-Verbose + + [void]$_EnclosureGroup.interconnectBayMappings.Add($_InterconnectBayMapping) + + $_c++ + + } + + } + + } + + } + + } + + elseif ($LogicalInterconnectGroupMapping -is [PSCustomObject] -and ('logical-interconnect-groups','sas-logical-interconnect-groups' -contains $LogicalInterconnectGroupMapping.category)) + { + + if ($LogicalInterconnectGroupMapping.enclosureType -NotMatch 'SY') + { + + $Message = "The provided Logical Interconnect Group {0} is modeled for the HPE BladeSystem C7000 enclosure type. Please provide a Synergy Logical Interconnect Group resource, and try again." -f $LogicalInterconnectGroupMapping.name + $ErrorRecord = New-ErrorRecord InvalidOperationException InvalidLogicalInterconnectGroupCategory InvalidType 'LogicalInterconnectGroupMapping' -TargetType 'PSObject' -Message $Message + + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + # Detect I3S setting in the Uplink Sets of the LIG + $_I3SSettingsFound = $LogicalInterconnectGroupMapping.uplinkSets | Where-Object ethernetNetworkType -eq 'ImageStreamer' + + ForEach ($_InterconnectMapEntry in $LogicalInterconnectGroupMapping.interconnectMapTemplate.interconnectMapEntryTemplates) + { + + ForEach ($_LocationEntry in ($_InterconnectMapEntry.logicalLocation.locationEntries | Where-Object type -eq 'Bay')) + { + + if (-not($_EnclosureGroup.interconnectBayMappings | Where-Object interconnectBay -eq $_LocationEntry.relativeValue)) + { + + $_InterconnectBayMapping = NewOBject -InterconnectBayMapping + + $_InterconnectBayMapping.interconnectBay = ($_LocationEntry | Where-Object type -eq 'bay').relativeValue + $_InterconnectBayMapping.logicalInterconnectGroupUri = $LogicalInterconnectGroupMapping.uri + + $_InterconnectBayMapping = $_InterconnectBayMapping | Select-Object * -ExcludeProperty enclosureIndex + + '[{0}] Mapping Interconnect Bay to LIG URI {1} --> {2}' -f $MyInvocation.InvocationName.ToString().ToUpper(), ($_LocationEntry | Where-Object type -eq 'bay').relativeValue, $LogicalInterconnectGroupMapping.uri | Write-Verbose + + "[{0}] Interconnect Bay Mapping Entry found in LIG resource: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_LocationEntry | Write-Verbose + + [void]$_EnclosureGroup.interconnectBayMappings.Add($_InterconnectBayMapping) + + } + + $_c++ + + } + + } + + } + + else + { + + '[{0}] Invalid LIG Category value provided: {1}' -f $MyInvocation.InvocationName.ToString().ToUpper(), ($LogicalInterconnectGroupMapping | Out-String) | Write-Verbose + + $Message = "Invalid LogicalInterconnectGroupMapping value provided '{0}'. Please check the value and try again." -f ($LogicalInterconnectGroupMapping ) + $ErrorRecord = New-ErrorRecord InvalidOperationException InvalidLogicalInterconnectGroupCategory InvalidType 'LogicalInterconnectGroupMapping' -TargetType $LogicalInterconnectGroupMapping.GetType().Fullname -Message $Message + + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + if (-not($PSBoundParameters['EnclosureCount'])) + { + + if ($LogicalInterconnectGroupMapping -is [System.Collections.IEnumerable]) + { + + $_EnclosureGroup.enclosureCount = $LogicalInterconnectGroupMapping.Count + + } + + else + { + + $_EnclosureGroup.enclosureCount = $LogicalInterconnectGroupMapping.enclosureIndexes.Count + + } + + } + + else + { + + $_EnclosureGroup.enclosureCount = $EnclosureCount + + } + + $_DeploymentSettings = NewObject -EnclosureGroupI3SDeploymentSettings + $_DeploymentSettings.deploymentMode = $DeploymentNetworkType + + $_EnclosureGroup.osDeploymentSettings = NewObject -DeploymentModeSettings + + if ($DeploymentNetworkType -eq 'None' -and $_I3SSettingsFound) + { + + $Message = "The provided LogicalInterconnectGroupMapping Parameter contains 1 or more LIGs with an ImageStreamer Uplink Set configured, but no DeploymentNetwork or DeploymentNetworkType Parameter were provided. You must specify a DeploymentNetwork and DeploymentNetworkType cannot be 'none'." + $ErrorRecord = New-ErrorRecord HPEOneView.NetworkResourceException InvalidDeploymentNetworkSettings InvalidArgument 'DeploymentNetworkType' -TargetType 'PSObject' -Message $message + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($DeploymentNetworkType -ne 'None') + { + + $_EnclosureGroup.osDeploymentSettings.manageOSDeployment = $true + + if ($DeploymentNetworkType -eq 'External') + { + + if (-not $DeploymentNetwork) + { + + '[{0}] DeploymentNetworkType is set to "External", but no DeploymentNetwork value.' -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $Message = "The DeploymentNetworkType was set to 'External', which requires the DeploymentNetwork parameter." + $ErrorRecord = New-ErrorRecord InvalidOperationException NullDeploymentNetwork InvalidArgument 'DeploymentNetworkType' -TargetType 'SwitchParameter' -Message $Message + + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + switch ($DeploymentNetwork.GetType()) + { + + 'PSCustomObject' + { + + if ($DeploymentNetworkType.category -ne 'ethernet-networks') + { + + $ErrorRecord = New-ErrorRecord HPEOneView.NetworkResourceException InvalidEthernetNetworkResource InvalidArgument 'DeploymentNetworkType' -TargetType 'PSObject' -Message "The provided Deployment Network resource object is not an Ethernet Network. Please validate the Parameter value and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + if ($DeploymentNetworkType.ethernetNetworkType -ne 'Tagged') + { + + $ErrorRecord = New-ErrorRecord HPEOneView.NetworkResourceException InvalidEthernetNetworkResource InvalidArgument 'DeploymentNetworkType' -TargetType 'PSObject' -Message "The provided Deployment Network resource object is not a 'Tagged' Ethernet Network. Please validate the Parameter value and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + 'String' + { + + Try + { + + $DeploymentNetwork = Get-OVNetwork -Name $DeploymentNetwork -ApplianceConnection $ApplianceConnection -ErrorAction Stop + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if ($DeploymentNetwork.ethernetNetworkType -ne 'Tagged') + { + + + $ErrorRecord = New-ErrorRecord HPEOneView.NetworkResourceException InvalidEthernetNetworkResource InvalidArgument 'DeploymentNetwork' -Message "The provided Deployment Network resource object is not a 'Tagged' Ethernet Network. Please validate the Parameter value and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + } + + $_DeploymentSettings.deploymentNetworkUri = $DeploymentNetwork.uri + + } + + } + + $_EnclosureGroup.osDeploymentSettings.deploymentModeSettings = $_DeploymentSettings + + $_EnclosureGroup.ipAddressingMode = $EnclosureGroupIpAddressModeEnum[$IPv4AddressType] + $_EnclosureGroup.ipv6AddressingMode = $EnclosureGroupIpAddressModeEnum[$IPv6AddressType] + + foreach ($_IPv4Range in $IPv4AddressRange) + { + + "[{0}] IPv4 address range: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_IPv4Range.Name | Write-Verbose + + if ($ResourceCategoryEnum.IPv4Range -ne $_IPv4Range.category) + { + + $ExceptionMessage = "An invalid Address Pool object was provided. Please check the value and try again." + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AddressPoolResourceException InvalidAddressPoolResource InvalidArgument 'AddressPool' -TargetType 'PSObject' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + [void]$_EnclosureGroup.ipRangeUris.Add($_IPv4Range.uri) + + } + + foreach ($_IPv6Range in $IPv6AddressRange) + { + + "[{0}] IPv6 address range: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_IPv6Range.Name | Write-Verbose + + if ($ResourceCategoryEnum.IPv6Range -ne $_IPv6Range.category) + { + + $ExceptionMessage = "An invalid Address Pool object was provided. Please check the value and try again." + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AddressPoolResourceException InvalidAddressPoolResource InvalidArgument 'AddressPool' -TargetType 'PSObject' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + [void]$_EnclosureGroup.ipv6RangeUris.Add($_IPv6Range.uri) + + } + + "[{0}] Creating '{1}' Enclosure Group" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_EnclosureGroup.name | Write-Verbose + + Try + { + + $resp = Send-OVRequest -Uri $EnclosureGroupsUri -Method POST -Body $_EnclosureGroup -Hostname $ApplianceConnection.Name + + $resp.PSObject.TypeNames.Insert(0,'HPEOneView.EnclosureGroup') + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + [void]$_EnclosureGroupCreateResults.Add($resp) + + } + + End + { + + return $_EnclosureGroupCreateResults + + } + +} + +function Set-OVEnclosureGroup +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = 'Default')] + param + ( + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = 'Default')] + [Alias('EnclosureGroup')] + [Object]$InputObject, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [String]$Name, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [Alias ('LogicalInterconnectGroupUri','LogicalInterconnectGroup')] + [object]$LogicalInterconnectGroupMapping, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateSet ('RedundantPowerFeed','RedundantPowerSupply', IgnoreCase = $false)] + [String]$PowerRedundantMode = "RedundantPowerFeed", + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateSet ('AddressPool', 'DHCP', 'External')] + [String]$IPv4AddressType, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [object]$IPv4AddressRange, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateSet ('AddressPool', 'DHCP', 'External')] + [String]$IPv6AddressType, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [object]$IPv6AddressRange, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateSet ('None', 'Internal', 'External')] + [String]$DeploymentNetworkType, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [object]$DeploymentNetwork, + + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = ($ConnectedSessions | Where-Object Default) + + ) + + Begin + { + + "[{0}] Bound PS Parameters: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(),($PSBoundParameters | out-string) | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not($PSBoundParameters['InputObject'])) + { + + $Pipelineinput = $True + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not($ConnectedSessions)) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command agian." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -gt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + } + + Process + { + + # Validate appliance type is supported + [ObsoleteMessage]::Write($ApplianceConnection) + + # Validate InputObject + if ($InputObject.category -ne $ResourceCategoryEnum['EnclosureGroup']) + { + + $ExceptionMessage = "The provided -InputObject value is not an {0} resource. Please correct the input object and try again." -f $ResourceCategoryEnum['EnclosureGroup'] + $ErrorRecord = New-ErrorRecord HPEOneView.InputObjectResourceException InvalidResourceObject InvalidArgument 'InputObject' -TargetType 'PSObject' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + $_EnclosureGroupToUpdate = $null + + try + { + + $_EnclosureGroupToUpdate = $InputObject.PSObject.Copy() + + } + + catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + # Determine operations that need to be performed + switch ($PSBoundParameters.Keys) + { + + 'Name' + { + + "[{0}] Updating Name." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_EnclosureGroupToUpdate.name = $Name + + } + + 'PowerRedundantMode' + { + + "[{0}] Updating PowerRedundantMode." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_EnclosureGroupToUpdate.powerMode = $PowerRedundantMode + + } + + 'LogicalInterconnectGroupMapping' + { + + "[{0}] Updating PowerRedunLogicalInterconnectGroupMappingdantMode." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + foreach ($_FrameLig in $LogicalInterconnectGroupMapping.GetEnumerator()) + { + + if (($_FrameLig -is [System.Collections.IEnumerable] -and $_FrameLig -isnot [String] -and $_FrameLig -isnot [Array]) -or ($_FrameLig -is [System.Collections.DictionaryEntry])) + { + + $_FrameLigIndex = $_FrameLig.Key.ToLower().TrimStart('frameenclosure') + + $_FrameLig = $_FrameLig.Value + + '[{0}] Frame LIG Index ID: {1}' -f $MyInvocation.InvocationName.ToString().ToUpper(), $_FrameLigIndex | Write-Verbose + + } + + ForEach ($_LigEntry in $_FrameLig) + { + + '[{0}] Processing LIG: {1}' -f $MyInvocation.InvocationName.ToString().ToUpper(), $_LigEntry.name | Write-Verbose + + if (('sas-logical-interconnect-groups' -eq $_LigEntry.category) -or ('-1' -contains $_LigEntry.enclosureIndexes)) + { + + '[{0}] Frame LIG is either Natasha or Carbon, storing EnclosureIndexID from FrameLigIndex: {1}' -f $MyInvocation.InvocationName.ToString().ToUpper(), $_FrameLigIndex | Write-Verbose + + $_EnclosureIndexID = $_FrameLigIndex + + } + + else + { + + $_EnclosureIndexID = $null + + } + + if ('logical-interconnect-groups','sas-logical-interconnect-groups' -notcontains $_LigEntry.category) + { + + $Message = "The provided Logical Interconnect Group value for Bay {0} is not a valid Logical Interconnect Group Object {1}." -f $_LigEntry.Name, $_LigEntry.Value.category + $ErrorRecord = New-ErrorRecord InvalidOperationException InvalidLogicalInterconnectGroupCategory InvalidType 'LogicalInterconnectGroupMapping' -TargetType 'PSObject' -Message $Message + + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + if ($_LigEntry.enclosureType -NotMatch 'SY') + { + + $Message = "The provided Logical Interconnect Group {0} is modeled for the HPE BladeSystem C7000 enclosure type. Please provide a Synergy Logical Interconnect Grou presource, and try again." -f $_LigEntry.name + $ErrorRecord = New-ErrorRecord InvalidOperationException InvalidLogicalInterconnectGroupCategory InvalidType 'LogicalInterconnectGroupMapping' -TargetType 'PSObject' -Message $Message + + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + # Loop through InterconnectMapTemplate Entries + ForEach ($_InterconnectMapTemplate in $_LigEntry.interconnectMapTemplate.interconnectMapEntryTemplates) + { + + # Detect I3S setting in the Uplink Sets of the LIG + if (-not $_I3SSettingsFound) + { + + $_I3SSettingsFound = $_LigEntry.uplinkSets | Where-Object ethernetNetworkType -eq 'ImageStreamer' + + } + + $_InterconnectBayMapping = NewObject -InterconnectBayMapping + + $_InterconnectBayMapping.enclosureIndex = if (-not $_EnclosureIndexID) { $_InterconnectMapTemplate.enclosureIndex } else { $_EnclosureIndexID } + $_InterconnectBayMapping.interconnectBay = ($_InterconnectMapTemplate.logicalLocation.locationEntries | Where-Object type -eq 'Bay').relativeValue + $_InterconnectBayMapping.logicalInterconnectGroupUri = $_LigEntry.uri + + # If LIG is not present in the EG interconnectBayMapping + if ((Compare-Object $_EnclosureGroup.interconnectBayMappings -DifferenceObject $_InterconnectBayMapping -Property enclosureIndex,interconnectBay,logicalInterconnectGroupUri -IncludeEqual).SideIndicator -notcontains '==') + { + + '[{0}] Mapping Frame {1} Bay {2} -> {3} ({4})' -f $MyInvocation.InvocationName.ToString().ToUpper(), $_InterconnectBayMapping.enclosureIndex, $_InterconnectBayMapping.interconnectBay, $_LigEntry.Name, $_LigEntry.uri | Write-Verbose + + [void]$_EnclosureGroup.interconnectBayMappings.Add($_InterconnectBayMapping) + + $_c++ + + } + + } + + } + + } + + } + + 'IPv4AddressType' + { + + "[{0}] IPv4 address type: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $EnclosureGroupIpAddressModeEnum[$IPv4AddressType] | Write-Verbose + + $_EnclosureGroupToUpdate.ipAddressingMode = $EnclosureGroupIpAddressModeEnum[$IPv4AddressType] + + if ($PSBoundParameters['IPv4AddressRange']) + { + + $UpdatedIPv4AddressRanges = [System.Collections.ArrayList]::new() + + foreach ($_IPv4Range in $IPv4AddressRange) + { + + "[{0}] IPv4 address range: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_IPv4Range.Name | Write-Verbose + + if ($ResourceCategoryEnum.IPv4Range -ne $_IPv4Range.category) + { + + $ExceptionMessage = "An invalid IPv4 Address Pool Range object was provided. Please check the value and try again." + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AddressPoolResourceException InvalidAddressPoolResource InvalidArgument 'IPv4AddressRange' -TargetType 'PSObject' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + if ($_EnclosureGroupToUpdate.ipv4RangeUris -notcontains $_IPv4Range.uri) + { + + "[{0}] IPv4 address range not within the existing collection. Adding." -f $MyInvocation.InvocationName.ToString().ToUpper()| Write-Verbose + + [void]$UpdatedIPv4AddressRanges.Add($_IPv4Range.ur) + + } + + else + { + + "[{0}] IPv4 address range is already within the existing collection." -f $MyInvocation.InvocationName.ToString().ToUpper()| Write-Verbose + + } + + } + + $_EnclosureGroupToUpdate.ipv4RangeUris = $UpdatedIPv4AddressRanges + + } + + } + + 'IPv6AddressType' + { + + "[{0}] IPv6 address type: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $EnclosureGroupIpAddressModeEnum[$IPv6AddressType] | Write-Verbose + + $_EnclosureGroupToUpdate.ipv6AddressingMode = $EnclosureGroupIpAddressModeEnum[$IPv6AddressType] + + if ($PSBoundParameters['IPv6AddressRange']) + { + + $UpdatedIPv6AddressRanges = [System.Collections.ArrayList]::new() + + foreach ($_IPv6Range in $IPv6AddressRange) + { + + "[{0}] IPv6 address range: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_IPv6Range.Name | Write-Verbose + + if ($ResourceCategoryEnum.IPv6Range -ne $_IPv6Range.category) + { + + $ExceptionMessage = "An invalid Address Pool object was provided. Please check the value and try again." + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AddressPoolResourceException InvalidAddressPoolResource InvalidArgument 'IPv6AddressRange' -TargetType 'PSObject' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + if ($_EnclosureGroupToUpdate.ipv6RangeUris -notcontains $_IPv6Range.uri) + { + + "[{0}] IPv6 address range not within the existing collection. Adding." -f $MyInvocation.InvocationName.ToString().ToUpper()| Write-Verbose + + [void]$UpdatedIPv6AddressRanges.Add($_IPv6Range.ur) + + } + + else + { + + "[{0}] IPv6 address range is already within the existing collection." -f $MyInvocation.InvocationName.ToString().ToUpper()| Write-Verbose + + } + + } + + $_EnclosureGroupToUpdate.ipv6RangeUris = $UpdatedIPv6AddressRanges + + } + + } + + 'DeploymentNetworkType' + { + + $_EnclosureGroupToUpdate.osDeploymentSettings.deploymentMode = $DeploymentNetworkType + + if ($DeploymentNetworkType -ne 'None') + { + + $_EnclosureGroupToUpdate.osDeploymentSettings.manageOSDeployment = $true + + if ($DeploymentNetworkType -eq 'External') + { + + if (-not $DeploymentNetwork) + { + + '[{0}] DeploymentNetworkType is set to "External", but no DeploymentNetwork value.' -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $Message = "The DeploymentNetworkType was set to 'External', which requires the DeploymentNetwork parameter." + $ErrorRecord = New-ErrorRecord InvalidOperationException NullDeploymentNetwork InvalidArgument 'DeploymentNetworkType' -TargetType 'SwitchParameter' -Message $Message + + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + switch ($DeploymentNetwork.GetType()) + { + + 'PSCustomObject' + { + + if ($DeploymentNetworkType.category -ne 'ethernet-networks') + { + + $ErrorRecord = New-ErrorRecord HPEOneView.NetworkResourceException InvalidEthernetNetworkResource InvalidArgument 'DeploymentNetworkType' -TargetType 'PSObject' -Message "The provided Deployment Network resource object is not an Ethernet Network. Please validate the Parameter value and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + if ($DeploymentNetworkType.ethernetNetworkType -ne 'Tagged') + { + + $ErrorRecord = New-ErrorRecord HPEOneView.NetworkResourceException InvalidEthernetNetworkResource InvalidArgument 'DeploymentNetworkType' -TargetType 'PSObject' -Message "The provided Deployment Network resource object is not a 'Tagged' Ethernet Network. Please validate the Parameter value and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + 'String' + { + + Try + { + + $DeploymentNetwork = Get-OVNetwork -Name $DeploymentNetwork -ApplianceConnection $ApplianceConnection -ErrorAction Stop + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if ($DeploymentNetwork.ethernetNetworkType -ne 'Tagged') + { + + + $ErrorRecord = New-ErrorRecord HPEOneView.NetworkResourceException InvalidEthernetNetworkResource InvalidArgument 'DeploymentNetwork' -Message "The provided Deployment Network resource object is not a 'Tagged' Ethernet Network. Please validate the Parameter value and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + } + + $_EnclosureGroup.osDeploymentSettings.deploymentModeSettings.deploymentNetworkUri = $DeploymentNetwork.uri + + } + + } + + if ($DeploymentNetworkType -eq 'None') + { + + $_EnclosureGroupToUpdate.osDeploymentSettings.manageOSDeployment = $false + + } + + } + + } + + "[{0}] Updating enclosure group configuration." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + try + { + + Send-OVRequest -Uri $_EnclosureGroupToUpdate.Uri -Method PUT -Body $_EnclosureGroupToUpdate -Hostname $InputObject.ApplianceConnection + + } + + catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + end + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Remove-OVEnclosureGroup +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "default",SupportsShouldProcess,ConfirmImpact = 'High')] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = "default")] + [ValidateNotNullOrEmpty()] + [Alias ("uri", "name", "EnclosureGroup",'Resource')] + [object]$InputObject, + + [Parameter (ValueFromPipelineByPropertyName, Mandatory = $false, ParameterSetName = "default")] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default), + + [Parameter (Mandatory = $false, ParameterSetName = "default")] + [Switch]$Force + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not($PSBoundParameters['Enclosure'])) + { + + $PipelineInput = $True + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + $_TaskCollection = [System.Collections.ArrayList]::new() + $_EnclosureGroupCollection = [System.Collections.ArrayList]::new() + + } + + Process + { + + if ($ApplianceConnection.Count -eq 0) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoAuthSessionFound InvalidArgument 'ApplianceConnection' -Message 'No ApplianceConnections were found. Please use Connect-OVMgmt to establish an appliance connection.' + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + if ($PipelineInput) + { + + "[{0}] Processing Pipeline input" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + "[{0}] Enclosure Group Object provided: {1} ({2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject.name, $InputObject.uri | Write-Verbose + + If ($InputObject.category -eq $ResourceCategoryEnum.EnclosureGroup) + { + + If (-not($InputObject.ApplianceConnection)) + { + + $ErrorRecord = New-ErrorRecord InvalidOperationException InvalidArgumentValue InvalidArgument 'InputObject' -TargetType PSObject -Message "The Enclosure Group resource provided is missing the source ApplianceConnection property. Please check the object provided and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + [void]$_EnclosureGroupCollection.Add($InputObject) + + } + + else + { + + $ErrorRecord = New-ErrorRecord InvalidOperationException InvalidArgumentValue InvalidArgument 'InputObject' -TargetType PSObject -Message "The Enclosure Group resource is not an expected category type [$($InputObject.category)]. Allowed resource category type is 'enclosure-groups'. Please check the object provided and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + else + { + + foreach ($enclosuregroup in $InputObject) + { + + # Enclosure passed is a URI + if (($enclosuregroup -is [String]) -and [System.Uri]::IsWellFormedUriString($enclosure,'Relative')) + { + + "[{0}] Received URI: $($enclosuregroup)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + "[{0}] Getting Enclosure Group Object" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + # // NEED APPLIANCE NAME HERE with If Condition + Try + { + + $enclosuregroup = Send-OVRequest -Uri $enclosuregroup -ApplianceConnection $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + # Enclosure passed is the Name + elseif (($enclosuregroup -is [String]) -and (-not($enclosuregroup.startsWith("/rest")))) + { + + "[{0}] Received Enclosure Group Name $($enclosuregroup)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + "[{0}] Getting Enclosure Group object from Get-OVEnclosureGroup" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + # // NEED APPLIANCE NAME HERE with If Condition + Try + { + + $enclosuregroup = Get-OVEnclosureGroup -Name $enclosuregroup -ErrorAction Stop -ApplianceConnection $ApplianceConnection + + } + + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + # Enclosure passed is an object + elseif ($enclosuregroup -is [PSCustomObject] -and ($enclosuregroup.category -ieq 'enclosure-groups')) + { + + "[{0}] Enclosure Group Object provided: $($enclosuregroup )" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + else + { + + $ErrorRecord = New-ErrorRecord InvalidOperationException InvalidArgumentValue InvalidArgument 'Resource' -TargetType 'PSObject' -Message "Invalid Resource Parameter: $($enclosuregroup )" + $PSCmdlet.WriteError($ErrorRecord) + + } + + [void]$_EnclosureGroupCollection.Add($enclosuregroup) + + } + + } + + } + + End + { + + "[{0}] Processing $($_EnclosureGroupCollection.count) Enclosure Group resources to remove." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + # Process Enclosure Resources + ForEach ($_enclosuregroup in $_EnclosureGroupCollection) + { + + # Display obselete message if the connection is a VM, not Synergy + [ObsoleteMessage]::Write($_enclosuregroup.ApplianceConnection) + + if ($PSCmdlet.ShouldProcess($_enclosuregroup.name,"Remove Enclosure Group from appliance '$($_enclosuregroup.ApplianceConnection)'?")) + { + + "[{0}] Removing Enclosure Group '$($_enclosuregroup.name)' from appliance '$($_enclosuregroup.ApplianceConnection)'." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + if ($PSBoundParameters['Force']) + { + + $_enclosuregroup.uri += "?force=true" + + } + + $_resp = Send-OVRequest -Uri $_enclosuregroup.Uri -Method DELETE -AddHeader @{'If-Match' = $_enclosuregroup.eTag } -Hostname $_enclosuregroup.ApplianceConnection + + [void]$_TaskCollection.Add($_resp) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + elseif ($PSBoundParameters['WhatIf']) + { + + "[{0}] WhatIf Parameter was passed." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + } + + Return $_TaskCollection + + } + +} + +function Add-OVEnclosure +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "Managed", SupportsShouldProcess, ConfirmImpact = "High")] + Param + ( + + [Parameter (Mandatory, ParameterSetName = "Monitored")] + [Parameter (Mandatory, ParameterSetName = "Managed")] + [Parameter (Mandatory, ParameterSetName = "MonitoredCredential")] + [Parameter (Mandatory, ParameterSetName = "ManagedCredential")] + [ValidateNotNullOrEmpty()] + [Alias ("oa")] + [String]$Hostname, + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = "Managed")] + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = "ManagedCredential")] + [ValidateNotNullOrEmpty()] + [Alias ("eg",'EnclGroupName')] + [object]$EnclosureGroup, + + [Parameter (Mandatory, ParameterSetName = "Monitored")] + [Parameter (Mandatory, ParameterSetName = "Managed")] + [Obsolete()] + [ValidateNotNullOrEmpty()] + [Alias ("u", "user")] + [String]$Username, + + [Parameter (Mandatory, ParameterSetName = "Monitored")] + [Parameter (Mandatory, ParameterSetName = "Managed")] + [Obsolete()] + [ValidateNotNullOrEmpty()] + [Alias ("p", "pw")] + [Object]$Password, + + [Parameter (Mandatory, ParameterSetName = "MonitoredCredential")] + [Parameter (Mandatory, ParameterSetName = "ManagedCredential")] + [PSCredential]$Credential, + + [Parameter (Mandatory = $false, ParameterSetName = "Managed")] + [Parameter (Mandatory = $false, ParameterSetName = "ManagedCredential")] + [ValidateSet ('OneView', 'OneViewNoiLO', IgnoreCase = $False)] + [Alias ("license", "l")] + [String]$LicensingIntent = 'OneView', + + [Parameter (Mandatory = $false, ParameterSetName = "Managed")] + [Parameter (Mandatory = $false, ParameterSetName = "ManagedCredential")] + [Alias ("fwIso","fwBaselineIsoFilename")] + [object]$Baseline, + + [Parameter (Mandatory = $false, ParameterSetName = "Managed")] + [Parameter (Mandatory = $false, ParameterSetName = "ManagedCredential")] + [Alias ('forceFw','forceInstall')] + [Switch]$ForceInstallFirmware, + + [Parameter (Mandatory, ParameterSetName = "Monitored")] + [Parameter (Mandatory, ParameterSetName = "MonitoredCredential")] + [Switch]$Monitored, + + [Parameter (Mandatory = $false, ParameterSetName = "Monitored")] + [Parameter (Mandatory = $false, ParameterSetName = "Managed")] + [Parameter (Mandatory = $false, ParameterSetName = "MonitoredCredential")] + [Parameter (Mandatory = $false, ParameterSetName = "ManagedCredential")] + [ValidateNotNullOrEmpty()] + [HPEOneView.Appliance.ScopeCollection[]]$Scope, + + [Parameter (Mandatory = $False, ParameterSetName = "Monitored")] + [Parameter (Mandatory = $False, ParameterSetName = "Managed")] + [Parameter (Mandatory = $False, ParameterSetName = "MonitoredCredential")] + [Parameter (Mandatory = $False, ParameterSetName = "ManagedCredential")] + [Switch]$Async, + + [Parameter (Mandatory = $False, ParameterSetName = "Monitored")] + [Parameter (Mandatory = $False, ParameterSetName = "Managed")] + [Parameter (Mandatory = $False, ParameterSetName = "MonitoredCredential")] + [Parameter (Mandatory = $False, ParameterSetName = "ManagedCredential")] + [ValidateNotNullorEmpty()] + [object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not($PSBoundParameters['EnclosureGroup']) -and ($PSCmdlet.ParameterSetName -ne 'Monitored')) + { + + $PipelineInput = $True + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection -is [HPEOneView.Appliance.Connection]) -and (-not($ApplianceConnection -is [System.String]))) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException InvalidApplianceConnectionDataType InvalidArgument 'ApplianceConnection' -Message 'The specified ApplianceConnection Parameter is not type [HPEOneView.Appliance.Connection] or [System.String]. Please correct this value and try again.' + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection.Count -gt 1) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException MultipleApplianceConnections InvalidArgument 'ApplianceConnection' -Message 'The specified ApplianceConnection Parameter contains multiple Appliance Connections. This CMDLET only supports 1 Appliance Connection in the ApplianceConnect Parameter value. Please correct this and try again.' + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -TargetType $ApplianceConnection.GetType().Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + $colStatus = [System.Collections.ArrayList]::new() + + if ($PSBoundParameters['Credential']) + { + + $_Username = $Credential.Username + $_Password = [Runtime.InteropServices.Marshal]::PtrToStringBSTR([Runtime.InteropServices.Marshal]::SecureStringToBSTR($Credential.Password)) + + } + + elseif ($PSBoundParameters['Username']) + { + + Write-Warning "The -Username and -Password parameters are being deprecated. Please transition your scripts to using the -Credential parameter." + + $_Username = $Username.clone() + + if ($Password -is [SecureString]) + { + + $_Password = [Runtime.InteropServices.Marshal]::PtrToStringBSTR([Runtime.InteropServices.Marshal]::SecureStringToBSTR($Password)) + + } + + else + { + + $_Password = $Password.Clone() + + } + + } + + elseif (-not $PSBoundParameters['Credential'] -and -not $PSBoundParameters['Username']) + { + + $ExceptionMessage = "This Cmdlet requires credentials to the target resource. Please provide either the -Username and -Password, or -Credential parameters." + $ErrorRecord = New-ErrorRecord HPEOneView.Library.UnsupportedArgumentException MissingRequiredPasswordParameter InvalidOperation 'Authentication' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + Process + { + + # Build the import object + "[{0}] - Starting" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_import = NewObject -EnclosureImport + $_import.hostname = $hostname + $_import.username = $_Username + $_import.password = $_Password + + if ($PSBoundParameters['Scope']) + { + + ForEach ($_Scope in $Scope) + { + + "[{0}] Adding resource to Scope: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_Scope.Name | Write-Verbose + + [void]$_import.initialScopeUris.Add($_Scope.Uri) + + } + + } + + If ('MonitoredCredential', 'Monitored' -contains $PSCmdlet.ParameterSetName) + { + + "[{0}] - Building Monitored Enclosure request" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_import.licensingIntent = "OneViewStandard" + $_import.state = "Monitored" + + } + + else + { + + "[{0}] - Building Managed Enclosure request" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + switch ($EnclosureGroup.GetType().Name) + { + + 'PSCustomObject' + { + + "[{0}] - EnclosureGroup Parameter is 'PSCustomObject'" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + "[{0}] - EnclosureGroup object category: '$($EnclosureGroup.category)'" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + "[{0}] - EnclosureGroup object name: '$($EnclosureGroup.name)'" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if ($EnclosureGroup.category -ne $ResourceCategoryEnum['EnclosureGroup']) + { + + $ErrorRecord = New-ErrorRecord HPEOneView.EnclosureGroupResourceException InvalidEnclosureGroupObject InvalidArgument 'EnclosureGroup' -TargetType 'PSObject' -Message "The EnclosureGroup Parameter value contains an invalid or unsupported resource category, '$($EnclosureGroup.category)'. The object category must be 'enclosure-groups'. Please correct the value and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + else + { + + $_enclosuregroup = $EnclosureGroup.PSObject.Copy() + + } + + } + + 'String' + { + + if ($EnclosureGroup.StartsWith($enclosureGroupsUri)) + { + + Try + { + + $_enclosuregroup = Get-OVEnclosureGroup -Name $EnclosureGroup -ErrorAction Stop -ApplianceConnection $ApplianceConnection + + } + + catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + else + { + + Try + { + + $_enclosuregroup = Get-OVEnclosureGroup -Name $EnclosureGroup -ErrorAction Stop -ApplianceConnection $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + "[{0}] - Found Enclosure Group: {1} ({2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_enclosuregroup.name, $_enclosuregroup.uri | Write-Verbose + + } + + } + + $_import.licensingIntent = $licensingIntent + $_import.enclosureGroupUri = $_enclosuregroup.uri + $_import.forceInstallFirmware = [Bool]$forceInstallFirmware + $_import.updateFirmwareOn = "EnclosureOnly" + + if ($PSBoundParameters['Baseline']) + { + + "[{0}] - Firmware Baseline is to be configured" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + switch ($baseline.Gettype().Name) + { + + "String" + { + + if ($Baseline.StartsWith($ApplianceFwDriversUri)) + { + + "[{0}] - Firmware Baseline URI Provided '$Baseline'" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $fwBaseLine = Send-OVRequest -Uri $Baseline -Hostname $ApplianceConnection.Name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + + } + + elseif ((-not ($baseline.StartsWith($ApplianceFwDriversUri)) -and ($baseline.StartsWith('/rest/')))) + { + + "[{0}] - Invalid Firmware Baseline URI Provided '$Baseline'" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.BaselineResourceException InavlideBaselineUri InvalidArgument 'Baseline' -Message "The Baseline URI '$baseline' provided does not Begin with '$ApplianceFwDriversUri'. Please correct the value and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + else + { + + "[{0}] - Firmware Baseline Name Provided '$Baseline'" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if ([RegEx]::Match($Baseline, "\.iso", $RegExInsensitiveFlag).Success) + { + + "[{0}] - Getting Baseline based on isoFileName." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $FirmwareBaselineName = $Baseline.PSObject.Copy() + + $fwBaseLine = Get-OVBaseline -isoFileName $Baseline -ApplianceConnection $ApplianceConnection -ErrorAction SilentlyContinue + + If (-not $fwBaseLine) + { + + $ExceptionMessage = "The provided Baseline '{0}' was not found." -f $FirmwareBaselineName + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.BaselineResourceException BaselineResourceNotFound ObjectNotFound 'Baseline' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + else + { + + "[{0}] - Getting Baseline based on Baseline Name." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $FirmwareBaselineName = $Baseline.PSObject.Copy() + + $fwBaseLine = Get-OVBaseline -SppName $Baseline -ApplianceConnection $ApplianceConnection -ErrorAction SilentlyContinue + + If (-not $fwBaseLine) + { + + $ExceptionMessage = "The provided Baseline '{0}' was not found." -f $FirmwareBaselineName + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.BaselineResourceException BaselineResourceNotFound ObjectNotFound 'Baseline' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + $_import.firmwareBaselineUri = $fwBaseLine.uri + + } + + "PSCustomObject" + { + + if ($Baseline.category -eq $ResourceCategoryEnum.Baseline -and $baseline.ApplianceConnection -eq $ApplianceConnection.Name) + { + + "[{0}] - Firmware Baseline Object Provided: {1} ({2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Baseline.FileName, $Baseline.uri | Write-Verbose + + $_import.firmwareBaselineUri = $Baseline.uri + + } + + else + { + + "[{0}] - Invalid Firmware Baseline Object Provided: {1} ({2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Baseline.name, $Baseline.uri | Write-Verbose + + if ($Baseline.category -ne $ResourceCategoryEnum['Baseline'] -and $baseline.ApplianceConnection -eq $ApplianceConnection.Name) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.BaselineResourceException InvalideBaselineObject InvalidArgument 'Baseline' -TargetType 'PSObject' -Message "The Baseline Category '$($baseline.category)' provided does not match the required value 'firmware-drivers'. Please correct the value and try again." + + } + + elseif ($Baseline.category -eq $ResourceCategoryEnum.Baseline -and $baseline.ApplianceConnection -ne $ApplianceConnection.Name) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.BaselineResourceException InvalidBaselineOrigin InvalidArgument 'Baseline' -TargetType 'PSObject' -Message "The Baseline '$($baseline.name)' provided does not originate from the same ApplianceConnection you have specified. Please correct the value and try again." + + } + + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + } + + } + + } + + "[{0}] - Sending request to claim enclosure" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $resp = Send-OVRequest -uri $EnclosuresUri -Method POST -Body $_import -Hostname $ApplianceConnection.Name | Wait-OVTaskStart + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + # "[{0}] - task response: $($resp | Format-List * )" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + # Check to see if the task errored, which should be in the Task Validation stage + if ($resp.taskState -ne "Running") + { + + if ($resp.taskState -eq "Error") + { + + "[{0}] - Task error found $($resp.taskState) $($resp.stateReason) " -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if ($resp.taskerrors | Where-Object { ($_.errorCode -eq "ENCLOSURE_ALREADY_MANAGED") -or ($_.errorCode -eq "ENCLOSURE_MANAGED_BY_VCM") }) + { + + $errorMessage = $resp.taskerrors | Where-Object { ($_.errorCode -eq "ENCLOSURE_ALREADY_MANAGED") -or ($_.errorCode -eq "ENCLOSURE_MANAGED_BY_VCM") } + + $externalManagerType = $errorMessage.data.managementProduct + $externalManagerIP = $errorMessage.data.managementUrl.Replace("https://","") + + Try + { + + $externalManagerFQDN = [System.Net.DNS]::GetHostByAddress($externalManagerIP) + + } + + Catch + { + + "[{0}] Unable to resolve IP Address to DNS A Record." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + $externalManagerFQDN = [PSCustomObject]@{HostName = 'UnknownFqdn'; Aliases = @(); AddressList = @($externalManagerIP.Clone())} + + } + + "[{0}] - Found enclosure '$hostname' is already being managed by $externalManagerType at $externalManagerIP." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + "[{0}] - $externalManagerIP resolves to $externalManagerFQDN" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + write-warning "Enclosure '$hostname' is already being managed by $externalManagerType at $externalManagerIP ($($externalManagerFQDN.HostName))." + + if ($PSCmdlet.ShouldProcess($hostname,"Enclosure '$hostname' is already being managed by $externalManagerType at $externalManagerIP ($($externalManagerFQDN.HostName)). Force add?")) + { + + "[{0}] - Server was claimed and user chose YES to force add." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_import.force = $true + + Try + { + + $resp = Send-OVRequest $EnclosuresUri POST $_import -Hostname $ApplianceConnection.Name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + else + { + + if ($PSBoundParameters['whatif'].ispresent) + { + + write-warning "-WhatIf was passed, would have force added '$hostname' enclosure to appliance." + + $resp = $null + + } + + else + { + + # If here, user chose "No", End Processing + write-warning "Not importing enclosure, $hostname." + + $resp = $Null + + } + + } + + } + + else + { + + $errorMessage = $resp.taskerrors + + if ($errorMessage -is [Array]) + { + + # Loop to find a Message value that is not blank. + $displayMessage = $errorMessage | Where-Object { $_.message } + + $ErrorRecord = New-ErrorRecord HPEOneView.EnclosureResourceException $displayMessage.errorCode InvalidResult 'New-OVEnclosure' -Message $displayMessage.message + + } + + else + { + + $ErrorRecord = New-ErrorRecord HPEOneView.EnclosureResourceException $errorMessage.errorCode InvalidResult 'New-OVEnclosure' -Message ($errorMessage.details + " " + $errorMessage.message) + + } + + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + } + + if (-not($PSBoundParameters['Async'])) + { + + Try + { + + $resp = Wait-OVTaskComplete -InputObject $resp + + } + + catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + [void]$colStatus.Add($resp) + + } + + End + { + + Return $colStatus + + } + +} + +function Add-OVRemoteFrame +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "Default")] + Param + ( + + [Parameter (Mandatory, ParameterSetName = "Default")] + [ValidateNotNullOrEmpty()] + [String]$Hostname, + + [Parameter (Mandatory = $False, ParameterSetName = "Default")] + [Switch]$Async, + + [Parameter (Mandatory = $False, ParameterSetName = "Default")] + [ValidateNotNullorEmpty()] + [object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection -is [HPEOneView.Appliance.Connection]) -and (-not($ApplianceConnection -is [System.String]))) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException InvalidApplianceConnectionDataType InvalidArgument 'ApplianceConnection' -Message 'The specified ApplianceConnection Parameter is not type [HPEOneView.Appliance.Connection] or [System.String]. Please correct this value and try again.' + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection.Count -gt 1) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException MultipleApplianceConnections InvalidArgument 'ApplianceConnection' -Message 'The specified ApplianceConnection Parameter contains multiple Appliance Connections. This CMDLET only supports 1 Appliance Connection in the ApplianceConnect Parameter value. Please correct this and try again.' + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -TargetType $ApplianceConnection.GetType().Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + Process + { + + # Locate the Enclosure Group specified + "[{0}] - Starting" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not $Hostname.StartsWith('fe80:')) + { + + $ExceptionMessage = 'The value provided for Hostname, {0}, is not a valid IPv6 Link Local Address.' -f $Hostname + $ErrorRecord = New-ErrorRecord HPEOneView.EnclosureResourceException InvalidIPv6LinkLocalAddress InvalidArgument 'Hostname' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + $_RemoteFrameAdd = @{hostname = $Hostname} + + "[{0}] - Sending request to claim remote frame: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Hostname | Write-Verbose + + Try + { + + $resp = Send-OVRequest -uri $EnclosuresUri -Method POST -Body $_RemoteFrameAdd -Hostname $ApplianceConnection | Wait-OVTaskStart + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if (-not $PSBoundParameters['Async']) + { + + Try + { + + $resp | Wait-OVTaskComplete + + } + + catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + else + { + + $resp + + } + + } + + End + { + + '[{0}] Done.' -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Update-OVEnclosure +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "Refresh", SupportsShouldProcess, ConfirmImpact = 'High')] + Param + ( + + [Parameter (ValueFromPipeline, Mandatory = $false, ParameterSetName = "Reapply")] + [Parameter (ValueFromPipeline, Mandatory = $false, ParameterSetName = "Refresh")] + [ValidateNotNullOrEmpty()] + [Alias('Enclosure')] + [object]$InputObject, + + [Parameter (ValueFromPipelineByPropertyName, Mandatory = $false, ParameterSetName = "Reapply")] + [Parameter (ValueFromPipelineByPropertyName, Mandatory = $false, ParameterSetName = "Refresh")] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default), + + [Parameter (Mandatory, ParameterSetName = "Refresh")] + [Switch]$Refresh, + + [Parameter (Mandatory = $false, ParameterSetName = "Refresh")] + [String]$Hostname, + + [Parameter (Mandatory = $false, ParameterSetName = "Refresh")] + [String]$Username, + + [Parameter (Mandatory = $false, ParameterSetName = "Refresh")] + [Object]$Password, + + [Parameter (Mandatory = $false, ParameterSetName = "Refresh")] + [PSCredential]$Credential, + + [Parameter (Mandatory, ParameterSetName = "Reapply")] + [Switch]$Reapply, + + [Parameter (Mandatory = $false, ParameterSetName = "Reapply")] + [Parameter (Mandatory = $false, ParameterSetName = "Refresh")] + [Switch]$Async + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not($PSBoundParameters['InputObject'])) + { + + $PipelineInput = $True + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + $_TaskCollection = [System.Collections.ArrayList]::new() + $_EnclosureCollection = [System.Collections.ArrayList]::new() + $_RefreshOptionsCollection = [System.Collections.ArrayList]::new() + + } + + Process + { + + if ($PipelineInput -or $InputObject -is [PSCustomobject]) + { + + "[{0}] Processing Pipeline input." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + # Error if the input value is not a PSObject + if (-not $InputObject -is [PSCustomObject]) + { + + $ErrorRecord = New-ErrorRecord HPEOneView.EnclosureResourceException InvalidEnclosureObjectType InvalidArgument 'InputObject' -TargetType 'PSObject' -Message "The provided InputObject value is not a valid PSObject ($($InputObject.GetType().Name)). Please correct your input value." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + "[{0}] Enclosure PSObject: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), ($InputObject | out-string) | Write-Verbose + + # Validate the Input object is the allowed category + if ($InputObject.category -ne $ResourceCategoryEnum['Enclosure']) + { + + $ExceptionMessage = "The provided InputObject object ({0}) category '{1}' is not an allowed value. Expected category value is 'enclosures'. Please correct your input value." -f $InputObject.name, $InputObject.category + $ErrorRecord = New-ErrorRecord HPEOneView.EnclosureResourceException InvalidEnclosureCategory InvalidArgument 'InputObject' -TargetType 'PSObject' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + if(-not $InputObject.ApplianceConnection) + { + + $ExceptionMessage = "The provided InputObject object ({0}) does not contain the required 'ApplianceConnection' object property. Please correct your input value." -f $InputObject.name + $ErrorRecord = New-ErrorRecord HPEOneView.EnclosureResourceException InvalidEnclosureObject InvalidArgument 'InputObject' -TargetType 'PSObject' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + [void]$_EnclosureCollection.Add($InputObject) + + } + + # Not Pipeline input, and support Array of Enclosure Name or PSObject + else + { + + "[{0}] Processing Enclosure Parameter." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + ForEach ($_encl in $InputObject) + { + + "[{0}] Enclosure value: {1}." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_encl | Write-Verbose + + "[{0}] Looking for Enclosure Name on connected sessions provided" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + # Loop through all Appliance Connections + ForEach ($_appliance in $ApplianceConnection) + { + + "[{0}] Processing '{1}' Session." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name | Write-Verbose + + Try + { + + $_resp = Get-OVLogicalEnclosure $_encl -ApplianceConnection $_appliance.Name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + [void]$_EnclosureCollection.Add($_resp) + + } + + } + + } + + } + + End + { + # Perform the work + ForEach ($_enclosure in $_EnclosureCollection) + { + + # Display obselete message if the connection is a VM, not Synergy + [ObsoleteMessage]::Write($_enclosure.ApplianceConnection) + + "[{0}] Processing Enclosure: '$($_enclosure.name) [$($_enclosure.uri)]'" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + switch ($PSCmdlet.ParameterSetName) + { + + "Reapply" + { + + "[{0}] Reapply Enclosure configuration." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_Params = @{ uri = $_enclosure.uri + "/configuration"; method = 'PUT' } + + } + + "Refresh" + { + + "[{0}] Refreshing Enclosure data." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_RefreshOptions = NewObject -EnclosureRefresh + + $_uri = $_enclosure.uri + "/refreshState" + + if ($_enclosure.state -ieq 'unmanaged' -and $_enclosure.stateReason -ieq 'unowned') + { + + $_RefreshOptions.refreshForceOptions = NewObject -EnclosureRefreshForceOptions + + if (-not $PSBoundParameters['Username'] -and -not $PSBoundParameters['Credential']) + { + + $ExceptionMessage = "The appliance can no longer communicate with {0} Enclosure, and requires a valid Username, Password and Hostname/IPAddress. Please provide the correct parameters." -f $_enclosure.name + $ErrorRecord = New-ErrorRecord HPEOneView.Library.UnsupportedArgumentException MissingRequiredUsernameParameter InvalidOperation 'Enclosure' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + if (-not $PSBoundParameters['Password'] -and -not $PSBoundParameters['Credential']) + { + + $ExceptionMessage = "The appliance can no longer communicate with {0} Enclosure, and requires a valid Username, Password and Hostname/IPAddress. Please provide the correct parameters." -f $_enclosure.name + $ErrorRecord = New-ErrorRecord HPEOneView.Library.UnsupportedArgumentException MissingRequiredPasswordParameter InvalidOperation 'Password' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + if (-not $PSBoundParameters['Hostname']) + { + + $ExceptionMessage = "The appliance can no longer communicate with {0} Enclosure, and requires a valid Username, Password and Hostname/IPAddress. Please provide the correct parameters." -f $_enclosure.name + $ErrorRecord = New-ErrorRecord HPEOneView.Library.UnsupportedArgumentException MissingRequiredHostnameParameter InvalidOperation 'Hostname' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + if ($PSBoundParameters['Credential']) + { + + $_Username = $Credential.Username + $_Password = [Runtime.InteropServices.Marshal]::PtrToStringBSTR([Runtime.InteropServices.Marshal]::SecureStringToBSTR($Credential.Password)) + + } + + elseif ($PSBoundParameters['Username']) + { + + Write-Warning "The -Username and -Password parameters are being deprecated. Please transition your scripts to using the -Credential parameter." + + $_Username = $Username.clone() + + if ($Password -is [SecureString]) + { + + $_Password = [Runtime.InteropServices.Marshal]::PtrToStringBSTR([Runtime.InteropServices.Marshal]::SecureStringToBSTR($Password)) + + } + + else + { + + $_Password = $Password.Clone() + + } + + } + + $_RefreshOptions.refreshForceOptions.address = $Hostname + $_RefreshOptions.refreshForceOptions.username = $_Username + $_RefreshOptions.refreshForceOptions.password = $_Password + + } + + $_Params = @{ uri = $_uri; method = 'PUT'; body = $_RefreshOptions } + + } + + } + + if ($PSCmdlet.ShouldProcess($_enclosure.name,"$($PSCmdlet.ParameterSetName) Enclosure configuration. WARNING: Depending on this action, there might be a brief outage.")) + { + + "[{0}] Sending request to $($PSCmdlet.ParameterSetName) Enclosure configuration" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $_task = Send-OVRequest @_Params -Hostname $_enclosure.ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if (-not $PSBoundParameters['Async']) + { + + $_task | Wait-OVTaskComplete + + } + + else + { + + $_task + + } + + } + + elseif ($PSBoundParameters['WhatIf']) + { + + "[{0}] User included -WhatIf." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + else + { + + "[{0}] User cancelled." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + } + + } + +} + +function Get-OVLogicalEnclosure +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "default")] + Param + ( + + [Parameter (Mandatory = $false, ParameterSetName = "default")] + [validateNotNullorEmpty()] + [String]$Name, + + [Parameter (Mandatory = $false, ValueFromPipeline, ParameterSetName = "default")] + [validateNotNullorEmpty()] + [Object]$EnclosureGroup, + + [Parameter (Mandatory = $false, ParameterSetName = "default")] + [Switch]$NonCompliant, + + [Parameter (Mandatory = $false, ParameterSetName = "default")] + [validateNotNullorEmpty()] + [Object]$Scope = "AllResourcesInScope", + + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = "default")] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $_LogicalEnclosureCollection = [System.Collections.ArrayList]::new() + + } + + Process + { + + ForEach ($_appliance in $ApplianceConnection) + { + + # Handle pipeline input for connection object + if ($_appliance -isnot [HPEOneView.Appliance.Connection]) + { + + $_appliance = $ConnectedSessions | Where-Object ConnectionId -eq $_appliance.ConnectionId + + } + + "[{0}] Processing appliance {1} (of {2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name, $ApplianceConnection.Count | Write-Verbose + + $_Query = [System.Collections.ArrayList]::new() + + # Handle default cause of AllResourcesInScope + if ($Scope -eq 'AllResourcesInScope') + { + + "[{0}] Processing AllResourcesInScope." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_Scopes = $_appliance.ActivePermissions | Where-Object Active + + # If one scope contains 'AllResources' ScopeName "tag", then all resources should be returned regardless. + if ($_Scopes | Where-Object ScopeName -eq 'AllResources') + { + + $_ScopeNames = [String]::Join(', ', ($_Scopes | Where-Object ScopeName -eq 'AllResources').ScopeName) + + "[{0}] Scope(s) {1} is set to 'AllResources'. Will not add scope to URI query parameter." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_ScopeNames | Write-Verbose + + } + + # Process ApplianceConnection ActivePermissions collection + else + { + + Try + { + + $_ScopeQuery = Join-Scope $_Scopes + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + [Void]$_Query.Add(("({0})" -f $_ScopeQuery)) + + } + + } + + elseif ($Scope | Where-Object ScopeName -eq 'AllResources') + { + + $_ScopeNames = [String]::Join(', ', ($_Scopes | Where-Object ScopeName -eq 'AllResources').ScopeName) + + "[{0}] Scope(s) {1} is set to 'AllResources'. Will not add scope to URI query parameter." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_ScopeNames | Write-Verbose + + } + + elseif ($Scope -eq 'AllResources') + { + + "[{0}] Requesting scope 'AllResources'. Will not add scope to URI query parameter." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_ScopeNames | Write-Verbose + + } + + else + { + + Try + { + + $_ScopeQuery = Join-Scope $Scope + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + [Void]$_Query.Add(("({0})" -f $_ScopeQuery)) + + } + + if ($Name) + { + + if ($Name.Contains('*')) + { + + [Void]$_Query.Add(("name%3A{0}" -f $Name.Replace("*", "%2A").Replace(',','%2C').Replace(" ", "?"))) + + } + + else + { + + [Void]$_Query.Add(("name:'{0}'" -f $Name)) + + } + + } + + if ($PSBoundParameters['NonCompliant']) + { + + "[{0}] Filtering for non-compliant logical enclosures." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + [Void]$_Query.Add("state:'Inconsistent'") + + } + + if ($Label) + { + + [Void]$_Query.Add(("labels:'{0}'" -f $Label)) + + } + + # Build the final URI + $_uri = '{0}?category=logical-enclosures&sort=name:asc&query={1}' -f $IndexUri, [String]::Join(' AND ', $_Query.ToArray()) + + Try + { + + [Array]$_ResourcesFromIndexCol = Get-AllIndexResources -Uri $_uri -ApplianceConnection $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if ($EnclosureGroup) + { + + "[{0}] Filtering Logical Enclosures for parent Enclosure Group '{1}'" -f $MyInvocation.InvocationName.ToString().ToUpper(), $EnclosureGroup.name | Write-Verbose + + [Array]$_ResourcesFromIndexCol = $_ResourcesFromIndexCol | Where-Object enclosureGroupUri -eq $EnclosureGroup.uri + + } + + if ($_ResourcesFromIndexCol.count -eq 0 -and $Name) + { + + "[{0}] Logical Enclosure '{1}' resource not found. Generating error" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Name | Write-Verbose + + $ExceptionMessage = "The specified Logical Enclosure '{0}' was not found on '{1}' appliance. Please check the name and try again." -f $Name, $_appliance.Name + $ErrorRecord = New-ErrorRecord HPEOneView.LogicalEnclosureResourceException LogicalEnclosureNotFound ObjectNotFound 'Name' -Message $ExceptionMessage + $PSCmdlet.WriteError($ErrorRecord) + + } + + elseif ($_ResourcesFromIndexCol.count -eq 0) + { + + "[{0}] No Logical Enclosure resources found on {1}." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.name | Write-Verbose + + } + + else + { + + "[{0}] Found {1} Enclosure Group resources." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_ResourcesFromIndexCol.count | Write-Verbose + + $_ResourcesFromIndexCol | ForEach-Object { + + $_.PSObject.TypeNames.Insert(0,'HPEOneView.LogicalEnclosure') + + [void]$_LogicalEnclosureCollection.Add($_) + + } + + } + + } + + } + + End + { + + "[{0}] Done. {1} total Logical Enclosure(s) found." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_LogicalEnclosureCollection.count | Write-Verbose + + # Export results to exportfile + if ($exportFile) + { + + $_LogicalEnclosureCollection | convertto-json -depth 99 > $exportFile + + } + + # else Return Logical Enclosure object(s) + else + { + + Return $_LogicalEnclosureCollection + + } + + } + +} + +function New-OVLogicalEnclosure +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = 'Default')] + Param + ( + + [Parameter (Mandatory, ParameterSetName = 'Default')] + [Parameter (Mandatory, ParameterSetName = 'AutoFill')] + [ValidateNotNullOrEmpty()] + [String]$Name, + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = 'Default')] + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = 'AutoFill')] + [ValidateNotNullOrEmpty()] + [object]$Enclosure, + + [Parameter (Mandatory, ParameterSetName = 'Default')] + [Parameter (Mandatory, ParameterSetName = 'AutoFill')] + [ValidateNotNullOrEmpty()] + [Alias ('eg')] + [object]$EnclosureGroup, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [Parameter (Mandatory = $false, ParameterSetName = 'AutoFill')] + [ValidateNotNullOrEmpty()] + [String]$FirmwareBaseline, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [Parameter (Mandatory = $false, ParameterSetName = 'AutoFill')] + [ValidateNotNullOrEmpty()] + [Bool]$ForceFirmwareBaseline, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [Object]$Ebipa, + + [Parameter (Mandatory = $false, ParameterSetName = 'AutoFill')] + [Switch]$AutoFillIPv4DeviceAddress, + + [Parameter (Mandatory = $false, ParameterSetName = 'AutoFill')] + [ValidateNotNullOrEmpty()] + [IPAddress]$StartingIPv4DeviceAddress, + + [Parameter (Mandatory = $false, ParameterSetName = 'AutoFill')] + [Switch]$AutoFillIPv4InterconnectAddress, + + [Parameter (Mandatory = $false, ParameterSetName = 'AutoFill')] + [ValidateNotNullOrEmpty()] + [IPAddress]$StartingIPv4InterconnectAddress, + + [Parameter (Mandatory = $false, ParameterSetName = 'AutoFill')] + [Switch]$AutoFillIPv6DeviceAddress, + + [Parameter (Mandatory = $false, ParameterSetName = 'AutoFill')] + [ValidateNotNullOrEmpty()] + [IPAddress]$StartingIPv6DeviceAddress, + + [Parameter (Mandatory = $false, ParameterSetName = 'AutoFill')] + [Switch]$AutoFillIPv6InterconnectAddress, + + [Parameter (Mandatory = $false, ParameterSetName = 'AutoFill')] + [ValidateNotNullOrEmpty()] + [IPAddress]$StartingIPv6InterconnectAddress, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [Parameter (Mandatory = $false, ParameterSetName = 'AutoFill')] + [ValidateNotNullOrEmpty()] + [HPEOneView.Appliance.ScopeCollection[]]$Scope, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [Parameter (Mandatory = $false, ParameterSetName = 'AutoFill')] + [Switch]$Async, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [Parameter (Mandatory = $false, ParameterSetName = 'AutoFill')] + [Switch]$Passthru, + + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = 'Default')] + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = 'AutoFill')] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not($PSBoundParameters['Enclosure'])) + { + + $PipelineInput = $true + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneView.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $_TaskResourceCollection = [System.Collections.ArrayList]::new() + + } + + Process + { + + if ($PipelineInput) + { + + "[{0}] Synergy Frame object was passed via pipeline." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + # Error when target appliance is not a Synergy Composer or the Enclosure object is not a Synergy Frame + if ((${Global:ConnectedSessions} | Where-Object Name -EQ $ApplianceConnection.Name).ApplianceType -ne 'Composer') + { + + $Message = 'The Appliance {0} is not a Synergy Composer, and this operation is not supported. Only Synergy managed resources are supported with this Cmdlet.' -f $ApplianceConnection.Name + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.ComposerNodeException UnsupportedMethod InvalidOperation 'ApplianceConnection' -TargetType 'HPEOneview.Appliance.Connection' -Message $Message + + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + $_LogicalEnclosure = NewObject -LogicalEnclosure + $_LogicalEnclosure.name = $Name + + # Get Frame object type + switch ($Enclosure.GetType().Name) + { + + 'PSCustomObject' + { + + "[{0}] Synergy Frame object: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), ($Enclosure | Out-String) | Write-Verbose + + if ($Enclosure.category -ne $ResourceCategoryEnum['Enclosure']) + { + + $ErrorRecord = New-ErrorRecord HPEOneView.EnclosureResourceException InvalidResourceObject InvalidArgument 'Enclosure' -TargetType 'PSObject' -Message "The provided -Enclosure resource object is not an Enclosure or Synergy Frame. Please correct the input object and try again." + + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + # Validate Frame resource object + if ($Enclosure.enclosureType -ne 'SY12000') + { + + # Throw error, wrong resource + $ErrorRecord = New-ErrorRecord HPEOneView.EnclosureResourceException UnsupportedEnclosureType InvalidArgument 'Enclosure' -TargetType 'PSObject' -Message "The provided input object is not a Synergy Frame resource object. Only Synergy Frames are supported with this Cmdlet." + + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + if ($Enclosure.state -ne 'Monitored') + { + + $ExceptionMessage = "The provided Synergy Frame resource '{0}' is already managed. Please select another Synergy Frame resource object." -f $Enclosure.name + $ErrorRecord = New-ErrorRecord HPEOneView.EnclosureResourceException InvalidConfigurationState InvalidArgument 'Enclosure' -TargetType 'PSObject' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + 'String' + { + + "[{0}] Synergy Frame Name provided: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Enclosure | Write-Verbose + + Try + { + + $Enclosure = Get-OVEnclosure -Name $Enclosure -ApplianceConnection $ApplianceConnection + + # Validate Frame resource object + if ($Enclosure.enclosureType -ne 'SY12000') + { + + # Throw error, wrong resource + $ExceptionMessage = "The provided input object is not a Synergy Frame resource object. Only Synergy Frames are supported with this Cmdlet." + $ErrorRecord = New-ErrorRecord HPEOneView.EnclosureResourceException UnsupportedEnclosureType InvalidArgument 'Enclosure' -TargetType 'PSObject' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + if ($Enclosure.state -ne 'Monitored') + { + + $ExceptionMessage = "The provided Synergy Frame resource '{0}' is already managed. Please select another Synergy Frame resource object." -f $Enclosure.name + $ErrorRecord = New-ErrorRecord HPEOneView.EnclosureResourceException InvalidConfigurationState InvalidArgument 'Enclosure' -TargetType 'PSObject' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + # Get list of logical Frame members fro ILT + Try + { + + $_LinkedSynergyFrames = Send-OVRequest -Uri $InterconnectLinkTopologies -Hostname $ApplianceConnection.Name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $_IltGroup = $_LinkedSynergyFrames.members | Where-Object { $_.enclosureMembers.enclosureUri -contains $Enclosure.uri } + + foreach ($_member in $_IltGroup.enclosureMembers) + { + + "[{0}] Processing Enclosure URI: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_member.enclosureUri | Write-Verbose + + if ($_member.errorFlag) + { + + Try + { + + $_EnclosureObject = Send-OVRequest $_member.enclosureUri -Hostname $ApplianceConnection.Name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + "[{0}] Synergy Frame is in an Error State: {1} ({2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_EnclosureObject.state, $_EnclosureObject.stateReason | Write-Verbose + + $ErrorRecord = New-ErrorRecord HPEOneView.EnclosureResourceException InvalidConfigurationState InvalidArgument 'Enclosure' -TargetType 'PSObject' -Message ("The provided or linked Synergy Frame resource '{0}' is in an Error State: {1} ({2}) Please select another Synergy Frame resource object." -f $_EnclosureObject.name, $_EnclosureObject.state, $_EnclosureObject.stateReason) + + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + [void]$_LogicalEnclosure.enclosureUris.Add($_member.enclosureUri) + + } + + $EnclosureBaySettings = NewObject -LogicalEnclosureEnclosureBaySettings + + # Process the enclosures from the ILT + For ($_e = 1; $_e -le $_IltGroup.enclosureMembers.Count; $_e++) + { + + # Device Bays + For ($_d = 1; $_d -le 12; $_d++) + { + + $DeviceBayToAdd = NewObject -LogicalEnclosureEbipaSetting + + $DeviceBayToAdd | Add-Member -NotePropertyName enclosureNumber -NotePropertyValue $_e #-force + + [int]$DeviceBayToAdd.bayNumber = $_d + + [void]$EnclosureBaySettings.deviceBays.Add($DeviceBayToAdd) + + } + + # ICMs + For ($_i = 1; $_i -le 6; $_i++) + { + + $ICMBay = NewObject -LogicalEnclosureEbipaSetting + + $ICMBay | Add-Member -NotePropertyName enclosureNumber -NotePropertyValue $_e #-force + $ICMBay.bayNumber = $_i + + [void]$EnclosureBaySettings.interconnectBays.Add($ICMBay) + + } + + } + + $_LogicalEnclosure.enclosureBaySettings = $EnclosureBaySettings + + # Process Ebipa Autofill here + if ($PSCmdlet.ParameterSetName -eq 'AutoFill') + { + + $LastIPv4AddressSet = $null + $LastIPv6AddressSet = $null + + $IPv4DeviceAddressesToConfigure = [System.Collections.ArrayList]::new() + $IPv4InterconnectAddressesToConfigure = [System.Collections.ArrayList]::new() + $IPv6DeviceAddressesToConfigure = [System.Collections.ArrayList]::new() + $IPv6InterconnectAddressesToConfigure = [System.Collections.ArrayList]::new() + + Switch ($PSBoundParameters.Keys) + { + + 'AutoFillIPv4DeviceAddress' + { + + if (-not $PSBoundParameters['StartingIPv4DeviceAddress']) + { + + $ExceptionMessage = "The StartingIPv4DeviceAddress is required when specifying to auto fill IPv4 device addresses." + $ErrorRecord = New-ErrorRecord HPEOneView.LogicalEnclosureResourceException MissingAutoFillParameter InvalidArgument 'StartingIPv4DeviceAddress' -TargetType 'IPAddress' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + if ($StartingIPv4DeviceAddress.AddressFamily -ne [System.Net.Sockets.AddressFamily]::InterNetwork) + { + + $ExceptionMessage = "The StartingIPv4DeviceAddress '{0}' is not an IPv4 address." -f $StartingIPv4DeviceAddress + $ErrorRecord = New-ErrorRecord HPEOneView.LogicalEnclosureResourceException InvalidIPv4AddressValue InvalidArgument 'StartingIPv4DeviceAddress' -TargetType 'IPAddress' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + $TotalBaysToAssign = ($_e - 1) * 12 - 1 + + [void]$IPv4DeviceAddressesToConfigure.Add($StartingIPv4DeviceAddress) + + ForEach ($Address in [System.Net.IPNetwork]::IncrementAddress($StartingIPv4DeviceAddress, $TotalBaysToAssign)) + { + + [void]$IPv4DeviceAddressesToConfigure.Add($Address) + + } + + # Save the last address + $LastIPv4AddressSet = $IPv4DeviceAddressesToConfigure[-1] + + "[{0}] Last set IPv4 address: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $LastIPv4AddressSet | Write-Verbose + + $max = 0 + + # Process each enclosure, and device bays within + For ($encl = 1; $encl -le ($_e - 1); $encl++) + { + + For ($x = 0; $x -le 11; $x++) + { + + $DeviceBayIP = NewObject -LogicalEnclosureEbipaAddress + + $DeviceBayIP.type = '{0}' -f [LogicalEnclosureEbipaAddresTypeEnum]::IPv4 + $DeviceBayIP.ipAddress = $IPv4DeviceAddressesToConfigure[$x + $max] + + [void]($_LogicalEnclosure.enclosureBaySettings.deviceBays | ? { $_.enclosureNumber -eq $encl -and $_.bayNumber -eq ($x + 1)}).manualAddresses.Add($DeviceBayIP) + + } + + $max += 12 + + } + + } + + 'AutoFillIPv4InterconnectAddress' + { + + $TotalBaysToAssign = ($_e - 1) * 6 + + # Validate that we didn't set any device IPs already. + if ($null -ne $LastIPv4AddressSet -and $PSBoundParameters['StartingIPv4InterconnectAddress']) + { + + # if we did, verify that StartingIPv4InterconnectAddress and the last IPv4 address used do not overlap + if ($IPv4DeviceAddressesToConfigure.IPAddressToString.Contains($StartingIPv4InterconnectAddress)) + { + + $ExceptionMessage = "The provided StartingIPv4InterconnectAddress address '{0}' is already assigned within the StartingIPv4DeviceAddress range. Please choose a different StartingIPv4InterconnectAddress address value." -f $StartingIPv4InterconnectAddress + $ErrorRecord = New-ErrorRecord HPEOneView.LogicalEnclosureResourceException OverlapIPAddress InvalidArgument 'StartingIPv4InterconnectAddress' -TargetType 'IPAddress' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + if ($StartingIPv4InterconnectAddress.AddressFamily -ne [System.Net.Sockets.AddressFamily]::InterNetwork) + { + + $ExceptionMessage = "The StartingIPv4InterconnectAddress '{0}' is not an IPv4 address." -f $StartingIPv4InterconnectAddress + $ErrorRecord = New-ErrorRecord HPEOneView.LogicalEnclosureResourceException InvalidIPv4AddressValue InvalidArgument 'StartingIPv4InterconnectAddress' -TargetType 'IPAddress' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + $InterconnectStartingAddress = $StartingIPv4InterconnectAddress + + } + + elseif (-not $PSBoundParameters['StartingIPv4InterconnectAddress'] -and $null -eq $LastIPv4AddressSet) + { + + $ExceptionMessage = "The StartingIPv4InterconnectAddress is required when specifying to auto fill IPv4 interconnect addresses." + $ErrorRecord = New-ErrorRecord HPEOneView.LogicalEnclosureResourceException MissingAutoFillParameter InvalidArgument 'StartingIPv4InterconnectAddress' -TargetType 'IPAddress' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + else + { + + $InterconnectStartingAddress = $LastIPv4AddressSet + + } + + "[{0}] Interconnect staging IPv4 address: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $InterconnectStartingAddress | Write-Verbose + + ForEach ($Address in [System.Net.IPNetwork]::IncrementAddress($InterconnectStartingAddress, $TotalBaysToAssign)) + { + + [void]$IPv4InterconnectAddressesToConfigure.Add($Address) + + } + + $max = 0 + + # Process each enclosure, and interconnect bays within + For ($encl = 1; $encl -le ($_e - 1); $encl++) + { + + For ($x = 0; $x -le 5; $x++) + { + + $IcmIP = NewObject -LogicalEnclosureEbipaAddress + + $IcmIP.type = '{0}' -f [LogicalEnclosureEbipaAddresTypeEnum]::IPv4 + $IcmIP.ipAddress = $IPv4InterconnectAddressesToConfigure[$x + $max] + + [void]($_LogicalEnclosure.enclosureBaySettings.interconnectBays | ? { $_.enclosureNumber -eq $encl -and $_.bayNumber -eq ($x + 1)}).manualAddresses.Add($IcmIP) + + } + + $max += 6 + + } + + } + + 'AutoFillIPv6DeviceAddress' + { + + if (-not $PSBoundParameters['StartingIPv6DeviceAddress']) + { + + $ExceptionMessage = "The StartingIPv6DeviceAddress is required when specifying to auto fill IPv6 device addresses." + $ErrorRecord = New-ErrorRecord HPEOneView.LogicalEnclosureResourceException MissingAutoFillParameter InvalidArgument 'StartingIPv6DeviceAddress' -TargetType 'IPAddress' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + if ($StartingIPv6DeviceAddress.AddressFamily -ne [System.Net.Sockets.AddressFamily]::InterNetworkV6) + { + + $ExceptionMessage = "The StartingIPv6DeviceAddress '{0}' is not an IPv6 address." -f $StartingIPv6DeviceAddres + $ErrorRecord = New-ErrorRecord HPEOneView.LogicalEnclosureResourceException InvalidIPv6AddressValue InvalidArgument 'StartingIPv6DeviceAddress' -TargetType 'IPAddress' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + $TotalBaysToAssign = ($_e - 1) * 12 - 1 + + [void]$IPv6DeviceAddressesToConfigure.Add($StartingIPv6DeviceAddress) + + ForEach ($Address in [System.Net.IPNetwork]::IncrementAddress($StartingIPv6DeviceAddress, $TotalBaysToAssign)) + { + + [void]$IPv6DeviceAddressesToConfigure.Add($Address) + + } + + # Save the last address + $LastIPv6AddressSet = $IPv6DeviceAddressesToConfigure[-1] + + $max = 0 + + # Process each enclosure, and device bays within + For ($encl = 1; $encl -le ($_e - 1); $encl++) + { + + For ($x = 0; $x -le 11; $x++) + { + + $DeviceBayIP = NewObject -LogicalEnclosureEbipaAddress + + $DeviceBayIP.type = '{0}' -f [LogicalEnclosureEbipaAddresTypeEnum]::IPv6 + $DeviceBayIP.ipAddress = $IPv6DeviceAddressesToConfigure[$x + $max] + + [void]($_LogicalEnclosure.enclosureBaySettings.deviceBays | ? { $_.enclosureNumber -eq $encl -and $_.bayNumber -eq ($x + 1)}).manualAddresses.Add($DeviceBayIP) + + } + + $max += 12 + + } + + } + + 'AutoFillIPv6InterconnectAddress' + { + + $TotalBaysToAssign = ($_e - 1) * 6 + + # Validate that we didn't set any device IPs already. + if ($null -ne $LastIPv6AddressSet -and $PSBoundParameters['StartingIPv6InterconnectAddress']) + { + + # if we did, verify that StartingIPv6InterconnectAddress and the last IPv6 address used do not overlap + if ($IPv6DeviceAddressesToConfigure.IPAddressToString.Contains($StartingIPv6InterconnectAddress)) + { + + $ExceptionMessage = "The provided StartingIPv6InterconnectAddress address '{0}' is already assigned within the StartingIPv6DeviceAddress range. Please choose a different StartingIPv4InterconnectAddress address value." -f $StartingIPv4InterconnectAddress + $ErrorRecord = New-ErrorRecord HPEOneView.LogicalEnclosureResourceException MissingAutoFillParameter InvalidArgument 'StartingIPv6InterconnectAddress' -TargetType 'IPAddress' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + if ($StartingIPv6InterconnectAddress.AddressFamily -ne [System.Net.Sockets.AddressFamily]::InterNetworkV6) + { + + $ExceptionMessage = "The StartingIPv6InterconnectAddress '{0}' is not an IPv6 address." -f $StartingIPv6InterconnectAddress + $ErrorRecord = New-ErrorRecord HPEOneView.LogicalEnclosureResourceException InvalidIPv6AddressValue InvalidArgument 'StartingIPv6InterconnectAddress' -TargetType 'IPAddress' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + $InterconnectStartingAddress = $StartingIPv6InterconnectAddress + + } + + elseif (-not $PSBoundParameters['StartingIPv6InterconnectAddress'] -and $null -eq $LastIPv6AddressSet ) + { + + $ExceptionMessage = "The StartingIPv6InterconnectAddress is required when specifying to auto fill IPv6 interconnect addresses." + $ErrorRecord = New-ErrorRecord HPEOneView.LogicalEnclosureResourceException MissingAutoFillParameter InvalidArgument 'StartingIPv6InterconnectAddress' -TargetType 'IPAddress' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + else + { + + $InterconnectStartingAddress = $LastIPv6AddressSet + + } + + ForEach ($Address in [System.Net.IPNetwork]::IncrementAddress($InterconnectStartingAddress, $TotalBaysToAssign)) + { + + [void]$IPv6InterconnectAddressesToConfigure.Add($Address) + + } + + $max = 0 + + # Process each enclosure, and interconnect bays within + For ($encl = 1; $encl -le ($_e - 1); $encl++) + { + + For ($x = 0; $x -le 5; $x++) + { + + $IcmIP = NewObject -LogicalEnclosureEbipaAddress + + $IcmIP.type = '{0}' -f [LogicalEnclosureEbipaAddresTypeEnum]::IPv6 + $IcmIP.ipAddress = $IPv6InterconnectAddressesToConfigure[$x + $max] + + [void]($_LogicalEnclosure.enclosureBaySettings.interconnectBays | ? { $_.enclosureNumber -eq $encl -and $_.bayNumber -eq ($x + 1)}).manualAddresses.Add($IcmIP) + + } + + $max += 6 + + } + + } + + } + + } + + if ($PSBoundParameters['Ebipa']) + { + + [Regex]$EnclosureIDRegex = [System.Text.RegularExpressions.Regex]::new('^(?[f|F]rame|[e|E]nclosure)(?[1-5]{1})$') + + # Loop through the Ebipa parameter, processing enclosure first + ForEach ($_EbipaSetting in $Ebipa.GetEnumerator()) + { + + $FoundEnclosure = $EnclosureIDRegex.Match($_EbipaSetting.Name) + + if (-not $FoundEnclosure.Success) + { + + $ExceptionMessage = "Unable to find enclosure '{0}' as the hashtable key name. Is the spelling correct? The hashtable format must follow @{EnclosureName = @{Device1 = @{IPv4Address = '192.168.1.1'}; Interconnect1 = @{IPv4Address = '192.168.1.2'}}}." -f $_EbipaSetting.Name + $ErrorRecord = New-ErrorRecord HPEOneView.LogicalEnclosureResourceException UnableToIdentifyEnclosureName InvalidArgument 'Ebipa' -TargetType 'Hashtable' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + ForEach ($Device in $_EbipaSetting.Value.GetEnumerator()) + { + + [Regex]$DeviceTypeAndIDRegex = [System.Text.RegularExpressions.Regex]::new('(?[d|D]evice|[i|I]nterconnect)(?\d{1,2})') + + $Matches = $DeviceTypeAndIDRegex.Match($Device.Name) + + $DeviceBayID = $Matches.Groups['deviceID'].Value + + Switch ($Matches.Groups['deviceType'].Value.ToLower()) + { + + 'device' + { + + $DeviceType = "deviceBays" + + } + + 'interconnect' + { + + $DeviceType = "interconnectBays" + + } + + default + { + + $ExceptionMessage = "Unable to determin device type, device or interconnect, from hashtable collection." + $ErrorRecord = New-ErrorRecord HPEOneView.LogicalEnclosureResourceException UnableToIdentifyEnclosureName InvalidArgument 'Ebipa' -TargetType 'Hashtable' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + ForEach ($IPType in $Device.Value.GetEnumerator()) + { + + Switch ($IPType.Name) + { + + 'IPv4Address' + { + + $DeviceBayIP = NewObject -LogicalEnclosureEbipaAddress + + $DeviceBayIP.type = '{0}' -f [LogicalEnclosureEbipaAddresTypeEnum]::IPv4 + $DeviceBayIP.ipAddress = $IPType.Value + + } + + 'IPv6Address' + { + + $DeviceBayIP = NewObject -LogicalEnclosureEbipaAddress + + $DeviceBayIP.type = '{0}' -f [LogicalEnclosureEbipaAddresTypeEnum]::IPv6 + $DeviceBayIP.ipAddress = $IPType.Value + + } + + default + { + + # Unknown type, generate error + $ExceptionMessage = "Unable to determin device IP version. '{0}' is not IPv4Address or IPv6Address allowed key names." -f $IPType.Name + $ErrorRecord = New-ErrorRecord HPEOneView.LogicalEnclosureResourceException UnableToIdentifyEnclosureName InvalidArgument 'Ebipa' -TargetType 'Hashtable' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + [void]($_LogicalEnclosure.enclosureBaySettings.$DeviceType | ? { $_.bayNumber -eq $DeviceBayID -and $_.enclosureNumber -eq $FoundEnclosure.Groups['ID'].Value}).manualAddresses.Add($DeviceBayIP) + + } + + } + + } + + } + + # Validate EG + switch ($EnclosureGroup.GetType().Name) + { + + 'PSCustomObject' + { + + "[{0}] Enclosure Group object: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), ($EnclosureGroup | ConvertTo-Json -Depth 99 | Out-String) | Write-Verbose + + if ($EnclosureGroup.category -ne $ResourceCategoryEnum['EnclosureGroup']) + { + + $ErrorRecord = New-ErrorRecord HPEOneView.EnclosureGroupResourceException InvalidResourceObject InvalidArgument -TargetType 'PSObject' -Message "The provided -EnclosureGroup resource object is not an Enclosure Group. Please correct the input object and try again." + + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + 'String' + { + + "[{0}] Enclosure Group Name provided: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $EnclosureGroup | Write-Verbose + + Try + { + + $EnclosureGroup = Get-OVEnclosureGroup -Name $EnclosureGroup -ErrorAction Stop -ApplianceConnection $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + $_LogicalEnclosure.enclosureGroupUri = $EnclosureGroup.uri + + if ($PSBoundParameters['FirmwareBaseline']) + { + + # Validate Firmware Baseline + switch ($FirmwareBaseline.GetType().Name) + { + + 'PSCustomObject' + { + + "[{0}] FirmwareBaseline object: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), ($FirmwareBaseline | Out-String) | Write-Verbose + + if ($FirmwareBaseline.category -ne $ResourceCategoryEnum['Baseline']) + { + + $ErrorRecord = New-ErrorRecord HPEOneView.FirmwareBaselineResourceException InvalidResourceObject InvalidArgument -TargetType 'PSObject' -Message "The provided -FirmwareBaseline resource object is not a Firmwaer Baseline. Please correct the input object and try again." + + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + 'String' + { + + "[{0}] Firmware Baseline Name provided: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $FirmwareBaseline | Write-Verbose + + Try + { + + $FirmwareBaselineName = $FirmwareBaseline.Clone() + $FirmwareBaseline = Get-OVBaseline -File $FirmwareBaseline -ApplianceConnection $ApplianceConnection -ErrorAction SilentlyContinue + + If (-not $FirmwareBaseline) + { + + $ExceptionMessage = "The provided Baseline '{0}' was not found." -f $FirmwareBaselineName + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.BaselineResourceException BaselineResourceNotFound ObjectNotFound 'FirmwareBaseline' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + $_LogicalEnclosure.firmwareBaselineUri = $FirmwareBaseline.uri + $_LogicalEnclosure.forceInstallFirmware = $ForceFirmwareBaseline + + } + + # "[{0}] Logical Enclosure object: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), ($_LogicalEnclosure | out-string) | Write-Verbose + + "[{0}] Creating {1} Logical Enclosure" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_LogicalEnclosure.name | Write-Verbose + + if ($PSBoundParameters['Scope']) + { + + ForEach ($_Scope in $Scope) + { + + "[{0}] Adding resource to Scope: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_Scope.Name | Write-Verbose + + [void]$_LogicalEnclosure.initialScopeUris.Add($_Scope.Uri) + + } + + } + + if ($PSBoundParameters['Passthru']) + { + + return $_LogicalEnclosure + + } + + else + { + + Try + { + + $resp = Send-OVRequest -URI $LogicalEnclosuresUri -Method 'POST' -Body $_LogicalEnclosure -ApplianceConnection $ApplianceConnection + + if (-not $PSBoundParameters['Async']) + { + + $resp = $resp | Wait-OVTaskComplete + + } + + else + { + + $resp + + } + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Set-OVLogicalEnclosure +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding ()] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = 'Default')] + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = 'cClass')] + [ValidateNotNullOrEmpty()] + [Object]$InputObject, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [String]$Name, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [String[]]$ConfigurationScript, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = 'cClass')] + [ValidateNotNullOrEmpty()] + [Alias ('eg')] + [Object]$EnclosureGroup, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateSet ('RedundantPowerFeed', 'RedundantPowerSupply')] + [String]$PowerMode, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateSet ('ASHRAE_A3', 'ASHRAE_A4', 'Standard', 'Telco')] + [String]$AmbientTemperatureSetting, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [Parameter (Mandatory = $false, ParameterSetName = 'cClass')] + [Switch]$Async, + + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = 'Default')] + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = 'cClass')] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not($PSBoundParameters['InputObject'])) + { + + $PipelineInput = $true + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $_TaskResources = [System.Collections.ArrayList]::new() + + } + + Process + { + + if ([RegEx]::Match($InputObject.enclosureModel, 'Synergy', $RegExInsensitiveFlag).Success -and $PSBoundParameters['ConfigurationScript']) + { + + $ExceptionMessage = 'The InputObject {0} is not a supported resource to set the Enclosure ConfigurationScript.' -f $InputObject.name + $ErrorRecord = New-ErrorRecord InvalidOperationException InvalidArgumentValue InvalidArgument 'ConfigurationScript' -Message $ExceptionMessage + $PSCmdlet.WriteError($ErrorRecord) + + } + + elseif ((${Global:ConnectedSessions} | Where-Object Name -EQ $ApplianceConnection.Name).ApplianceType -ne 'Composer') + { + + $Message = 'The Appliance {0} is not a Synergy Composer, and this operation is not supported. Only Synergy managed resources are supported with this Cmdlet.' -f $ApplianceConnection.Name + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.ComposerNodeException UnsupportedMethod InvalidOperation 'ApplianceConnection' -TargetType 'HPEOneview.Appliance.Connection' -Message $Message + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + if ($PipelineInput) + { + + "[{0}] Resource object was passed via pipeline." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + # Get type + switch ($InputObject.GetType().Name) + { + + 'PSCustomObject' + { + + "[{0}] Synergy Frame object: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), ($InputObject | Out-String) | Write-Verbose + + if ($InputObject.category -ne $ResourceCategoryEnum['LogicalEnclosure']) + { + + $ExceptionMessage = "The provided -Enclosure resource object is not an Enclosure or Synergy Frame. Please correct the input object and try again." + $ErrorRecord = New-ErrorRecord HPEOneView.InputObjectResourceException InvalidResourceObject InvalidArgument 'InputObject' -TargetType 'PSObject' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Try + { + + "[{0}] Getting associated Enclosure Group to identify enclosure type." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_EnclosureGroup = Send-OVRequest -Uri $InputObject.enclosureGroupUri -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if ($_EnclosureGroup.enclosureTypeUri -NotMatch 'SY12000') + { + + # Throw error, wrong resource + $ExceptionMessage = "The provided input object is not a Synergy Frame resource object. Only Synergy Frames and associated Logical Enclosures are supported with this Cmdlet." + $ErrorRecord = New-ErrorRecord HPEOneView.EnclosureResourceException UnsupportedEnclosureType InvalidArgument -TargetType 'PSObject' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + $_UpdatedLogicalEnclosure = $InputObject.PSObject.Copy() + + } + + 'String' + { + + "[{0}] Synergy Frame name: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject | Write-Verbose + + Try + { + + $_UpdatedLogicalEnclosure = Get-OVLogicalEnclosure -Name $InputObject -ErrorAction Stop -ApplianceConnection $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + Try + { + + "[{0}] Getting associated Enclosure Group to identify enclosure type." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_EnclosureGroup = Send-OVRequest -Uri $InputObject.enclosureGroupUri -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if ($_EnclosureGroup.enclosureTypeUri -NotMatch 'SY12000') + { + + # Throw error, wrong resource + $ExceptionMessage = "The provided input object is not a Synergy Frame resource object. Only Synergy Frames and associated Logical Enclosures are supported with this Cmdlet." + $ErrorRecord = New-ErrorRecord HPEOneView.EnclosureResourceException UnsupportedEnclosureType InvalidArgument -TargetType 'PSObject' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + } + + switch ($PSBoundParameters.Keys) + { + + 'Name' + { + + $_UpdatedLogicalEnclosure.name = $Name + + } + + 'EnclosureGroup' + { + + # Validate EG + switch ($EnclosureGroup.GetType().Name) + { + + 'PSCustomObject' + { + + "[{0}] Enclosure Group object: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), ($EnclosureGroup | ConvertTo-Json -Depth 99 | Out-String) | Write-Verbose + + if ($EnclosureGroup.category -ne $ResourceCategoryEnum['EnclosureGroup']) + { + + $ExceptionMessage = "The provided -EnclosureGroup resource object is not an Enclosure Group. Please correct the input object and try again." + $ErrorRecord = New-ErrorRecord HPEOneView.EnclosureGroupResourceException InvalidResourceObject InvalidArgument -TargetType 'PSObject' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + 'String' + { + + "[{0}] Enclosure Group Name provided: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $EnclosureGroup | Write-Verbose + + Try + { + + $EnclosureGroup = Get-OVEnclosureGroup -Name $EnclosureGroup -ErrorAction Stop -ApplianceConnection $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + $_UpdatedLogicalEnclosure.enclosureGroupUri = $EnclosureGroup.uri + + } + + 'PowerMode' + { + + $_UpdatedLogicalEnclosure.powerMode = $FramePowerModeEnum[$PowerMode] + + } + + 'AmbientTemperatureSetting' + { + + $_UpdatedLogicalEnclosure.ambientTemperatureMode = $FrameAmbientTemperatureEnum[$AmbientTemperatureSetting] + + } + + } + + Try + { + + $resp = Send-OVRequest -Uri $InputObject.uri -Method PUT $_UpdatedLogicalEnclosure -Hostname $ApplianceConnection.Name + + if (-not $PSBoundParameters['Async']) + { + + $resp = $resp | Wait-OVTaskComplete -TimeOut (New-TimeSpan -Minutes 45) + + } + + [void]$_TaskResources.Add($resp) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if ($PSBoundParameters['ConfigurationScript']) + { + + # Need to test this if true. + # if ($PSBoundParameters['Async']) + # { + + # "[{0}] Async it not supported while also needing to update the Logical Enclosure configuration script." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + # $resp | Wait-OVTaskComplete -TimeOut (New-TimeSpan -Minutes 45) + + # } + + "[{0}] Setting Logical Enclosure configuration script." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_Uri = '{0}/script' -f $InputObject.uri + + Try + { + + $_resp = Send-OVRequest -Uri $_Uri -Method PUT -Body $ConfigurationScript -Hostname $InputObject.ApplianceConnection + + if (-not $PSBoundParameters['Async']) + { + + $_resp = $_resp | Wait-OVTaskComplete + + } + + [void]$_TaskResources.Add($_resp) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + End + { + + '[{0}] Done.' -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + return $_TaskResources + + } + +} + +function Update-OVLogicalEnclosure +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "Reapply", SupportsShouldProcess, ConfirmImpact = 'High')] + Param + ( + + [Parameter (ValueFromPipeline, Mandatory = $false, ParameterSetName = "Update")] + [Parameter (ValueFromPipeline, Mandatory = $false, ParameterSetName = "Reapply")] + [ValidateNotNullOrEmpty()] + [Alias ('le','LogicalEnclosure')] + [object]$InputObject, + + [Parameter (ValueFromPipelineByPropertyName, Mandatory = $false, ParameterSetName = "Update")] + [Parameter (ValueFromPipelineByPropertyName, Mandatory = $false, ParameterSetName = "Reapply")] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default), + + [Parameter (Mandatory, ParameterSetName = "Update")] + [Alias ('UpdateFromGroup')] + [Switch]$Update, + + [Parameter (Mandatory, ParameterSetName = "Reapply")] + [Switch]$Reapply, + + [Parameter (Mandatory = $false, ParameterSetName = "Update")] + [Parameter (Mandatory = $false, ParameterSetName = "Reapply")] + [Switch]$Async + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not($PSBoundParameters['InputObject'])) + { + + $PipelineInput = $True + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + $_TaskCollection = [System.Collections.ArrayList]::new() + $_LogicalEnclosureCollection = [System.Collections.ArrayList]::new() + + } + + Process + { + + if ($PipelineInput -or $InputObject) + { + + "[{0}] Processing Pipeline input." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + # Error if the input value is not a PSObject + if (-not $InputObject -is [PSCustomObject]) + { + + $ErrorRecord = New-ErrorRecord HPEOneView.LogicalEnclosureResourceException InvalidLogicalEnclosureObjectType InvalidArgument 'InputObject' -TargetType 'PSObject' -Message "The provided LogicalEnclosure value is not a valid PSObject ($($LogicalEnclosure.GetType().Name)). Please correct your input value." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + "[{0}] LogicalEnclosure PSObject: $($InputObject | Out-String)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + # Validate the Input object is the allowed category + if ($InputObject.category -ne $ResourceCategoryEnum['LogicalEnclosure']) + { + + $ErrorRecord = New-ErrorRecord HPEOneView.LogicalEnclosureResourceException InvalidLogicalEnclosureCategory InvalidArgument 'InputObject' -TargetType 'PSObject' -Message "The provided LogicalEnclosure object ($($LogicalEnclosure.name)) category '$($LogicalEnclosure.category)' is not an allowed value. Expected category value is 'logical-enclosures'. Please correct your input value." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + if(-not $InputObject.ApplianceConnection) + { + + $ErrorRecord = New-ErrorRecord HPEOneView.LogicalEnclosureResourceException InvalidLogicalEnclosureObject InvalidArgument 'InputObject' -TargetType 'PSObject' -Message "The provided LogicalEnclosure object ($($LogicalEnclosure.name)) does not contain the required 'ApplianceConnection' object property. Please correct your input value." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + [void]$_LogicalEnclosureCollection.Add($InputObject) + + } + + # Not Pipeline input, and support Array of Logical Enclosure Name or PSObject + else + { + + "[{0}] Processing InputObject Parameter." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + "[{0}] InputObject is [$($InputObject.GetType().Name)]." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + ForEach ($_le in $InputObject) + { + + "[{0}] InputObject value: $($_le)." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + "[{0}] Looking for Logical Enclosure Name on connected sessions provided" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + # Loop through all Appliance Connections + ForEach ($_appliance in $ApplianceConnection) + { + + "[{0}] Processing '$($_appliance.Name)' Session." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $_resp = Get-OVLogicalEnclosure $_le -ApplianceConnection $_appliance.Name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + [void]$_LogicalEnclosureCollection.Add($_resp) + + } + + } + + } + + } + + End + { + # Perform the work + ForEach ($_leObject in $_LogicalEnclosureCollection) + { + + "[{0}] Processing Logical Enclosure: '$($_leObject.name) [$($_leObject.uri)]'" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $NothingToDo = $false + + switch ($PSCmdlet.ParameterSetName) + { + + "Reapply" + { + + "[{0}] Reapply configuration." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $uri = $_leObject.uri + "/configuration" + + } + + "Update" + { + + "[{0}] Update from Group." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $uri = $_leObject.uri + "/updateFromGroup" + + if ($_leObject.state -eq 'Consistent') + { + + $NothingToDo = $true + + } + + } + + } + + if ((-not $NothingToDo) -and $PSCmdlet.ShouldProcess($_leObject.name,"$($PSCmdlet.ParameterSetName) Logical Enclosure configuration. WARNING: Depending on this action, there might be a brief outage.")) + { + + "[{0}] Sending request to $($PSCmdlet.ParameterSetName) configuration" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $_task = Send-OVRequest $uri PUT -Hostname $_leObject.ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if (-not($PSBoundParameters['Async'])) + { + + $_task | Wait-OVTaskComplete + + } + + else + { + + $_task + + } + + } + + elseif ($NothingToDo) + { + + Write-Warning ("The {0} Logical Enclosure is already consistent. There is nothing to do." -f $_leObject.Name) + + } + + elseif ($PSBoundParameters['WhatIf']) + { + + "[{0}] User included -WhatIf." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if ($PSCmdlet.ParameterSetName -eq 'Update') + { + + Try + { + + Compare-LogicalInterconnect -InputObject $_leObject + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + "[{0}] User cancelled." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + } + + } + +} + +function Update-OVLogicalEnclosureFirmware +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "Default", SupportsShouldProcess, ConfirmImpact = 'High')] + Param + ( + + [Parameter (ValueFromPipeline, Mandatory, ParameterSetName = "Default")] + [ValidateNotNullOrEmpty()] + [Alias ('le','LogicalEnclosure')] + [object]$InputObject, + + [Parameter (Mandatory, ParameterSetName = "Default")] + [ValidateNotNullOrEmpty()] + [HPEOneView.Appliance.Baseline]$Baseline, + + [Parameter (Mandatory, ParameterSetName = "Default")] + [ValidateSet('EnclosureOnly', 'SharedInfrastructureOnly', 'SharedInfrastructureAndServerProfiles')] + [String]$FirmwareUpdateProcess, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [ValidateSet('Orchestrated','Parallel')] + [String]$InterconnectActivationMode = 'Orchestrated', + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Switch]$ForceInstallation, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Switch]$Async, + + [Parameter (ValueFromPipelineByPropertyName, Mandatory = $false, ParameterSetName = "Default")] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not($PSBoundParameters['InputObject'])) + { + + $PipelineInput = $True + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + $_TaskCollection = [System.Collections.ArrayList]::new() + $_LogicalEnclosureCollection = [System.Collections.ArrayList]::new() + + } + + Process + { + + ForEach ($_InputObject in $InputObject) + { + + # Resource Validations + + # Validate the Input object is the allowed category + if ($_InputObject.category -ne $ResourceCategoryEnum.LogicalEnclosure) + { + + $ExceptionMessage = "The provided LogicalEnclosure object {0} category '{1}' is not an allowed value. Expected category value is 'logical-enclosures'. Please correct your input value." -f $_InputObject.name, $_InputObject.category + $ErrorRecord = New-ErrorRecord HPEOneView.LogicalEnclosureResourceException InvalidLogicalEnclosureCategory InvalidArgument 'InputObject' -TargetType 'PSObject' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + if ($Baseline.BundleType -ne [HPEOneView.Appliance.BundleType]::ServicePack -and $Baseline.BundleType -ne [HPEOneView.Appliance.BundleType]::SPP -and $Baseline.BundleType -ne [HPEOneView.Appliance.BundleType]::Custom) + { + + $ExceptionMessage = "The provided Baseline object {0} is not a valid resource object. Only an SPP can be used to update firmware. Please correct your input value." -f $Baseline.name + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.BaselineResourceException InvalidBaselineObject InvalidArgument 'Baseline' -TargetType 'PSObject' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + if (-not $baseline.ApplianceConnection.Equals($_InputObject.ApplianceConnection)) + { + + $ExceptionMessage = "The provided LogicalEnclosure object {0} and baseline object {1} are not from the same HPE OneViwe appliance." -f $_InputObject.name, $Baseline.name + $ErrorRecord = New-ErrorRecord HPEOneView.LogicalEnclosureResourceException InvalidLogicalEnclosureCategory InvalidArgument 'InputObject' -TargetType 'PSObject' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + "[{0}] Processing Logical Enclosure: {0} [{1}]'" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_InputObject.name, $_InputObject.uri | Write-Verbose + + $_FirmwareUpdate = NewObject -LogicalEnclosureFirmareUpdate + + $_FirmwareUpdate.firmwareBaselineUri = $Baseline.uri + $_FirmwareUpdate.firmwareUpdateOn = $LogicalEnclosureFirmwareUpdateMethodEnum[$FirmwareUpdateProcess] + $_FirmwareUpdate.forceInstallFirmware = $ForceInstallation.IsPresent + $_FirmwareUpdate.logicalInterconnectUpdateMode = $LogicalInterconnectUpdateModeEnum[$InterconnectActivationMode] + + $_PatchOperation = NewObject -PatchOperation + + $_PatchOperation.op = "replace" + $_PatchOperation.path = "/firmware" + $_PatchOperation.value = $_FirmwareUpdate + + Switch ($LogicalEnclosureFirmwareUpdateMethodEnum[$FirmwareUpdateProcess]) + { + + 'EnclosureOnly' + { + + $_ShouldProcessMessage = 'update enclosure controller (Onboard Administrator or Frame Link Module(s)) only' + + } + + 'SharedInfrastructureOnly' + { + + if ($LogicalInterconnectUpdateModeEnum[$InterconnectActivationMode] -eq $LogicalInterconnectUpdateModeEnum['Parallel']) + { + + Write-Warning "Parallel activation is optimized for faster updates and will cause service outages. Firmware updates using parallel activation should be performed within a maintenance window." + + } + + $_ShouldProcessMessage = 'update all infrastructure components, enclosure controller (Onboard Administrator or Frame Link Module(s)) and Virtual Connect. Servers without assigned Server Profiles will also be updated.' + + } + + 'SharedInfrastructureAndServerProfiles' + { + + if ($LogicalInterconnectUpdateModeEnum[$InterconnectActivationMode] -eq $LogicalInterconnectUpdateModeEnum['Parallel']) + { + + Write-Warning "Parallel activation is optimized for faster updates and will cause service outages. Firmware updates using parallel activation should be performed within a maintenance window." + + } + + $_ShouldProcessMessage = 'update all components within the logical enclosure, including enclosure controller, Virtual Connect and servers' + + } + + } + + if ($ForceInstallation.IsPresent) + { + + Write-Warning "Downgrading the firmware can result in the installation of unsupported firmware and cause hardware to cease operation." + + } + + if ($PSCmdlet.ShouldProcess($_InputObject.name, $_ShouldProcessMessage)) + { + + "[{0}] Sending request to update firmware on the Logical Enclosure with {1} mode" -f $MyInvocation.InvocationName.ToString().ToUpper(), $LogicalEnclosureFirmwareUpdateMethodEnum[$FirmwareUpdateProcess] | Write-Verbose + + Try + { + + $_task = Send-OVRequest -Uri $_InputObject.uri -Method PATCH -Body $_PatchOperation -AddHeader @{'If-Match' = $_InputObject.eTag} -Hostname $_InputObject.ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if (-not($PSBoundParameters['Async'])) + { + + $_task | Wait-OVTaskComplete + + } + + else + { + + $_task + + } + + } + + + elseif ($PSBoundParameters['WhatIf']) + { + + "[{0}] User included -WhatIf." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + # + # // TODO: Need to get API calls to supply the report + # if ($PSCmdlet.ParameterSetName -eq 'Update') + # { + + # Try + # { + + # Compare-LogicalInterconnect -InputObject $_leObject + + # } + + # Catch + # { + + # $PSCmdlet.ThrowTerminatingError($_) + + # } + + # } + + } + + else + { + + "[{0}] User cancelled." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + } + + } + + End + { + + '[{0}] Done.' -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Remove-OVLogicalEnclosure +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "default",SupportsShouldProcess,ConfirmImpact = 'High')] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = "default")] + [ValidateNotNullOrEmpty()] + [Alias ("uri", "name", "le",'Resource')] + [object]$InputObject, + + [Parameter (ValueFromPipelineByPropertyName, Mandatory = $false, ParameterSetName = "default")] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default), + + [Parameter (Mandatory = $false, ParameterSetName = "default")] + [Switch]$Force + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not($PSBoundParameters['Resource'])) + { + + $PipelineInput = $True + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + $_TaskCollection = [System.Collections.ArrayList]::new() + $_LECollection = [System.Collections.ArrayList]::new() + + } + + Process + { + + if ($PipelineInput) + { + + "[{0}] Processing Pipeline input" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + "[{0}] Logical Enclosure Object provided: {1} ({2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject.name, $InputObject.uri | Write-Verbose + + If ($InputObject.category -eq $ResourceCategoryEnum.LogicalEnclosure) + { + + If (-not($InputObject.ApplianceConnection)) + { + + $ErrorRecord = New-ErrorRecord InvalidOperationException InvalidArgumentValue InvalidArgument 'InputObject' -TargetType PSObject -Message "The Network resource provided is missing the source ApplianceConnection property. Please check the object provided and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + [void]$_LECollection.Add($InputObject) + + } + + else + { + + $ErrorRecord = New-ErrorRecord InvalidOperationException InvalidArgumentValue InvalidArgument 'InputObject' -TargetType PSObject -Message "The Enclosure resource is not an expected category type [$($InputObject.category)]. Allowed resource category type is 'enclosures'. Please check the object provided and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + else + { + + foreach ($enclosure in $InputObject) + { + + # Enclosure passed is a URI + if (($enclosure -is [String]) -and [System.Uri]::IsWellFormedUriString($enclosure,'Relative')) + { + + "[{0}] Received URI: $($enclosures)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + "[{0}] Getting Enclosure Object" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + # // NEED APPLIANCE NAME HERE with If Condition + Try + { + + $enclosure = Send-OVRequest -Uri $enclosure -ApplianceConnection $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + # Enclosure passed is the Name + elseif (($enclosure -is [String]) -and (-not($enclosure.startsWith("/rest")))) + { + + "[{0}] Received Enclosure Name $($enclosure)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + "[{0}] Getting Enclosure object from Get-OVEnclosure" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + # // NEED APPLIANCE NAME HERE with If Condition + Try + { + + $enclosure = Get-OVLogicalEnclosure -Name $enclosure -ApplianceConnection $ApplianceConnection + + } + + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + # Enclosure passed is an object + elseif ($enclosure -is [PSCustomObject] -and ($enclosure.category -ieq 'enclosures')) + { + + "[{0}] Enclosure Object provided: $($enclosure )" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + else + { + + $ErrorRecord = New-ErrorRecord InvalidOperationException InvalidArgumentValue InvalidArgument 'Resource' -TargetType 'PSObject' -Message "Invalid Resource Parameter: $($enclosure )" + $PSCmdlet.WriteError($ErrorRecord) + + } + + [void]$_LECollection.Add($enclosure) + + } + + } + + } + + End + { + + "[{0}] Processing $($_LECollection.count) Logical Enclosure resources to remove." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + # Process Enclosure Resources + ForEach ($_enclosure in $_LECollection) + { + + # Validate that the LE isn't c-Class as that isn't supported + if (($ConnectedSessions | ? Name -eq $_enclosure.ApplianceConnection).ApplianceType -eq "VMA") + { + + $_Message = 'Only Synergy Logical Enclosure resources are supported. To remove a c-Class based Logical Enclosure, you must remove the enclosure resource with Remove-OVEnclosure.' + $ErrorRecord = New-ErrorRecord HPEOneView.EnclosureResourceException InvalidObjectType InvalidArgument 'InputObject' -TargetType $_enclosure.Gettype().Name -Message $_Message + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($PSCmdlet.ShouldProcess($_enclosure.name,"Remove Logical Enclosure from appliance '$($_enclosure.ApplianceConnection)'")) + { + + "[{0}] Removing Logical Enclosure '$($_enclosure.name)' from appliance '$($_enclosure.ApplianceConnection)'." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + if ($PSBoundParameters['Force']) + { + + $_enclosure.uri += "?force=true" + + } + + $_resp = Send-OVRequest -Uri $_enclosure.Uri -Method DELETE -AddHeader @{'If-Match' = $_enclosure.eTag } -Hostname $_enclosure.ApplianceConnection + + [void]$_TaskCollection.Add($_resp) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + elseif ($PSBoundParameters['WhatIf']) + { + + "[{0}] WhatIf Parameter was passed." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + } + + Return $_TaskCollection + + } + +} + +function Invoke-OVVcmMigration +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "Default", SupportsShouldProcess, ConfirmImpact = "High")] + [Obsolete("This Cmdlet is no longer supported, as the feature was removed starting with HPE OneView 5.50.")] + Param + ( + + [Parameter (Mandatory = $false, ParameterSetName = "Report")] + [Parameter (Mandatory = $false, ParameterSetName = "VCEMMigration")] + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Alias ('oip')] + [ValidateNotNullOrEmpty()] + [System.String]$OAIPAddress, + + [Parameter (Mandatory = $false, ParameterSetName = "Report")] + [Parameter (Mandatory = $false, ParameterSetName = "VCEMMigration")] + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Alias ('ou')] + [ValidateNotNullOrEmpty()] + [System.String]$OAUserName, + + [Parameter (Mandatory = $false, ParameterSetName = "Report")] + [Parameter (Mandatory = $false, ParameterSetName = "VCEMMigration")] + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Alias ('op')] + [ValidateNotNullOrEmpty()] + [System.Object]$OAPassword, + + [Parameter (Mandatory = $false, ParameterSetName = "Report")] + [Parameter (Mandatory = $false, ParameterSetName = "VCEMMigration")] + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [PSCredential]$OACredential, + + [Parameter (Mandatory = $false, ParameterSetName = "Report")] + [Parameter (Mandatory = $false, ParameterSetName = "VCEMMigration")] + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Alias ('vu')] + [ValidateNotNullOrEmpty()] + [System.String]$VCMUserName, + + [Parameter (Mandatory = $false, ParameterSetName = "Report")] + [Parameter (Mandatory = $false, ParameterSetName = "VCEMMigration")] + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Alias ('vp')] + [ValidateNotNullOrEmpty()] + [System.Object]$VCMPassword, + + [Parameter (Mandatory = $false, ParameterSetName = "Report")] + [Parameter (Mandatory = $false, ParameterSetName = "VCEMMigration")] + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [PSCredential]$VCMCredential, + + [Parameter (Mandatory = $false, ValueFromPipeline, ParameterSetName = "Report")] + [Parameter (Mandatory = $false, ValueFromPipeline, ParameterSetName = "VCEMMigration")] + [Parameter (Mandatory = $false, ValueFromPipeline, ParameterSetName = "Default")] + [Alias ('eg')] + [ValidateScript({ + if (($_ -is [String]) -and ($_.StartsWith('/rest/')) -and (-not ($_.StartsWith('/rest/enclosure-groups')))) { Throw "'$_' is not an allowed resource URI. Enclosure Group Resource URI must start with '/rest/enclosure-groups'. Please check the value and try again." } + elseif ($_ -is [String] -and ($_.StartsWith('/rest/'))) { $True } + elseif ($_ -is [String]) { $True } + + elseif (($_ -is [PSCustomObject]) -and (-not ($_.category -eq $ResourceCategoryEnum.EnclosureGroup))) { + + if ($_.category) { Throw "'$_.category' is not an allowed resource category. The resource object category must be 'enclosure-groups'. Please check the value and try again." } + else { Throw "The object provided does not contain an the allowed resource category 'enclosure-groups'. Please check the value and try again." } + } + else { $True } })] + [Object]$EnclosureGroup, + + [Parameter (Mandatory = $false, ParameterSetName = "Report")] + [Parameter (Mandatory = $false, ParameterSetName = "VCEMMigration")] + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Alias ('lig')] + [ValidateScript({ + if (($_ -is [String]) -and ($_.StartsWith('/rest/')) -and (-not ($_.StartsWith('/rest/logical-interconnect-groups')))) { Throw "'$_' is not an allowed resource URI. Logical Interconnect Group Resource URI must start with '/rest/logical-interconnect-groups'. Please check the value and try again." } + elseif ($_ -is [String] -and ($_.StartsWith('/rest/'))) { $True } + elseif ($_ -is [String]) { $True } + + elseif (($_ -is [PSCustomObject]) -and (-not ($_.category -eq $ResourceCategoryEnum.LogicalInterconnectGroup))) { + + if ($_.category) { Throw "'$_.category' is not an allowed resource category. The resource object category must be 'logical-interconnect-groups'. Please check the value and try again." } + else { Throw "The object provided does not contain an the allowed resource category 'logical-interconnect-groups'. Please check the value and try again." } + } + else { $True } })] + [Object]$LogicalInterconnectGroup, + + [Parameter (Mandatory = $false, ParameterSetName = "Report")] + [Parameter (Mandatory = $false, ParameterSetName = "VCEMMigration")] + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [ValidateSet ("OneView", "OneViewNoiLO", IgnoreCase = $false)] + [ValidateNotNullOrEmpty()] + [Alias ("license", "l")] + [System.String]$LicensingIntent, + + [Parameter (Mandatory = $false, ParameterSetName = "VCEMMigration")] + [String]$VCEMCMS, + + [Parameter (Mandatory = $false, ParameterSetName = "VCEMMigration")] + [String]$VCEMUser, + + [Parameter (Mandatory = $false, ParameterSetName = "VCEMMigration")] + [System.Object]$VCEMPassword, + + [Parameter (Mandatory = $false, ParameterSetName = "VCEMMigration")] + [PSCredential]$VCEMCredential, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Alias ('NoWait')] + [Switch]$Async, + + [Parameter (Mandatory = $false, ParameterSetName = "Report")] + [Switch]$Report, + + [Parameter (Mandatory = $false, ParameterSetName = "Report")] + [Alias ("Export")] + [ValidateScript({ + if ({split-path $_ | Test-Path}) { $True } + else { Throw "'$(Split-Path $_)' is not a valid directory. Please verify $(Split-Path $_) exists and try again." } + })] + [System.IO.FileInfo]$Path, + + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = "Default")] + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = "VCEMMigration")] + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = "Report")] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + +} + +function Get-OVEnclosure +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "default")] + Param + ( + + [Parameter (Mandatory = $false, ParameterSetName = "default")] + [Parameter (Mandatory = $false, ParameterSetName = "export")] + [Parameter (Mandatory = $false, ParameterSetName = "report")] + [validateNotNullorEmpty()] + [String]$Name, + + [Parameter (Mandatory = $false, ParameterSetName = "default")] + [Parameter (Mandatory = $false, ParameterSetName = "export")] + [Parameter (Mandatory = $false, ParameterSetName = "report")] + [ValidateNotNullOrEmpty()] + [Object]$Scope = "AllResourcesInScope", + + [Parameter (Mandatory = $false, ParameterSetName = "default")] + [Parameter (Mandatory = $false, ParameterSetName = "export")] + [Parameter (Mandatory = $false, ParameterSetName = "report")] + [ValidateNotNullOrEmpty()] + [String]$Label, + + [Parameter (Mandatory = $false, ParameterSetName = "default")] + [Parameter (Mandatory = $false, ParameterSetName = "export" )] + [Parameter (Mandatory = $false, ParameterSetName = "report")] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default), + + [Parameter (Mandatory = $false, ParameterSetName = "export")] + [Alias ("x", "export")] + [ValidateScript({split-path $_ | Test-Path})] + [String]$exportFile, + + [Parameter (Mandatory = $false, ParameterSetName = "report")] + [Switch]$Report + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $_EnclosureCollection = [System.Collections.ArrayList]::new() + + } + + Process + { + + ForEach ($_appliance in $ApplianceConnection) + { + + # Display obselete message if the connection is a VM, not Synergy + [ObsoleteMessage]::Write($_appliance) + + "[{0}] Processing '{1}' Appliance (of {2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name, $ApplianceConnection.Count | Write-Verbose + + $_Query = [System.Collections.ArrayList]::new() + + # Handle default cause of AllResourcesInScope + if ($Scope -eq 'AllResourcesInScope') + { + + "[{0}] Processing AllResourcesInScope." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_Scopes = $_appliance.ActivePermissions | Where-Object Active + + # If one scope contains 'AllResources' ScopeName "tag", then all resources should be returned regardless. + if ($_Scopes | Where-Object ScopeName -eq 'AllResources') + { + + $_ScopeNames = [String]::Join(', ', ($_Scopes | Where-Object ScopeName -eq 'AllResources').ScopeName) + + "[{0}] Scope(s) {1} is set to 'AllResources'. Will not add scope to URI query parameter." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_ScopeNames | Write-Verbose + + } + + # Process ApplianceConnection ActivePermissions collection + else + { + + Try + { + + $_ScopeQuery = Join-Scope $_Scopes + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + [Void]$_Query.Add(("({0})" -f $_ScopeQuery)) + + } + + } + + elseif ($Scope | Where-Object ScopeName -eq 'AllResources') + { + + $_ScopeNames = [String]::Join(', ', ($_Scopes | Where-Object ScopeName -eq 'AllResources').ScopeName) + + "[{0}] Scope(s) {1} is set to 'AllResources'. Will not add scope to URI query parameter." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_ScopeNames | Write-Verbose + + } + + elseif ($Scope -eq 'AllResources') + { + + "[{0}] Requesting scope 'AllResources'. Will not add scope to URI query parameter." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_ScopeNames | Write-Verbose + + } + + else + { + + Try + { + + $_ScopeQuery = Join-Scope $Scope + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + [Void]$_Query.Add(("({0})" -f $_ScopeQuery)) + + } + + if ($Name) + { + + if ($Name.Contains('*')) + { + + [Void]$_Query.Add(("name%3A{0}" -f $Name.Replace("*", "%2A"))) + + } + + else + { + + [Void]$_Query.Add(("name:'{0}'" -f $Name)) + + } + + } + + if ($Label) + { + + [Void]$_Query.Add(("labels:'{0}'" -f $Label)) + + } + + # Build the final URI + $_uri = '{0}?category=enclosures&sort=name:asc&query={1}' -f $IndexUri, [String]::Join(' AND ', $_Query.ToArray()) + + Try + { + + [Array]$_ResourcesFromIndexCol = Get-AllIndexResources -Uri $_uri -ApplianceConnection $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if ($_ResourcesFromIndexCol.count -eq 0 -and $Name) + { + + "[{0}] Enclosure '{1}' resource not found. Generating error" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Name | Write-Verbose + + $ExceptionMessage = "The specified Enclosure '{0}' was not found on '{1}' appliance. Please check the name and try again." -f $Name, $_appliance.Name + $ErrorRecord = New-ErrorRecord InvalidOperationException EnclosureGroupNotFound ObjectNotFound 'Name' -Message $ExceptionMessage + $PSCmdlet.WriteError($ErrorRecord) + + } + + elseif ($_ResourcesFromIndexCol.count -eq 0) + { + + "[{0}] No Enclosure resources found on {1}." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.name | Write-Verbose + + } + + ForEach ($_member in $_ResourcesFromIndexCol) + { + + "[{0}] Adding Enclosure resource '{1}' to collection." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_member.name | Write-Verbose + + $_member.PSObject.TypeNames.Insert(0,'HPEOneView.Servers.Enclosure') + + [void]$_EnclosureCollection.Add($_member) + + } + + } + + } + + End + { + + "[{0}] Done. {1} enclosure(s) found." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_EnclosureCollection.count | Write-Verbose + + # Display a report of an enclsosure + if ($Report) + { + + $_EnclosureCollection | ForEach-Object { Enclosure-Report $_ } + + } + + # Display the JSON body of the enclosure + elseif ($exportFile) + { + + $_EnclosureCollection | convertto-json -depth 99 > $exportFile + + } + + # else Return enclosure object + else + { + + "[{0}] Return collection." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Return $_EnclosureCollection + + } + + } + +} + +function Reset-OVEnclosureDevice +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "default", SupportsShouldProcess, ConfirmImpact = 'High')] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = "default")] + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = "ManagerOrDeviceBay")] + [Alias('Enclosure')] + [ValidateNotNullOrEmpty()] + [Object]$InputObject, + + [Parameter (ParameterSetName = "default", Mandatory)] + [Parameter (ParameterSetName = "ManagerOrDeviceBay", Mandatory)] + [ValidateNotNullorEmpty()] + [ValidateSet ('FLM','Appliance','ICM','Device')] + [String]$Component, + + [Parameter (ParameterSetName = "default", Mandatory)] + [Parameter (ParameterSetName = "ManagerOrDeviceBay", Mandatory)] + [ValidateNotNullorEmpty()] + [Int]$DeviceID, + + [Parameter (ParameterSetName = 'ManagerOrDeviceBay', Mandatory)] + [Switch]$Reset, + + [Parameter (ParameterSetName = 'default', Mandatory = $False)] + [Switch]$Efuse, + + [Parameter (ParameterSetName = 'default', Mandatory = $False)] + [Parameter (ParameterSetName = 'ManagerOrDeviceBay', Mandatory = $False)] + [Switch]$Async, + + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = "default")] + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = "ManagerOrDeviceBay")] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not($PSBoundParameters['InputObject'])) + { + + $PipelineInput = $True + + } + + else + { + + if ($InputObject -isnot [PSCustomObject]) + { + + $_Message = 'An invalid Enclosure object type was provided, {0}. This Cmdlet only support PSObject types from Get-OVEnclosure. Please check the value and try agin.' + $ErrorRecord = New-ErrorRecord HPEOneView.EnclosureResourceException InvalidObjectType InvalidArgument 'Enclosure' -TargetType $Enclosure.Gettype().Name -Message $_Message + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + $_TaskCollection = [System.Collections.ArrayList]::new() + $_EnclosureCollection = [System.Collections.ArrayList]::new() + + } + + Process + { + + if ($InputObject.enclosureModel -notmatch 'Synergy') + { + + $ExceptionMessage = 'The InputObject {0} is not a supported resource to set the Enclosure Name. For C-Class, you must use the Onboard Administrator to e-Fuse a supported resource.' -f $InputObject.name + $ErrorRecord = New-ErrorRecord InvalidOperationException InvalidArgumentValue InvalidArgument 'InputObject' -TargetType 'PSObject' -Message $ExceptionMessage + $PSCmdlet.WriteError($ErrorRecord) + + } + + else + { + + if ($InputObject -isnot [PSCustomObject] -and $InputObject.category -ne $ResourceCategoryEnum.Enclosure) + { + + $_Message = 'An invalid Enclosure object type was provided, {0}. This Cmdlet only support PSObject types from Get-OVEnclosure. Please check the value and try agin.' -f $InputObject.Gettype().Name + $ErrorRecord = New-ErrorRecord HPEOneView.EnclosureResourceException InvalidObjectType InvalidArgument 'InputObject' -TargetType $InputObject.Gettype().Name -Message $_Message + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + if (-not($InputObject.ApplianceConnection)) + { + + $_Message = 'The provided Enclosure resource object is missing the ApplianceConnection property. This Cmdlet only support PSObject types from Get-OVEnclosure. Please check the value and try agin.' + $ErrorRecord = New-ErrorRecord HPEOneView.EnclosureResourceException InvalidObjectType InvalidArgument 'InputObject' -TargetType $InputObject.Gettype().Name -Message $_Message + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + $_Operation = NewObject -PatchOperation + $_Operation.op = 'replace' + $_Operation.value = 'E-Fuse' + + switch ($Component) + { + + 'FLM' + { + + $_Operation.path = '/managerBays/{0}/bayPowerState' -f $DeviceID + + if ($PSBoundParameters['Reset']) + { + + $_Operation.value = 'Reset' + + } + + } + + 'Device' + { + + $_Operation.path = '/deviceBays/{0}/bayPowerState' -f $DeviceID + + if ($PSBoundParameters['Reset']) + { + + $_Operation.value = 'Reset' + + } + + } + + 'ICM' + { + + $_Operation.path = '/interconnectBays/{0}/bayPowerState' -f $DeviceID + + } + + 'Appliance' + { + + $_Operation.path = '/applianceBays/{0}/bayPowerState' -f $DeviceID + + } + + } + + "[{0}] Power Operation: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), ($_Operation | Out-String) | Write-Verbose + + if ($PSCmdlet.ShouldProcess(('{0} {1} within {2}' -f $Component, $DeviceID, $InputObject.name),'Reset power for device')) + { + + Try + { + + $_resp = Send-OVRequest -Uri $InputObject.Uri -Method PATCH -Body $_Operation -AddHeader @{'If-Match' = $InputObject.eTag} -Hostname $InputObject.ApplianceConnection | Wait-OVTaskStart + + if (-not($PSBoundParameters['Async'])) + { + + $_resp = Wait-OVTaskComplete $_resp + + } + + $_resp + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + elseif ($PSCmdlet.PSBoun['WhatIf']) + { + + "[{0}] WhatIf operation." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + else + { + + "[{0}] User cancelled operation." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + } + + } + + End + { + + '[{0}] Done.' -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Set-OVEnclosureActiveFLM +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "default", SupportsShouldProcess,ConfirmImpact = 'High')] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = "default")] + [ValidateNotNullOrEmpty()] + [object]$Enclosure, + + [Parameter (Mandatory, ParameterSetName = "default")] + [ValidateNotNullOrEmpty()] + [Int]$BayID, + + [Parameter (Mandatory = $false)] + [Switch]$Force + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not($PSBoundParameters['Enclosure'])) + { + + $PipelineInput = $True + + } + + else + { + + if ($Enclosure -isnot [PSCustomObject]) + { + + $_Message = 'An invalid Enclosure object type was provided, {0}. This Cmdlet only support PSObject types from Get-OVEnclosure. Please check the value and try agin.' + $ErrorRecord = New-ErrorRecord HPEOneView.EnclosureResourceException InvalidObjectType InvalidArgument 'Enclosure' -TargetType $Enclosure.Gettype().Name -Message $_Message + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + + $_TaskCollection = [System.Collections.ArrayList]::new() + + } + + Process + { + + if ($Enclosure -isnot [PSCustomObject] -and $Enclosure.category -ne $ResourceCategoryEnum.Enclosure) + { + + $_Message = 'An invalid Enclosure object type was provided, {0}. This Cmdlet only support PSObject types from Get-OVEnclosure. Please check the value and try agin.' -f $Enclosure.Gettype().Name + $ErrorRecord = New-ErrorRecord HPEOneView.EnclosureResourceException InvalidObjectType InvalidArgument 'Enclosure' -TargetType $Enclosure.Gettype().Name -Message $_Message + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + if (-not($Enclosure.ApplianceConnection)) + { + + $_Message = 'The provided Enclosure resource object is missing the ApplianceConnection property. This Cmdlet only support PSObject types from Get-OVEnclosure. Please check the value and try agin.' + $ErrorRecord = New-ErrorRecord HPEOneView.EnclosureResourceException InvalidObjectType InvalidArgument 'Enclosure' -TargetType $Enclosure.Gettype().Name -Message $_Message + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + $_Operation = NewObject -PatchOperation + $_Operation.op = 'replace' + $_Operation.path = '/managerBays/{0}/role' -f $BayID + $_Operation.value = 'Active' + + "[{0}] Requesting to Activate FLM in Bay {1} within {2} Enclosure" -f $MyInvocation.InvocationName.ToString().ToUpper(), $BayID, $Enclosure.name | Write-Verbose + + if ($PSCmdlet.ShouldProcess(('FLM Bay {0} within {1} Enclosure' -f $BayID, $Enclosure.name),'Change FLM State to Active')) + { + + Try + { + + $_resp = Send-OVRequest $Enclosure.Uri PATCH $_Operation -Hostname $Enclosure.ApplianceConnection | Wait-OVTaskStart + + if (-not($PSBoundParameters['Async'])) + { + + $_resp = Wait-OVTaskComplete $_resp + + } + + [Void]$_TaskCollection.Add($_resp) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + elseif ($PSCmdlet.PSBoun['WhatIf']) + { + + "[{0}] WhatIf operation." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + else + { + + "[{0}] User cancelled operation." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + } + + End + { + + Return $_TaskCollection + + } + +} + +function Set-OVEnclosure +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "default")] + Param + ( + + [Parameter (ValueFromPipeline, Mandatory, ParameterSetName = "default")] + [ValidateNotNullOrEmpty()] + [Alias('Enclosure', 'Encl')] + [object]$InputObject, + + [Parameter (Mandatory = $False, ParameterSetName = "default")] + [ValidateNotNullOrEmpty()] + [String]$Name, + + [Parameter (Mandatory = $False, ParameterSetName = "default")] + [ValidateNotNullOrEmpty()] + [String]$RackName, + + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = "default")] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not($PSBoundParameters['InputObject'])) + { + + $PipelineInput = $True + + } + + # Support ApplianceConnection property value via pipeline from Enclosure Object + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + $_RequestCollection = [System.Collections.ArrayList]::new() + $_TaskCollection = [System.Collections.ArrayList]::new() + + } + + Process + { + + "[{0}] Processing Enclosure: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject.name | Write-Verbose + + if ($InputObject.enclosureModel -notmatch 'Synergy' -and ($PSBoundParameters['Name'] -or $PSBoundParameters['RackName'])) + { + + $ExceptionMessage = 'The InputObject {0} is not a supported resource to set the Enclosure Name. For C-Class, you must update the Enclosure or Rack Name within the Onboard Administrator.' -f $InputObject.name + $ErrorRecord = New-ErrorRecord InvalidOperationException InvalidArgumentValue InvalidArgument 'InputObject' -TargetType 'PSObject' -Message $ExceptionMessage + $PSCmdlet.WriteError($ErrorRecord) + + } + + elseif ($PSBoundParameters['Name']) + { + + "[{0}] Setting Enclosure Name to: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Name | Write-Verbose + + $_PatchRequest = NewObject -PatchOperation + + $_PatchRequest.op = 'replace' + $_PatchRequest.path = '/name' + $_PatchRequest.value = $Name + + [void]$_RequestCollection.Add($_PatchRequest) + + Try + { + + $_resp = Send-OVRequest $InputObject.uri PATCH $_RequestCollection -AddHeader @{'If-Match' = $InputObject.eTag} -Hostname $InputObject.ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + if ($PSBoundParameters['RackName']) + { + + "[{0}] Setting Enclosure RackName to: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $RackName | Write-Verbose + + if ($PSBoundParameters['Name']) + { + + Try + { + + $_resp = Wait-OVTaskComplete -InputObject $_resp + + [void]$_TaskCollection.Add($_resp) + + "[{0}] Getting updated object" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $InputObject = Send-OVRequest -Uri $InputObject.uri -Hostname $InputObject.ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $_RequestCollection = [System.Collections.ArrayList]::new() + + $_PatchRequest = NewObject -PatchOperation + + $_PatchRequest.op = 'replace' + $_PatchRequest.path = '/rackName' + $_PatchRequest.value = $RackName + + [void]$_RequestCollection.Add($_PatchRequest) + + Try + { + + $_resp = Send-OVRequest $InputObject.uri PATCH $_RequestCollection -AddHeader @{'If-Match' = $InputObject.eTag} -Hostname $InputObject.ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + [void]$_TaskCollection.Add($_resp) + + } + + End + { + + Return $_TaskCollection + + } + +} + +function Start-OVEnclosureAppliance +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "default")] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = "default")] + [ValidateNotNullOrEmpty()] + [Alias ("Encl")] + [Object]$InputObject, + + [Parameter (Mandatory, ParameterSetName = "default")] + [ValidateRange(1,2)] + [Int]$BayID, + + [Parameter (Mandatory = $False, ParameterSetName = "default")] + [Switch]$Async, + + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = "default")] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not($PSBoundParameters['Enclosure'])) + { + + $PipelineInput = $True + + } + + else + { + + if ($Enclosure -isnot [PSCustomObject] -or ($Enclosure -is [PSCustomObject] -and $Enclosure.category -ne $ResourceCategoryEnum.Enclosure) -or ($Enclosure.model -notmatch 'Synergy')) + { + + $Message = '{0} is an unsupported resource object ({1}). This Cmdlet only supports Synergy Frame resource objects.' -f $Enclosure.name, $Enclosure.category + $ErrorRecord = New-ErrorRecord HPEOneView.EnclosureResourceException InvalidResoureObject InvalidArgument 'Enclosure' -Message $Message + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + $_TaskCollection = [System.Collections.ArrayList]::new() + + } + + Process + { + + "[{0}] Processing Enclosure: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject.name | Write-Verbose + + if ($PipelineInput) + { + + Try + { + + $ApplianceConnection = Test-OVAuth $Enclosure.ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + Try + { + + # Validate to make sure the Appliance bay is not already powered on. + $_InputObject = Send-OVRequest $InputObject.uri -ApplianceConnection $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if (($_InputObject.applianceBays | Where-Object bayNumber -eq $BayID).poweredOn) + { + + '[{0}]Appliance Bay {1} in {2} Enclosure is already powered on. Not Processing.' -f $MyInvocation.InvocationName.ToString().ToUpper(), $BayID, $InputObject.name | Write-Warning + + } + + else + { + + '[{0}] Appliance Bay {1} in {2} Enclosure is already powered off. Processing.' -f $MyInvocation.InvocationName.ToString().ToUpper(), $BayID, $InputObject.name | Write-Verbose + + $_PatchRequest = NewObject -PatchOperation + $_PatchRequest.op = 'replace' + $_PatchRequest.path = '/applianceBays/{0}/power' -f $BayID + $_PatchRequest.value = 'on' + + Try + { + + $_resp = Send-OVRequest -Uri $InputObject.uri -Method PATCH -Body $_PatchRequest -ApplianceConnection $ApplianceConnection -AddHeader @{'If-Match' = $InputObject.eTag} + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if (-not $PSBoundParameters['Async']) + { + + $_resp = Wait-OVTaskComplete -InputObject $_resp + + } + + $_resp + + } + + } + + End + { + + '[{0}] Done.' -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Get-OVComposerNode +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding ()] + Param + ( + + [Parameter (Mandatory = $False)] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $_ComposerNodeCollection = [System.Collections.ArrayList]::new() + + } + + Process + { + + ForEach ($_appliance in $ApplianceConnection) + { + + if ($_appliance.ApplianceType -ne 'Composer') + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.ComposerNodeException InvalidOperation InvalidOperation 'ApplianceConnection' -Message ('The ApplianceConnection {0} is not a Synergy Composer. This Cmdlet is only supported with Synergy Composers.' -f $_appliance.Name) + $PSCmdlet.WriteError($ErrorRecord) + + } + + else + { + + "[{0}] Processing Appliance Connection {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name | Write-Verbose + + Try + { + + $_ComposerNodes = Send-OVRequest -Uri $ApplianceHANodesUri -Hostname $_appliance + + $_ComposerNodes.members | ForEach-Object { + + $_.PSObject.TypeNames.Insert(0,'HPEOneView.ComposerNode') + + $_ + + } + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Get-OVApplianceStatus +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding()] + [OutputType([HPEOneView.Appliance.ApplianceStatus])] + Param + ( + + [Parameter (Mandatory = $False)] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $_ComposerNodeCollection = [System.Collections.ArrayList]::new() + + } + + Process + { + + ForEach ($_appliance in $ApplianceConnection) + { + + "[{0}] Processing Appliance Connection {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name | Write-Verbose + + Try + { + + $_ApplianceStatusInfo = Send-OVRequest -Uri $ApplianceStatusInfoUri -Hostname $_appliance + + $_ApplianceStatus = [HPEOneView.Appliance.ApplianceStatus]::new(($_ApplianceStatusInfo.memory * 1GB), + $_ApplianceStatusInfo.memoryStatusError, + $_ApplianceStatusInfo.cpuSpeed, + $_ApplianceStatusInfo.cpuStatusError, + $_ApplianceStatusInfo.lan, + $_ApplianceStatusInfo.lanStatusError, + $_ApplianceStatusInfo.lanLinkStatusError, + [Timespan]::new($_ApplianceStatusInfo.activeUptime.days,$_ApplianceStatusInfo.activeUptime.hours, $_ApplianceStatusInfo.activeUptime.minutes, 0), + $_ApplianceStatusInfo.activeStartTime, + $_ApplianceStatusInfo.ApplianceConnection) + + if (-not [String]::IsNullOrEmpty($_ApplianceStatusInfo.standbyStartTime)) + { + + $_ApplianceStatus | Add-Member -NotePropertyName StandbyStartTime -NotePropertyValue $_ApplianceStatusInfo.standbyStartTime + $_ApplianceStatus | Add-Member -NotePropertyName StandbyUptime -NotePropertyValue [Timespan]::new($_ApplianceStatusInfo.standbyUptime.days,$_ApplianceStatusInfo.standbyUptime.hours, $_ApplianceStatusInfo.standbyUptime.minutes, 0) + + } + + $_ApplianceStatus + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Enable-OVComposerHANode +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (SupportsShouldProcess, ConfirmImpact = 'High')] + Param + ( + + [Parameter (Mandatory = $False)] + [Switch]$Async, + + [Parameter (Mandatory = $False)] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $_ComposerNodeTaskCollection = [System.Collections.ArrayList]::new() + + } + + Process + { + + ForEach ($_appliance in $ApplianceConnection) + { + + "[{0}] Processing Appliance Connection {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name | Write-Verbose + + if ($_appliance.ApplianceType -ne 'Composer') + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.ComposerNodeException InvalidOperation InvalidOperation 'ApplianceConnection' -Message ('The ApplianceConnection {0} is not a Synergy Composer. This Cmdlet is only supported with Synergy Composers.' -f $_appliance.Name) + $PSCmdlet.WriteError($ErrorRecord) + + } + + else + { + + Try + { + + $_ComposerNodes = Send-OVRequest -Uri $ApplianceHANodesUri -Hostname $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $_StandbyComposer = $_ComposerNodes.members | Where-Object role -eq 'Standby' + + if ($_StandbyComposer) + { + + if ($PSCmdlet.ShouldProcess($_StandbyComposer.name,"transition from Standby to Active")) + { + + $_operation = NewObject -PatchOperation + $_operation.op = 'replace' + $_operation.path = '/role' + $_operation.value = 'Standby' + + Try + { + + $_resp = Send-OVRequest $_StandbyComposer.uri PATCH $_operation -Hostname $_appliance -AddHeader @{'If-Match' = $_StandbyComposer.eTag} + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if (-not($PSBoundParameters['Async'])) + { + + Try + { + + $_resp = Wait-OVTaskComplete $_resp + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + [void]$_ComposerNodeTaskCollection.Add($_resp) + + } + + elseif ($PSBoundParameters['Whatif']) + { + + "[{0}] -Whatif scenario." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + else + { + + "[{0}] User cancelled operation." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + } + + else + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.ComposerNodeException NoStandbyComposerFound ObjectNotFound 'Composer' -Message ('No standby Composers were found in {0} ApplianceConnection.' -f $_connection.Name) + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + } + + } + + End + { + + Return $_ComposerNodeTaskCollection + + } + +} + +function Remove-OVStandbyComposerNode +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (SupportsShouldProcess, ConfirmImpact = 'High')] + Param + ( + + [Parameter (Mandatory = $False)] + [Switch]$Async, + + [Parameter (Mandatory = $False)] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $_ComposerNodeTaskCollection = [System.Collections.ArrayList]::new() + + } + + Process + { + + ForEach ($_appliance in $ApplianceConnection) + { + + "[{0}] Processing Appliance Connection {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name | Write-Verbose + + if ($_appliance.ApplianceType -ne 'Composer') + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.ComposerNodeException InvalidOperation InvalidOperation 'ApplianceConnection' -Message ('The ApplianceConnection {0} is not a Synergy Composer. This Cmdlet is only supported with Synergy Composers.' -f $_appliance.Name) + $PSCmdlet.WriteError($ErrorRecord) + + } + + else + { + + Try + { + + $_ComposerNodes = Send-OVRequest -Uri $ApplianceHANodesUri -Hostname $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $_StandbyComposer = $_ComposerNodes.members | Where-Object role -eq 'Standby' + + if ($_StandbyComposer) + { + + if ($PSCmdlet.ShouldProcess($_StandbyComposer.name,"Remove Standby from Cluster, factory reset and power off")) + { + + $_operation = NewObject -PatchOperation + $_operation.op = 'replace' + $_operation.path = '/role' + $_operation.value = 'Unused' + + Try + { + + $_resp = Send-OVRequest -Uri $_StandbyComposer.uri -Method PATCH -Body $_operation -Hostname $_appliance -AddHeader @{'If-Match' = $_StandbyComposer.eTag} + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if (-not($PSBoundParameters['Async'])) + { + + Try + { + + $_resp = Wait-OVTaskComplete $_resp + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + [void]$_ComposerNodeTaskCollection.Add($_resp) + + } + + elseif ($PSBoundParameters['Whatif']) + { + + "[{0}] -Whatif scenario." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + else + { + + "[{0}] User cancelled operation." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + } + + else + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.ComposerNodeException NoStandbyComposerFound ObjectNotFound 'Composer' -Message ('No standby Composers were found in {0} ApplianceConnection.' -f $_connection.Name) + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + } + + } + + End + { + + Return $_ComposerNodeTaskCollection + + } + +} + +function Enable-OVComposerIlo +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (SupportsShouldProcess, ConfirmImpact = 'High', DefaultParameterSetName = "Default")] + Param + ( + + [Parameter (Mandatory, ParameterSetName = "Default")] + [Parameter (Mandatory, ParameterSetName = "StaticAddress")] + [ValidateNotNullorEmpty()] + [Object]$InputObject, + + [Parameter (Mandatory, ParameterSetName = "Default")] + [Parameter (Mandatory, ParameterSetName = "StaticAddress")] + [ValidateNotNullorEmpty()] + [String]$Username, + + [Parameter (Mandatory, ParameterSetName = "Default")] + [Parameter (Mandatory, ParameterSetName = "StaticAddress")] + [ValidateNotNullorEmpty()] + [SecureString]$Password, + + [Parameter (Mandatory = $False, ParameterSetName = "StaticAddress")] + [ValidateScript({ [String]::IsNullOrEmpty($_) -or + $_ -match [Net.IPAddress]$_})] + [IPAddress]$IPv4Address, + + [Parameter (Mandatory = $False, ParameterSetName = "StaticAddress")] + [ValidateNotNullorEmpty()] + [String]$IPv4SubnetMask, + + [Parameter (Mandatory = $False, ParameterSetName = "StaticAddress")] + [ValidateScript({ [String]::IsNullOrEmpty($_) -or + $_ -match [Net.IPAddress]$_})] + [IPAddress]$IPv4Gateway, + + [Parameter (Mandatory = $False, ParameterSetName = "StaticAddress")] + [ValidateNotNullorEmpty()] + [IPAddress[]]$IPv4DnsServer, + + [Parameter (Mandatory = $False, ParameterSetName = "StaticAddress")] + [ValidateScript({ [String]::IsNullOrEmpty($_) -or + $_ -match [Net.IPAddress]$_})] + [IPAddress]$IPv6Address, + + [Parameter (Mandatory = $False, ParameterSetName = "StaticAddress")] + [ValidateNotNullorEmpty()] + [String]$IPv6SubnetMask, + + [Parameter (Mandatory = $False, ParameterSetName = "StaticAddress")] + [ValidateNotNullorEmpty()] + [IPAddress]$IPv6Gateway, + + [Parameter (Mandatory = $False, ParameterSetName = "StaticAddress")] + [ValidateNotNullorEmpty()] + [IPAddress[]]$IPv6DnsServer, + + [Parameter (Mandatory = $False, ParameterSetName = "StaticAddress")] + [ValidateNotNullorEmpty()] + [String]$IloHostname, + + [Parameter (Mandatory = $False, ParameterSetName = "Default")] + [Parameter (Mandatory = $False, ParameterSetName = "StaticAddress")] + [Switch]$Async, + + [Parameter (Mandatory = $False, ParameterSetName = "Default")] + [Parameter (Mandatory = $False, ParameterSetName = "StaticAddress")] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if ($PSBoundParameters['IPv6Address']) + { + + if (-not $PSBoundParameters['IPv6SubnetMask']) + { + + $ExceptionMessage = "The IPv6Address parameter was provided but did not include the required IPv6SubnetMask parameter." + $ErrorRecord = New-ErrorRecord InvalidOperationException InvalidArgumentValue InvalidArgument 'IPv6Address' -TargetType PSObject -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + + if (-not $PSBoundParameters['IPv6Gateway']) + { + + $ExceptionMessage = "The IPv6Address parameter was provided but did not include the required IPv6Gateway parameter." + $ErrorRecord = New-ErrorRecord InvalidOperationException InvalidArgumentValue InvalidArgument 'IPv6Gateway' -TargetType PSObject -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + if (($IPv4SubnetMask -lt 1 -or $IPv4SubnetMask -gt 32) -and ($IPv4SubnetMask -notmatch $IPSubnetAddressPattern)) + { + + $Exceptionmessage = "The provided SubnetID {0} does not appear to be a valid Subnet Mask." -f $IPv4SubnetMask + $ErrorRecord = New-ErrorRecord InvalidOperationException InvalidIPv4SubnetMask InvalidArgument 'IPv4SubnetMask' -TargetType 'String' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneView.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneView.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneView.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + Process + { + + # Validate Composer type is Composer2 + if ($InputObject.model -ne "SynergyComposer2") + { + + $ExceptionMessage = "The specified '{0}' InputObject parameter value is not a supported HPE Synergy Composer type. Only 'Synergy Composer 2' appliances are supported." -f $InputObject.name + $ErrorRecord = New-ErrorRecord HPEOneView.InputObjectResourceException InvalidInputObjectResource InvalidArgument "InputObject" -TargetType $InputObject.GetType().Name -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + $_NewComposerConfig = NewObject -ComposerIloConfig + + $_NewIPv4Address = NewObject -ComposerIloAddress + $_NewIPv4Address.address = $IPv4Address.IPAddressToString + $_NewIPv4Address.gateway = $IPv4Gateway.IPAddressToString + + # Calculate the CIDR bit value to the SubnetMask Address + if ($PSBoundParameters['IPv4SubnetMask'].Length -le 2) + { + + Try + { + + "[{0}] Converting Subnet CIDR Bit value to Subnet Mask Address." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + [Int64]$_Int64Value = ([convert]::ToInt64(('1' * $IPv4SubnetMask + '0' * (32 - $IPv4SubnetMask)), 2)) + + $_SubnetMask = '{0}.{1}.{2}.{3}' -f ([math]::Truncate($_Int64Value / 16777216)).ToString(), + ([math]::Truncate(($_Int64Value % 16777216) / 65536)).ToString(), + ([math]::Truncate(($_Int64Value % 65536)/256)).ToString(), + ([math]::Truncate($_Int64Value % 256)).ToString() + + $_NewIPv4Address.subnet = $_SubnetMask + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + else + { + + "[{0}] Subnet mask: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $IPv4SubnetMask | Write-Verbose + + $_NewIPv4Address.subnet = $IPv4SubnetMask + + } + + if ($PSBoundParameters['IPv4DnsServer']) + { + + $_NewIPv4Address.preferredDNS = $IPv4DnsServer[0].IPAddressToString + + "[{0}] Primary DNS: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $IPv4DnsServer[0] | Write-Verbose + + if ($IPv4DnsServer.Count -gt 1) + { + + "[{0}] Secondary DNS: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $IPv4DnsServer[1] | Write-Verbose + + $_NewIPv4Address.secondaryDNS = $IPv4DnsServer[1].IPAddressToString + + } + + } + + if ($PSBoundParameters['IPv6Address']) + { + + "[{0}] Will configure IPv6 address: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $IPv6Address | Write-Verbose + + $_NewIPv6Address = NewObject -ComposerIloAddress + $_NewIPv6Address.address = $IPv6Address.IPAddressToString + $_NewIPv6Address.gateway = $IPv6Gateway.IPAddressToString + + if ($PSBoundParameters['IPv6DnsServer']) + { + + "[{0}] Primary DNS: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $IPv6DnsServer[0] | Write-Verbose + + $_NewIPv6Address.preferredDNS = $IPv6DnsServer[0].IPAddressToString + + if ($IPv6DnsServer.Count -gt 1) + { + + "[{0}] Secondary DNS: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $IPv6DnsServer[1] | Write-Verbose + + $_NewIPv6Address.secondaryDNS = $IPv6DnsServer[1].IPAddressToString + + } + + } + + $_NewComposerConfig.ipv6Config = $_NewIPv6Address + + } + + $_NewComposerConfig.ipv4Config = $_NewIPv4Address + + if ($PSBoundParameters['IloHostname']) + { + + "[{0}] Setting iLO subsystem hostname: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $IloHostname | Write-Verbose + + $_NewComposerConfig.iloHostName = $IloHostname + + } + + if ($Username.StartsWith("_")) + { + + $Exceptionmessage = "The provided iLO Username '{0}' cannot start with the '_' (underscore) character." -f $Username + $ErrorRecord = New-ErrorRecord InvalidOperationException InvalidIloUsername InvalidArgument 'Username' -TargetType 'String' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($Username.ToLower() -eq 'administrator') + { + + $Exceptionmessage = "The provided iLO Username '{0}' cannot be the built-in Administrator account." -f $Username + $ErrorRecord = New-ErrorRecord InvalidOperationException InvalidIloUsername InvalidArgument 'Username' -TargetType 'String' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + else + { + + "[{0}] Setting iLO subsystem hostname: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $IloHostname | Write-Verbose + + $_NewComposerConfig.iloUsername = $Username + $_NewComposerConfig.iloPassword = [Runtime.InteropServices.Marshal]::PtrToStringBSTR([Runtime.InteropServices.Marshal]::SecureStringToBSTR($Password)) + + } + + Try + { + + $_Uri = "{0}/iloConfig" -f $InputObject.Uri + + $resp = Send-OVRequest -Uri $_Uri -Method PUT -Body $_NewComposerConfig -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if ($PSBoundParameters['Async']) + { + + $resp + + } + + else + { + + Try + { + + $resp | Wait-OVTaskComplete + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Disable-OVComposerIlo +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (SupportsShouldProcess, ConfirmImpact = 'High', DefaultParameterSetName = 'Default')] + Param + ( + + [Parameter (Mandatory, ParameterSetName = 'Default')] + [Parameter (Mandatory, ParameterSetName = 'DisableIPv4Address')] + [Parameter (Mandatory, ParameterSetName = 'DisableIPv6Address')] + [ValidateNotNullorEmpty()] + [Object]$InputObject, + + [Parameter (Mandatory, ParameterSetName = 'DisableIPv4Address')] + [Switch]$DisableIPv4Address, + + [Parameter (Mandatory, ParameterSetName = 'DisableIPv6Address')] + [Switch]$DisableIPv6Address, + + [Parameter (Mandatory = $False, ParameterSetName = 'Default')] + [Parameter (Mandatory = $False, ParameterSetName = 'DisableIPv4Address')] + [Parameter (Mandatory = $False, ParameterSetName = 'DisableIPv6Address')] + [Switch]$Async, + + [Parameter (Mandatory = $False, ParameterSetName = 'Default')] + [Parameter (Mandatory = $False, ParameterSetName = 'DisableIPv4Address')] + [Parameter (Mandatory = $False, ParameterSetName = 'DisableIPv6Address')] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneView.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneView.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneView.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + Process + { + + # Validate Composer type is Composer2 + if ($InputObject.model -ne "SynergyComposer2") + { + + $ExceptionMessage = "The specified '{0}' InputObject parameter value is not a supported HPE Synergy Composer type. Only 'Synergy Composer 2' appliances are supported." -f $InputObject.name + $ErrorRecord = New-ErrorRecord HPEOneView.InputObjectResourceException InvalidInputObjectResource InvalidArgument "InputObject" -TargetType $InputObject.GetType().Name -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + # Figure outwhat to prompt user + Switch ($PSCmdlet.ParameterSetName) + { + + 'DisableIPAddress' + { + + if ($PSBoundParameters['DisableIPv4Address']) + { + + # Check to see if an IPv6 address is configured. If not, generate error + if ([String]::IsNullOrEmpty($InputObject.IloConfig.IPv6Config)) + { + + $ExceptionMessage = "The HPE Synergy Composer does not have a configured IPv6 address. You cannot disable both address types. At least one address must be assigned to the iLO." + $ErrorRecord = New-ErrorRecord InvalidOperationException InvalidBaselineResouce InvalidArgument 'DisableIPv4Address' -TargetType 'SwitchParameter' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Write-Warning "Disabling the IPv4 address will unassign the IP address and the Composer iLO will no longer be accessible." + + $ShouldProcessMessage = "disable iLO IPv4 address" + + } + + elseif ($PSBoundParameters['DisableIPv6Address']) + { + + # Check to see if an IPv4 address is configured. If not, generate error + if ([String]::IsNullOrEmpty($InputObject.IloConfig.IPv4Config)) + { + + $ExceptionMessage = "The HPE Synergy Composer does not have a configured IPv4 address. You cannot disable both address types. At least one address must be assigned to the iLO." + $ErrorRecord = New-ErrorRecord InvalidOperationException InvalidBaselineResouce InvalidArgument 'DisableIPv4Address' -TargetType 'SwitchParameter' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Write-Warning "Disabling the IPv6 address will unassign the IP address and the Composer iLO will no longer be accessible." + + $ShouldProcessMessage = "disable iLO IPv6 address" + + } + + $Method = "PUT" + + } + + default + { + + Write-Warning "Disabling external iLO access will delete the iLO user account and unassign the IP address(es)." + + $ShouldProcessMessage = "disable iLO settings" + + $Method = "DELETE" + + } + + } + + if ($PSCmdlet.ShouldProcess($InputObject.name, $ShouldProcessMessage)) + { + + Try + { + + $_ComposerHwToProcess = (Send-OVRequest -Uri $InputObject.uri -Hostname $InputObject.ApplianceConnection).iloConfig + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + Switch ($PSCmdlet.ParameterSetName) + { + + 'DisableIPAddress' + { + + if ($PSBoundParameters['DisableIPv4Address']) + { + + $_ComposerHwToProcess.ipv4Config = $null + + } + + if ($PSBoundParameters['DisableIPv6Address']) + { + + $_ComposerHwToProcess.ipv6Config = $null + + } + + } + + default + { + + $_ComposerHwToProcess.ipv4Config = $null + $_ComposerHwToProcess.ipv6Config = $null + + } + + } + + Try + { + + $_Uri = "{0}/iloConfig" -f $InputObject.Uri + + $resp = Send-OVRequest -Uri $_Uri -Method $Method -Body $_ComposerHwToProcess -Hostname $InputObject.ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if ($PSBoundParameters['Async']) + { + + $resp + + } + + else + { + + Try + { + + $resp | Wait-OVTaskComplete + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Set-OVComposerIlo +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (SupportsShouldProcess, ConfirmImpact = 'High', DefaultParameterSetName = "Default")] + Param + ( + + [Parameter (Mandatory, ParameterSetName = "Default")] + [ValidateNotNullorEmpty()] + [Object]$InputObject, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [ValidateNotNullorEmpty()] + [String]$Username, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [ValidateNotNullorEmpty()] + [SecureString]$Password, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [ValidateScript({ [String]::IsNullOrEmpty($_) -or + $_ -match [Net.IPAddress]$_})] + [IPAddress]$IPv4Address, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [ValidateNotNullorEmpty()] + [IPAddress]$IPv4SubnetMask, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [ValidateScript({ [String]::IsNullOrEmpty($_) -or + $_ -match [Net.IPAddress]$_})] + [IPAddress]$IPv4Gateway, + + [Parameter (Mandatory = $False, ParameterSetName = "Default")] + [ValidateNotNullorEmpty()] + [IPAddress[]]$IPv4DnsServer, + + [Parameter (Mandatory = $False, ParameterSetName = "Default")] + [ValidateScript({ [String]::IsNullOrEmpty($_) -or + $_ -match [Net.IPAddress]$_})] + [IPAddress]$IPv6Address, + + [Parameter (Mandatory = $False, ParameterSetName = "Default")] + [ValidateNotNullorEmpty()] + [String]$IPv6SubnetMask, + + [Parameter (Mandatory = $False, ParameterSetName = "Default")] + [ValidateNotNullorEmpty()] + [IPAddress]$IPv6Gateway, + + [Parameter (Mandatory = $False, ParameterSetName = "Default")] + [ValidateNotNullorEmpty()] + [IPAddress[]]$IPv6DnsServer, + + [Parameter (Mandatory = $False, ParameterSetName = "Default")] + [String]$IloHostname, + + [Parameter (Mandatory = $False, ParameterSetName = "Default")] + [Switch]$Async, + + [Parameter (Mandatory = $False, ParameterSetName = "Default")] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if ($PSBoundParameters['IPv4SubnetMask']) + { + + if (($IPv4SubnetMask -lt 1 -or $IPv4SubnetMask -gt 32) -and ($IPv4SubnetMask -notmatch $IPSubnetAddressPattern)) + { + + $Exceptionmessage = "The provided SubnetID {0} does not appear to be a valid Subnet Mask." -f $IPv4SubnetMask + $ErrorRecord = New-ErrorRecord InvalidOperationException InvalidIPv4SubnetMask InvalidArgument 'IPv4SubnetMask' -TargetType 'String' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneView.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneView.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneView.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + Process + { + + # Validate Composer type is Composer2 + if ($InputObject.model -ne "SynergyComposer2") + { + + $ExceptionMessage = "The specified '{0}' InputObject parameter value is not a supported HPE Synergy Composer type. Only 'Synergy Composer 2' appliances are supported." -f $InputObject.name + $ErrorRecord = New-ErrorRecord HPEOneView.InputObjectResourceException InvalidInputObjectResource InvalidArgument "InputObject" -TargetType $InputObject.GetType().Name -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Try + { + + $_ComposerHwToProcess = (Send-OVRequest -Uri $InputObject.uri -Hostname $InputObject.ApplianceConnection).iloConfig + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $_ShouldProcessCol = [System.Collections.ArrayList]::new() + + switch ($PSBoundParameters.Keys) + { + + 'Username' + { + + Write-Warning "The existing iLO account is removed and the new specified local user account will be created." + + "[{0}] Updating user account: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Username | Write-Verbose + + $_ComposerHwToProcess.iloUsername = $Username + + [void]$_ShouldProcessCol.Add('Username') + + } + + 'Password' + { + + "[{0}] Updating user password." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_ComposerHwToProcess.iloPassword = [Runtime.InteropServices.Marshal]::PtrToStringBSTR([Runtime.InteropServices.Marshal]::SecureStringToBSTR($Password)) + + [void]$_ShouldProcessCol.Add('Password') + + } + + 'IloHostname' + { + + "[{0}] Updating iLO subsystem hostname." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_ComposerHwToProcess.iloHostName = $IloHostname + + [void]$_ShouldProcessCol.Add('IloHostname') + + } + + 'IPv4Address' + { + + if ([String]::IsNullOrEmpty($_ComposerHwToProcess.ipv6Config)) + { + + $_ComposerHwToProcess.ipv4Config = NewObject -ComposerIloAddress + + } + + "[{0}] Updating iLO IPv4 address: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $IPv4Address | Write-Verbose + + $_ComposerHwToProcess.ipv4Config.address = $IPv4Address.IPAddressToString + + [void]$_ShouldProcessCol.Add('IPv4Address') + + } + + 'IPv4SubnetMask' + { + + if ([String]::IsNullOrEmpty($_ComposerHwToProcess.ipv6Config)) + { + + $_ComposerHwToProcess.ipv4Config = NewObject -ComposerIloAddress + + } + + # Calculate the CIDR bit value to the SubnetMask Address + if ($PSBoundParameters['IPv4SubnetMask'].Length -le 2) + { + + Try + { + + "[{0}] Converting Subnet CIDR Bit value to Subnet Mask Address." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + [Int64]$_Int64Value = ([convert]::ToInt64(('1' * $IPv4SubnetMask + '0' * (32 - $IPv4SubnetMask)), 2)) + + $_SubnetMask = '{0}.{1}.{2}.{3}' -f ([math]::Truncate($_Int64Value / 16777216)).ToString(), + ([math]::Truncate(($_Int64Value % 16777216) / 65536)).ToString(), + ([math]::Truncate(($_Int64Value % 65536)/256)).ToString(), + ([math]::Truncate($_Int64Value % 256)).ToString() + + $_ComposerHwToProcess.ipv4Config.subnet = $_SubnetMask + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + else + { + + "[{0}] Subnet mask: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $IPv4SubnetMask | Write-Verbose + + $_ComposerHwToProcess.ipv4Config.subnet = $IPv4SubnetMask + + } + + [void]$_ShouldProcessCol.Add('IPv4SubnetMask') + + } + + 'IPv4Gateway' + { + + if ([String]::IsNullOrEmpty($_ComposerHwToProcess.ipv6Config)) + { + + $_ComposerHwToProcess.ipv4Config = NewObject -ComposerIloAddress + + } + + "[{0}] Updating iLO IPv4 gateway: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $IPv4Gateway | Write-Verbose + + $_ComposerHwToProcess.ipv4Config.gateway = $IPv4Gateway.IPAddressToString + + [void]$_ShouldProcessCol.Add('IPv4Gateway') + + } + + 'IPv4DnsServer' + { + + "[{0}] Primary DNS: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $IPv4DnsServer[0] | Write-Verbose + + $_ComposerHwToProcess.ipv4Config.preferredDNS = $IPv4DnsServer[0].IPAddressToString + + if ($IPv4DnsServer.Count -gt 1) + { + + "[{0}] Secondary DNS: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $IPv4DnsServer[1] | Write-Verbose + + $_ComposerHwToProcess.ipv4Config.secondaryDNS = $IPv4DnsServer[1].IPAddressToString + + } + + [void]$_ShouldProcessCol.Add('IPv4DnsServer') + + } + + 'IPv6Address' + { + + if ([String]::IsNullOrEmpty($_ComposerHwToProcess.ipv6Config)) + { + + $_ComposerHwToProcess.ipv6Config = NewObject -ComposerIloAddress + + } + + "[{0}] Updating iLO IPv6 address: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $IPv6Address | Write-Verbose + + $_ComposerHwToProcess.ipv6Config.address = $IPv6Address.IPAddressToString + + [void]$_ShouldProcessCol.Add('IPv6Address') + + } + + 'IPv6SubnetMask' + { + + if ([String]::IsNullOrEmpty($_ComposerHwToProcess.ipv6Config)) + { + + $_ComposerHwToProcess.ipv6Config = NewObject -ComposerIloAddress + + } + + "[{0}] Updating iLO IPv6 subnet mask: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $IPv6SubnetMask | Write-Verbose + + $_ComposerHwToProcess.ipv6Config.subnet = $IPv6SubnetMask + + [void]$_ShouldProcessCol.Add('IPv6SubnetMask') + + } + + 'IPv6Gateway' + { + + if ([String]::IsNullOrEmpty($_ComposerHwToProcess.ipv6Config)) + { + + $_ComposerHwToProcess.ipv6Config = NewObject -ComposerIloAddress + + } + + "[{0}] Updating iLO IPv6 gateway: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $IPv6Gateway | Write-Verbose + + $_ComposerHwToProcess.ipv6Config.gateway = $IPv6Gateway.IPAddressToString + + [void]$_ShouldProcessCol.Add('IPv6Gateway') + + } + + 'IPv6DnsServer' + { + + "[{0}] IPv6 Primary DNS: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $IPv6DnsServer[0] | Write-Verbose + + $_ComposerHwToProcess.ipv6Config.preferredDNS = $IPv6DnsServer[0].IPAddressToString + + if ($IPv6DnsServer.Count -gt 1) + { + + "[{0}] IPv6 Secondary DNS: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $IPv6DnsServer[1] | Write-Verbose + + $_ComposerHwToProcess.ipv6Config.secondaryDNS = $IPv6DnsServer[1].IPAddressToString + + } + + [void]$_ShouldProcessCol.Add('IPv6DnsServer') + + } + + } + + $ShouldProcessMessage = "update {0}" -f [String]::Join(", ", $_ShouldProcessCol.ToArray()) + + if ($PSCmdlet.ShouldProcess($InputObject.name, $ShouldProcessMessage)) + { + + Try + { + + $_Uri = "{0}/iloConfig" -f $InputObject.Uri + + $resp = Send-OVRequest -Uri $_Uri -Method PUT -Body $_ComposerHwToProcess -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if ($PSBoundParameters['Async']) + { + + $resp + + } + + else + { + + Try + { + + $resp | Wait-OVTaskComplete + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Get-OVComposerIloStatus +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding ()] + Param + ( + + [Parameter (Mandatory = $False)] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneView.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneView.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneView.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + Process + { + + ForEach ($_appliance in $ApplianceConnection) + { + + if (($ConnectedSessions | Where-Object Name -eq $_appliance.Name).ApplianceType -ne 'Composer') + { + + $ErrorRecord = [Management.Automation.ErrorRecord]::new([HPEOneView.Appliance.ComposerNodeException]::new('The ApplianceConnection {0} is not a Synergy Composer. The logical enclosure resource and this Cmdlet is only supported with Synergy Composers.' -f $ApplianceConnection)), 'InvalidOperation', 'InvalidOperation', 'ApplianceConnection' + + $PSCmdlet.WriteError($ErrorRecord) + + } + + else + { + + Try + { + + $resp = Send-OVRequest -Uri $ApplianceComposerConfigUri -Hostname $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + ForEach ($hwappliance in ($resp.members | ? model -match "Composer")) + { + + Try + { + + $enclosure = Send-OVRequest -Uri $hwappliance.locationUri -Hostname $_appliance + $HWComposerUri = $ApplianceHANodesUri + '/' + $hwappliance.Id + $haNodeInfo = Send-OVRequest -Uri $HWComposerUri -Hostname $_appliance + + } + + catch [HPEOneView.ResourceNotFoundException] + { + + "[{0}] '{1}' was not found. Skipping." -f $MyInvocation.InvocationName.ToString().ToUpper(), $HWComposerUri | Write-Verbose + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $IPv4Config = $IPv6Config = $null + + if (-not [String]::IsNullorEmpty($hwappliance.iloConfig.ipv4Config)) + { + + $IPv4Config = [HPEOneView.Appliance.IloConfig+IPConfig]::new($hwappliance.iloConfig.ipv4Config.address, + $hwappliance.iloConfig.ipv4Config.subnet, + $hwappliance.iloConfig.ipv4Config.gateway, + $hwappliance.iloConfig.ipv4Config.primaryDnsServer, + $hwappliance.iloConfig.ipv4Config.secondaryDnsServer) + + } + + if (-not [String]::IsNullorEmpty($hwappliance.iloConfig.ipv6Config)) + { + + $IPv6Config = [HPEOneView.Appliance.IloConfig+IPConfig]::new($hwappliance.iloConfig.ipv6Config.address, + $hwappliance.iloConfig.ipv6Config.subnet, + $hwappliance.iloConfig.ipv6Config.gateway, + $hwappliance.iloConfig.ipv6Config.primaryDnsServer, + $hwappliance.iloConfig.ipv6Config.secondaryDnsServer) + + } + + $iLoConfig = [HPEOneView.Appliance.IloConfig]::new($hwappliance.iloConfig.username, $hwappliance.iloConfig.hostname, $IPv4Config, $IPv6Config) + + [HPEOneView.Appliance.HardwareConfig]::new(('{0}, appliance bay {1}' -f $enclosure.name, $hwappliance.bayNumber), + $hwappliance.id, + $hwappliance.model.Replace(" ", $null), + $haNodeInfo.role, + $haNodeInfo.version, + $enclosure, + $hwappliance.bayNumber, + $hwappliance.isExtAccessible, + $iLoConfig, + $hwappliance.uri, + $hwappliance.ApplianceConnection) + + } + + } + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Enclosure-Report +{ + + <# + .DESCRIPTION + Internal helper function to display the report of an enclosure + + .Parameter Enclosure + The enclosure object. + + .Parameter file + File to save the report to. + + .INPUTS + Enclosure object. + + .OUTPUTS + Enclosure report. + + .LINK + Get-OVEnclosure + + .LINK + Send-OVRequest + + .EXAMPLE + PS C:\> $enclosures = Get-OVEnclosure + Return all the enclosure hardware managed by this appliance. + + #> + + [CmdletBinding ()] + Param + ( + + [Parameter (Mandatory,ValueFromPipeline)] + [object]$Enclosure, + + [Parameter (Mandatory = $false,ValueFromPipeline = $false)] + [object]$file, + + [Parameter (Mandatory = $false)] + [Switch]$fwreport + ) + + Process + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + Write-Verbose "ENCLOSURE OBJECT: $($enclosure)" + Write-Verbose "ENCLOSURE UUID: $($Enclosure.uuid)" + + # ENCLOSURE REPORT DATA + $a = @{Expression={$_.name};Label="Enclosure Name";width=15}, + @{Expression={$_.serialNumber};Label="Serial Number";width=15}, + @{Expression={$_.enclosureType};Label="Enclosure Model";width=30}, + @{Expression={$_.rackName};Label="Rack Name";width=12}, + @{Expression={$_.isFwManaged};Label="FW Managed";width=10}, + @{Expression={$_.fwBaseLineName};Label="Baseline Name";width=30} + + # Generate Report + $Enclosure | format-table $a -AutoSize + + # License Intent Report + $a = @{Expression={$_.licensingIntent};Label="Licensing";width=15} + + $Enclosure | format-table $a -AutoSize + + # ONBOARD ADMINISTRATOR REPORT DATA + $a = @{Expression={$_.bayNumber};Label="OA Bay";width=10}, + @{Expression={$_.role};Label="Role";width=15}, + @{Expression={$_.ipAddress};Label="IP Address";width=15}, + @{Expression={($_.fwVersion + " " + $_.fwBuildDate)};Label="Firmware Version";width=20} + + $Enclosure.oa | Format-Table $a -AutoSize + + # DEVICE BAY REPORT DATA + # Looking for servers related to the requested enclosure + $serversCol = [System.Collections.ArrayList]::new() + + # Loop through populated device bays + ForEach ($_DeviceBay in ($Enclosure.deviceBays | Where-Object { $_.devicePresence -eq 'Present' -and $_.deviceUri } )) + { + + # Loop through index association results + Try + { + + $_server = Send-OVRequest $_DeviceBay.deviceUri -Hostname $Enclosure.ApplianceConnection + + [void]$serversCol.Add($_server) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $serversCol | out-string | Write-Verbose + + $a = @{Expression={$_.name};Label="Server Name";width=20}, + @{Expression={$_.serialNumber};Label="Serial Number";width=15}, + @{Expression={$_.shortModel};Label="Model";width=12}, + @{Expression={$_.romVersion};Label="System ROM";width=15}, + @{Expression={($_.mpModel + " " + $_.mpFirmwareVersion)};Label="iLO Firmware Version";width=22}, + @{Expression={ + + if (-not($_.serverProfileUri)) + { + + 'No Profile' + + } + + else + { + + Try + { + + (Send-OVRequest $_.serverProfileUri -Hostname $Enclosure.ApplianceConnection).name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + };Label="Server Profile";width=30}, + @{Expression={$_.licensingIntent};Label="Licensing";width=15} + + $serversCol | Sort-Object name | format-table $a -AutoSize + + # INTERCONNECT BAY REPORT DATA + # Loop through interconnect bays + $interconnectsCol = [System.Collections.ArrayList]::new() + + foreach ($interconnect in $enclosure.interconnectBays) + { + + Write-Verbose "INTERCONNECT: $($interconnect)" + + if ($interconnect.interconnectUri) + { + + Try + { + + # Get the Interconnect object to read properties + $tempInterconnect = Send-OVRequest $interconnect.interconnectUri -Hostname $Enclosure.ApplianceConnection + + # Get Logical Interconnect associated with the Interconnect to report its Name + $li = Send-OVRequest $interconnect.logicalInterconnectUri -Hostname $Enclosure.ApplianceConnection + + $tempInterconnect | Add-Member -type NoteProperty -name liName -value $li.name + $tempInterconnect | out-string | Write-Verbose + + [void]$interconnectsCol.Add($tempInterconnect) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + # Display Interconnect information (Name, Model, Serial Number, FW Ver) + $a = @{Expression={$_.name};Label="Interconnect Name";width=22}, + @{Expression={$_.model};Label="Module";width=38}, + @{Expression={$_.serialNumber};Label="Serial Number";width=20}, + @{Expression={$_.firmwareVersion};Label="Firmware Version";width=20} + + $interconnectsCol | format-Table $a -AutoSize + + # Display Interconnect information (PAD, Name, Logical Interconnect Name, State, Status) + $b = @{Expression={' '};Label=" ";width=5}, + @{Expression={$_.name};Label="Interconnect Name";width=22}, + @{Expression={$_.liName};Label="Logical Interconnect";width=30}, + @{Expression={$_.state};Label="State";width=14}, + @{Expression={$_.status};Label="Status";width=20}, + @{Expression={ + + switch ($_.category) + { + + $ResourceCategoryEnum.SasInterconnect + { + + $_uriPropertyName = 'sasLogicalInterconnectUri' + + } + + default + { + + $_uriPropertyName = 'logicalInterconnectUri' + + } + + } + + Try + { + + $tempLI = Send-OVRequest $_.$_uriPropertyName -Hostname $Enclosure.ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + switch ($tempLI.consistencyStatus) + { + + 'CONSISTENT' { "Consistent" } + 'NOT_CONSISTENT' { "Inconsistent with group" } + default { $tempLI.consistencyStatus } + + } + + };Label="Consistency state";width=26} + + $interconnectsCol | format-Table $b -AutoSize + + # Write-Host "==================================================================================================================" + + } + +} + +function Remove-OVEnclosure +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "default",SupportsShouldProcess,ConfirmImpact = 'High')] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = "default")] + [ValidateNotNullOrEmpty()] + [Alias ("uri", "name", "Enclosure",'Resource')] + [object]$InputObject, + + [Parameter (ValueFromPipelineByPropertyName, Mandatory = $false, ParameterSetName = "default")] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default), + + [Parameter (Mandatory = $false, ParameterSetName = "default")] + [Switch]$Force + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + + if (-not($PSBoundParameters['Enclosure'])) + { + + $PipelineInput = $True + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + $_TaskCollection = [System.Collections.ArrayList]::new() + $_EnclosureCollection = [System.Collections.ArrayList]::new() + + } + + Process + { + + ForEach ($enclosure in $InputObject) + { + + if ($enclosure -is [String]) + { + + if ([System.Uri]::IsWellFormedUriString($enclosure,'Relative')) + { + + "[{0}] Received URI: $($enclosure)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + "[{0}] Getting Enclosure Object" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $enclosureToRemove = Send-OVRequest -Uri $enclosure -ApplianceConnection $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + # Enclosure passed is the Name + elseif (-not $enclosure.startsWith("/rest")) + { + + "[{0}] Received Enclosure Name $($enclosure)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + "[{0}] Getting Enclosure object from Get-OVEnclosure" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $enclosureToRemove = Get-OVEnclosure -Name $enclosure -ApplianceConnection $ApplianceConnection -ErrorAction Stop + + } + + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + # Enclosure passed is an object + if ($enclosure -is [PSCustomObject] -and ($enclosure.category -ieq $ResourceCategoryEnum.Enclosure)) + { + + "[{0}] Enclosure Object provided: {1} ({2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $enclosure.name, $enclosure.uri | Write-Verbose + + $enclosureToRemove = $enclosure.PSObject.Copy() + + } + + else + { + + $ErrorRecord = New-ErrorRecord InvalidOperationException InvalidArgumentValue InvalidArgument 'InputObject' -TargetType 'PSObject' -Message "Invalid Resource Parameter: $($enclosure)" + $PSCmdlet.WriteError($ErrorRecord) + + } + + } + + # Display obselete message if the connection is a VM, not Synergy + [ObsoleteMessage]::Write($enclosureToRemove.ApplianceConnection) + + if ($PSCmdlet.ShouldProcess($enclosureToRemove.name,"Remove Enclosure from appliance '$($enclosureToRemove.ApplianceConnection)'")) + { + + "[{0}] Removing Enclosure '$($enclosureToRemove.name)' from appliance '$($enclosureToRemove.ApplianceConnection)'." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + if ($PSBoundParameters['Force']) + { + + $enclosureToRemove.uri += "?force=true" + + } + + Send-OVRequest -Uri $enclosureToRemove.Uri -Method DELETE -AddHeader @{'If-Match' = $enclosureToRemove.eTag } -Hostname $enclosureToRemove.ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + elseif ($PSBoundParameters['WhatIf']) + { + + "[{0}] WhatIf Parameter was passed." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Get-OVServerHardwareType +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = 'Default')] + Param + ( + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullorEmpty()] + [String]$Name, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullorEmpty()] + [String]$Model, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default), + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [Alias ("x", "export")] + [ValidateScript ({split-path $_ | Test-Path})] + [String]$exportFile + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $_SHTCollection = [System.Collections.ArrayList]::new() + + } + + Process + { + + ForEach ($_appliance in $ApplianceConnection) + { + + "[{0}] Processing Appliance Connection {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name | Write-Verbose + + $uri = '{0}?sort=name:asc' -f $ServerHardwareTypesUri + + if ($PSBoundParameters['Name']) + { + + "[{0}] Server Hardware Type name provided: '{1}'" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Name | Write-Verbose + + $uri = "{0}&filter=name matches '{1}'" -f $uri, $Name.Replace('*','%25') + + } + + if ($PSBoundParameters['Model']) + { + + "[{0}] Server Hardware Type model provided: '{1}'" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Model | Write-Verbose + + $uri = "{0}&filter=model matches '{1}'" -f $uri, $model.Replace('*','%25') + + } + + Try + { + + $_resp = Send-OVRequest $uri -hostname $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if ($PSBoundParameters['Name'] -and $_resp.count -eq 0) + { + + $ExceptionMessage = "'{0}' Server Hardware Type not found on '{1}' appliance connection. Please check the name and try again." -f $Name, $_appliance.Name + $ErrorRecord = New-ErrorRecord InvalidOperationException ServerHardwareTypeNotFound ObjectNotFound 'Name' -Message $ExceptionMessage + $PSCmdlet.WriteError($ErrorRecord) + + } + + elseif ($PSBoundParameters['Model'] -and $_resp.count -eq 0) + { + + $ExceptionMessage = "'{0}' Server Hardware Type model not found on '{1}' appliance connection. Please check the name and try again." -f $Model, $_appliance.Name + $ErrorRecord = New-ErrorRecord InvalidOperationException ServerHardwareTypeNotFound ObjectNotFound 'Model' -Message $ExceptionMessage + $PSCmdlet.WriteError($ErrorRecord) + + } + + else + { + + $_resp.members | ForEach-Object { + + $_.PSObject.TypeNames.Insert(0,'HPEOneView.ServerHardwareType') + + [void]$_SHTCollection.Add($_) + + } + + } + + } + + } + + End + { + + if ($PSboundParameters['ExportFile']) + { + + $_SHTCollection | ConvertTo-JSON -Depth 99 > $ExportFile + + } + + else + { + + Return $_SHTCollection + + } + + } + +} + +function Set-OVServerHardwareType +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding ()] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline)] + [Alias('Resource')] + [validateNotNullorEmpty()] + [Object]$InputObject, + + [Parameter (Mandatory)] + [validateNotNullorEmpty()] + [String]$Name, + + [Parameter (Mandatory = $false)] + [String]$Description, + + [Parameter (ValueFromPipelineByPropertyName, Mandatory = $false)] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + # Support ApplianceConnection property value via pipeline from Enclosure Object + if(-not $PSboundParameters['InputObject']) + { + + $PipelineInput = $True + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + } + + Process + { + + # Validate the input object category is server-hardware-types + if ($InputObject.category -ne 'server-hardware-types') + { + + $ExceptionMessage = "The specified '{0}' InputObject parameter value is not supported type. Only Server Hardware Type resources are allowed." -f $InputObject + $ErrorRecord = New-ErrorRecord HPEOneView.InputObjectResourceException InvalidInputObjectResource InvalidArgument "InputObject" -TargetType $InputObject.GetType().Name -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + $_UpdatedSHTResourceDescriptions = [PSCustomObject]@{ + name = $Name; + description = $Description + } + + "[{0}] Will update the SHT name from {1} to {2}." -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject.name, $Name | Write-Verbose + + if ($PSBoundParameters['Description']) + { + + "[{0}] Will update the SHT sescription from {1} to {2}." -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject.description, $Description | Write-Verbose + + } + + try + { + + $_resp = Send-OVRequest -Uri $InputObject.uri -Method PUT -Body $_UpdatedSHTResourceDescriptions -Hostname $ApplianceConnection + + } + + catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $_resp.PSObject.TypeNames.Insert(0, 'HPEOneView.ServerHardwareType') + $_resp + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Show-OVFirmwareReport +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding ()] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline)] + [Alias('Resource')] + [validateNotNullorEmpty()] + [Object]$InputObject, + + [Parameter (Mandatory = $false)] + [validateNotNullorEmpty()] + [Object]$Baseline, + + [Parameter (Mandatory = $false)] + [validateSet("LowerThanBaseline", "NotEqualToBaseline")] + [String]$InstallationPolicy = "LowerThanBaseline", + + [Parameter (Mandatory = $false)] + [Switch]$Export, + + [Parameter (Mandatory = $false)] + [validateNotNullorEmpty()] + [String]$Location = (get-location).Path, + + [Parameter (ValueFromPipelineByPropertyName, Mandatory = $false)] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + # Support ApplianceConnection property value via pipeline from Enclosure Object + if(-not($PSboundParameters['InputObject'])) + { + + $PipelineInput = $True + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + $_ResourceCollection = [System.Collections.ArrayList]::new() + $_FirmwareReportCollection = [System.Collections.ArrayList]::new() + + # Test for location + if ($Export) + { + + if ( -not (Test-Path $Location)) + { + + $ErrorRecord = New-ErrorRecord InvalidOperationException LocationPathNotFound ObjectNotFound 'Location' -Message "The specified path $Location does not exist. Please verify it and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + } + + Process + { + + $_r = 1 + + # Add Resource to Collection, which can be accepted via the pipeline + ForEach ($_resource in ($InputObject | ? state -ne 'Unmanaged')) + { + + if ($_resource -is [String]) + { + + # Error that the Resource isn't an object + $ExceptionMessage = 'The Inputobject {0} is not a supported resource type, PSObject.' -f $_resource + $ErrorRecord = New-ErrorRecord InvalidOperationException InvalidBaselineResouce InvalidArgument 'InputObject' -TargetType $InputObject.GetType().Name -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + "[{0}] Adding '{1}' object to collection ({2}/{3})." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_resource.name, $_r, ($InputObject | Measure-Object).Count | Write-Verbose + + [void]$_ResourceCollection.Add($_resource) + + $_r++ + + } + + } + + End + { + + $_P = 0 + + # Process the report generation here + ForEach ($_resource in $_ResourceCollection) + { + + if (-not($PSBoundParameters['Verbose']) -or -not($VerbosePreference -eq 'Continue')) + { + + Write-Progress -id 1 -activity "Generate Firmware Report" -percentComplete (($_P / $_ResourceCollection.count) * 100) + + } + + switch ($_resource.category) + { + + $ResourceCategoryEnum.EnclosureGroup + { + + $_P++ + + $_ProgressParams = @{ + + ID = 1; + Activity = "Generate Firmware Report"; + CurrentOperation = ("Processing '{0}' Enclosure Group" -f $_resource.name); + PercentComplete = (($_P / $_ResourceCollection.count) * 100) + + } + + # Handle the call from -Verbose so Write-Progress does not get borked on display. + if ($PSBoundParameters['Verbose'] -or $VerbosePreference -eq 'Continue') + { + + "[{0}] Collecting Enclosure Firmware Information - {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), ($_ProgressParams | Out-String) | Write-Verbose + + } + + else + { + + Write-Progress @_ProgressParams + + } + + "[{0}] Getting Enclosure Group to Enclosure associations, then getting found Enclosure Resources." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + # Get associated Logical Enclosures with Enclosure Group + $_uri = '{0}?parentUri={1}&name=ENCLOSURE_GROUP_TO_LOGICAL_ENCLOSURE' -f $AssociationsUri, $_resource.uri + [Array]$_ResourcesFromIndexCol = Get-AllIndexResources -Uri $_uri -ApplianceConnection $_resource.ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + # Make sure the EG has associated Enclosures/LogicalEnclosures. + if ($_ResourcesFromIndexCol) + { + + $_e = 0 + + "[{0}] Total number of Logical Enclosures to Process: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_ResourcesFromIndexCol.Count | Write-Verbose + + foreach ($_le in $_ResourcesFromIndexCol) + { + + # Loop through LE EnclosureUris + foreach ($_enclosureUri in $_le.enclosureUris) + { + + # Get Enclosure Resource Object + Try + { + + $_enclosure = Send-OVRequest -uri $_enclosureUri -Hostname $_resource.ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $_e++ + + $_EnclParams = @{ + + ID = 10; + ParentID = 1; + Activity = "Create Enclosure Firmware Report"; + CurrentOperation = ("[{0}\{1}] Processing '{2}' Enclosure" -f $_e, $_ResourcesFromIndexCol.Count, $_enclosure.name); + PercentComplete = (($_e / $_ResourcesFromIndexCol.Count) * 100) + + } + + # Handle the call from -Verbose so Write-Progress does not get borked on display. + if ($PSBoundParameters['Verbose'] -or $VerbosePreference -eq 'Continue') + { + + "[{0}] Collecting Enclosure Firmware Information: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), ($_EnclParams | Out-String) | Write-Verbose + + } + + else + { + + Write-Progress @_EnclParams + + } + + Try + { + + $_EnclosureReportCol = Get-EnclosureFirmware -Enclosure $_enclosure -Baseline $Baseline -ProgressID 1 + + "[{0}] Enclosure Firmware Report return: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), ($_EnclosureReportCol | Out-String) | Write-Verbose + + ForEach ($_item in $_EnclosureReportCol) + { + + "[{0}] Adding {1} in {2} to Enclosure Firmware collection" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_item.Component, $_item.Name | Write-Verbose + + # $_item | add-member -Type NoteProperty -Name eg -value $_resource.name + + [void]$_FirmwareReportCollection.Add($_item) + + } + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + } + + # Clear Child Write-Progress progress bars + # Handle the call from -Verbose so Write-Progress does not get borked on display. + if ($PSBoundParameters['Verbose'] -or $VerbosePreference -eq 'Continue') + { + + "[{0}] Completed Collecting Enclosure Firmware Information - Skipping Write-Progress display." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + else + { + + Write-Progress -ParentId 1 -id 2 -activity "Collecting Enclosure Firmware Information" -CurrentOperation "Completed" -Completed + + } + + # Handle the call from -Verbose so Write-Progress does not get borked on display. + if ($PSBoundParameters['Verbose'] -or $VerbosePreference -eq 'Continue') + { + + "[{0}] Completed Collecting Enclosure Group Firmware Information Skipping Write-Progress display." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + else + { + + Write-Progress -Id 1 -activity "Collecting Enclosure Group Firmware Information" -CurrentOperation "Completed" -Completed + + } + + } + + $ResourceCategoryEnum.LogicalEnclosure + { + + $_P++ + + $_ProgressParams = @{ + + ID = 1; + Activity = "Generate Firmware Report"; + CurrentOperation = ("Processing '{0}' Logical Enclosure" -f $_resource.name); + PercentComplete = (($_P / $_ResourceCollection.count) * 100) + + } + + # Handle the call from -Verbose so Write-Progress does not get borked on display. + if ($PSBoundParameters['Verbose'] -or $VerbosePreference -eq 'Continue') + { + + "[{0}] Collecting Logical Enclosure Firmware Information - {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), ($_ProgressParams | Out-String) | Write-Verbose + + } + + else + { + + Write-Progress @_ProgressParams + + } + + "[{0}] Getting Enclosure resources from Logical Enclosure." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_e = 0 + + # Loop through LE EnclosureUris + foreach ($_enclosureUri in $_resource.enclosureUris) + { + + # Get Enclosure Resource Object + Try + { + + $_enclosure = Send-OVRequest -uri $_enclosureUri -Hostname $_resource.ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $_e++ + + $_EnclParams = @{ + + ID = 10; + ParentID = 1; + Activity = "Create Enclosure Firmware Report"; + CurrentOperation = ("[{0}\{1}] Processing '{2}' Enclosure" -f $_e, $_resource.enclosureUris.Count, $_enclosure.name); + PercentComplete = (($_e / $_resource.enclosureUris.Count) * 100) + + } + + # Handle the call from -Verbose so Write-Progress does not get borked on display. + if ($PSBoundParameters['Verbose'] -or $VerbosePreference -eq 'Continue') + { + + "[{0}] Collecting Enclosure Firmware Information: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), ($_EnclParams | Out-String) | Write-Verbose + + } + + else + { + + Write-Progress @_EnclParams + + } + + Try + { + + $_EnclosureReportCol = Get-EnclosureFirmware -Enclosure $_enclosure -Baseline $Baseline -ProgressID 1 + + "[{0}] Enclosure Firmware Report return: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), ($_EnclosureReportCol | Out-String) | Write-Verbose + + ForEach ($_item in $_EnclosureReportCol) + { + + "[{0}] Adding {1} in {2} to Enclosure Firmware collection" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_item.Component, $_item.Name | Write-Verbose + + [void]$_FirmwareReportCollection.Add($_item) + + } + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + # Clear Child Write-Progress progress bars + # Handle the call from -Verbose so Write-Progress does not get borked on display. + if ($PSBoundParameters['Verbose'] -or $VerbosePreference -eq 'Continue') + { + + "[{0}] Completed Collecting Enclosure Firmware Information - Skipping Write-Progress display." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + else + { + + Write-Progress -ParentId 1 -id 2 -activity "Collecting Enclosure Firmware Information" -CurrentOperation "Completed" -Completed + + } + + # Handle the call from -Verbose so Write-Progress does not get borked on display. + if ($PSBoundParameters['Verbose'] -or $VerbosePreference -eq 'Continue') + { + + "[{0}] Completed Collecting Enclosure Group Firmware Information Skipping Write-Progress display." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + else + { + + Write-Progress -Id 1 -activity "Collecting Enclosure Group Firmware Information" -CurrentOperation "Completed" -Completed + + } + + } + + $ResourceCategoryEnum.Enclosure + { + + # Keep track of the number of resources + $_P++ + + $_ProgressParams = @{ + + ID = 1; + Activity = "Generate Firmware Report"; + CurrentOperation = ("Processing '{0}' Enclosure" -f $_resource.name); + PercentComplete = (($_P / $_ResourceCollection.count) * 100) + + } + + # Handle the call from -Verbose so Write-Progress does not get borked on display. + if ($PSBoundParameters['Verbose'] -or $VerbosePreference -eq 'Continue') + { + + "[{0}] Collecting Enclosure Firmware Information - {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), ($_ProgressParams | Out-String) | Write-Verbose + } + + else + { + + Write-Progress @_ProgressParams + + } + + Try + { + + $_EnclosureReport = Get-EnclosureFirmware -Enclosure $_resource -Baseline $Baseline -ProgressID 1 + + $_EnclosureReport | ForEach-Object { + + [void]$_FirmwareReportCollection.Add($_) + + } + + } + + Catch + { + + Write-Progress -id 1 -activity "Collecting Enclosure Firmware Information" -CurrentOperation "Completed" -Completed + + $PSCmdlet.ThrowTerminatingError($_) + + } + + # Handle the call from -Verbose so Write-Progress does not get borked on display. + if ($PSBoundParameters['Verbose'] -or $VerbosePreference -eq 'Continue') + { + + "[{0}] Completed Collecting Enclosure Firmware Information - Skipping Write-Progress display." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + else + { + + Write-Progress -id 1 -activity "Collecting Enclosure Firmware Information" -CurrentOperation "Completed" -Completed + + } + + } + + $ResourceCategoryEnum.ServerHardware + { + + # Keep track of the number of resources + $_P++ + + $_ProgressParams = @{ + + ID = 1; + Activity = "Generate Firmware Report"; + CurrentOperation = ("Processing '{0}' Server(s)" -f $_resource.name); + PercentComplete = (($_P / $_ResourceCollection.count) * 100) + + } + + # Handle the call from -Verbose so Write-Progress does not get borked on display. + if ($PSBoundParameters['Verbose'] -or $VerbosePreference -eq 'Continue') + { + + "[{0}] Collecting Server Firmware Information - {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), ($_ProgressParams | Out-String) | Write-Verbose + + } + + else + { + + Write-Progress @_ProgressParams + + } + + Try + { + + $_ServerReport = Get-ServerFirmware -Server $_resource -Baseline $Baseline -InstallationPolicy $InstallationPolicy -ProgressID 1 + + $_ServerReport | ForEach-Object { + + [void]$_FirmwareReportCollection.Add($_) + + } + + } + + Catch + { + + Write-Progress -id 1 -activity "Collecting Server Firmware Information" -CurrentOperation "Completed" -Completed + + $PSCmdlet.ThrowTerminatingError($_) + + } + + # Handle the call from -Verbose so Write-Progress does not get borked on display. + if ($PSBoundParameters['Verbose'] -or $VerbosePreference -eq 'Continue') + { + + "[{0}] Completed Collecting Server Firmware Information - Skipping Write-Progress display." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + else + { + + Write-Progress -id 1 -activity "Collecting Server Firmware Information" -CurrentOperation "Completed" -Completed + + } + + } + + {$ResourceCategoryEnum.Interconnect, $ResourceCategoryEnum.SasInterconnect -Contains $_} + { + + # Keep track of the number of resources + $_P++ + + $_ProgressParams = @{ + + ID = 1; + Activity = "Generate Firmware Report"; + CurrentOperation = ("Processing '{0}' Interconnects(s)" -f $_resource.name); + PercentComplete = (($_P / $_ResourceCollection.count) * 100) + + } + + # Handle the call from -Verbose so Write-Progress does not get borked on display. + if ($PSBoundParameters['Verbose'] -or $VerbosePreference -eq 'Continue') + { + + "[{0}] Completed Collecting Server Firmware Information - {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), ($_ProgressParams | Out-String) | Write-Verbose + + } + + else + { + + Write-Progress @_ProgressParams + + } + + Try + { + + $_InterconnectFirmwareReport = Get-InterconnectFirmware -Interconnect $_resource -Baseline $Baseline -ProgressID 1 + + $_InterconnectFirmwareReport | ForEach-Object { + + [void]$_FirmwareReportCollection.Add($_) + + } + + } + + Catch + { + + Write-Progress -id 1 -activity "Collecting Interconnect Firmware Information" -CurrentOperation "Completed" -Completed + + $PSCmdlet.ThrowTerminatingError($_) + + } + + # Handle the call from -Verbose so Write-Progress does not get borked on display. + if ($PSBoundParameters['Verbose'] -or $VerbosePreference -eq 'Continue') + { + + "[{0}] Completed Collecting Interconnect Firmware Information - Skipping Write-Progress display." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + else + { + + Write-Progress -id 1 -activity "Collecting Server Firmware Information" -CurrentOperation "Completed" -Completed + + } + + } + + } + + } + + Write-Progress -ID 10 -ParentID 1 -Activity "Create Enclosure Firmware Report" -Status "Finished." -Completed + + Write-Progress -Activity "Firmware collection report complete." -Status "Finished." -Completed + + if ($Export) + { + + $_Location = '{0}\FirmwareReport_{1}.csv' -f $Location,[DateTime]::Now.ToUniversalTime().ToString('yyyy-MM-ddTHH.mm.ss.ff.fffZzzz').Replace(':','') + + $_FirmwareReportCollection | ForEach-Object { Export-Csv -InputObject $_ -Path $_Location -AppEnd -NoTypeInformation -Encoding UTF8 } + + } + + # Display Report + else + { + + Return $_FirmwareReportCollection + + } + + } + +} + +function Get-EnclosureFirmware +{ + + <# + Internal-only function. + #> + + [CmdletBinding (DefaultParameterSetName = 'Default')] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = "Default")] + [ValidateScript({ + if ($_.category -ne 'enclosures') + { + + Throw ("The resource object provided is not an Enclosure Resource. Expected category 'enclosures', Received '{0}' [{1}]." -f $_.category, $_.name) + } + + else + { + + $True + + } + + })] + [PsCustomObject]$Enclosure, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [object]$Baseline, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Int]$ProgressID = 0 + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + # Reset private variables + $_BaseLinePolicy = $Null + $_EnclosureReport = [System.Collections.ArrayList]::new() + + # Keep track of the number of Servers + $_s = 0 + + # Keep track of the number of Interconnects + $_i = 0 + + # Keep track of the number of OAs + $_o = 0 + + # Keep track of the number of composable infrastructure appliances + $_cia = 0 + # See if EnclosureObject was passed via Pipeline + if (-not $PSBoundParameters['Enclosure']) + { + + $PipelineInput = $True + + } + + } + + Process + { + + $_NoBaselinePolicy = [PsCustomObject]@{ baselineShortName = "NoPolicySet" } + + "[{0}] Enclosure Object passed via pipeline: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), [Bool]$PipelineInput | Write-Verbose + "[{0}] Processing Enclosure firmware report for: '{1}'" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Enclosure.name | Write-Verbose + + # Use the Enclosure FwBaseline if it is set + if ($Enclosure.isFwManaged) + { + + if ($null -eq $Baseline -and -not [String]::IsNullOrEmpty($Enclosure.fwBaselineUri)) + { + + Try + { + + $BaseLinePolicy = Send-OVRequest -Uri $Enclosure.fwBaselineUri -Hostname $Enclosure.ApplianceConnection + + } + + Catch [ResourceNotFoundException] + { + + "[{0}] The baseline associated with the provided enclosure cannot be found. Was it removed from the repository?" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Enclosure.name | Write-Verbose + + $BaseLinePolicy = $_NoBaselinePolicy + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + elseif ($Baseline) + { + + $BaseLinePolicy = $Baseline + + } + + else + { + + "[{0}] No baseline provided, and provided enclosure is not assigned a baseline resource." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $BaseLinePolicy = $_NoBaselinePolicy + + } + + } + + elseif (($Baseline) -and ($Baseline -is [PsCustomObject]) -and ($Baseline.category -eq $ResourceCategoryEnum.Baseline)) + { + + "[{0}] Baseline resource passed." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + "[{0}] Baseline resource name: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Baseline.name | Write-Verbose + "[{0}] Baseline resource uri: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Baseline.uri | Write-Verbose + + $BaseLinePolicy = $Baseline + + } + + # Check to see if the wrong Object has been passed + elseif (($Baseline) -and ($Baseline -is [PsCustomObject]) -and ($Baseline.category -ne "firmware-drivers")) + { + + "[{0}] Invalid Baseline resource passed. Generating error." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $ExceptionMessage = "An invalid Baseline Object was passed. Expected Category type 'firmware-drivers', received '{0}' (Object Name: {1}" -f $Baseline.category, $Baseline.name + $ErrorRecord = New-ErrorRecord InvalidOperationException InvalidBaselineResouce InvalidArgument 'Baseline' -TargetType 'PSObject' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif (($Baseline) -and ($Baseline -is [String]) -and ($Baseline.StartsWith(($ApplianceFwDriversUri)))) + { + + "[{0}] Baseline URI passed: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Baseline | Write-Verbose + + Try + { + + $BaseLinePolicy = Send-OVRequest -Uri $Baseline -Hostname $Enclosure.ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + + } + + # Check to see if the wrong URI has been passed + elseif (($Baseline) -and ($Baseline -is [String]) -and $Baseline.StartsWith("/rest/") -and ( -not $Baseline.StartsWith(($ApplianceBaselineRepoUri)))) + { + + "[{0}] Invalid Baseline URI passed. Generating error." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $ExceptionMessage = "An invalid Baseline URI was passed. URI must start with '/rest/firmware-drivers/', received '{0}'" -f $Baseline + $ErrorRecord = New-ErrorRecord InvalidOperationException InvalidBaselineValue InvalidArgument 'Baseline' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif (($Baseline) -and ($Baseline -is [String])) + { + + "[{0}] Baseline Name passed: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Baseline | Write-Verbose + + Try + { + + $FirmwareBaselineName = $Baseline.PSObject.Copy() + + $BaseLinePolicy = Get-OVBaseline -name $Baseline -ErrorAction SilentlyContinue + + If (-not $BaseLinePolicy) + { + + $ExceptionMessage = "The provided Baseline '{0}' was not found." -f $FirmwareBaselineName + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.BaselineResourceException BaselineResourceNotFound ObjectNotFound 'Baseline' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + else + { + + "[{0}] No Baseline provided." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $BaseLinePolicy = $_NoBaselinePolicy + + } + + # Process shared infrastructure components based on enclosure type + # If C-Class, attach to XML interface to get OA module information. Will need to override SslValidator checks + Switch ($Enclosure.enclosureType) + { + + 'C7000' + { + + # Process OAs first + ForEach ($_oa in $Enclosure.managerbays) + { + + if ($_oa.devicePresence -ne 'Absent') + { + + $_o ++ + + $_ProgressParams = @{ + + id = (2 + $ProgressID); + ParentId = 1; + activity = "Collecting Enclosure Manager Firmware Information"; + CurrentOperation = ("[{0}/{1}] Processing '{2}'" -f $_o, $Enclosure.managerBays.count, $_oa.role); + percentComplete = (($_o / $Enclosure.managerBays.count) * 100) + + } + + # Handle the call from -Verbose so Write-Progress does not get borked on display. + if ($PSBoundParameters['Verbose'] -or $VerbosePreference -eq 'Continue') + { + + "[{0}] Collecting Enclosure Manager Firmware Information - Skipping Write-Progress display: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), ($_ProgressParams | Out-String) | Write-Verbose + + } + + else + { + + Write-Progress @_ProgressParams + + } + + if ($BaseLinePolicy.baselineShortName -eq $_NoBaselinePolicy.baselineShortName) + { + + $BaselineVer = "N/A" + $BaselineName = "N/A" + $BaselineUri = $null + + } + + else + { + + $_BaselineVersions = $BaseLinePolicy.fwComponents | Where-Object KeyNameList -contains "oa" + + $_BaselineVer = GetNewestVersion -Collection $_BaselineVersions + $BaselineName = $Baseline.description + $BaselineUri = $Baseline.uri + + } + + "[{0}] Adding '{1}, OA {2}' to firmware report collection" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Enclosure.name, $_oa.bayNumber | Write-Verbose + + $_EnclosureDeviceReport = [HPEOneView.Servers.Enclosure+Firmware]::new(("{0}, OA {1}" -f $Enclosure.name, $_oa.bayNumber), + 'OnboardAdministrator', + 'Firmware', + $_oa.fwVersion, + $_BaselineVer, + $BaselineName, + $BaselineUri, + $Enclosure.name, + $Enclosure.uri, + $Enclosure.ApplianceConnection) + + [void]$_EnclosureReport.Add($_EnclosureDeviceReport) + + } + + else + { + + "[{0}] Onboard Administrator device bay {1} is absent." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_o | Write-Verbose + + } + + } + + } + + 'SY12000' + { + + # Process FLMs first + ForEach ($_em in $Enclosure.managerbays) + { + + $_o ++ + + $_ProgressParams = @{ + + id = (2 + $ProgressID); + ParentId = 1; + activity = "Collecting Enclosure Manager Firmware Information"; + CurrentOperation = ("[{0}/{1}] Processing '{2}'" -f $_o, $Enclosure.managerBays.count, $_em.role); + percentComplete = (($_o / $Enclosure.managerBays.count) * 100) + + } + + # Handle the call from -Verbose so Write-Progress does not get borked on display. + if ($PSBoundParameters['Verbose'] -or $VerbosePreference -eq 'Continue') + { + + "[{0}] Collecting Enclosure Manager Firmware Information - Skipping Write-Progress display: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), ($_ProgressParams | Out-String) | Write-Verbose + + } + + else + { + + Write-Progress @_ProgressParams + + } + + if ($BaseLinePolicy.baselineShortName -eq $_NoBaselinePolicy.baselineShortName) + { + + $BaselineVer = "N/A" + $BaselineName = "N/A" + $BaselineUri = $null + + } + + else + { + + $_BaselineVersions = $BaseLinePolicy.fwComponents | Where-Object KeyNameList -Contains "em" + + $_BaselineVer = GetNewestVersion -Collection $_BaselineVersions + $BaselineName = $Baseline.description + $BaselineUri = $Baseline.uri + + } + + $_EnclosureDeviceReport = [HPEOneView.Servers.Enclosure+Firmware]::new(("{0} (Bay {1})" -f $_em.model.Trim(), $_em.bayNumber), + 'EnclosureManager', + 'Firmware', + $_em.fwVersion, + $_em.serialNumber, + $_em.partNumber, + $_BaselineVer, + $BaselineName, + $BaselineUri, + $Enclosure.name, + $Enclosure.uri, + $Enclosure.ApplianceConnection) + + [void]$_EnclosureReport.Add($_EnclosureDeviceReport) + + } + + ForEach ($_appliance in ($Enclosure.applianceBays | Where-Object devicePresence -ne 'Absent')) + { + + $_cia ++ + + $_ProgressParams = @{ + + id = (3 + $ProgressID); + ParentId = 1; + activity = "Collecting Composable Infrastructure appliance firmware information"; + CurrentOperation = ("[{0}/{1}] Processing '{2}'" -f $_cia, $Enclosure.applianceBays.count, $_appliance.model); + percentComplete = (($_cia / $Enclosure.applianceBays.count) * 100) + + } + + # Handle the call from -Verbose so Write-Progress does not get borked on display. + if ($PSBoundParameters['Verbose'] -or $VerbosePreference -eq 'Continue') + { + + "[{0}] Collecting Enclosure Manager Firmware Information - Skipping Write-Progress display: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), ($_ProgressParams | Out-String) | Write-Verbose + + } + + else + { + + Write-Progress @_ProgressParams + + } + + $_applianceSerialNumber = $_appliance.serialNumber + $_appliancePartNumber = $_appliance.partNumber + + # Get installed firmware + + if ([RegEx]::Match($_appliance.Model, 'Composer', $RegExInsensitiveFlag).Success) + { + + $_applianeFirmareVersion = $PSLibraryVersion.($Enclosure.ApplianceConnection.Name).ApplianceVersion + + $_EnclosureDeviceReport = [HPEOneView.Servers.Enclosure+Firmware]::new(("{0} (Bay {1})" -f $_appliance.Model, $_appliance.bayNumber), + 'ApplianceDevice', + 'Firmware', + $_applianeFirmareVersion, + $_applianceSerialNumber, + $_appliancePartNumber, + 'N/A', + 'N/A', + $null, + $Enclosure.name, + $Enclosure.uri, + $Enclosure.ApplianceConnection) + + [void]$_EnclosureReport.Add($_EnclosureDeviceReport) + + } + + } + + # Locate drive enclosure relative to the frame + Try + { + + $uri = "{0}?filter=enclosureUri EQ '{1}'" -f $DriveEnclosureUri, $Enclosure.uri + $_driveEnclosures = Send-OVRequest -Uri $uri -Hostname $Enclosure.ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + ForEach ($_driveEnclosure in $_driveEnclosures.members) + { + + # Report drive enclosure IO Adapter(s) + ForEach ($_IOAdatper in $_driveEnclosure.ioAdapters) + { + + $_EnclosureDeviceReport = [HPEOneView.Servers.Enclosure+Firmware]::new(("{0} {1}{2}" -f $_IOAdatper.Model, $_IOAdatper.ioAdapterLocation.locationEntries.type, $_IOAdatper.ioAdapterLocation.locationEntries.value), + 'DriveEnclosureIOAdapter', + 'Firmware', + $_IOAdatper.firmwareVersion, + $_IOAdatper.serialNumber, + $_IOAdatper.partNumber, + 'N/A', + 'N/A', + $null, + $_driveEnclosure.name, + $_driveEnclosure.uri, + $Enclosure.ApplianceConnection) + + [void]$_EnclosureReport.Add($_EnclosureDeviceReport) + + } + + # Report drive device + ForEach ($_driveBay in $_driveEnclosure.driveBays) + { + + $_diskDrive = $_driveBay.drive + + $_EnclosureDeviceReport = [HPEOneView.Servers.Enclosure+Firmware]::new(("{0} {1}" -f $_diskDrive.name, $_diskDrive.model), + 'DiskDrive', + 'Firmware', + $_driveBay.drive.firmwareVersion, + $_diskDrive.serialNumber, + $_diskDrive.model, + 'N/A', + 'N/A', + $null, + $_driveEnclosure.name, + $_driveEnclosure.uri, + $Enclosure.ApplianceConnection) + + [void]$_EnclosureReport.Add($_EnclosureDeviceReport) + + } + + } + + } + + default + { + + Throw ("'{0}' Not implemented." -f $Enclosure.enclosureType) + + } + + } + + # Process Interconnects within Enclosure + "[{0}] Getting Interconnect resources from the enclosure." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_Interconnects = [System.Collections.ArrayList]::new() + + Try + { + + ForEach ($_InterconnectBay in ($Enclosure.interconnectBays | Where-Object { $null -ne $_.interconnectUri })) + { + + $_Object = Send-OVRequest -Uri $_InterconnectBay.interconnectUri -Hostname $Enclosure.ApplianceConnection + + [void]$_Interconnects.Add($_Object) + + } + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + # Process each interconnect + foreach ($_interconnect in $_Interconnects) + { + + $_i++ + + $_ProgressParams = @{ + + id = (4 + $ProgressID); + ParentId = 1; + activity = "Collecting Interconnect Firmware Information"; + CurrentOperation = ("Processing {0}: {1} of {2} Interconnect(s)" -f $_Interconnect.name, $_i, $_Interconnects.Count); + percentComplete = (($_i / $_Interconnects.Count) * 100) + + } + + # Handle the call from -Verbose so Write-Progress does not get borked on display. + if ($PSBoundParameters['Verbose'] -or $VerbosePreference -eq 'Continue') + { + + "[{0}] Collecting Interconnect Firmware Information - Skipping Write-Progress display: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), ($_ProgressParams | Out-String) | Write-Verbose + + } + + else + { + + Write-Progress @_ProgressParams + + } + + Try + { + + $_InterconnectReport = Get-InterconnectFirmware -Interconnect $_interconnect -Baseline $BaseLinePolicy + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + "[{0}] Adding {1} in {2} to Enclosure Firmware collection" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_InterconnectReport.Component, $_InterconnectReport.Name | Write-Verbose + + [void]$_EnclosureReport.Add($_InterconnectReport) + + } + + # Process Server Resource Objects + "[{0}] Getting Server resources from the enclosure." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + # This is faster to get all associated servers within the enclosure than to loop through deviceBays to make additional API calls + $Uri = "{0}?filter=locationUri='{1}'" -f $ServerHardwareUri, $Enclosure.uri + $_Servers = Send-OVRequest -Uri $uri -Hostname $Enclosure.ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $_s = 0 + + foreach ($_server in $_Servers.members) + { + + $_s++ + + $_ProgressParams = @{ + + id = (3 + $ProgressID); + ParentId = 1; + activity = "Collecting Server Firmware Information"; + CurrentOperation = ("[{1}/{2}] Processing '{0}' Server" -f $_server.name, $_s, $_Servers.Count); + percentComplete = (($_s / $_Servers.members.count) * 100) + + } + + # Handle the call from -Verbose so Write-Progress does not get borked on display. + if ($PSBoundParameters['Verbose'] -or $VerbosePreference -eq 'Continue') + { + + "[{0}] Collecting Server Firmware Information - Skipping Write-Progress display: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), ($_ProgressParams | Out-String) | Write-Verbose + + } + + else + { + + Write-Progress @_ProgressParams + + } + + Try + { + + $_ServerFirmwareReport = Get-ServerFirmware -Server $_server -Baseline $BaseLinePolicy + + ForEach ($_item in $_ServerFirmwareReport) + { + + "[{0}] Adding {0} in {1} to Enclosure Firmware collection" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_item.Component, $_item.Name | Write-Verbose + + [void]$_EnclosureReport.Add($_item) + + } + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + # Handle the call from -Verbose so Write-Progress does not get borked on display. + if ($PSBoundParameters['Verbose'] -or $VerbosePreference -eq 'Continue') + { + + "[{0}] Completed Collecting Enclosure Manager/Server/Interconnect Firmware Information - Skipping Write-Progress display." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + else + { + + Write-Progress -ParentId 1 -id (2 + $ProgressID) -activity "Collecting Enclosure Manager Firmware Information" -CurrentOperation "Completed" -Completed + Write-Progress -ParentId 1 -id (3 + $ProgressID) -activity "Collecting Server Firmware Information" -CurrentOperation "Completed" -Completed + Write-Progress -ParentId 1 -id (4 + $ProgressID) -activity "Collecting Interconnect Firmware Information" -CurrentOperation "Completed" -Completed + Write-Progress -Activity "Create Enclosure Firmware Report" -PercentComplete (100) -Status "Finished." -Completed + + } + + } + + End + { + + Return $_EnclosureReport | Sort-Object Name, Component + + } + +} + +function Get-ServerFirmware +{ + + <# + Internal-only function. + #> + + [CmdletBinding (DefaultParameterSetName = 'Default')] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = "Default")] + [Object]$Server, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Object]$Baseline, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [String]$InstallationPolicy, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Int]$ProgressID + + ) + + + Begin + { + + $_ServerReport = [System.Collections.ArrayList]::new() + + } + + Process + { + + $_NoBaselinePolicy = [PsCustomObject]@{ + + name = "NoPolicySet"; + baselineShortName = "NoPolicySet" + + } + + if ([System.String]::IsNullOrWhiteSpace($Server.serverName)) + { + + $_servername = $Server.name + + } + + else + { + + $_servername = $Server.serverName + + } + + "[{0}] Processing Server firmware report for: '{1}'" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_servername | Write-Verbose + + # Check the state of the server. Supported server hardware here first. + if ('Unknown', 'Adding', 'Unmanaged','Removed', 'Unsupported' -notcontains $Server.state) + { + + # A monitored server does not need nor does it support an SHT. + if ($Server.state -eq 'Monitored') + { + + "[{0}] Server is monitored, which does not support a baseline policy." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_BaselinePolicy = [PsCustomObject]@{ + + name = "Unmanageable"; + baselineShortName = "Unmanaged"; + resourceId = $Baseline.ResourceId; + # uri = $null + uri = $Baseline.uri + + } + + } + + # Get the server details if firmware can be managed + else + { + + "[{0}] Getting Server Hardware Type" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + # Check if the server hardware type allows firmware management + Try + { + + $_sht = Send-OVRequest -Uri $Server.serverHardwareTypeUri -Hostname $Server.ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + # Server hardware supports firmware update capability, so build the baseline object to process later + if ([RegEx]::Match($_sht.capabilities, "FirmwareUpdate", $RegExInsensitiveFlag).Success) + { + + "[{0}] Server Hardware Type supports firmware management." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + "[{0}] Baseline value provided: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), ($Baseline | Out-String) | Write-Verbose + + # If a bladeserver and that the caller hasn't specified a Baseline, Use the Enclosure FwBaseline if it is set + if (-not($Baseline)) + { + + # Check to see if there is a profile + if ($Server.serverProfileUri) + { + + "[{0}] No Baseline provided. Checking Server Profile." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $_ServerProfile = Send-OVRequest -Uri $Server.serverProfileUri -Hostname $Server.ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + # Then check if a Baseline is attached there + if ($_ServerProfile.firmware.manageFirmware) + { + + "[{0}] Server Profile has baseline attached. Getting baseline details." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $_BaselinePolicy = Send-OVRequest -Uri $_ServerProfile.firmware.firmwareBaselineUri -Hostname $Server.ApplianceConnection.Name + + } + + Catch [ResourceNotFoundException] + { + + "[{0}] The baseline associated with the provided server profile cannot be found. Was it removed from the repository?" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Enclosure.name | Write-Verbose + + $BaseLinePolicy = $_NoBaselinePolicy + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + "[{0}] Server Profile Baseline name: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_BaselinePolicy.name | Write-Verbose + + "[{0}] Server Profile Baseline name: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_BaselinePolicy.uri | Write-Verbose + + } + + # If not, set $BaselinePolicy to NoPolicySet + else + { + + "[{0}] Server Profile does not have a baseline attached." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_BaselinePolicy.uri | Write-Verbose + + $_BaselinePolicy = $_NoBaselinePolicy + + } + + } + + else + { + + "[{0}] No Server Profile assigned, which does not have a baseline policy set." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_BaselinePolicy = [PsCustomObject]@{ + + name = "NoPolicySet"; + baselineShortName = "NoPolicySet" + + } + + } + + } + + elseif ($Baseline -is [PSCustomObject]) + { + + if ($Baseline.baselineShortName -eq 'NoPolicySet') + { + + "[{0}] No Baseline provided." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_BaselinePolicy = [PsCustomObject]@{ + + name = "NoPolicySet"; + baselineShortName = "NoPolicySet" + + } + + } + + elseif (($Baseline) -and ($Baseline.category -eq $ResourceCategoryEnum.Baseline)) + { + + "[{0}] Baseline resource passed." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + "[{0}] Baseline resource name: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Baseline.baselineShortName | Write-Verbose + "[{0}] Baseline resource uri: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Baseline.uri | Write-Verbose + + $_BaselinePolicy = $Baseline.PSObject.Copy() + + } + + # Check to see if the wrong Object has been passed + elseif (($Baseline) -and ($Baseline.category -ne "firmware-drivers")) + { + + "[{0}] Invalid Baseline resource passed. Generating error." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $ExceptionMessage = "The wrong Baseline Object was passed. Expected Category type 'firmware-drivers', received '{0}' (Object Name: {1}" -f $Baseline.category, $Baseline.name + $ErrorRecord = New-ErrorRecord InvalidOperationException InvalidArgumentType InvalidArgument 'getserverfirmware' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + elseif (($Baseline) -and ($Baseline -is [String]) -and ($Baseline.StartsWith(($ApplianceFwDriversUri)))) + { + + "[{0}] Baseline URI passed: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Baseline | Write-Verbose + + Try + { + + $_BaseLinePolicy = Send-OVRequest -Uri $Baseline -Hostname $Server.ApplianceConnection.Name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + # Check to see if the wrong URI has been passed + elseif (($Baseline) -and ($Baseline -is [String]) -and $Baseline.StartsWith("/rest/") -and (-not($Baseline.StartsWith(($ApplianceBaselineRepoUri))))) + { + + "[{0}] Invalid Baseline URI passed. Generating error." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + $ExceptionMessage = "The wrong Baseline URI was passed. URI must start with '/rest/firmware-drivers/', received '{0}'" -f $Baseline + $ErrorRecord = New-ErrorRecord InvalidOperationException InvalidArgumentType InvalidArgument 'getserverfirmware' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + # Baseline must be a Name + else + { + + "[{0}] Baseline Name passed: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Baseline | Write-Verbose + + Try + { + + $FirmwareBaselineName = $Baseline.PSObject.Copy() + + $_BaseLinePolicy = Get-OVBaseline -name $Baseline -ApplianceConnection $Server.ApplianceConnection.Name -ErrorAction Stop + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + "[{0}] Server resource does not support firmware management." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_BaselinePolicy = [PsCustomObject]@{ + + name = "Unmanageable"; + baselineShortName = "Unmanaged"; + uri = $null + + } + + } + + } + + # Check Baseline Policy and set Compliance statement, and just get the available firmware/driver/utilities details + # if ('Unmanaged', "NoPolicySet" -contains $_BaseLinePolicy.baselineShortName) + if ($_BaseLinePolicy.baselineShortName -eq "NoPolicySet") + { + + # Get firmware report from server resource since no baseline is associated + $_Uri = '{0}/firmware' -f $Server.uri + + Try + { + + $_ServerHardwareFirmwareCompliance = Send-OVRequest -Uri $_Uri -Hostname $Server.ApplianceConnection.Name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + # Generate a firmware compliance report based on the available/assigned baseline + else + { + + # This is where we generate compliance report of server hardware with baseline + Try + { + + $_FirmwareComplianceReportRequest = @{ + serverUUID = $Server.uuid; + firmwareBaselineId = $_BaseLinePolicy.resourceId; + installationPolicy = $InstallationPolicy + } + + $_ServerHardwareFirmwareCompliance = Send-OVRequest -Uri $ServerHardwareFirmwareComplianceUri -Method POST -Body $_FirmwareComplianceReportRequest -Hostname $Server.ApplianceConnection.Name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + Switch ($_ServerHardwareFirmwareCompliance.type) + { + + 'server-hardware-firmware-1' + { + + ForEach ($_Component in $_ServerHardwareFirmwareCompliance.components) + { + + $_ComponentName = $_Component.componentName + + # Need to check AMS here, as it is showing up as firmware component type + if ([String]::IsNullOrEmpty($_Component.componentLocation) -or $_Component.componentLocation -eq " ") + { + + $_ComponentType = 'Software' + + if ($_ComponentName -eq 'null') + { + + $_ComponentName = $_Component.componentLocation + + } + + } + + else + { + + $_ComponentType = "Firmware" + + } + + if (($_ComponentName.Contains('System ROM') -or $_ComponentName.Contains('System BIOS')) -and -not $_ComponentName.Contains('Backup')-and -not $_ComponentName.Contains('Redundant')) + { + + $_SerialNumber = $Server.serialNumber + $_PartNumber = $Server.partNumber + + } + + else + { + + $_SerialNumber = 'N/A' + $_PartNumber = 'N/A' + + } + + $_ComponentVersion = [HPEOneView.Servers.ServerHardware+Firmware]::new($_ComponentName, + $_ComponentType, + $_Component.componentVersion, + $_SerialNumber, + $_PartNumber, + $_Component.baselineVersion, + $_BaseLinePolicy.name, + $_BaseLinePolicy.uri, + $_servername, + $Server.shortModel, + $Server.uri, + $Server.ApplianceConnection) + + [void]$_ServerReport.Add($_ComponentVersion) + + } + + } + + default + { + + if ($_ServerHardwareFirmwareCompliance.componentMappingList.Count -eq 0 -and $Baseline -ne "NoPolicySet") + { + + Try + { + + $_ServerFirmwareComponents = Send-OVRequest -Uri ($Server.uri + "/firmware") -Hostname $Server.ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + ForEach ($_Component in $_ServerFirmwareComponents.components) + { + + $_componentName = $_Component.componentName + $_componentType = 'Firmware' + + Switch ($_componentName) + { + + {([Regex]::Match($_, 'System (ROM|BIOS)')).Success} + { + + $_swKeyNameListName = $Server.romVersion.SubString(0,3) + $_BaselineVersion = GetNewestVersion -Collection ($Baseline.fwComponents | Where-Object KeyNameList -contains $_swKeyNameListName) + + if ($_Component.componentName.Contains('System ROM') -or $_Component.componentName.Contains('System BIOS') -and -not $_Component.componentName.Contains('Backup')-and -not $_Component.componentName.Contains('Redundant')) + { + + $_SerialNumber = $Server.serialNumber + $_PartNumber = $Server.partNumber + + } + + else + { + + $_SerialNumber = 'N/A' + $_PartNumber = 'N/A' + + } + + } + + 'iLO' + { + + $_swKeyNameListName = $MpModelTable.($Server.mpModel) + $_BaselineVersion = GetNewestVersion -Collection ($Baseline.fwComponents | Where-Object KeyNameList -contains $_swKeyNameListName) + + } + + 'Intelligent Provisioning' + { + + $_BaselineVersion = 'N/A' + + } + + {([Regex]::Match($_, 'Power Management Controller (Firmware|System)?')).Success} + { + + switch ($Server.model) + { + + {([Regex]::Match($_, 'Gen9')).Success} + { + + $_swKeyNameListName = 'PowerPIC-Gen9' + + } + + {([Regex]::Match($_, 'Gen8')).Success} + { + + $_swKeyNameListName = 'PowerPIC-Gen8' + + } + + default + { + + $_swKeyNameListName = $_componentName + + } + + } + + $_BaselineVersion = GetNewestVersion -Collection ($Baseline.fwComponents | Where-Object KeyNameList -contains $_swKeyNameListName) + + } + + 'null' + { + + $_componentName = $_Component.componentLocation + $_componentType = 'Driver' + + } + + } + + $_ComponentVersion = [HPEOneView.Servers.ServerHardware+Firmware]::new($_componentName, + $_componentType, + $_Component.componentVersion, + $_SerialNumber, + $_PartNumber, + $_BaselineVersion, + $_BaseLinePolicy.name, + $_BaseLinePolicy.uri, + $_servername, + $Server.shortModel, + $Server.uri, + $Server.ApplianceConnection) + + [void]$_ServerReport.Add($_ComponentVersion) + + } + + } + + else + { + + ForEach ($_Component in $_ServerHardwareFirmwareCompliance.componentMappingList) + { + + $_componentName = $_Component.componentName + $_componentType = 'Firmware' + + Switch ($_componentName) + { + + {([Regex]::Match($_, 'System (ROM|BIOS)')).Success} + { + + if ($_Component.componentName.Contains('System ROM') -or $_Component.componentName.Contains('System BIOS') -and -not $_Component.componentName.Contains('Backup')-and -not $_Component.componentName.Contains('Redundant')) + { + + $_SerialNumber = $Server.serialNumber + $_PartNumber = $Server.partNumber + + } + + else + { + + $_SerialNumber = 'N/A' + $_PartNumber = 'N/A' + + } + + } + + 'Intelligent Provisioning' + { + + $_BaselineVersion = 'N/A' + + } + + 'null' + { + + $_componentName = $_Component.componentLocation + $_componentType = 'Software' + + } + + } + + if ([String]::IsNullOrEmpty($_Component.componentLocation) -or $_Component.componentLocation -eq " ") + { + + $_ComponentType = 'Software' + + if ($_ComponentName -eq 'null') + { + + $_ComponentName = $_Component.componentLocation + + } + + } + + $_ComponentVersion = [HPEOneView.Servers.ServerHardware+Firmware]::new($_componentName, + $_ComponentType, + $_Component.installedVersion, + $_SerialNumber, + $_PartNumber, + $_Component.baselineVersion, + $_BaseLinePolicy.name, + $_BaseLinePolicy.uri, + $_servername, + $Server.shortModel, + $Server.uri, + $Server.ApplianceConnection) + + [void]$_ServerReport.Add($_ComponentVersion) + + } + + } + + } + + } + + } + + else + { + + "[{0}] Server Hardware is not in a Managed state." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_SerialNumber = $Server.serialNumber + $_PartNumber = $Server.partNumber + + $_UnmanageableServer = [HPEOneView.Servers.ServerHardware+Firmware]::new("N/A", + "N/A", + "N/A", + $_SerialNumber, + $_PartNumber, + "Unmanageable", + "Unmanaged", + $null, + $_servername, + $Server.shortModel, + $Server.uri, + $Server.ApplianceConnection) + [void]$_ServerReport.Add($_UnmanageableServer) + + } + + } + + End + { + + Return $_ServerReport | Sort-Object Name, Component + + } + +} + +function Get-InterconnectFirmware +{ + + <# + Internal-only function. + #> + + [CmdletBinding (DefaultParameterSetName = 'Default')] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = "Default")] + [PsCustomObject]$Interconnect, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [object]$Baseline = $Null, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Int]$ProgressID + + ) + + + Begin + { + + $_InterconnectReport = [System.Collections.ArrayList]::new() + + } + + Process + { + + $_NoBaselinePolicy = [PsCustomObject]@{ + + name = "NoPolicySet"; + baselineShortName = "NoPolicySet" + + } + + "[{0}] Processing Interconnect firmware report for: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Interconnect.name | Write-Verbose + + $_InterconnectFirmwareVersion = $Interconnect.firmwareVersion + + if (-not $Baseline) + { + + "[{0}] Baseline was not provided, checking Logical Interconnect Firmware Baseline set." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + switch ($Interconnect.category) + { + + 'sas-interconnects' + { + + $_baseUri = $Interconnect.sasLogicalInterconnectUri + + } + + 'interconnects' + { + + $_baseUri = $Interconnect.logicalInterconnectUri + + } + + } + + $_Uri = '{0}/firmware' -f $_baseUri + + $_LogicalInterconnectFirmware = Send-OVRequest -Uri $_Uri -Hostname $Interconnect.ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if ($_LogicalInterconnectFirmware.sppUri.ToLower() -ne 'unknown' -and -not [System.String]::IsNullOrWhiteSpace($_LogicalInterconnectFirmware.sppUri)) + { + + Try + { + + $_BaseLinePolicy = Send-OVRequest -Uri $_LogicalInterconnectFirmware.sppUri -Hostname $Interconnect.ApplianceConnection.Name + + "[{0}] Logical Interconenct Firmware Baseline name: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_BaseLinePolicy.name | Write-Verbose + + } + + Catch [ResourceNotFoundException] + { + + "[{0}] The baseline associated with the provided server profile cannot be found. Was it removed from the repository?" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Enclosure.name | Write-Verbose + + $BaseLinePolicy = $_NoBaselinePolicy + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + Elseif (-not [System.String]::IsNullOrWhiteSpace($Interconnect.enclosureUri)) + { + + "[{0}] Baseline was not provided, checking Enclosure Firmware Baseline set." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $_Enclosure = Send-OVRequest -Uri $Interconnect.enclosureUri -Hostname $Interconnect.ApplianceConnection.Name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + "[{0}] Enclosure Firmware Baseline set: {0}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_Enclosure.isFwManaged | Write-Verbose + + # Check if the Enclosure has a Firmware Baseline attached + if ($_Enclosure.isFwManaged -and $_Enclosure.fwBaselineUri) + { + + Try + { + + $_BaseLinePolicy = Send-OVRequest -Uri $_Enclosure.fwBaselineUri -Hostname $Interconnect.ApplianceConnection.Name + + "[{0}] Enclosure Firmware Baseline name: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_BaseLinePolicy.name | Write-Verbose + + } + + Catch [ResourceNotFoundException] + { + + "[{0}] The baseline associated with the provided server profile cannot be found. Was it removed from the repository?" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Enclosure.name | Write-Verbose + + $BaseLinePolicy = $_NoBaselinePolicy + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + else + { + + "[{0}] No Baseline provided." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_BaselinePolicy = $_NoBaselinePolicy + + } + + } + + else + { + + "[{0}] No Baseline provided." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_BaselinePolicy = $_NoBaselinePolicy + + } + + } + + elseif ($Baseline -is [PSCustomObject]) + { + + if ($Baseline.baselineShortName -eq 'NoPolicySet') + { + + "[{0}] No Baseline provided." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_BaselinePolicy = $_NoBaselinePolicy + + } + + elseif (($Baseline) -and ($Baseline.category -eq $ResourceCategoryEnum.Baseline)) + { + + "[{0}] Baseline resource passed." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + "[{0}] Baseline resource name: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Baseline.baselineShortName | Write-Verbose + "[{0}] Baseline resource uri: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Baseline.uri | Write-Verbose + + $_BaselinePolicy = $Baseline.PSObject.Copy() + + } + + # Check to see if the wrong Object has been passed + elseif ($null -ne $Baseline -and $Baseline.category -ne "firmware-drivers") + { + + "[{0}] Invalid Baseline resource passed. Generating error." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $ExceptionMessage = "An invalid Baseline Object was passed. Expected Category type 'firmware-drivers', received '{0}' (Object Name: {1})" -f $Baseline.category, $Baseline.name + $ErrorRecord = New-ErrorRecord InvalidOperationException InvalidArgumentType InvalidArgument 'Baseline' -TargetType 'PSObject' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + elseif ($null -ne $Baseline -and $Baseline -is [String] -and $Baseline.StartsWith($ApplianceFwDriversUri)) + { + + "[{0}] Baseline URI passed: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Baseline | Write-Verbose + + Try + { + + $_BaseLinePolicy = Send-OVRequest -Uri $Baseline -Hostname $Server.ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + # Check to see if the wrong URI has been passed + elseif ($null -ne $Baseline -and $Baseline -is [String] -and -not $Baseline.StartsWith($ApplianceBaselineRepoUri)) + { + + "[{0}] Invalid Baseline URI passed. Generating error." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $ExceptionMessage = "An invalid Baseline URI was passed. URI must start with '/rest/firmware-drivers/', received '{0}'" -f $Baseline + $ErrorRecord = New-ErrorRecord InvalidOperationException InvalidArgumentType InvalidArgument 'Baseline' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + else + { + + "[{0}] Unknown baseline." -f $MyInvocation.InvocationName.ToString().ToUpper(), $Baseline | Write-Verbose + + } + + if ($_BaseLinePolicy.baselineShortName -eq "NoPolicySet") + { + + $_BaselineVer = "N/A" + $_Compliance = "N/A" + + } + + else + { + + switch ($Interconnect.enclosureType) + { + + 'C7000' + { + + # C-CLASS + # {vceth, vc8gb} HPE BladeSystem c-Class Virtual Connect Firmware, Ethernet plus 8Gb 20-port and 8/16Gb 24-port FC Edition Component for Linux + $_ComponentType = 'vceth' + + } + + default + { + + switch ($Interconnect.model) + { + + 'Virtual Connect SE 100Gb F32 Module for Synergy' + { + + $_ComponentType = 'icmvc100gbf32' + + } + + 'Virtual Connect SE 40Gb F8 Module for Synergy' + { + + # {icmvc40gbf8} HPE Virtual Connect SE 40Gb F8 Module for Synergy Firmware install package + $_ComponentType = 'icmvc40gbf8' + + } + + + 'Virtual Connect SE 16Gb FC Module for Synergy' + { + + # {icmvc16gbfc} Virtual Connect SE 16Gb FC Module for Synergy + $_ComponentType = 'icmvc16gbfc' + + } + + 'Virtual Connect SE 32Gb FC Module for Synergy' + { + + $_ComponentType = 'icmvc32gbfc' + + } + + 'Synergy 50Gb Interconnect Link Module' + { + + $_ComponentType = 'icmslm' + + } + + {'Synergy 10Gb Interconnect Link Module', 'Synergy 20Gb Interconnect Link Module' -contains $_} + { + + # {icmlm} Synergy 10/20 Gb Interconnect Link Module + $_ComponentType = 'icmlm' + + } + + 'Synergy 10Gb Pass-Thru Module' + { + + # {icmpt} Synergy 10Gb Pass-Thru Module + $_ComponentType = 'icmpt' + + } + + 'Synergy 12Gb SAS Connection Module' + { + + # {12G SAS Conn Mod} Smart Component for HPE Synergy 12Gb SAS Connection Module Firmware + $_ComponentType = '12G SAS Conn Mod' + + } + + default + { + + Throw ("{0} module not implemented." -f $Interconnect.model) + + } + + } + + } + + } + + $_BaselineVersions = $_BaseLinePolicy.fwComponents | Where-Object KeyNameList -contains $_ComponentType + + $_BaselineVer = GetNewestVersion -Collection $_BaselineVersions + + } + + $_EnclosureDeviceReport = [HPEOneView.Servers.Enclosure+Firmware]::new($Interconnect.name, + $Interconnect.model, + 'Firmware', + $_InterconnectFirmwareVersion, + $Interconnect.serialNumber, + $Interconnect.partNumber, + $_BaselineVer, + $_BaselinePolicy.name, + $_BaselinePolicy.uri, + $Interconnect.enclosureName, + $Interconnect.enclosureUri, + $Interconnect.ApplianceConnection) + + [void]$_InterconnectReport.Add($_EnclosureDeviceReport) + + } + + End + { + + Return $_InterconnectReport + + } + +} + +Function GetNewestVersion +{ + + <# + Internal-only function. + #> + + [CmdletBinding (DefaultParameterSetName = "Default")] + Param + ( + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Array]$Collection + + ) + + Process + { + + if ($Collection.Count -eq 0) + { + + # The baseline likely doesn't contain the component firmware + + Return 'N/A' + + } + + $_NewerVersion = '0.0' + + # Figure out which is the newest, and only display that if multiple ROM versions found + foreach ($_Component in $Collection) + { + + if ($_Component.PSObject.Properties.name -contains "Version") + { + + $_ComponentVersionPropName = "Version" + + } + + else + { + + $_ComponentVersionPropName = "componentVersion" + + } + + 'Processing {0} version of {1}' -f $_Component.$_ComponentVersionPropName, $_Component.name | Write-Verbose + + if ($_Component.$_ComponentVersionPropName -ge $_NewerVersion) + { + + $_NewerVersion = $_Component.$_ComponentVersionPropName + + } + + } + + if ($_NewerVersion -eq '0.0') + { + + $_NewerVersion = 'N/A' + + } + + Return $_NewerVersion + + } + +} + +function Enable-OVDeviceUid +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "Default")] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = "Default")] + [ValidateNotNullOrEmpty()] + [Alias ('Server','Enclosure','Frame','Resource')] + [Object]$InputObject, + + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = "Default")] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not($PSBoundParameters['Resource'])) + { + + $PipelineInput = $True + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + $_ResourceStatusCollection = [System.Collections.ArrayList]::new() + + } + + Process + { + + $_RequestCollection = [System.Collections.ArrayList]::new() + + if ($PiplineInput) + { + + "[{0}] Pipeline Input Received." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + if ($InputObject -isnot [PSCustomObject]) + { + + $Message = 'The -Resource Parameter value is not an Object. Please use Get-OVServer or Get-OVEnclosure to provide an allowed resource object.' + $ErrorRecord = New-ErrorRecord InvalidOperationException InvalidArgumentValue InvalidArgument 'InputObject' -TargetType $InputObject.GetType().Name -Message $Message + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + $_PatchRequest = NewObject -PatchOperation + + "[{0}] Turning UID on for: {1} {{2}}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject.name, $InputObject.category | Write-Verbose + + switch ($InputObject.category) + { + + {'server-hardware', 'enclosures', 'interconnects', 'sas-interconnects' -contains $_} + { + + if ($InputObject.enclosureType -eq 'C7000') + { + + $Message = "The -InputObject parameter value is an unsupported enclosure resource type. Only HPE Synergy enclosure resources are supported." + $ErrorRecord = New-ErrorRecord InvalidOperationException InvalidArgumentValue InvalidArgument 'InputObject' -TargetType $InputObject.GetType().Name -Message $Message + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + $_PatchRequest.op = 'replace' + $_PatchRequest.path = '/uidState' + $_PatchRequest.value = 'On' + + } + + default + { + + $Message = "The -InputObject Parameter value is not a supported object, {0}. This Cmdlet only supports 'server-hardware' or 'enclosures'. Please use Get-OVServer or Get-OVEnclosure to provide an allowed resource object." -f $InputObject.category + $ErrorRecord = New-ErrorRecord InvalidOperationException InvalidArgumentValue InvalidArgument 'InputObject' -TargetType $InputObject.GetType().Name -Message $Message + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + [void]$_RequestCollection.Add($_PatchRequest) + + Try + { + + Send-OVRequest -Uri $InputObject.uri -Method PATCH -Body $_RequestCollection -AddHeader @{'if-match' = $InputObject.eTag} -ApplianceConnection $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Disable-OVDeviceUid +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "Default")] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = "Default")] + [ValidateNotNullOrEmpty()] + [Alias ('Server','Enclosure','Frame','Resource')] + [Object]$InputObject, + + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = "Default")] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not($PSBoundParameters['Resource'])) + { + + $PipelineInput = $True + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $_ResourceStatusCollection = [System.Collections.ArrayList]::new() + + } + + Process + { + + $_RequestCollection = [System.Collections.ArrayList]::new() + + if ($PiplineInput) + { + + "[{0}] Pipeline Input Received." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + if ($InputObject -isnot [PSCustomObject]) + { + + $ErrorRecord = New-ErrorRecord InvalidOperationException InvalidArgument InvalidArgument 'InputObject' -Message "InputObject is not a PSCustomObject." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + $_PatchRequest = NewObject -PatchOperation + + "[{0}] Turning UID OFF for: {1} {{2}}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject.name, $InputObject.category | Write-Verbose + + switch ($InputObject.category) + { + + {'server-hardware', 'enclosures', 'interconnects', 'sas-interconnects' -contains $_} + { + + if ($InputObject.enclosureType -eq 'C7000') + { + + $Message = "The -InputObject parameter value is an unsupported enclosure resource type. Only HPE Synergy enclosure resources are supported." + $ErrorRecord = New-ErrorRecord InvalidOperationException InvalidArgumentValue InvalidArgument 'InputObject' -TargetType $InputObject.GetType().Name -Message $Message + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + $_PatchRequest.op = 'replace' + $_PatchRequest.path = '/uidState' + $_PatchRequest.value = 'Off' + + } + + default + { + + $Message = "The -InputObject Parameter value is not a supported object, {0}. This Cmdlet only supports 'server-hardware' or 'enclosures'. Please use Get-OVServer or Get-OVEnclosure to provide an allowed resource object." -f $InputObject.category + $ErrorRecord = New-ErrorRecord InvalidOperationException InvalidArgumentValue InvalidArgument 'InputObject' -TargetType $InputObject.GetType().Name -Message $Message + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + [void]$_RequestCollection.Add($_PatchRequest) + + Try + { + + Send-OVRequest -Uri $InputObject.uri -Method PATCH -Body $_RequestCollection -AddHeader @{'if-match' = $InputObject.eTag} -ApplianceConnection $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function ConvertTo-OVImageStreamerConfiguration +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdLetBinding (DefaultParameterSetName = "default", SupportsShouldProcess, ConfirmImpact = 'High')] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = "default")] + [ValidateNotNullOrEmpty()] + [Alias ('EnclosureGroup','EG')] + [Object]$InputObject, + + [Parameter (Mandatory, ParameterSetName = "default")] + [ValidateNotNullOrEmpty()] + [String]$UplinkSetName, + + [Parameter (Mandatory = $false, ParameterSetName = "default")] + [ValidateNotNullOrEmpty()] + [Array]$UplinkPorts = @("Enclosure1:Bay3:Q1.1", "Enclosure1:Bay3:Q2.1", "Enclosure2:Bay6:Q1.1", "Enclosure2:Bay6:Q2.1"), + + [Parameter (Mandatory, ParameterSetName = 'default')] + [ValidateNotNullOrEmpty()] + [Object]$DeploymentNetwork, + + [Parameter (ValueFromPipelineByPropertyName, Mandatory = $false, ParameterSetName = "default")] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + "[{0}] Bound PS Parameters: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), ($PSBoundParameters | out-string) | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + + if (-not($PSBoundParameters['InputObject'])) + { + + $PipelineInput = $True + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -gt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + $_TaskCollection = [System.Collections.ArrayList]::new() + $_Collection = [System.Collections.ArrayList]::new() + + } + + Process + { + + If ($ApplianceConnection.ApplianceType -ne 'Composer') + { + + $ExceptionMessage = 'The ApplianceConnection {0} ({1}) is not a Synergy Composer. This Cmdlet only support Synergy Composer management appliances.' -f $ApplianceConnection.Name, $ApplianceConnection.ApplianceType + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.ComposerNodeException InvalidOperation InvalidOperation 'ApplianceConnection' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Try + { + + if (-not(Get-OVOSDeploymentServer -ApplianceConnection $ApplianceConnection -ErrorAction SilentlyContinue)) + { + + $ExceptionMessage = 'The appliance {0} does not have a Deployment Server. One must be created before attempting to set an Enclosure Group and Logical Interconnect Group policy change.' -f $ApplianceConnection.name + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.DeploymentServerResourceException OsDeploymentServerNotFound ObjectNotFound 'ApplianceConnect' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $MultipleAssociatedEGs = $False + + "[{0}] InputObject: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), ($InputObject | Out-String) | Write-Verbose + + # Validate InputObject + if ($InputObject -is [PCustomObject]) + { + + "[{0}] Processing category: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject.category | Write-Verbose + + if ($InputObject.category -eq $ResourceCategoryEnum.LogicalEnclosure) + { + + Try + { + + $InputObject = Send-OVRequest -Uri $InputObject.enclosureGroupUri -ApplianceConnection $InputObject.ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + elseif ($InputObject.category -eq $ResourceCategoryEnum.LogicalInterconnectGroup) + { + + # Check to see if the LIG is a member of other EG's via the Index? + try + { + + $IndexResults = Send-OVRequest -Uri ('{0}?childUri={1}&name=ENCLOSURE_GROUP_TO_LOGICAL_INTERCONNECT_GROUP' -f $IndexUri, $InputObject.uri) + + $MultipleAssociatedEGs = $IndexResults.count -gt 1 + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + elseif ($InputObject.category -ne $ResourceCategoryEnum.EnclosureGroup) + { + + $ErrorRecord = New-ErrorRecord + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + # Look for name? + else + { + + Try + { + + $InputObject = Get-OVEnclosureGroup -Name $InputObject -ErrorAction Stop + + } + + catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + # Process multiple EG's + if ($MultipleAssociatedEGs) + { + + $InputObject = [System.Collections.ArrayList]::new() + + "[{0}] Processing multiple Enclosure Group associations to Logical Interconnect Group" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + ForEach ($_Item in $IndexResults) + { + + Try + { + + $EnclosureGroup = Send-OVRequest -Uri $_Item.parentUri -Hostname $ApplianceConnection + + [void]$InputObject.Add($EnclosureGroup) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + # Single EG + else + { + + "[{0}] Processing single Enclosure Group associations to Logical Interconnect Group" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + # Process all EG's by removing the LIG association from Bay3 and Bay6 first + ForEach ($_EnclosureGroup in $InputObject) + { + + # EG is already configured for Image Streamer, generate error + if ($_EnclosureGroup.osDeploymentSettings.manageOSDeployment) + { + + $ExceptionMessage = 'The Enclosure Group {0} is already configured for Image Streamer.' -f $_EnclosureGroup.name + $ErrorRecord = New-ErrorRecord HPEOneView.EnclosureGroupResourceException EnclosureGroupAlreadyConfigured InvalidParameter 'InputObject' -TargetType 'PSObject' -Message $ExceptionMessage + $PSCmdlet.WriteError($ErrorRecord) + + } + + else + { + + # Locate LIG within EG at Frame 1, Bay 3 and Frame 2, Bay 6 + ForEach ($_LIGUri in ($_EnclosureGroup.interconnectBayMappings | Where-Object { 3,6 -contains $_.interconnectBay })) + { + + Try + { + + $Bay3LIG = Send-OVRequest -Uri ($_LigUri | Where-Object interconnectBay -eq 3).logicalInterconnectGroupUri + $Bay6LIG = Send-OVRequest -Uri ($_LigUri | Where-Object interconnectBay -eq 6).logicalInterconnectGroupUri + $associatedig = $Bay3Lig.PSObject.Copy() + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + # LIGs do not match, generate terminating error that it is not supported. + if ($Bay3Lig.uri -ne $Bay6Lig.uri) + { + + $ExceptionMessage = 'The Logical Interconnect Groups assigned to Bays 3 and 6 are not the same policy (Bay3: {0}; Bay6: {1}). Image Streamer is only supported with Redundant Interconnect Modules.' -f $Bay3Lig.name,$Bay6Lig.name + $ErrorRecord = New-ErrorRecord HPEOneView.LogicalInterconnectGroupResourceException UnsupportedLigConfiguration InvalidOperation 'InputObject' -TargetType $InputObject.GetType().Name -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + # UPDATE EG + $ShouldProcessMessage = "Remove Logical Interconnect Group {0} from Enclosure Group on appliance '{1}'" -f $Bay3Lig.name, $InputObject.ApplianceConnection.Name + + if ($PSCmdlet.ShouldProcess($_EnclosureGroup.name, $ShouldProcessMessage)) + { + + # Copy object to then update copy, retain original for use later + $UpdateEg = $_EnclosureGroup.PSObject.Copy() + + # Strip out Bays 3 and 6 from Interconnect Bay Mappings + $UpdateEg.interconnectBayMappings | Where-Object { 3,6 -notcontains $_.interconnectBay } + + # Update EG object on appliance + Try + { + + $Results = Send-OVRequest -Uri $UpdateEg.uri -Method PUT -Body $UpdateEg -ApplianceConnection $UpdateEg.ApplianceConnection | Wait-OVTaskComplete + + [void]$_Collection.Add($UpdateEg) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if ($Results.taskState -ne 'Completed') + { + + $ExceptionMessage = 'The Logical Interconnect Groups update did not complete successfully: {0}' -f [String]::Join(' ', $Results.taskErrors.message) + $ErrorRecord = New-ErrorRecord HPEOneView.LogicalInterconnectGroupResourceException InvalidUpdateLigResult InvalidResult 'InputObject' -TargetType $_EnclosureGroup.GetType().Name -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + elseif ($PSBoundParameters['WhatIf']) + { + + "[{0}] User passed -WhatIf parameter." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + } + + # Update LIG with new Uplink Set + $ShouldProcessMessage = "Add new Image Streamer Uplink Set {0}" -f $UplinkSetName + + if ($PSCmdlet.ShouldProcess($associatedig.name, $ShouldProcessMessage)) + { + + $UplinkSetParams = @{ + + Name = $UplinkSetName; + Type = 'ImageStreamer'; + InputObject = $Bay3Lig; + Networks = $DeploymentNetwork; + UplinkPorts = $UplinkPorts + + } + + Try + { + + $i3SUplinkSetResults = New-OVUplinkSet @UplinkSetParams -ApplianceConnection $InputObject.ApplianceConnection | Wait-OVTaskComplete + + } + + Catch + { + + $PSCmdlet.ThrowterminatingError($_) + + } + + } + + elseif ($PSBoundParameters['WhatIf']) + { + + "[{0}] User passed -WhatIf parameter." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + # Update each EG with Deployment Network settings and Bay3 and Bay6 LIG mapping; + ForEach ($_EnclosureGroupToUpdate in $InputObject) + { + + # Get EG resource to get updated eTag and modifiedDate values + Try + { + + $UpdatedEg = Get-OVEnclosureGroup -Name $_EnclosureGroupToUpdate.name -ApplianceConnection $_EnclosureGroupToUpdate.ApplianceConnection -ErrorAction Stop + + } + + Catch + { + + $PSCmdlet.ThrowterminatingError($_) + + } + + # Update original object with new eTag and modifiedDate values + $_EnclosureGroupToUpdate.eTag = $UpdatedEg.eTag.Copy() + $_EnclosureGroupToUpdate.modifiedDate = $UpdatedEg.modifiedDate.Copy() + + Try + { + + Send-OVRequest -Uri $_EnclosureGroupToUpdate.uri -Method PUT -Body $_EnclosureGroupToUpdate -ApplianceConnection $_EnclosureGroupToUpdate.ApplianceConnection | Wait-OVTaskComplete + + } + + Catch + { + + $PSCmdlet.ThrowterminatingError($_) + + } + + } + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Show-OVUtilization +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "default")] + [OutputType ([HPEOneView.ServerUtilization])] + [OutputType ([HPEOneView.EnclosureUtilization])] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = "default")] + [ValidateNotNullOrEmpty()] + [Alias ('Resource')] + [Object]$InputObject, + + [Parameter (ValueFromPipelineByPropertyName, Mandatory = $false, ParameterSetName = "default")] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + "[{0}] Bound PS Parameters: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), ($PSBoundParameters | out-string) | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + # Key off of ApplianceConnection for Pipeline Input + if (-not($PSBoundParameters['InputObject'])) + { + + $PipelineInput = $True + + } + + else + { + + Try + { + + $null = Test-OVAuth $InputObject.ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $errorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $InputObject.ApplianceConnection -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($errorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + Process + { + + function GetPeakValue ([Object]$Object1) + { + + $_PeakValue = 0 + + ForEach ($_Sample in $Object1.metricSamples) + { + + if ($_Sample[1] -gt $_PeakValue) + { + + $_PeakValue = $_Sample[1] + + } + + } + + return $_PeakValue + + } + + ForEach ($_resource in $InputObject) + { + + "[{0}] Processing object: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_resource.name | Write-Verbose + + switch ($_resource.category) + { + + $ResourceCategoryEnum.ServerProfile + { + + $_uri = $_resource.serverHardwareUri + '/utilization' + + } + + $ResourceCategoryEnum.ServerHardware + { + + $_uri = $_resource.uri + '/utilization' + + } + + $ResourceCategoryEnum.Enclosure + { + + $_uri = $_resource.uri + '/utilization' + + } + + default + { + + # Resource is unsupported, generate error + $ExceptionMessage = "The provided InputObject is not an enclosure, server hardware or server profile resource." + $ErrorRecord = New-ErrorRecord HPEOneView.Library.ParameterValidationException InvalidInputObjectParameter InvalidOperation 'InputObject' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + # Check to see if the resource is eligable for performance monitoring. + + Try + { + + $_UtilizationData = Send-OVRequest -uri $_uri -Hostname $_resource.ApplianceConnection.Name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $_TempData = @{ + PowerCurrent = 0; + PowerAverage = 0; + PowerPeak = 0; + PowerMax = 0; + AverageTemp = 0; + AmbientTemperature = 0; + CPUCurrent = 0; + CPUAverage = 0; + CPUPeak = 0 + } + + ForEach ($_item in $_UtilizationData.metricList) + { + + switch ($_item.metricName) + { + + # CurrentTemp + 'AmbientTemperature' + { + + $_total = 0 + $_count = 0 + $_item.metricSamples | ForEach-Object { $_[1] | ForEach-Object { $_total += $_; $_count++ } } + + $_TempData.AverageTemp = [Math]::Round(($_total / $_count), 2) + + # Current value + $_TempData.AmbientTemperature = $_item.metricSamples[0][1] + + } + + # Will get both average and current power + 'AveragePower' + { + + $_total = 0 + $_count = 0 + $_item.metricSamples | ForEach-Object { $_[1] | ForEach-Object { $_total += $_; $_count++ } } + + $_TempData.PowerAverage = [Math]::Round(($_total / $_count), 2) + + # Current value + switch ($_resource.category) + { + + # Enclosure + $ResourceCategoryEnum.Enclosure + { + + if ($_resource.enclosureType -eq "C7000") + { + + $_TempData.PowerCurrent = $_item.metricSamples[0][1] + $_TempData.PowerMax = $_item.metricCapacity + + } + + else + { + + $_TempData.PowerCurrent = $_resource.powerAllocatedWatts + + } + + } + + # Server + {$ResourceCategoryEnum.ServerProfile, $ResourceCategoryEnum.ServerHardware -contains $_} + { + + $_TempData.PowerCurrent = $_item.metricSamples[0][1] + + } + + } + + } + + 'PeakPower' + { + + # $_TempData.PowerPeak = GetPeakValue $_item + $_TempData.PowerPeak = $_item.metricSamples[0][1] + + } + + 'CpuUtilization' + { + + $_total = 0 + $_count = 0 + ($_item.metricSamples | ForEach-Object { $_[1] | ForEach-Object { $_total += $_; $_count++ } }) + + $_TempData.CPUAverage = [Math]::Round(($_total / $_count), 2) + + $_TempData.CPUCurrent = $_item.metricSamples[0][1] + + $_TempData.CPUPeak = GetPeakValue $_item + + } + + } + + } + + switch ($_resource.category) + { + + {$ResourceCategoryEnum.ServerProfile, $ResourceCategoryEnum.ServerHardware -contains $_} + { + + [HPEOneView.ServerUtilization]::new($_resource.name, + $_resource.uri, + $_TempData.CPUCurrent, + $_TempData.CPUAverage, + $_TempData.CPUPeak, + $_TempData.PowerCurrent, + $_TempData.PowerAverage, + $_TempData.PowerPeak, + $_TempData.AverageTemp, + $_TempData.AmbientTemperature, + $_UtilizationData.newestSampleTime, + $_UtilizationData.resolution, + [HPEOneView.Library.ApplianceConnection]$_resource.ApplianceConnection) + + } + + $ResourceCategoryEnum.Enclosure + { + + [HPEOneView.EnclosureUtilization]::new($_resource.name, + $_resource.uri, + $_TempData.PowerCurrent, + $_TempData.PowerAverage, + $_TempData.PowerPeak, + $_TempData.PowerMax, + $_TempData.AverageTemp, + $_TempData.AmbientTemperature, + $_UtilizationData.newestSampleTime, + $_UtilizationData.resolution, + [HPEOneView.Library.ApplianceConnection]$_resource.ApplianceConnection) + + } + + } + + } + + } + + End + { + + '[{0}] Done.' -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +####################################################### +# Storage Systems and Volume Management: +# + +function Get-OVStorageSystem +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "Name")] + Param + ( + + [Parameter (Mandatory = $false, ParameterSetName = "Name")] + [ValidateNotNullOrEmpty()] + [Alias ('SystemName')] + [String]$Name, + + [Parameter (Mandatory = $false, ParameterSetName = "Name")] + [ValidateNotNullOrEmpty()] + [String]$Hostname, + + [Parameter (Mandatory = $false, ParameterSetName = "Serial")] + [ValidateNotNullOrEmpty()] + [Alias ('SN')] + [String]$SerialNumber, + + [Parameter (Mandatory = $false, ParameterSetName = "Name")] + [Parameter (Mandatory = $false, ParameterSetName = "Serial")] + [ValidateSet ('Alletra6000', 'Alletra9000', 'StoreVirtual', 'StoreServ', 'Nimble', 'Primera')] + [String]$Family, + + [Parameter (Mandatory = $false, ParameterSetName = "Name")] + [Parameter (Mandatory = $false, ParameterSetName = "Serial")] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default), + + [Parameter (Mandatory = $false, ParameterSetName = "Name")] + [Parameter (Mandatory = $false, ParameterSetName = "Serial")] + [Alias ('Report')] + [Switch]$List + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + if ($PSBoundParameters['List']) + { + + Write-Warning "The -List parameter has been deprecated." + + } + + $_StorageSystemCollection = [System.Collections.ArrayList]::new() + + } + + Process + { + + ForEach ($_appliance in $ApplianceConnection) + { + + $uri = $StorageSystemsUri + '?sort:asc' + + "[{0}] Processing '{1}' Appliance (of {2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name, $ApplianceConnection.Count | Write-Verbose + + if ($Name) + { + + "[{0}] Filtering for Name property" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_method = 'eq' + + if ($Name.Contains('*')) + { + + $Name = $Name.Replace("*","%25").Replace("&","%26") + + $_method = 'matches' + + } + + + $uri += "&filter=name {0} '{1}'" -f $_method, $Name + + } + + elseif ($Hostname) + { + + "[{0}] Filtering for Hostname property" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_method = 'eq' + + if ($Hostname.Contains('*')) + { + + $Hostname = $Hostname.Replace("*","%25").Replace("&","%26") + + $_method = 'matches' + + } + + $uri += "&filter=hostname {0} '{1}'" -f $_method, $Hostname + + } + + if ($Family) + { + + $uri += "&filter=family EQ '{0}'" -f $StorageSystemFamilyTypeEnum[$Family] + + } + + "[{0}] Getting list of Storage Systems" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $_StorageSystems = Send-OVRequest -Uri $uri -Hostname $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if ($SerialNumber) + { + + [Array]$_StorageSystems.members = $_StorageSystems.members | Where-Object { $_.deviceSpecificAttributes.serialNumber -eq $SerialNumber } + + } + + # Generate Terminating Error if resource not found + if (-not($_StorageSystems.members.Count -gt 0) -and ($Name -or $SerialNumber -or $Hostname)) + { + + if ($Name) + { + + "[{0}] No '$Name' Storage System found." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + $ExceptionMessage = "No Storage System with '{0}' system name found. Please check the name or use Add-OVStorageSystem to add the Storage System." -f $Name + + $ErrorRecord = New-ErrorRecord HPEOneView.StorageSystemResourceException StorageSystemResourceNotFound ObjectNotFound 'Name' -Message $ExceptionMessage + + } + + elseif ($Hostname) + { + + "[{0}] No '$Hostname' Storage System found." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + $ExceptionMessage = "No Storage System with '{0}' system name found. Please check the name or use Add-OVStorageSystem to add the Storage System." -f $Hostname + + $ErrorRecord = New-ErrorRecord HPEOneView.StorageSystemResourceException StorageSystemResourceNotFound ObjectNotFound 'Hostname' -Message $ExceptionMessage + + } + + elseif ($SerialNumber) + { + + "[{0}] No Storage System with '$SerialNumber' serial number found." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + $ExceptionMessage = "No Storage System with '{0}' serial number found. Please check the name or use Add-OVStorageSystem to add the Storage System." -f $SerialNumber + $ErrorRecord = New-ErrorRecord HPEOneView.StorageSystemResourceException StorageSystemResourceNotFound ObjectNotFound 'SerialNumber' -Message $ExceptionMessage + + } + + # Generate Terminating Error + $PSCmdlet.WriteError($ErrorRecord) + + } + + else + { + + $_StorageSystems.members | ForEach-Object { + + $_.PSObject.TypeNames.Insert(0,'HPEOneView.Storage.System') + + if ($_.ports) + { + + $_.ports | ForEach-Object { + + # This is temporary + Add-Member -InputObject $_ -NotePropertyName ApplianceConnection -NotePropertyValue $_.ApplianceConnection + + $_.PSObject.TypeNames.Insert(0,'HPEOneView.Storage.System.Port') + + } + + } + + if ($_.deviceSpecificAttributes.discoverdPools) { $_.deviceSpecificAttributes.discoverdPools | ForEach-Object { $_.PSObject.TypeNames.Insert(0,'HPEOneView.Storage.System.Pool')} } + if ($_.deviceSpecificAttributes.managedPools) { $_.deviceSpecificAttributes.managedPools | ForEach-Object { $_.PSObject.TypeNames.Insert(0,'HPEOneView.Storage.System.Pool')} } + + $_ + + } + + } + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Update-OVStorageSystem +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "Default")] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = "Default")] + [ValidateNotNullOrEmpty()] + [Alias ('Name','StorageSystem')] + [Object]$InputObject, + + [Parameter (ValueFromPipelineByPropertyName, Mandatory = $false, ParameterSetName = "Default")] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not($PSBoundParameters['InputObject'])) + { + + $PipelineInput = $true + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + $_StorageSystemRefreshCollection = [System.Collections.ArrayList]::new() + + } + + Process + { + + ForEach ($_system in $InputObject) + { + + switch ($_system.gettype().name) + { + + "String" + { + + + "[{0}] System Name was provided, calling Get-OVStorageSystem." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $_system = Get-OVStorageSystem $_system + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + "PSCustomObject" + { + + if ($_system.category -eq $ResourceCategoryEnum.StorageSystem) + { + + "[{0}] Storage System resource object provided" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + "[$($MyInvocation.InvocationName.ToString().ToUpper())] Storage System Name: {0}" -f $_system.name | Write-Verbose + "[$($MyInvocation.InvocationName.ToString().ToUpper())] Storage System URI: {0}" -f $_system.uri | Write-Verbose + + } + + else + { + + # Wrong category, generate error + $ErrorRecord = New-ErrorRecord HPEOneView.StorageSystemResourceException WrongCategoryType InvalidResult 'InputObject' -TargetType 'PSObject' -Message ("The '{0}' is the wrong value. Only 'storage-systems' category is allowed. Please check the value and try again." -f $_system.category)#-verbose + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + default + { + + # Wrong category, generate error + $ErrorRecord = New-ErrorRecord HPEOneView.StorageSystemResourceException UnsupportedDataType InvalidArgument 'InputObject' -TargetType $_system.GetType().Name -Message ("The {0} is unsupported. Only [System.String], [System.Array] of [System.String] or [System.Management.Automation.PSCustomObject] are allowed. Please check the value and try again." -f $_system.Gettype().Name ) + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + # Update object to refresh state + $_system.requestingRefresh = $true + + Try + { + + $_results = Send-OVRequest -uri $_system.uri -Method PUT -Body $_system -Hostname $_system.ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + [void]$_StorageSystemRefreshCollection.Add($_results) + + } + + } + + End + { + + Return $_StorageSystemRefreshCollection + + } + +} + +function Add-OVStorageSystem +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = 'StoreServe')] + Param + ( + + [Parameter (Mandatory, ParameterSetName = 'StoreServe')] + [Parameter (Mandatory, ParameterSetName = 'StoreVirtualOrNimble')] + [ValidateNotNullOrEmpty()] + [String]$Hostname, + + [Parameter (Mandatory = $False, ParameterSetName = 'StoreServe')] + [Parameter (Mandatory = $False, ParameterSetName = 'StoreVirtualOrNimble')] + [ValidateNotNullOrEmpty()] + [PSCredential]$Credential, + + [Parameter (Mandatory = $False, ParameterSetName = 'StoreServe')] + [Parameter (Mandatory = $False, ParameterSetName = 'StoreVirtualOrNimble')] + [ValidateNotNullOrEmpty()] + [String]$Username, + + [Parameter (Mandatory = $False, ParameterSetName = 'StoreServe')] + [Parameter (Mandatory = $False, ParameterSetName = 'StoreVirtualOrNimble')] + [ValidateNotNullOrEmpty()] + [Object]$Password, + + [Parameter (Mandatory = $false, ParameterSetName = 'StoreServe')] + [Parameter (Mandatory = $false, ParameterSetName = 'StoreVirtualOrNimble')] + [ValidateSet ('Alletra5000','Alletra6000','Alletra9000','StoreServ', 'Nimble', 'Primera')] + [String]$Family = 'StoreServ', + + [Parameter (Mandatory = $false, ParameterSetName = 'StoreServe')] + [ValidateNotNullOrEmpty()] + [String]$Domain = 'NO DOMAIN', + + [Parameter (Mandatory = $false, ParameterSetName = 'StoreServe')] + [ValidateNotNullOrEmpty()] + [Hashtable]$Ports, + + [Parameter (Mandatory = $false, ParameterSetName = 'StoreVirtualOrNimble')] + [ValidateNotNullOrEmpty()] + [Hashtable]$VIPS, + + [Parameter (Mandatory = $false, ParameterSetName = 'StoreServe')] + [ValidateNotNullOrEmpty()] + [Hashtable]$PortGroups, + + [Parameter (Mandatory = $false, ParameterSetName = 'StoreServe')] + [Parameter (Mandatory = $false, ParameterSetName = 'StoreVirtualOrNimble')] + [Switch]$ShowSystemDetails, + + [Parameter (Mandatory = $false, ParameterSetName = 'StoreServe')] + [Parameter (Mandatory = $false, ParameterSetName = 'StoreVirtualOrNimble')] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $colStatus = [System.Collections.ArrayList]::new() + + if ($Password -is [SecureString]) + { + + $Password = [Runtime.InteropServices.Marshal]::PtrToStringBSTR([Runtime.InteropServices.Marshal]::SecureStringToBSTR($Password)) + + } + + if ($PSBoundParameters['Credential']) + { + + $Username = $Credential.Username + $Password = [Runtime.InteropServices.Marshal]::PtrToStringBSTR([Runtime.InteropServices.Marshal]::SecureStringToBSTR($Credential.Password)) + + } + + if (-not($PSBoundParameters['Credential']) -and -not($PSBoundParameters['Username'])) + { + + $ExceptionMessage = "Credentials are required in order to add a storage system. Please use either the -Credential or -Username parameter to supply a valid account to authenticate with." + $ErrorRecord = New-ErrorRecord InvalidOperationException MissingCredentialParameter InvalidArgument 'Auth' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + if (-not($PSBoundParameters['Password']) -and $PSBoundParameters['Username']) + { + + $ExceptionMessage = "Credentials are required in order to add a storage system. Please use the Password parameter to supply a String or SecureString value. Or use the Credential parameter to supply a PSCredential object." + $ErrorRecord = New-ErrorRecord InvalidOperationException MissingPasswordParameter InvalidArgument 'Password' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + # Will need to re-evaluate this statement when Nimble FC support is added + # if ((-not $PSBoundParameters['VIPS']) -and 'Alletra6000', 'Nimble', 'StoreVirtual' -Contains $Family) + # { + # $ExceptionMessage = "Adding a StoreVirtual resource requires you to provide the VIP or VIPS and associated Ethernet Network." + # $ErrorRecord = New-ErrorRecord InvalidOperationException MissingVIPSParameter InvalidArgument 'VIPS' -Message $ExceptionMessage + # $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + # } + + } + + Process + { + + ForEach ($_appliance in $ApplianceConnection) + { + + "[{0}] Processing appliance '{1}' (of {2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name, $ApplianceConnection.Count | Write-Verbose + + $_storagesystemcredentials = NewObject -StorageSystemCredentials + + $_storagesystemcredentials.hostname = $hostname + $_storagesystemcredentials.username = $username + $_storagesystemcredentials.password = $password + $_storagesystemcredentials.family = $StorageSystemFamilyTypeEnum[$Family] + + Try + { + + $_storageSystemDiscoveryTask = Send-OVRequest -Uri $StorageSystemsUri -Method POST -Body $_storagesystemcredentials -Hostname $_appliance.Name | Wait-OVTaskComplete + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if ($_storageSystemDiscoveryTask.taskState -eq "Completed") + { + + Try + { + + $_connectedStorageSystem = Send-OVRequest -Uri $_storageSystemDiscoveryTask.associatedResource.resourceUri -Hostname $_appliance.Name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + "[{0}] Processing '{1}' Storage System." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_connectedStorageSystem.name | Write-Verbose + + $_connectedStorageSystem.PSObject.TypeNames.Insert(0,'HPEOneView.Storage.System') + + # Display Storage System details + if ($ShowSystemDetails) + { + + $_connectedStorageSystem | Out-Host + + } + + if ($_connectedStorageSystem.deviceSpecificAttributes.discoveredPools) + { + + $_connectedStorageSystem.deviceSpecificAttributes.discoveredPools | ForEach-Object { + + $_.PSObject.TypeNames.Insert(0,'HPEOneView.Storage.System.DiscoveredPool') + + } + + # Display Storage System Unmanaged Pool details + if ($ShowSystemDetails) + { + + $_connectedStorageSystem.deviceSpecificAttributes.discoveredPools | Sort-Object domain,name | Out-Host + + } + + } + + if ($_connectedStorageSystem.ports) + { + + ForEach ($_port in $_connectedStorageSystem.ports) + { + + # This is temporary + Add-Member -InputObject $_port -NotePropertyName ApplianceConnection -NotePropertyValue $_connectedStorageSystem.ApplianceConnection + + $_port.PSObject.TypeNames.Insert(0,'HPEOneView.Storage.System.Port') + + } + + # Display Storage System Unmanaged Port details + if ($ShowSystemDetails) + { + + $_connectedStorageSystem.ports | Out-Host + + } + + } + + # Check if ISCSI paramset first, and handle ports + if ($PSCmdlet.ParameterSetName -eq 'StoreVirtualOrNimble' -or ('Nimble', "Alletra5000", "Alletra6000" -Contains $Family)) + { + + if ($PSBoundParameters['VIPS']) + { + + ForEach ($_VIP in $VIPS.GetEnumerator()) + { + + if ($null -eq $_VIP.Value) + { + + Try + { + + CleanUpStorageSystemOnError -InputObject $_connectedStorageSystem + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $ExceptionMessage = "The associated Network to the provided VIP {0} is a null value." -f $_VIP.Name + $ErrorRecord = New-ErrorRecord InvalidOperationException NullVIPNetwork InvalidArgument 'VIPS' -TargetType 'VIPNetwork' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + # Validate the Network associated with the VIP is an Ethernet resource + if ($_VIP.Value.category -ne $ResourceCategoryEnum.EthernetNetwork) + { + + Try + { + + CleanUpStorageSystemOnError -InputObject $_connectedStorageSystem + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $ExceptionMessage = "The provided VIP {0} and associated Network {1} is not an allowed Ethernet network resource." -f $_VIP.Name, $_VIP.Value.name + $ErrorRecord = New-ErrorRecord InvalidOperationException InvalidVIPNetwork InvalidArgument 'VIPS' -TargetType $VIPS.GetType().Name -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + if ($_connectedStorageSystem.ports | Where-Object name -eq $_VIP.Name) + { + + $_StoragePort = ($_connectedStorageSystem.ports | Where-Object name -eq $_VIP.Name).PSObject.Copy() + $_IndexOf = $_connectedStorageSystem.ports.name.IndexOf($_StoragePort.name) + + } + + else + { + + Try + { + + CleanUpStorageSystemOnError -InputObject $_connectedStorageSystem + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $ExceptionMessage = "The provided VIP {0} name was not found to be present on the {1} system: {2}." -f $_VIP.Name, [String]::Join(', ', $Family, $_connectedStorageSystem.ports.name) + $ErrorRecord = New-ErrorRecord InvalidOperationException InvalidVIPName InvalidArgument 'VIPS' -TargetType $VIPS.GetType().Name -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + $_StoragePort.expectedNetworkUri = $_VIP.Value.uri + $_StoragePort.expectedNetworkName = $_VIP.Value.name + $_StoragePort.mode = 'Managed' + + $_connectedStorageSystem.ports[$_IndexOf] = $_StoragePort + + } + + } + + } + + else + { + + # Handle Host Port configuration + if ($PSBoundParameters['Ports']) + { + + ForEach ($_port in $Ports.GetEnumerator()) + { + + "[{0}] Processing '{1}' Port" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_port.name | Write-Verbose + + if ($_connectedStorageSystem.ports | Where-Object name -eq $_port.Name) + { + + $_StoragePort = ($_connectedStorageSystem.ports | Where-Object name -eq $_port.Name).PSObject.Copy() + $_IndexOf = $_connectedStorageSystem.ports.name.IndexOf($_StoragePort.name) + + "[{0}] Found port: '{1}' [{2}]" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_StoragePort.Name, $_IndexOf | Write-Verbose + + } + + else + { + + "[{0}] Cleaning up storage system" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + CleanUpStorageSystemOnError -InputObject $_connectedStorageSystem + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $ExceptionMessage = "The provided host port {0} name was not found to be present on the StoreServ system. Available host ports are: {1}." -f $_port.Name, [String]::Join(', ', $_connectedStorageSystem.ports.name) + $ErrorRecord = New-ErrorRecord InvalidOperationException InvalidVIPName InvalidArgument 'Ports' -TargetType $Ports.GetType().Name -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + # First get the network. Will error if network does not exist + switch ($_port.value.GetType().Name) + { + + 'String' + { + + if ($_port.value -ne 'Auto' -and $null -ne $_port.value) + { + + Try + { + + '[{0}] Looking in idex for {1}' -f $MyInvocation.InvocationName.ToString().ToUpper(), $_port.value | Write-Verbose + + $uri = '{0}?filter=name:"{1}"&category:fc-networks&category:fcoe-networks' -f $IndexUri, $_port.value + + $_resp = Send-OVRequest -Uri $uri -ApplianceConnection $_appliance.Name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + # Error, as we couldn't find a unique FC/FCoE resource from the name via the Index + if ($_resp.count -gt 1) + { + + Try + { + + CleanUpStorageSystemOnError -InputObject $_connectedStorageSystem + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $Message = "The provided Storage Port Network Resource name {0} was found via the index as the name of {1} resources. Please make sure you are specifying a unique FC or FCoE resource name." -f $_port.value, $_resp.count + $ErrorRecord = New-ErrorRecord InvalidOperationException NonUniqueStoragePortFabricName InvalidResult 'Ports' -TargetType $Ports.GetType().Name -Message $Message + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($_resp.count -eq 0) + { + + Try + { + + CleanUpStorageSystemOnError -InputObject $_connectedStorageSystem + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $Message = "The provided Storage Port Network Resource name {0} was not found via the index. Please verify the FC or FCoE Network exists." -f $_port.Value + $ErrorRecord = New-ErrorRecord InvalidOperationException StorageSystemPortNetworkNotFound ObjectNotFound 'Ports' -TargetType $Ports.GetType().Name -Message $Message + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Try + { + + '[{0}] Getting full network object {1}' -f $MyInvocation.InvocationName.ToString().ToUpper(), $_port.value | Write-Verbose + + $_sNet = Send-OVRequest -Uri $_resp.members.uri + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + else + { + + $_snet = [PScustomObject]@{ + + expectedNetorkUri = 'Auto'; + name = 'Auto'; + + } + + } + + } + + 'PSCustomObject' + { + + if ('fc-networks', 'fcoe-networks' -contains $_port.value.category) + { + + $_snet = [PScustomObject]@{ + + expectedNetorkUri = $_port.value.uri; + name = $_port.value.name + + } + + } + + elseif ($_port.value.category -eq $ResourceCategoryEnum.ManagedSAN) + { + + $_snet = [PScustomObject]@{ + + expectedNetorkUri = $_port.value.associatedNetworks.uri; + name = $_port.value.associatedNetworks.name + + } + + } + + } + + default + { + + Try + { + + CleanUpStorageSystemOnError -InputObject $_connectedStorageSystem + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $Message = "The provided Storage Port Network value is not a supported object type, {0}. Please verify the FC or FCoE Network exists." -f $_port.value.GetType().FullName + $ErrorRecord = New-ErrorRecord InvalidOperationException StorageSystemPortNetworkNotFound ObjectNotFound 'Ports' -TargetType $Ports.GetType().Name -Message $Message + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + # Update the ports Expected SAN/Network property + if ($_sNet.expectedNetorkUri -eq 'Auto' -and $null -eq $_StoragePort.actualSanUri) + { + + $_StoragePort.mode = 'AutoSelectExpectedSan' + + } + + elseif ($_sNet.expectedNetorkUri -ne 'Auto' -and $null -eq $_StoragePort.actualSanUri) + { + + $_StoragePort.expectedNetworkUri = $_sNet.expectedNetorkUri + $_StoragePort.expectedNetworkName = $_sNet.name + $_StoragePort.mode = 'Managed' + + } + + if ($PSBoundParameters['PortGroups']) + { + + if ($PortGroups.Get_Item($_port.Name)) + { + + "[{0}] Found '{1}' Port Group for '{2}' port." -f $MyInvocation.InvocationName.ToString().ToUpper(), $PortGroups.Get_Item($_port.Name), $_port.Name | Write-Verbose + + $_StoragePort.groupName = $PortGroups.Get_Item($_port.Name) + + # Remove the PortGroup item from the Hashtable so we can Process left overs later + $PortGroups.Remove($_port.Name) + + } + + } + + $_connectedStorageSystem.ports[$_IndexOf] = $_StoragePort + + } + + } + + # Process any of the leftover portgroup collection + if ($PortGroups) + { + + "[{0}] {1} PortGroups remain to be configured." -f $MyInvocation.InvocationName.ToString().ToUpper(), $PortGroups.Count | Write-Verbose + + ForEach ($_pg in $PortGroups.GetEnumerator()) + { + + "[{0}] Processing {1} Port for PortGroup assignment." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_pg.Name, $_pg.Value | Write-Verbose + + if ($_connectedStorageSystem.ports | Where-Object name -eq $_pg.Name) + { + + $_port = $_connectedStorageSystem.ports | Where-Object name -eq $_pg.Name + + "[{0}] Found {1} -> {2}." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_pg.Name, $_pg.Value | Write-Verbose + + $_connectedStorageSystem.ports[($_connectedStorageSystem.ports.IndexOf($_port))].groupName = $_pg.Value + + } + + else + { + + "[{0}] {1} was not found in the unmanagedPorts collection." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_pg.Name | Write-Verbose + + } + + } + + } + + # Validate the $Domain Parameter exists in the list of unmanaged domains returned in the connect call + if ($_connectedStorageSystem.deviceSpecificAttributes.discoveredDomains -ccontains $Domain) + { + + "[{0}] Found Virtual Domain '{1}'." -f $MyInvocation.InvocationName.ToString().ToUpper(), $Domain| Write-Verbose + + # The domain exists, update the managedDomain property + $_connectedStorageSystem.deviceSpecificAttributes.managedDomain = $_connectedstoragesystem.deviceSpecificAttributes.discoveredDomains | Where-Object { $_ -eq $Domain } + + [Array]$_connectedStorageSystem.deviceSpecificAttributes.discoveredDomains = @($_connectedStorageSystem.deviceSpecificAttributes.discoveredDomains | Where-Object { $_ -ne $Domain }) + + } + + else + { + + "[{0}] Domain '{1}' not found (name is Case Sensitive). Cleaning up." -f $MyInvocation.InvocationName.ToString().ToUpper(), $Domain | Write-Verbose + + Try + { + + CleanUpStorageSystemOnError -InputObject $_connectedStorageSystem + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $ExceptionMessage = "Storage Domain '{0}' not found (name is Case Sensitive). Please check the storage domain exist on the storage system." -f $Domain + $ErrorRecord = New-ErrorRecord InvalidOperationException StorageDomainResourceNotFound ObjectNotFound 'Domain' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + } + + else + { + + # ERROR + $_connectedStorageSystem | Out-Host + + if ($_storageSystemDiscoveryTask.taskErrors.errorCode -eq 'STRM_RESOURCE_ALREADY_PRESENT' -or -not $_storageSystemDiscoveryTask.associatedResource.resourceUri) + { + + "[{0}] {1} {2} {3}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_storageSystemDiscoveryTask.taskErrors.details, $_storageSystemDiscoveryTask.taskErrors.recommendedActions, $_storageSystemDiscoveryTask.taskErrors.errorCode| Write-Verbose + + $ErrorRecord = New-ErrorRecord InvalidOperationException $_storageSystemDiscoveryTask.taskErrors[0].errorCode InvalidResult 'StoragSystem' -Message ($_storageSystemDiscoveryTask.taskErrors[0].message + ' ' + $_storageSystemDiscoveryTask.taskErrors[0].recommendedActions) + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + else + { + + "[{0}] Task error occurred. Cleaning Up." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + CleanUpStorageSystemOnError -InputObject $_connectedStorageSystem + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + "[{0}] Generating error message." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $ErrorRecord = New-ErrorRecord InvalidOperationException $_storageSystemDiscoveryTask.taskErrors[0].errorCode InvalidResult 'Add-OVStorageSystem' -Message "$($_storageSystemDiscoveryTask.taskErrors[0].message)" + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + "[{0}] Sending request to finalize adding Storage System to appliance" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $task = Send-OVRequest -Uri $_connectedStorageSystem.uri -Method PUT -Body $_connectedStorageSystem -Hostname $_appliance.Name + + } + + Catch + { + + $task = $null + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if ($PSBoundParameters['Async']) + { + + $task + + } + + else + { + + $task | Wait-OVTaskComplete + + } + + } + + } + + End + { + + '{0} Done.' -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +# Helper function +function CleanUpStorageSystemOnError +{ + + [CmdletBinding (DefaultParameterSetName = "default",SupportsShouldProcess,ConfirmImpact = 'High')] + Param + ( + + [Parameter (Mandatory, ParameterSetName = "default")] + [ValidateNotNullOrEmpty()] + $InputObject + + ) + + + Try + { + + $reply = Send-OVRequest -Uri $InputObject.uri -Method DELETE -AddHeader @{'If-Match' = $InputObject.eTag } -Hostname $InputObject.ApplianceConnection | Wait-OVTaskComplete + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + +} + +function Remove-OVStorageSystem +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "default",SupportsShouldProcess,ConfirmImpact = 'High')] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = "default")] + [ValidateNotNullOrEmpty()] + [Alias ("uri","name","StorageSystem")] + [object]$InputObject, + + [Parameter (Mandatory = $false)] + [Switch]$force, + + [Parameter (Mandatory = $False, ValueFromPipelineByPropertyName, ParameterSetName = "default")] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not($PSBoundParameters['InputObject'])) + { + + $PipelineInput = $True + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command agian." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + $_TaskCollection = [System.Collections.ArrayList]::new() + $_StorageSystemCollection = [System.Collections.ArrayList]::new() + + } + + Process + { + + if ($PipelineInput -or $InputObject -is [PSCustomObject]) + { + + "[{0}] Processing input" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + "[{0}] Storage System Object provided: {1} ({2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject.name, $InputObject.uri | Write-Verbose + + If ('storage-systems' -contains $InputObject.category) + { + + If (-not($InputObject.ApplianceConnection)) + { + + $ErrorRecord = New-ErrorRecord InvalidOperationException InvalidArgumentValue InvalidArgument "InputObject:$($InputObject.Name)" -TargetType PSObject -Message "The Storage System resource object provided is missing the source ApplianceConnection property. Please check the object provided and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + [void]$_StorageSystemCollection.Add($InputObject) + + } + + else + { + + $ErrorRecord = New-ErrorRecord InvalidOperationException InvalidArgumentValue InvalidArgument "InputObject:$($InputObject.Name)" -TargetType PSObject -Message "The Storage System resource object is not an expected category type [$($InputObject.category)]. The allowed resource category type is 'storage-systems'. Please check the object provided and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + else + { + + ForEach ($_appliance in $ApplianceConnection) + { + + "[{0}] Processing Appliance $($_appliance.Name) (of $($ApplianceConnection.Count))" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + "[{0}] Processing Storage System Name $($StorageSystem)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $_StorageSystem = Get-OVStorageSystem $InputObject -ApplianceConnection $_appliance + + $_StorageSystem | ForEach-Object { + + [void]$_StorageSystemCollection.Add($_) + + } + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + } + + End + { + + "[{0}] Processing $($_StorageSystemCollection.count) Storage System object resources to remove." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + # Process Storage Resources + ForEach ($_storagesystem in $_StorageSystemCollection) + { + + if ($PSCmdlet.ShouldProcess($_storagesystem.ApplianceConnection.Name,"Remove Storage System '$($_storagesystem.name)' from appliance")) + { + + "[{0}] Removing Storage System '$($_storagesystem.name)' from appliance '$($_storagesystem.ApplianceConnection.Name)'." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if ($PSboundParameters['force']) + { + + $_storagesystem.uri += "?force=true" + + } + + Try + { + + Send-OVRequest -Uri $_storagesystem.Uri -Method DELETE -Hostname $_storagesystem.ApplianceConnection.Name -AddHeader @{'If-Match' = '*'} + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + elseif ($PSBoundParameters['WhatIf']) + { + + "[{0}] WhatIf Parameter was passed." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + } + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Show-OVStorageSystemPerformancePolicy +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "default")] + [OutputType ([HPEOneView.Storage.PerformancePolicy])] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = "default")] + [ValidateNotNullOrEmpty()] + [object]$InputObject, + + [Parameter (Mandatory = $false)] + [String]$Name + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not($PSBoundParameters['InputObject'])) + { + + $PipelineInput = $True + + } + + } + + Process + { + + # Validate the provided inputobject is a Numble class storage system + if ($InputObject.family -ne 'Nimble') + { + + $ExceptionMessage = "The provided InputObject is not a Nimble storage system." + $ErrorRecord = New-ErrorRecord HPEOneView.Library.ParameterValidationException InvalidInputObjectParameter InvalidOperation 'InputObject' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + if ($PSBoundParameters['Name']) + { + + $_PerformancePolicies = $InputObject.deviceSpecificAttributes.performancePolicies | ? name -eq $Name + + } + + else + { + + $_PerformancePolicies = $InputObject.deviceSpecificAttributes.performancePolicies + + } + + ForEach ($_performancePolicy in $_PerformancePolicies) + { + + [HPEOneView.Storage.PerformancePolicy]::new($_performancePolicy.id, + $_performancePolicy.name, + $_performancePolicy.isCached, + $_performancePolicy.blockSize, + $_performancePolicy.spacePolicy, + $_performancePolicy.isCompressed, + $_performancePolicy.applicationCategory, + $InputObject.name, + $InputObject.uri, + $InputObject.ApplianceConnection) + } + + } + + End + { + + '{0} Done.' -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Get-OVStoragePool +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding ()] + [OutputType ([HPEOneView.Storage.StoragePool])] + Param + ( + + [Parameter (Mandatory = $false)] + [ValidateNotNullOrEmpty()] + [Alias ('pool', 'PoolName')] + [String]$Name, + + [Parameter (Mandatory = $false, ValueFromPipeline)] + [ValidateNotNullOrEmpty()] + [Alias ('systemName', 'system')] + [object]$StorageSystem, + + [Parameter (Mandatory = $false)] + [Switch]$Managed, + + [Parameter (Mandatory = $false)] + [Switch]$Unmanaged, + + [Parameter (Mandatory = $false)] + [ValidateNotNullOrEmpty()] + [String]$Label, + + [Parameter (Mandatory = $false)] + [ValidateNotNullOrEmpty()] + [Object]$Scope = "AllResourcesInScope", + + [Parameter (Mandatory = $false, ValueFromPipelinebyPropertyName)] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $colStoragePools = [System.Collections.ArrayList]::new() + + } + + Process + { + + # Check if StorageSystem is a PSCustomObject + if ($StorageSystem -is [PSCustomObject] -and $StorageSystem.category -eq $ResourceCategoryEnum.StorageSystem) + { + + "[{0}] StorageSystem Object provided. Using ApplianceConnection property of object." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $ApplianceConnection = $ConnectedSessions | Where-Object Name -eq $StorageSystem.ApplianceConnection.Name + + } + + ForEach ($_appliance in $ApplianceConnection) + { + + "[{0}] Processing appliance {1} (of {2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name, $ApplianceConnection.Count | Write-Verbose + + $_Query = [System.Collections.ArrayList]::new() + + # Handle default cause of AllResourcesInScope + if ($Scope -eq 'AllResourcesInScope') + { + + "[{0}] Processing AllResourcesInScope." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_Scopes = $_appliance.ActivePermissions | Where-Object Active + + # If one scope contains 'AllResources' ScopeName "tag", then all resources should be returned regardless. + if ($_Scopes | Where-Object ScopeName -eq 'AllResources') + { + + $_ScopeNames = [String]::Join(', ', ($_Scopes | Where-Object ScopeName -eq 'AllResources').ScopeName) + + "[{0}] Scope(s) {1} is set to 'AllResources'. Will not add scope to URI query parameter." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_ScopeNames | Write-Verbose + + } + + # Process ApplianceConnection ActivePermissions collection + else + { + + "[{0}] Getting list of Scope names to pass into query." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $_ScopeQuery = Join-Scope $_Scopes + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + [Void]$_Query.Add(("({0})" -f $_ScopeQuery)) + + } + + } + + elseif ($Scope | Where-Object ScopeName -eq 'AllResources') + { + + $_ScopeNames = [String]::Join(', ', ($_Scopes | Where-Object ScopeName -eq 'AllResources').ScopeName) + + "[{0}] Scope(s) {1} is set to 'AllResources'. Will not add scope to URI query parameter." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_ScopeNames | Write-Verbose + + } + + elseif ($Scope -eq 'AllResources') + { + + "[{0}] Requesting scope 'AllResources'. Will not add scope to URI query parameter." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_ScopeNames | Write-Verbose + + } + + else + { + + Try + { + + $_ScopeQuery = Join-Scope $Scope + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + [Void]$_Query.Add(("({0})" -f $_ScopeQuery)) + + } + + if ($Name) + { + + "[{0}] Filtering for Name: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Name | Write-Verbose + + if ($Name.Contains('*')) + { + + [Void]$_Query.Add(("name%3A{0}" -f $Name.Replace("*", "%2A").Replace(',','%2C').Replace(" ", "?"))) + + } + + else + { + + [Void]$_Query.Add(("name:'{0}'" -f $Name)) + + } + + } + + if ($Label) + { + + "[{0}] Filtering for Label: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Label | Write-Verbose + + [Void]$_Query.Add(("labels:'{0}'" -f $Label)) + + } + + if ($PSBoundParameters['Managed']) + { + + "[{0}] Filtering for unmanaged pools." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + [Void]$_Query.Add("isManaged:'true'") + + } + + if ($PSBoundParameters['Unmanaged']) + { + + "[{0}] Filtering for unmanaged pools." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + [Void]$_Query.Add("isManaged:'false'") + + } + + if ($PSBoundParameters['StorageSystem']) + { + + if ($StorageSystem -is [String] -and (-not $StorageSystem.startswith($StorageSystemsUri))) + { + + "[{0}] Storage system name was provided: '{1}'" -f $MyInvocation.InvocationName.ToString().ToUpper(), $StorageSystem | Write-Verbose + + Try + { + + $StorageSystem = Get-OVStorageSystem -SystemName $StorageSystem -ApplianceConnection $_appliance.Name -ErrorAction Stop + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + elseif ($StorageSystem -is [PsCustomObject] -and $StorageSystem.category -eq $ResourceCategoryEnum.StorageSystem) + { + + "[{0}] StorageSystem Object provided" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + "[{0}] StorageSystem Name: '{1}'" -f $MyInvocation.InvocationName.ToString().ToUpper(), $StorageSystem.name | Write-Verbose + "[{0}] StorageSystem Uri: '{1}'" -f $MyInvocation.InvocationName.ToString().ToUpper(), $StorageSystem.uri | Write-Verbose + + } + + [Void]$_Query.Add(("storageSystemUri:'{0}'" -f $StorageSystem.uri)) + + } + + $_Category = 'category=storage-pools' + + # Build the final URI + $_uri = '{0}?{1}&sort=name:asc&query={2}' -f $IndexUri, [String]::Join('&', $_Category), [String]::Join(' AND ', $_Query.ToArray()) + + Try + { + + [Array]$_ResourcesFromIndexCol = Get-AllIndexResources -Uri $_uri -ApplianceConnection $_appliance + + "[{0}] {1} returned objects" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_ResourcesFromIndexCol.Count | Write-Verbose + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + # Look for empty return and write error + if ($_ResourcesFromIndexCol.Count -gt 0) + { + + ForEach ($_member in $_ResourcesFromIndexCol) + { + + "[{0}] Adding Storage System '{1}' to collection" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_member.name | Write-Verbose + + # StoreServ pool + if ($_member.deviceSpecificAttributes.domain) + { + + $_DeviceAttrib = [HPEOneView.Storage.StoreServeDeviceSpecificAttributes]::new($_member.deviceSpecificAttributes.uuid, + $_member.deviceSpecificAttributes.domain, + $_member.deviceSpecificAttributes.deviceType, + $_member.deviceSpecificAttributes.deviceSpeed, + $_member.deviceSpecificAttributes.supportedRAIDLevel, + $_member.deviceSpecificAttributes.capacityLimit, + $_member.deviceSpecificAttributes.capacityWarningLimit, + ([HPEOneView.Storage.AllocatedCapacity]::new($_member.deviceSpecificAttributes.allocatedCapacity.totalAllocatedCapacity, $_member.deviceSpecificAttributes.allocatedCapacity.volumeAllocatedCapacity,$_member.deviceSpecificAttributes.allocatedCapacity.snapshotAllocatedCapacity))) + + } + + elseif ($_member.deviceSpecificAttributes.freePinnableCacheCapacity) + { + + $_Folders = [System.Collections.Generic.List[HPEOneView.Storage.NimbleFolder]]::new() + + ForEach ($_folder in $_member.deviceSpecificAttributes.folders) + { + + $_Folders.Add(([HPEOneView.Storage.NimbleFolder]::new($_folder.id, $_folder.name))) + + } + + $_DeviceAttrib = [HPEOneView.Storage.NimbleDeviceSpecificAttributes]::new($_Folders, + $_member.deviceSpecificAttributes.deviceId, + $_member.deviceSpecificAttributes.isDeduplicationCapable, + $_member.deviceSpecificAttributes.freePinnableCacheCapacity) + + } + + # StoreVirtual pool + else + { + + $_VolumeCreationSpacePolicyCol = [System.Collections.Generic.List[HPEOneView.Storage.VolumeCreationSpace]]::new() + + ForEach ($_Policy in $_member.deviceSpecificAttributes.volumeCreationSpace) + { + + $_VolumeCreationSpacePolicyCol.Add(([HPEOneView.Storage.VolumeCreationSpace]::new($_Policy.availableSpace, $_Policy.replicationLevel))) + + } + + $_DeviceAttrib = [HPEOneView.Storage.StoreVirtualDeviceSpecificAttributes]::new($_member.deviceSpecificAttributes.isMlptEnabled, + $_VolumeCreationSpacePolicyCol) + + } + + [HPEOneView.Storage.StoragePool]::new($_member.name, + $_member.description, + $_member.scopesUri, + $_member.storageSystemUri, + $_member.isManaged, + $_member.totalCapacity, + $_member.freeCapacity, + $_member.allocatedCapacity, + $_member.requestingRefresh, + $_member.lastRefreshTime, + $_DeviceAttrib, + $_member.status, + $_member.state, + $_member.uri, + $_member.eTag, + $_member.created, + $_member.modified, + $_member.ApplianceConnection) + + } + + } + + elseif ($_ResourcesFromIndexCol.Count -eq 0 -and $Name) + { + + "[{0}] Storage Pool '{1}' not found." -f $MyInvocation.InvocationName.ToString().ToUpper(), $Name | Write-Verbose + + $ExceptionMessage = "Storage Pool '{0}' not found on '{1}' appliance connection. Please check the name and try again." -f $Name, $_appliance.Name + $ErrorRecord = New-ErrorRecord InvalidOperationException StoragePoolResourceNotFound ObjectNotFound 'Name' -Message $ExceptionMessage + $PSCmdlet.WriteError($ErrorRecord) + + } + + else + { + + "[{0}] No Storage Pools found." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Add-OVStoragePool +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding ()] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline)] + [ValidateNotNullOrEmpty()] + [Alias ('Hostname', 'name')] + [object]$StorageSystem, + + [Parameter (Mandatory)] + [ValidateNotNullOrEmpty()] + [Alias ('PoolName', 'spName', 'cpg')] + [object]$Pool, + + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName)] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not($PSboundParameters['StorageSystem'])) + { + + $PipelineInput = $True + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + $colStatus = [System.Collections.ArrayList]::new() + + Write-Warning "This Cmdlet will be deprecated in a future release. Please update your scripts to use Set-OVStoragePool." + + } + + Process + { + + ForEach ($_appliance in $ApplianceConnection) + { + + "[{0}] Processing appliance '{1}' (of {2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name, $ApplianceConnection.Count | Write-Verbose + + ForEach ($_pool in $Pool) + { + + "[{0}] Processing '$_pool'" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + # Validate StroageSystem Parameter object + if ($StorageSystem -is [PSCustomObject] -and $StorageSystem.ApplianceConnection.Name -ne $_appliance.Name) + { + + $ErrorRecord = New-ErrorRecord HPEOneView.StoragePoolResourceException InvalidateStorageSystemApplianceConnection InvalidArgument 'StorageSystem' -TargetType 'PSObject' -Message "The -StorageSystem object does not appear to originate [$($StorageSystem.ApplianceConnection.Name)] from the same provided ApplianceConnection [$($_appliance.Name)]" + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($StorageSystem -is [PsCustomObject] -and $StorageSystem.category -eq $ResourceCategoryEnum.StorageSystem) + { + + "[{0}] Storage System resource object was provided: {1} ({2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $StorageSystem.name, $StorageSystem.uri | Write-Verbose + + $_StorageSystem = $StorageSystem.PSObject.Copy() + + } + + # Else the PsCustomObject is not the correct Category type, so error. + elseif ($StorageSystem -is [PsCustomObject]) + { + + $ErrorRecord = New-ErrorRecord HPEOneView.StoragePoolResourceException InvalidResourceCategoryValue InvalidArgument 'StorageSystem' -TargetType 'PSObject' -Message "The -StorageSystem Parameter value is the wrong resource type ($($StorageSystem.category)). The correct resource category 'storage-systems' is allowed. Please check the value and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + # Do not allow an array + elseif ($StorageSystem -is [Array]) + { + + $ErrorRecord = New-ErrorRecord HPEOneView.StoragePoolResourceException ArrayNotAllow InvalidArgument 'StorageSystem' -TargetType 'PSObject' -Message "The -StorageSystem Parameter only accepts [System.String] or [System.Management.Automation.PSCustomObject] value. Please correct the value and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + else + { + + "[{0}] Storage System Name is passed $($StoragSystem)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + "[{0}] Getting list of Storage Systems" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $_storagesystem = Get-OVStorageSystem -SystemName $StorageSystem -ApplianceConnection $_appliance.Name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + # Generate Terminating Error if Storage System resource not found + if (-not($_storagesystem)) + { + + "[{0}] Woops! No '$StorageSystem' Storage System found." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $ErrorRecord = New-ErrorRecord HPEOneView.StoragePoolResourceException StorageSystemResourceNotFound ObjectNotFound 'StorageSystem' -Message "No Storage System with '$StorageSystem' system name found. Please check the name or use Add-OVStorageSystem to add the Storage System." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + # Get the list of unmanaged and managed pools in the managed domain + Try + { + + $_Results = Send-OVRequest ("{0}?filter=name EQ '{1}'" -f $_storagesystem.storagePoolsUri, $_pool) -Hostname $_appliance.Name + [PSCustomObject]$_PoolFound = $_Results.members[0] + + "[{0}] Storage Pool object: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), ($_PoolFound | Out-String) | Write-Verbose + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if (-not $_PoolFound) + { + + # Storage pool resource does not exist in the existing managed list or in the unmanaged list in the managed domain + "[{0}] No Storage pool resource with '{1}' found in the managed Storage System." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_pool | Write-Verbose + + $ErrorRecord = New-ErrorRecord HPEOneView.StoragePoolResourceException StorageSystemResourceNotFound ObjectNotFound 'PoolName' -Message "No Storage pool resource with '$_pool' found in the managed Storage System." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($_PoolFound.isManaged) + { + + "[{0}] Storage pool resource '{1}' already exists in the managed list." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_pool | Write-Verbose + + $ErrorRecord = New-ErrorRecord HPEOneView.StoragePoolResourceException StoragePoolResourceExists ResourceExists 'PoolName' -Message "Storage pool resource '$_pool' already exists in the managed list." + $PSCmdlet.WriteError($ErrorRecord) #"Storage pool resource '$p' already exists" + + } + + else + { + + # Good here... Add the storage pool + $_PoolFound.isManaged = $true + + # Add the pool to array of pools to manage + Try + { + + Send-OVRequest -Uri $_PoolFound.uri -method PUT -Body $_PoolFound -Hostname $_PoolFound.ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Return $colStatus + + } + +} + +function Set-OVStoragePool +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = 'Default')] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [Alias ('Pool')] + [HPEOneView.Storage.StoragePool[]]$InputObject, + + [Parameter (Mandatory, ParameterSetName = 'Default')] + [Bool]$Managed, + + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = 'Default')] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not($PSboundParameters['StorageSystem'])) + { + + $PipelineInput = $True + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + } + + Process + { + + ForEach ($_pool in $InputObject) + { + + "[{0}] Processing storage pool {1} ({2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_pool.Name, $_pool.uri | Write-Verbose + + if ($_pool.isManaged -and $Managed) + { + + "[{0}] Storage pool resource '{1}' is already managed." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_pool.Name | Write-Verbose + + $ExceptionMessage = "Storage pool resource '{0}' is already managed." -f $_pool.Name + $ErrorRecord = New-ErrorRecord HPEOneView.StoragePoolResourceException StoragePoolResourceExists ResourceExists 'InputObject' -Message $ExceptionMessage + $PSCmdlet.WriteError($ErrorRecord) + + } + + else + { + + # Get the list of unmanaged and managed pools in the managed domain + Try + { + + $__pool = Send-OVRequest -Uri $_pool.uri -Hostname $_pool.ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + # Good here... Add the storage pool + $__pool.isManaged = $Managed + + # Add the pool to array of pools to manage + Try + { + + Send-OVRequest -Uri $_pool.uri -method PUT -Body $__pool -Hostname $_pool.ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Update-OVStoragePool +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "Default")] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = "Default")] + [ValidateNotNullOrEmpty()] + [Alias ('Name','StoragePool')] + [HPEOneView.Storage.StoragePool[]]$InputObject, + + [Parameter (ValueFromPipelineByPropertyName, Mandatory = $false, ParameterSetName = "Default")] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not($PSBoundParameters['InputObject'])) + { + + $PipelineInput = $true + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + } + + Process + { + + ForEach ($_pool in $InputObject) + { + + Try + { + + $_PoolToUpdate = Send-OVRequest -uri $_pool.uri -Hostname $_pool.ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + # Update object to refresh state + $_PoolToUpdate.requestingRefresh = $true + + Try + { + + Send-OVRequest -uri $_pool.uri -Method PUT -Body $_PoolToUpdate -Hostname $_pool.ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Remove-OVStoragePool +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "default",SupportsShouldProcess,ConfirmImpact = 'High')] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = "default")] + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = "StorageSystem")] + [ValidateNotNullOrEmpty()] + [Alias ("uri", "name", 'StoragePool')] + [Object]$InputObject, + + [Parameter (Mandatory, ParameterSetName = "StorageSystem")] + [ValidateNotNullOrEmpty()] + [Alias ("storage")] + [Object]$StorageSystem, + + [Parameter (Mandatory = $False, ParameterSetName = "default")] + [Parameter (Mandatory = $False, ParameterSetName = "StorageSystem")] + [Switch]$Force, + + [Parameter (Mandatory = $False, ValueFromPipelineByPropertyName, ParameterSetName = "default")] + [Parameter (Mandatory = $False, ValueFromPipelineByPropertyName, ParameterSetName = "StorageSystem")] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not($PSBoundParameters['InputObject'])) + { + + $PipelineInput = $True + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + $_TaskCollection = [System.Collections.ArrayList]::new() + $_StoragePoolCollection = [System.Collections.ArrayList]::new() + + } + + Process + { + + if ($PipelineInput -or $InputObject -is [PSCustomObject]) + { + + "[{0}] Processing input" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + "[{0}] Storage Pool Object provided: {1} ({2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject.name, $InputObject.uri | Write-Verbose + + If ($InputObject -is [HPEOneView.Storage.StoragePool] -or 'storage-pools' -contains $InputObject.category) + { + + If (-not($InputObject.ApplianceConnection)) + { + + $ErrorRecord = New-ErrorRecord InvalidOperationException InvalidArgumentValue InvalidArgument "InputObject:$($InputObject.Name)" -TargetType PSObject -Message "The Storage Pool resource object provided is missing the source ApplianceConnection property. Please check the object provided and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + [void]$_StoragePoolCollection.Add($InputObject) + + } + + else + { + + $ErrorRecord = New-ErrorRecord InvalidOperationException InvalidArgumentValue InvalidArgument "InputObject:$($InputObject.Name)" -TargetType PSObject -Message "The Storage Pool resource object is not an expected category type [$($StoragePool.category)]. The allowed resource category type is 'storage-pools'. Please check the object provided and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + else + { + + ForEach ($_appliance in $ApplianceConnection) + { + + "[{0}] Processing Appliance $($_appliance.Name) (of $($ApplianceConnection.Count))" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + "[{0}] Processing Storage Pool Name $($InputObject)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $_StoragePool = Get-OVStoragePool $InputObject -ApplianceConnection $_appliance -ErrorAction Stop + + $_StoragePool | ForEach-Object { + + [void]$_StoragePoolCollection.Add($_) + + } + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + } + + End + { + + "[{0}] Processing $($_StoragePoolCollection.count) Storage Pool object resources to remove." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + # Process Storage Resources + ForEach ($_storagepool in $_StoragePoolCollection) + { + + if ($PSCmdlet.ShouldProcess($_storagepool.ApplianceConnection.Name,"Remove Storage Pool '$($_storagepool.name)' from appliance")) + { + + "[{0}] Setting Storage Pool '$($_storagepool.name)' to 'Unmanaged' on appliance '$($_storagepool.ApplianceConnection.Name)'." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $__pool = Send-OVRequest -Uri $_storagepool.uri -Hostname $_storagepool.ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + # Good here... unmanage the storage pool + $__pool.isManaged = $false + + Try + { + + $_resp = Send-OVRequest -Uri $_storagepool.Uri -Method PUT -Body $__pool -Hostname $_storagepool.ApplianceConnection + + [void]$_TaskCollection.Add($_resp) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + elseif ($PSBoundParameters['WhatIf']) + { + + "[{0}] WhatIf Parameter was passed." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + } + + Return $_TaskCollection + + } + +} + +function Get-OVStorageVolumeSet +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding ()] + [OutputType ([HPEOneView.Storage.VolumeSet])] + Param + ( + + [Parameter (Mandatory = $false)] + [ValidateNotNullOrEmpty()] + [String]$Name, + + [Parameter (Mandatory = $false)] + [ValidateNotNullOrEmpty()] + [String]$Label, + + [Parameter (Mandatory = $false)] + [ValidateNotNullOrEmpty()] + [Object]$Scope = "AllResourcesInScope", + + [Parameter (Mandatory = $false, ValueFromPipelinebyPropertyName)] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $colStoragePools = [System.Collections.ArrayList]::new() + + } + + Process + { + + ForEach ($_appliance in $ApplianceConnection) + { + + "[{0}] Processing appliance {1} (of {2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name, $ApplianceConnection.Count | Write-Verbose + + $_Query = [System.Collections.ArrayList]::new() + + # Handle default cause of AllResourcesInScope + if ($Scope -eq 'AllResourcesInScope') + { + + "[{0}] Processing AllResourcesInScope." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_Scopes = $_appliance.ActivePermissions | Where-Object Active + + # If one scope contains 'AllResources' ScopeName "tag", then all resources should be returned regardless. + if ($_Scopes | Where-Object ScopeName -eq 'AllResources') + { + + $_ScopeNames = [String]::Join(', ', ($_Scopes | Where-Object ScopeName -eq 'AllResources').ScopeName) + + "[{0}] Scope(s) {1} is set to 'AllResources'. Will not add scope to URI query parameter." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_ScopeNames | Write-Verbose + + } + + # Process ApplianceConnection ActivePermissions collection + else + { + + Try + { + + $_ScopeQuery = Join-Scope $_Scopes + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + [Void]$_Query.Add(("({0})" -f $_ScopeQuery)) + + } + + } + + elseif ($Scope | Where-Object ScopeName -eq 'AllResources') + { + + $_ScopeNames = [String]::Join(', ', ($_Scopes | Where-Object ScopeName -eq 'AllResources').ScopeName) + + "[{0}] Scope(s) {1} is set to 'AllResources'. Will not add scope to URI query parameter." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_ScopeNames | Write-Verbose + + } + + elseif ($Scope -eq 'AllResources') + { + + "[{0}] Requesting scope 'AllResources'. Will not add scope to URI query parameter." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_ScopeNames | Write-Verbose + + } + + else + { + + Try + { + + $_ScopeQuery = Join-Scope $Scope + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + [Void]$_Query.Add(("({0})" -f $_ScopeQuery)) + + } + + if ($Name) + { + + "[{0}] Filtering for Name: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Name | Write-Verbose + + if ($Name.Contains('*')) + { + + [Void]$_Query.Add(("name%3A{0}" -f $Name.Replace("*", "%2A").Replace(',','%2C').Replace(" ", "?"))) + + } + + else + { + + [Void]$_Query.Add(("name:'{0}'" -f $Name)) + + } + + } + + if ($Label) + { + + "[{0}] Filtering for Label: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Label | Write-Verbose + + [Void]$_Query.Add(("labels:'{0}'" -f $Label)) + + } + + $_Category = 'category={0}' -f $ResourceCategoryEnum.StorageVolumeSet + + # Build the final URI + $_uri = '{0}?{1}&sort=name:asc&query={2}' -f $IndexUri, [String]::Join('&', $_Category), [String]::Join(' AND ', $_Query.ToArray()) + + Try + { + + [Array]$_ResourcesFromIndexCol = Get-AllIndexResources -Uri $_uri -ApplianceConnection $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if ($_ResourcesFromIndexCol.Count -eq 0 -and $Name) + { + + "[{0}] No Storage Volume Template with '{1}' name found on '{2}' appliance connection." -f $MyInvocation.InvocationName.ToString().ToUpper(), $Name, $_appliance.Name | Write-Verbose + + $ExceptionMessage = "No Storage Volume with '{0}' name found on '{1}' appliance connection. Please check the name or use New-OVStorageVolumeTemplate to create the volume template." -f $Name, $_appliance.Name + $ErrorRecord = New-ErrorRecord InvalidOperationException StorageVolumeResourceNotFound ObjectNotFound 'Name' -Message $ExceptionMessage + $PSCmdlet.WriteError($ErrorRecord) + + } + + elseif ($_ResourcesFromIndexCol -eq 0) + { + + "[{0}] No Storage Volume Templates found." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + else + { + + ForEach ($_member in $_ResourcesFromIndexCol) + { + + # Get associated Storage Systems to Volume Sets with "name EQ 'STORAGE_SYSTEM_TO_STORAGE_VOLUME_SET'" to then embed within the Storage Volume object + + $_StorageVolumeResources = [System.Collections.ArrayList]::new() + + Try + { + + $_StorageSystem = Send-OVRequest -Uri $_member.storageSystemUri -ApplianceConnection $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + # Get associated volumes to volume sets + $_uri = '{0}?name=STORAGE_VOLUME_SET_TO_STORAGE_VOLUME&parentUri={1}' -f $AssociationsUri, $_member.uri + + Try + { + + [Array]$_StorageVolumeResourcesFromIndexCol = Get-AllIndexResources -Uri $_uri -ApplianceConnection $_appliance + + if (-not $_StorageVolumeResourcesFromIndexCol.Count) + { + + [Array]$_StorageVolumeResourcesFromIndexCol = @() + + } + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $_NimbleVolumeSetDeviceSpecificAttributes = [HPEOneView.Storage.NimbleVolumeSetDeviceSpecificAttributes]::new($_member.deviceSpecificAttributes.appSync, + $_member.deviceSpecificAttributes.totalSnapshots, + $_member.deviceSpecificAttributes.replicationPartner, + $_member.deviceSpecificAttributes.lastSnapshotCollection) + + [HPEOneView.Storage.VolumeSet]::new($_member.name, + $_StorageVolumeResourcesFromIndexCol, + $_StorageSystem, + $_NimbleVolumeSetDeviceSpecificAttributes, + $_member.status, + $_member.state, + $_member.eTag, + $_member.uri, + $_member.ApplianceConnection) + + } + + } + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Get-OVStorageVolumeTemplate +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding ()] + Param + ( + + [Parameter (Mandatory = $false)] + [ValidateNotNullOrEmpty()] + [Alias ('TemplateName')] + [String]$Name, + + [Parameter (Mandatory = $false)] + [ValidateNotNullOrEmpty()] + [String]$Label, + + [Parameter (Mandatory = $false)] + [ValidateNotNullOrEmpty()] + [Object]$Scope = "AllResourcesInScope", + + [Parameter (Mandatory = $False)] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $_StorageVolumeTemplateCollection = [System.Collections.ArrayList]::new() + + } + + Process + { + + ForEach ($_appliance in $ApplianceConnection) + { + + "[{0}] Processing appliance {1} (of {2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name, $ApplianceConnection.Count | Write-Verbose + + $_Query = [System.Collections.ArrayList]::new() + + # Handle default cause of AllResourcesInScope + if ($Scope -eq 'AllResourcesInScope') + { + + "[{0}] Processing AllResourcesInScope." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_Scopes = $_appliance.ActivePermissions | Where-Object Active + + # If one scope contains 'AllResources' ScopeName "tag", then all resources should be returned regardless. + if ($_Scopes | Where-Object ScopeName -eq 'AllResources') + { + + $_ScopeNames = [String]::Join(', ', ($_Scopes | Where-Object ScopeName -eq 'AllResources').ScopeName) + + "[{0}] Scope(s) {1} is set to 'AllResources'. Will not add scope to URI query parameter." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_ScopeNames | Write-Verbose + + } + + # Process ApplianceConnection ActivePermissions collection + else + { + + Try + { + + $_ScopeQuery = Join-Scope $_Scopes + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + [Void]$_Query.Add(("({0})" -f $_ScopeQuery)) + + } + + } + + elseif ($Scope | Where-Object ScopeName -eq 'AllResources') + { + + $_ScopeNames = [String]::Join(', ', ($_Scopes | Where-Object ScopeName -eq 'AllResources').ScopeName) + + "[{0}] Scope(s) {1} is set to 'AllResources'. Will not add scope to URI query parameter." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_ScopeNames | Write-Verbose + + } + + elseif ($Scope -eq 'AllResources') + { + + "[{0}] Requesting scope 'AllResources'. Will not add scope to URI query parameter." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_ScopeNames | Write-Verbose + + } + + else + { + + Try + { + + $_ScopeQuery = Join-Scope $Scope + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + [Void]$_Query.Add(("({0})" -f $_ScopeQuery)) + + } + + if ($Name) + { + + "[{0}] Filtering for Name: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Name | Write-Verbose + + if ($Name.Contains('*')) + { + + [Void]$_Query.Add(("name%3A{0}" -f $Name.Replace("*", "%2A").Replace(',','%2C').Replace(" ", "?"))) + + } + + else + { + + [Void]$_Query.Add(("name:'{0}'" -f $Name)) + + } + + } + + if ($Label) + { + + "[{0}] Filtering for Label: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Label | Write-Verbose + + [Void]$_Query.Add(("labels:'{0}'" -f $Label)) + + } + + $_Category = 'category=storage-volume-templates' + + # Build the final URI + $_uri = '{0}?{1}&sort=name:asc&query={2}' -f $IndexUri, [String]::Join('&', $_Category), [String]::Join(' AND ', $_Query.ToArray()) + + Try + { + + [Array]$_ResourcesFromIndexCol = Get-AllIndexResources -Uri $_uri -ApplianceConnection $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if ($_ResourcesFromIndexCol.Count -eq 0 -and $Name) + { + + "[{0}] No Storage Volume Template with '{1}' name found on '{2}' appliance connection." -f $MyInvocation.InvocationName.ToString().ToUpper(), $Name, $_appliance.Name | Write-Verbose + + $ExceptionMessage = "No Storage Volume with '{0}' name found on '{1}' appliance connection. Please check the name or use New-OVStorageVolumeTemplate to create the volume template." -f $Name, $_appliance.Name + $ErrorRecord = New-ErrorRecord InvalidOperationException StorageVolumeResourceNotFound ObjectNotFound 'Name' -Message $ExceptionMessage + $PSCmdlet.WriteError($ErrorRecord) + + } + + elseif ($_ResourcesFromIndexCol -eq 0) + { + + "[{0}] No Storage Volume Templates found." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + else + { + + ForEach ($_member in $_ResourcesFromIndexCol) + { + + $_member.PSObject.TypeNames.Insert(0,'HPEOneView.Storage.VolumeTemplate') + + $_member + + } + + } + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function New-OVStorageVolumeTemplate +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = 'Default')] + Param + ( + + [Parameter (Mandatory, ParameterSetName = "Default")] + [Parameter (Mandatory, ParameterSetName = "Nimble")] + [ValidateNotNullOrEmpty()] + [Alias ('TemplateName')] + [String]$Name, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Parameter (Mandatory = $false, ParameterSetName = "Nimble")] + [ValidateNotNullOrEmpty()] + [String]$Description, + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = "Default")] + [Parameter (Mandatory, ParameterSetName = "Nimble")] + [ValidateNotNullOrEmpty()] + [HPEOneView.Storage.StoragePool]$StoragePool, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Parameter (Mandatory = $false, ParameterSetName = "Nimble")] + [Switch]$LockStoragePool, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [ValidateNotNullOrEmpty()] + [HPEOneView.Storage.StoragePool]$SnapshotStoragePool, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Switch]$LockSnapShotStoragePool, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [ValidateNotNullOrEmpty()] + [object]$StorageSystem, + + [Parameter (Mandatory, ParameterSetName = "Default")] + [Parameter (Mandatory, ParameterSetName = "Nimble")] + [ValidateScript({$_ -ge 1})] + [Alias ("size")] + [int64]$Capacity, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Parameter (Mandatory = $false, ParameterSetName = "Nimble")] + [Switch]$LockCapacity, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Switch]$Full, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Parameter (Mandatory = $false, ParameterSetName = "Nimble")] + [Alias ('ProvisionType')] + [ValidateSet ('Thin','Full','TPDD')] + [String]$ProvisioningType, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Parameter (Mandatory = $false, ParameterSetName = "Nimble")] + [Switch]$LockProvisionType, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Bool]$EnableDeduplication, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Switch]$LockEnableDeduplication, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Bool]$EnableCompression, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Switch]$LockEnableCompression, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Parameter (Mandatory = $false, ParameterSetName = "Nimble")] + [Switch]$Shared, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Parameter (Mandatory = $false, ParameterSetName = "Nimble")] + [Switch]$LockProvisionMode, + + [Parameter (Mandatory, ParameterSetName = "Nimble")] + [HPEOneView.Storage.PerformancePolicy]$PerformancePolicy, + + [Parameter (Mandatory = $false, ParameterSetName = "Nimble")] + [Switch]$LockPerformancePolicy, + + [Parameter (Mandatory = $false, ParameterSetName = "Nimble")] + [Bool]$EnableEncryption, + + [Parameter (Mandatory = $false, ParameterSetName = "Nimble")] + [Switch]$LockEnableEncryption, + + [Parameter (Mandatory = $false, ParameterSetName = "Nimble")] + [Bool]$CachePinning, + + [Parameter (Mandatory = $false, ParameterSetName = "Nimble")] + [Switch]$LockCachePinning, + + [Parameter (Mandatory = $false, ParameterSetName = "Nimble")] + [HPEOneView.Storage.VolumeSet]$VolumeSet, + + [Parameter (Mandatory = $false, ParameterSetName = "Nimble")] + [Switch]$LockVolumeSet, + + [Parameter (Mandatory = $false, ParameterSetName = "Nimble")] + [Bool]$EnableIOPSLimit, + + [Parameter (Mandatory = $false, ParameterSetName = "Nimble")] + [ValidateRange (256,4294967295)] + [Int]$IOPSLimit = 256, + + [Parameter (Mandatory = $false, ParameterSetName = "Nimble")] + [Switch]$LockIOPSLimit, + + [Parameter (Mandatory = $false, ParameterSetName = "Nimble")] + [Bool]$EnableDataTransferLimit, + + [Parameter (Mandatory = $false, ParameterSetName = "Nimble")] + [Int]$DataTransferLimit, + + [Parameter (Mandatory = $false, ParameterSetName = "Nimble")] + [Switch]$LockDataTransferLimit, + + [Parameter (Mandatory = $false, ParameterSetName = "Nimble")] + [HPEOneView.Storage.NimbleFolder]$Folder, + + [Parameter (Mandatory = $false, ParameterSetName = "Nimble")] + [Switch]$LockFolder, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Parameter (Mandatory = $false, ParameterSetName = "Nimble")] + [ValidateNotNullOrEmpty()] + [HPEOneView.Appliance.ScopeCollection[]]$Scope, + + [Parameter (Mandatory = $false, ValueFromPipelinebyPropertyName, ParameterSetName = "Default")] + [Parameter (Mandatory = $false, ValueFromPipelinebyPropertyName, ParameterSetName = "Nimble")] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + "[{0}] Bound PS Parameters: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), ($PSBoundParameters | out-string) | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not($PSboundParameters['StoragePool'])) + { + + $PipelineInput = $True + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + $colStatus = [System.Collections.ArrayList]::new() + + if ($PSBoundParameters['Thin']) + { + + $ExceptionMessage = 'The -Thin parameter is being deprecated. Please update your scripts to use the -ProvisioningType parameter instead.' + $ErrorRecord = New-ErrorRecord HPEOneView.Library.ParameterValidationException InvalidProvisionTypeParameter InvalidOperation 'StorageSystem' -Message $ExceptionMessage + $PSCmdlet.WriteError($ErrorRecord) + + $PSBoundParameters.Add('ProvisioningType', $StorageVolumeProvisioningTypeEnum['Thin']) + + } + + if ($PSBoundParameters['Full']) + { + + $ExceptionMessage = 'The -Full parameter is being deprecated. Please update your scripts to use the -ProvisioningType parameter instead.' + $ErrorRecord = New-ErrorRecord HPEOneView.Library.ParameterValidationException InvalidProvisionTypeParameter InvalidOperation 'StorageSystem' -Message $ExceptionMessage + $PSCmdlet.WriteError($ErrorRecord) + + $PSBoundParameters.Add('ProvisioningType', $StorageVolumeProvisioningTypeEnum['Full']) + + } + + if ($PSBoundParameters['ProvisioningType'] -eq 'TPDD') + { + + $ExceptionMessage = 'The -ProvisioningType "TPDD" value is being deprecated. Please update your script(s) to use the "Thin" value and -EnableCompression $True parameter.' + $ErrorRecord = New-ErrorRecord HPEOneView.Library.ParameterValidationException InvalidProvisionTypeParameter InvalidOperation 'StorageSystem' -Message $ExceptionMessage + $PSCmdlet.WriteError($ErrorRecord) + + $ProvisioningType = $StorageVolumeProvisioningTypeEnum['Thin'] + $PSBoundParameters.Add('EnableDeduplication', $True) + + # If LockProvisionType is set to true, then also lock Deduplication + if ($PSBoundParameters.Keys -Contains 'LockProvisionType') + { + + $PSBoundParameters.Add('LockEnableDeduplication', $True) + + } + + } + + if ($PSBoundParameters['StorageSystem']) + { + + $ExceptionMessage = "The -StorageSystem is deprecated. Please update your script(s) to use Get-OVStoragePool to get the specific pool object." + $ErrorRecord = New-ErrorRecord HPEOneView.Library.ParameterValidationException InvalidProvisionTypeParameter InvalidOperation 'StorageSystem' -Message $ExceptionMessage + $PSCmdlet.WriteError($ErrorRecord) + + } + + } + + Process + { + + if ($StoragePool -isnot [PSCustomObject]) + { + + Try + { + + "[{0}] Getting and validating StoragePool parameter." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_StoragePool = GetStoragePool -InputObject $StoragePool -StorageSystem $StorageSystem -ApplianceConnection $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + else + { + + "[{0}] StoragePool object: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $StoragePool.name | Write-Verbose + "[{0}] StoragePool object category: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $StoragePool.category | Write-Verbose + "[{0}] StoragePool object URI: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $StoragePool.uri | Write-Verbose + $_StoragePool = $StoragePool.PSObject.Copy() + + } + + # Get Root Volume Template from Storage System + Try + { + + "[{0}] Getting storage system root volume template." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + $_Uri = '{0}/templates?filter=isRoot EQ true' -f $_StoragePool.storageSystemUri + $_RootTemplate = (Send-OVRequest -Uri $_Uri -Hostname $ApplianceConnection).members[0] + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + "[{0}] Root template: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_RootTemplate.name | Write-Verbose + "[{0}] Root template family: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_RootTemplate.family | Write-Verbose + + $_svt = NewObject -StorageVolumeTemplate + $_svt.properties = $_RootTemplate.properties + + # Get the storage system to validate certain settings if they are available + Try + { + + $_StorageSystem = Send-OVRequest -Uri $_StoragePool.storageSystemUri -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + switch ($_RootTemplate.family) + { + + {'Nimble', 'Alletra5000', 'Alletra6000' -contains $_} + { + + if ($PSBoundParameters.Keys -Contains 'EnableEncryption') + { + + "[{0}] Enable Encryption: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $EnableEncryption | Write-Verbose + + $_svt.properties.isEncrypted.default = $EnableEncryption + + } + + if ($PSBoundParameters['LockEnableEncryption']) + { + + "[{0}] Locking EnableEncryption: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $LockEnableEncryption.IsPresent | Write-Verbose + + $_svt.properties.isDeduplicated.meta.locked = $LockEnableEncryption.IsPresent + + } + + # PerformancePolicy parameter + $_FilterDelegate = [Func[object,bool]]{ param ($p) return $p.id -eq $PerformancePolicy.Id } + + if ($_PerformancePolicy = [Linq.Enumerable]::ToArray([System.Linq.Enumerable]::Where($_StorageSystem.deviceSpecificAttributes.performancePolicies, $_FilterDelegate))) + { + + "[{0}] Config PerformancePolicy: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $PerformancePolicy | Write-Verbose + + $_svt.properties.performancePolicy | Add-Member -NotePropertyName default -NotePropertyValue $_PerformancePolicy.id -Force + + if ($PSBoundParameters['LockPerformancePolicy']) + { + + "[{0}] Locking PerformancePolicy: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $LockPerformancePolicy.IsPresent | Write-Verbose + + $_svt.properties.performancePolicy.meta.locked = $LockPerformancePolicy.IsPresent + + } + + # Check for cache pinning + if ($PSBoundParameters.Keys -Contains 'CachePinning') + { + + # Error that cache pinning is not supported by the Performance Policy chosen and the parameter was provided + if (-not $_PerformancePolicy.isCached) + { + + "[{0}] Performance Policy '{1}' does not support cache pinning." -f $MyInvocation.InvocationName.ToString().ToUpper(), $PerformancePolicy | Write-Verbose + + $ExceptionMessage = "The provided {0} performance policy '{1}' does not allow Cache Pinning to be configured." -f $_RootTemplate.family, $PerformancePolicy + $ErrorRecord = New-ErrorRecord HPEOneView.Library.ParameterValidationException InvalidCachePinningParameter InvalidOperation 'CachePinning' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + else + { + + "[{0}] Config CachePinning: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $CachePinning | Write-Verbose + + $_svt.properties.isCached = $CachePinning + + if ($PSBoundParameters['LockCachePinning']) + { + + "[{0}] Locking CachePinning: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $LockCachePinning.IsPresent | Write-Verbose + + $_svt.properties.isCached.meta.locked = $LockCachePinning.IsPresent + + } + + } + + } + + } + + else + { + + $ExceptionMessage = "The provided {0} performance policy '{1}' is not found in '{2}' storage system." -f $_RootTemplate.family, $PerformancePolicy, $_StorageSystem.name + $ErrorRecord = New-ErrorRecord HPEOneView.Library.ParameterValidationException InvalidPerformancePolicyParameter InvalidOperation 'PerformancePolicy' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + # Volume set management + if ($PSBoundParameters['VolumeSet']) + { + + "[{0}] Setting VolumeSet: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $VolumeSet | Write-Verbose + + $_svt.properties.volumeSet.default = $VolumeSet.Uri + + } + + # Since VS can be set to null, allow it to be locked. + if ($PSBoundParameters['LockVolumeSet']) + { + + "[{0}] Locking VolumeSet: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $LockVolumeSet.IsPresent | Write-Verbose + + $_svt.properties.volumeSet.meta.locked = $LockVolumeSet.IsPresent + + } + + # IOPSLimit management + if ($PSBoundParameters['EnableIOPSLimit']) + { + + "[{0}] Setting IOPSLimit: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $IOPSLimit | Write-Verbose + + $_svt.properties.iopsLimit.default = $IOPSLimit + + } + + # Since VS can be set to null, allow it to be locked. + if ($PSBoundParameters['LockIOPSLimit']) + { + + "[{0}] Locking IOPSLimit: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $LockIOPSLimit.IsPresent | Write-Verbose + + $_svt.properties.iopsLimit.meta.locked = $LockIOPSLimit.IsPresent + + } + + # DataTransferLimit management + if ($PSBoundParameters['EnableDataTransferLimit']) + { + + if ($EnableDataTransferLimit -and $DataTransferLimit -lt $_RootTemplate.properties.dataTransferLimit.minimum -or $DataTransferLimit -gt $_RootTemplate.properties.dataTransferLimit.maximum) + { + + $ExceptionMessage = "The provided {0} DataTransferLimit '{1}' is not within the allowed '{2}' and '{3}' limit." -f $_RootTemplate.family, $DataTransferLimit, $_RootTemplate.properties.dataTransferLimit.minimum, $_RootTemplate.properties.dataTransferLimit.maximum + $ErrorRecord = New-ErrorRecord HPEOneView.Library.ParameterValidationException InvalidDataTransferLimitParameter InvalidOperation 'DataTransferLimit' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + "[{0}] Setting DataTransferLimit: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $DataTransferLimit | Write-Verbose + + $_svt.properties.dataTransferLimit.default = $DataTransferLimit + + } + + # Since VS can be set to null, allow it to be locked. + if ($PSBoundParameters['LockDataTransferLimit']) + { + + "[{0}] Locking LockDataTransferLimit: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $LockDataTransferLimit.IsPresent | Write-Verbose + + $_svt.properties.dataTransferLimit.meta.locked = $LockDataTransferLimit.IsPresent + + } + + # NimbleFolder management + if ($PSBoundParameters['Folder']) + { + + $_FilterDelegate = [Func[object,bool]]{ param ($p) return $p.id -eq $Folder.Id } + + if ($_FolderLocation = [Linq.Enumerable]::ToArray([System.Linq.Enumerable]::Where($_StoragePool.deviceSpecificAttributes.folders, $_FilterDelegate))) + { + + "[{0}] Config Folder: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Folder | Write-Verbose + + $_svt.properties.folder.default = $Folder.id + + } + + else + { + + $ExceptionMessage = "The provided {0} folder '{1}' is not found in '{2}' storage pool." -f $_RootTemplate.family, $Folder, $_StoragePool.name + $ErrorRecord = New-ErrorRecord HPEOneView.Library.ParameterValidationException InvalidFolderParameter InvalidOperation 'Folder' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + # Since VS can be set to null, allow it to be locked. + if ($PSBoundParameters['LockFolder']) + { + + "[{0}] Locking LockFolder: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $LockFolder.IsPresent | Write-Verbose + + $_svt.properties.folder.meta.locked = $LockFolder.IsPresent + + } + + } + + {'3Par', 'StoreServ', 'Primera', 'Alletra9000' -contains $_} + { + + if ($PSBoundParameters['DataProtectionLevel'] -or $PSBoundParameters['LockProtectionLevel']) + { + + $ExceptionMessage = "The Storage System family of the Storage Pool, {0}, is not a Nimble, Alletra5000 or Alletra6000 system. DataProtectionLevel is only supported with StoreVirtual class of storage systems." -f $_StoragePool.name + $ErrorRecord = New-ErrorRecord ArgumentException InvalidArgumentType InvalidArgument 'DataProtectionLevel' -TargetType $DataProtectionLevel.gettype().Name -Message $ExceptionMessage + + # Generate Terminating Error + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + if ($PSboundParameters['SnapShotStoragePool']) + { + + Try + { + + $_SnapShotStoragePool = GetStoragePool -InputObject $SnapShotStoragePool -StorageSystem $StorageSystem -ApplianceConnection $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + "[{0}] Setting snapshot storage pool: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_SnapShotStoragePool.uri | Write-Verbose + + $_svt.properties.snapshotPool.default = $_SnapShotStoragePool.uri + + } + + else + { + + "[{0}] No SnapShotStoragePool resource provided. Setting Snapshot Pool to: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_StoragePool.name | Write-Verbose + + $_svt.properties.snapshotPool.default = $_StoragePool.uri + + } + + if ($PSBoundParameters['LockStoragePool']) + { + + "[{0}] Locking Snapshot Storage Pool: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $LockSnapshotStoragePool.IsPresent | Write-Verbose + + $_svt.properties.snapshotPool.meta.locked = $LockSnapshotStoragePool.IsPresent + + } + + if ($PSBoundParameters.Keys -Contains 'EnableDeduplication') + { + + "[{0}] Enable Deduplication: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $PSBoundParameters['EnableDeduplication'] | Write-Verbose + + switch ($_RootTemplate.family) + { + + {'Alletra9000', 'Primera' -contains $_} + { + + $_PropertyName = 'isDataReductionEnabled' + + } + + default + { + + $_PropertyName = 'isDeduplicated' + + } + + } + + $_svt.properties.$_PropertyName.default = $PSBoundParameters['EnableDeduplication'] + + if ($PSBoundParameters['LockEnableDeduplication']) + { + + "[{0}] Locking Deduplication: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $LockEnableDeduplication.IsPresent | Write-Verbose + + $_svt.properties.$_PropertyName.meta.locked = $LockEnableDeduplication.IsPresent + + } + + } + + if ($PSBoundParameters.Keys -Contains 'EnableCompression') + { + + if ($StorageSystemFamilyTypeEnum.Primera, $StorageSystemFamilyTypeEnum.Alletra9000 -notcontains $_RootTemplate.family) + { + + "[{0}] Enable Compression: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $PSBoundParameters['EnableCompression'] | Write-Verbose + + $_svt.properties.isCompressed.default = $PSBoundParameters['EnableCompression'] + + if ($PSBoundParameters['LockEnableCompression']) + { + + "[{0}] Locking Compression: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $LockEnableCompression.IsPresent | Write-Verbose + + $_svt.properties.isCompressed.meta.locked = $LockEnableCompression.IsPresent + + } + + } + + } + + } + + } + + # Set common values here + $_svt.name = $Name + $_svt.description = $description + $_svt.rootTemplateUri = $_RootTemplate.uri + + switch ($PSBoundParameters.Keys) + { + + 'Capacity' + { + + "[{0}] Setting capacity default value: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), [int64]($capacity * 1GB) | Write-Verbose + + $_svt.properties.size.default = [int64]($capacity * 1GB) + + } + + 'LockCapacity' + { + + "[{0}] Locking capacity: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $LockCapacity.IsPresent | Write-Verbose + + $_svt.properties.size.meta.locked = $LockCapacity.IsPresent + + } + + 'StoragePool' + { + + "[{0}] Setting Storage Pool default value: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_StoragePool.uri | Write-Verbose + + $_svt.properties.storagepool | Add-Member -NotePropertyName default -NotePropertyValue $_StoragePool.uri + + } + + 'LockStoragePool' + { + + "[{0}] Locking Storage Pool: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $LockStoragePool.IsPresent | Write-Verbose + + $_svt.properties.storagepool.meta.locked = $LockStoragePool.IsPresent + + } + + 'Full' + { + + "[{0}] Setting Provisioning Type to Full: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Full.IsPresent | Write-Verbose + + $_svt.properties.provisioningType.default = if ($Full.IsPresent) { 'Full' } else { 'Thin' } + + } + + 'ProvisioningType' + { + + "[{0}] Setting Provisioning Type to: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $StorageVolumeProvisioningTypeEnum[$ProvisioningType] | Write-Verbose + + $_svt.properties.provisioningType.default = $StorageVolumeProvisioningTypeEnum[$ProvisioningType] + + if ($ProvisioningType -eq 'TPDD') + { + + "[{0}] Setting isDeduplicated: true" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_svt.properties.isDeduplicated.default = $true + + } + + } + + 'LockProvisionType' + { + + "[{0}] Locking provisioning type: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $LockProvisionType.IsPresent | Write-Verbose + + $_svt.properties.provisioningType.meta.locked = $LockProvisionType.IsPresent + + if ($ProvisioningType -eq 'TPDD') + { + + "[{0}] Locking Deduplication: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $LockProvisionType.IsPresent | Write-Verbose + + $_svt.properties.isDeduplicated.meta.locked = $LockProvisionType.IsPresent + + } + + } + + 'Shared' + { + + "[{0}] Setting Provisioning Type to Full: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Shared.IsPresent | Write-Verbose + + $_svt.properties.isShareable.default = $Shared.IsPresent + + } + + 'LockProvisionMode' + { + + "[{0}] Locking provisioning type: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $LockProvisionMode.IsPresent | Write-Verbose + + $_svt.properties.isShareable.meta.locked = $LockProvisionMode.IsPresent + + } + + } + + if ($PSBoundParameters['Scope']) + { + + ForEach ($_Scope in $Scope) + { + + "[{0}] Adding resource to Scope: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_Scope.Name | Write-Verbose + + [void]$_svt.initialScopeUris.Add($_Scope.Uri) + + } + + } + + # Send the request + Try + { + + $_resp = Send-OVRequest -method POST -uri $StorageVolumeTemplateUri -Body $_svt -Hostname $ApplianceConnection.Name + $_resp.PSObject.TypeNames.Insert(0,'HPEOneView.Storage.VolumeTemplate') + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $_resp + + } + + End + { + + '[{0}] Done.' -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Set-OVStorageVolumeTemplate +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = 'Default')] + [OutputType ([HPEOneView.Appliance.TaskResource])] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = "Default")] + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = "Nimble")] + [Alias('SVT','Template')] + [ValidateNotNullOrEmpty()] + [Object]$InputObject, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Parameter (Mandatory = $false, ParameterSetName = "Nimble")] + [ValidateNotNullOrEmpty()] + [Alias ('TemplateName')] + [String]$Name, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Parameter (Mandatory = $false, ParameterSetName = "Nimble")] + [ValidateNotNullOrEmpty()] + [String]$Description, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [ValidateNotNullOrEmpty()] + [object]$SnapshotStoragePool, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Switch]$LockSnapShotStoragePool, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Parameter (Mandatory = $false, ParameterSetName = "Nimble")] + [ValidateNotNullOrEmpty()] + [object]$StorageSystem, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Parameter (Mandatory = $false, ParameterSetName = "Nimble")] + [ValidateScript({$_ -ge 1})] + [Alias ("size")] + [int64]$Capacity, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Parameter (Mandatory = $false, ParameterSetName = "Nimble")] + [Switch]$LockCapacity, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Switch]$Thin, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Switch]$Full, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Parameter (Mandatory = $false, ParameterSetName = "Nimble")] + [Alias ('ProvisionType')] + [ValidateSet ('Thin','Full','TPDD')] + [String]$ProvisioningType, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Switch]$LockProvisionType, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Bool]$Shared, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Switch]$LockProvisionMode, + + [Parameter (Mandatory = $false, ParameterSetName = "Nimble")] + [HPEOneView.Storage.PerformancePolicy]$PerformancePolicy, + + [Parameter (Mandatory = $false, ParameterSetName = "Nimble")] + [Switch]$LockPerformancePolicy, + + [Parameter (Mandatory = $false, ParameterSetName = "Nimble")] + [Bool]$EnableEncryption, + + [Parameter (Mandatory = $false, ParameterSetName = "Nimble")] + [Switch]$LockEnableEncryption, + + [Parameter (Mandatory = $false, ParameterSetName = "Nimble")] + [Bool]$CachePinning, + + [Parameter (Mandatory = $false, ParameterSetName = "Nimble")] + [Switch]$LockCachePinning, + + [Parameter (Mandatory = $false, ParameterSetName = "Nimble")] # From Get-OVStorageVolumeSet + [HPEOneView.Storage.VolumeSet]$VolumeSet, + + [Parameter (Mandatory = $false, ParameterSetName = "Nimble")] + [Switch]$LockVolumeSet, + + [Parameter (Mandatory = $false, ParameterSetName = "Nimble")] + [Bool]$EnableIOPSLimit, + + [Parameter (Mandatory = $false, ParameterSetName = "Nimble")] + [ValidateRange (256,4294967295)] + [Int]$IOPSLimit = 256, + + [Parameter (Mandatory = $false, ParameterSetName = "Nimble")] + [Switch]$LockIOPSLimit, + + [Parameter (Mandatory = $false, ParameterSetName = "Nimble")] + [Bool]$EnableDataTransferLimit, + + [Parameter (Mandatory = $false, ParameterSetName = "Nimble")] + [Int]$DataTransferLimit, + + [Parameter (Mandatory = $false, ParameterSetName = "Nimble")] + [Switch]$LockDataTransferLimit, + + [Parameter (Mandatory = $false, ParameterSetName = "Nimble")] + [HPEOneView.Storage.NimbleFolder]$Folder, + + [Parameter (Mandatory = $false, ParameterSetName = "Nimble")] + [Switch]$LockFolder, + + [Parameter (Mandatory = $false, ValueFromPipelinebyPropertyName, ParameterSetName = "Default")] + [Parameter (Mandatory = $false, ValueFromPipelinebyPropertyName, ParameterSetName = "Nimble")] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not($PSBoundParameters['InputObject'])) + { + + $PipelineInput = $True + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + } + + Process + { + + if ($PSBoundParameters['Thin']) + { + + $ExceptionMessage = 'The -Thin parameter is being deprecated. Please update your scripts to use the -ProvisioningType parameter instead.' + $ErrorRecord = New-ErrorRecord HPEOneView.Library.ParameterValidationException InvalidProvisionTypeParameter InvalidOperation 'StorageSystem' -Message $ExceptionMessage + $PSCmdlet.WriteError($ErrorRecord) + + $PSBoundParameters.Add('ProvisioningType', $StorageVolumeProvisioningTypeEnum['Thin']) + + } + + if ($PSBoundParameters['Full']) + { + + $ExceptionMessage = 'The -Full parameter is being deprecated. Please update your scripts to use the -ProvisioningType parameter instead.' + $ErrorRecord = New-ErrorRecord HPEOneView.Library.ParameterValidationException InvalidProvisionTypeParameter InvalidOperation 'StorageSystem' -Message $ExceptionMessage + $PSCmdlet.WriteError($ErrorRecord) + + $PSBoundParameters.Add('ProvisioningType', $StorageVolumeProvisioningTypeEnum['Full']) + + } + + if ($PSBoundParameters['ProvisioningType'] -eq 'TPDD') + { + + $ExceptionMessage = 'The -ProvisioningType "TPDD" value is being deprecated. Please update your script(s) to use the "Thin" value and -EnableCompression $True parameter.' + $ErrorRecord = New-ErrorRecord HPEOneView.Library.ParameterValidationException InvalidProvisionTypeParameter InvalidOperation 'StorageSystem' -Message $ExceptionMessage + $PSCmdlet.WriteError($ErrorRecord) + + $ProvisioningType = $StorageVolumeProvisioningTypeEnum['Thin'] + $PSBoundParameters.Add('EnableCompression', $True) + + } + + if ($PSBoundParameters['StorageSystem']) + { + + $ExceptionMessage = "The -StorageSystem is deprecated. Please update your script(s) to use Get-OVStoragePool to get the specific pool object." + $ErrorRecord = New-ErrorRecord HPEOneView.Library.ParameterValidationException InvalidProvisionTypeParameter InvalidOperation 'StorageSystem' -Message $ExceptionMessage + $PSCmdlet.WriteError($ErrorRecord) + + } + + # Need to generate an error + if ($InputObject.family -eq 'Nimble' -and $PSBoundParameters['ProvisioningType'] -eq 'TPDD') + { + + $ExceptionMessage = "The provided ProvisioningType policy '{0}' is not supported by Nimble. Please update your script to use either 'Thin' or 'Full'. Setting ProvisioningType parameter to 'Thin'." -f $ProvisioningType + $ErrorRecord = New-ErrorRecord HPEOneView.Library.ParameterValidationException InvalidProvisionTypeParameter InvalidOperation 'ProvisioningType' -Message $ExceptionMessage + $PSCmdlet.WriteError($ErrorRecord) + + $ProvisioningType = $StorageVolumeProvisioningTypeEnum['Thin'] + + } + + "[{0}] object name: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject.name | Write-Verbose + "[{0}] object uri: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject.uri | Write-Verbose + "[{0}] object appliance connection: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject.ApplianceConnection | Write-Verbose + "[{0}] object category: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject.category | Write-Verbose + + # Validate the object + if ($InputObject.category -ne $ResourceCategoryEnum.StorageVolumeTemplate) + { + + $ExceptionMessage = "Invalid InputObject parameter value. Expected Resource Category 'storage-volume-templates', received '{0}'." -f $InputObject.category + $ErrorRecord = New-ErrorRecord HPEOneView.StorageVolumeTemplateResourceException InvalidStorageVolumeTemplateCategory InvalidArgument 'InputObject' -TargetType 'PSObject' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + $_InputObject = $InputObject.PSObject.Copy() + + "[{0}] ORIGINAL Storage Volume object properties: {1} ({2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject.name, $InputObject.uri | Write-Verbose + + switch ($_InputObject.family) + { + + 'StoreServ' + { + + if ($PSBoundParameters['DataProtectionLevel'] -or $PSBoundParameters['LockProtectionLevel']) + { + + $ExceptionMessage = "The Storage System family of the volume template, {0}, is not a StoreVirtual system. DataProtectionLevel is only supported with StoreVirtual class of storage systems." -f $_InputObject.name + $ErrorRecord = New-ErrorRecord ArgumentException InvalidArgumentType InvalidArgument 'DataProtectionLevel' -TargetType $DataProtectionLevel.gettype().Name -Message $ExceptionMessage + + # Generate Terminating Error + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + if ($PSboundParameters['SnapShotStoragePool']) + { + + Try + { + + $_SnapShotStoragePool = GetStoragePool -InputObject $SnapShotStoragePool -StorageSystem $StorageSystem -ApplianceConnection $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + Try + { + + $_StoragePool = Send-OVRequest -Uri $_InputObject.storagePoolUri -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if ($_StoragePool.storageSystemUri -ne $_SnapShotStoragePool.storageSystemUri) + { + + $ExceptionMessage = "The Storage Pool and SnapShot Storage Pool are not from the same Storage System. please correct the SnapshotStoragePool parameter value." + $ErrorRecord = New-ErrorRecord HPEOneView.StorageVolumeResourceException InvalidSnapshotStoragePoolLocation InvalidOperation 'SnapShotStoragePool' -TargetType 'PSObject' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + "[{0}] Setting snapshot storage pool: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_SnapShotStoragePool.uri | Write-Verbose + + $_InputObject.properties.snapshotPool.default = $_SnapShotStoragePool.uri + + } + + if ($PSBoundParameters['LockStoragePool']) + { + + "[{0}] Locking Snapshot Storage Pool: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $LockSnapshotStoragePool.IsPresent | Write-Verbose + + $_InputObject.properties.snapshotPool.meta.locked = $LockSnapshotStoragePool.IsPresent + + } + + } + + 'Nimble' + { + + if ($PSBoundParameters.Keys -Contains 'EnableEncryption') + { + + "[{0}] Enable Encryption: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $EnableEncryption | Write-Verbose + + $_InputObject.properties.isEncrypted.default = $EnableEncryption + + } + + if ($PSBoundParameters['LockEnableEncryption']) + { + + "[{0}] Locking EnableEncryption: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $LockEnableEncryption.IsPresent | Write-Verbose + + $_InputObject.properties.isDeduplicated.meta.locked = $LockEnableEncryption.IsPresent + + } + + if ($PSBoundParameters['PerformancePolicy']) + { + + # PerformancePolicy parameter + $_FilterDelegate = [Func[object,bool]]{ param ($p) return $p.id -eq $PerformancePolicy.Id } + + if ($_PerformancePolicy = [Linq.Enumerable]::ToArray([System.Linq.Enumerable]::Where($_StorageSystem.deviceSpecificAttributes.performancePolicies, $_FilterDelegate))) + { + + "[{0}] Config PerformancePolicy: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $PerformancePolicy | Write-Verbose + + $_InputObject.properties.performancePolicy | Add-Member -NotePropertyName default -NotePropertyValue $_PerformancePolicy.id -Force + + # Check for cache pinning + if ($PSBoundParameters.Keys -Contains 'CachePinning') + { + + # Error that cache pinning is not supported by the Performance Policy chosen and the parameter was provided + if (-not $_PerformancePolicy.isCached) + { + + "[{0}] Performance Policy '{1}' does not support cache pinning." -f $MyInvocation.InvocationName.ToString().ToUpper(), $PerformancePolicy | Write-Verbose + + $ExceptionMessage = "The provided Nimble performance policy '{0}' does not allow Cache Pinning to be configured." -f $PerformancePolicy + $ErrorRecord = New-ErrorRecord HPEOneView.Library.ParameterValidationException InvalidCachePinningParameter InvalidOperation 'CachePinning' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + else + { + + "[{0}] Config CachePinning: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $CachePinning | Write-Verbose + + $_InputObject.properties.isCached = $CachePinning + + if ($PSBoundParameters['LockCachePinning']) + { + + "[{0}] Locking CachePinning: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $LockCachePinning.IsPresent | Write-Verbose + + $_InputObject.properties.isCached.meta.locked = $LockCachePinning.IsPresent + + } + + } + + } + + } + + else + { + + $ExceptionMessage = "The provided Nimble performance policy '{0}' is not found in '{1}' storage system." -f $PerformancePolicy, $_StorageSystem.name + $ErrorRecord = New-ErrorRecord HPEOneView.Library.ParameterValidationException InvalidPerformancePolicyParameter InvalidOperation 'PerformancePolicy' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + if ($PSBoundParameters['LockPerformancePolicy']) + { + + "[{0}] Locking PerformancePolicy: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $LockPerformancePolicy.IsPresent | Write-Verbose + + $_InputObject.properties.performancePolicy.meta.locked = $LockPerformancePolicy.IsPresent + + } + + # Volume set management + if ($PSBoundParameters['VolumeSet']) + { + + "[{0}] Setting VolumeSet: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $VolumeSet | Write-Verbose + + $_InputObject.properties.volumeSet.default = $VolumeSet.Uri + + } + + # Since VS can be set to null, allow it to be locked. + if ($PSBoundParameters['LockVolumeSet']) + { + + "[{0}] Locking VolumeSet: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $LockVolumeSet.IsPresent | Write-Verbose + + $_InputObject.properties.volumeSet.meta.locked = $LockVolumeSet.IsPresent + + } + + # IOPSLimit management + if ($PSBoundParameters.Keys -Contains 'EnableIOPSLimit') + { + + "[{0}] Enable IOPSLimit: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $EnableIOPSLimit | Write-Verbose + + if ($EnableIOPSLimit) + { + + "[{0}] Setting IOPSLimit: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $IOPSLimit | Write-Verbose + + $_InputObject.properties.iopsLimit.default = $IOPSLimit + + } + + else + { + + $_InputObject.properties.iopsLimit.default = $EnableIOPSLimit + + } + + } + + # Since VS can be set to null, allow it to be locked. + if ($PSBoundParameters['LockIOPSLimit']) + { + + "[{0}] Locking IOPSLimit: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $LockIOPSLimit.IsPresent | Write-Verbose + + $_InputObject.properties.iopsLimit.meta.locked = $LockIOPSLimit.IsPresent + + } + + # DataTransferLimit management + if ($PSBoundParameters.Keys -Contains 'EnableDataTransferLimit') + { + + "[{0}] Enable DataTransferLimit: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $EnableDataTransferLimit | Write-Verbose + + if ($EnableDataTransferLimit -and $DataTransferLimit -lt $_RootTemplate.properties.dataTransferLimit.minimum -or $DataTransferLimit -gt $_RootTemplate.properties.dataTransferLimit.maximum) + { + + $ExceptionMessage = "The provided Nimble DataTransferLimit '{0}' is not within the allowed '{1}' and '{2}' limit." -f $DataTransferLimit, $_RootTemplate.properties.dataTransferLimit.minimum, $_RootTemplate.properties.dataTransferLimit.maximum + $ErrorRecord = New-ErrorRecord HPEOneView.Library.ParameterValidationException InvalidDataTransferLimitParameter InvalidOperation 'DataTransferLimit' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($EnableDataTransferLimit) + { + + + "[{0}] Setting DataTransferLimit: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $DataTransferLimit | Write-Verbose + + $_InputObject.properties.dataTransferLimit.default = $DataTransferLimit + + } + + else + { + + $_InputObject.properties.dataTransferLimit.default = $EnableDataTransferLimit + + } + + } + + # Since VS can be set to null, allow it to be locked. + if ($PSBoundParameters['LockDataTransferLimit']) + { + + "[{0}] Locking LockDataTransferLimit: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $LockDataTransferLimit.IsPresent | Write-Verbose + + $_InputObject.properties.dataTransferLimit.meta.locked = $LockDataTransferLimit.IsPresent + + } + + # NimbleFolder management + if ($PSBoundParameters['Folder']) + { + + $_FilterDelegate = [Func[object,bool]]{ param ($p) return $p.id -eq $Folder.Id } + + if ($_FolderLocation = [Linq.Enumerable]::ToArray([System.Linq.Enumerable]::Where($_StorageSystem.deviceSpecificAttributes.folders, $_FilterDelegate))) + { + + "[{0}] Config Folder: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Folder | Write-Verbose + + $_InputObject.properties.folder.default = $Folder.id + + } + + else + { + + $ExceptionMessage = "The provided Nimble folder '{0}' is not found in '{1}' storage system." -f $Folder, $_StorageSystem.name + $ErrorRecord = New-ErrorRecord HPEOneView.Library.ParameterValidationException InvalidFolderParameter InvalidOperation 'Folder' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + # Since VS can be set to null, allow it to be locked. + if ($PSBoundParameters['LockFolder']) + { + + "[{0}] Locking LockFolder: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $LockFolder.IsPresent | Write-Verbose + + $_InputObject.properties.folder.meta.locked = $LockFolder.IsPresent + + } + + } + + } + + switch ($PSBoundParameters.Keys) + { + + 'Name' + { + + $_InputObject.name = $Name + + } + + 'Description' + { + + $_InputObject.description = $description + + } + + 'Capacity' + { + + "[{0}] Setting capacity default value: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), [int64]($Capacity * 1GB) | Write-Verbose + + $_InputObject.properties.size.default = [int64]($Capacity * 1GB) + + } + + 'LockCapacity' + { + + "[{0}] Locking capacity: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $LockCapacity.IsPresent | Write-Verbose + + $_InputObject.properties.size.meta.locked = $LockCapacity.IsPresent + + } + + 'LockStoragePool' + { + + "[{0}] Locking Storage Pool: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $LockStoragePool.IsPresent | Write-Verbose + + $_InputObject.properties.storagepool.meta.locked = $LockStoragePool.IsPresent + + } + + 'LockProvisionType' + { + + "[{0}] Locking provisioning type: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $LockProvisionType.IsPresent | Write-Verbose + + $_InputObject.properties.provisioningType.meta.locked = $LockProvisionType.IsPresent + + } + + 'Shared' + { + + "[{0}] Setting Provisioning Type to Full: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Shared.IsPresent | Write-Verbose + + $_InputObject.properties.isShareable.default = $Shared.IsPresent + + } + + 'LockProvisionMode' + { + + "[{0}] Locking provisioning type: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $LockProvisionType.IsPresent | Write-Verbose + + $_InputObject.properties.isShareable.meta.locked = $LockProvisionType.IsPresent + + } + + } + + "[{0}] Updated Storage Volume Template object properties: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), ($_InputObject | out-string) | Write-Verbose + + "[{0}] Sending updated storage volume template to appliance." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $Resp = Send-OVRequest -Uri $_InputObject.uri -Method PUT -Body $_InputObject -Hostname $ApplianceConnection | Wait-OVTaskComplete + + $Resp + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Remove-OVStorageVolumeTemplate +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "default",SupportsShouldProcess,ConfirmImpact = 'High')] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = "default")] + [ValidateNotNullOrEmpty()] + [Alias ('uri', 'name', 'templateName', 'Template')] + [Object]$InputObject, + + [Parameter (Mandatory = $False, ValueFromPipelineByPropertyName, ParameterSetName = "default")] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default), + + [Parameter (Mandatory = $False, ParameterSetName = "default")] + [Switch]$Force + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not($PSBoundParameters['Template'])) + { + + $PipelineInput = $True + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + $_TaskCollection = [System.Collections.ArrayList]::new() + $_SVTCollection = [System.Collections.ArrayList]::new() + + } + + Process + { + + if ($PipelineInput) + { + + "[{0}] Processing Pipeline input" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + foreach ($_svt in $InputObject) + { + + # SVT passed is a URI + if (($_svt -is [String]) -and [System.Uri]::IsWellFormedUriString($_svt,'Relative')) + { + + "[{0}] Received URI: $($_svt)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + "[{0}] Getting SVT object" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (($ApplianceConnection | Measure-Object).Count -gt 1) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException MultipleApplianceConnections InvalidArgument 'ApplianceConnection' -Message 'The specified ApplianceConnection Parameter contains multiple Appliance Connections. This CMDLET only supports 1 Appliance Connection in the ApplianceConnect Parameter value when using a Storage Volume Template URI value. Please correct this and try again.' + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Try + { + + $_svtObject = Send-OVRequest $_svt -ApplianceConnection $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + [void]$_SVTCollection.Add($_svtObject) + + } + + # SVT passed is the Name + elseif (($_svt -is [String]) -and (-not $_svt.startsWith("/rest"))) + { + + "[{0}] Received SVT Name {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_svt | Write-Verbose + + "[{0}] Getting SVT object from Get-OVStorageVolumeTemplate" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + ForEach ($_appliance in $ApplianceConnection) + { + + "[{0}] Processing '$_appliance' Appliance Connection [of $($ApplianceConnection.count)]" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $_svtObject = Get-OVStorageVolumeTemplate $_svt -ApplianceConnection $ApplianceConnection -ErrorAction Stop + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $_svtObject | ForEach-Object { + + "[{0}] Adding '$($_.name)' SVT to collection." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + [void]$_SVTCollection.Add($_) + + } + + } + + } + + # SVT passed is the object + elseif ($_svt -is [PSCustomObject]) + { + + "[{0}] SVT Object provided." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + "[{0}] object name: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_svt.name | Write-Verbose + "[{0}] object uri: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_svt.uri | Write-Verbose + "[{0}] object appliance connection: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_svt.ApplianceConnection.Name | Write-Verbose + "[{0}] object category: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_svt.category | Write-Verbose + + if ($_svt.category -ieq 'storage-volume-templates') + { + + If (-not $_svt.ApplianceConnection) + { + + $ErrorRecord = New-ErrorRecord InvalidOperationException InvalidArgumentValue InvalidArgument "Template:$($Template.Name)" -TargetType PSObject -Message "The Template resource provided is missing the source ApplianceConnection property. Please check the object provided and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + [void]$_SVTCollection.Add($_svt) + + } + + else + { + + $ExceptionMessage = "The InputObject parameter value {0} is not a supported object type. Only 'storage-volume-templates' resources are permitted." -f $_svt.Name + $ErrorRecord = New-ErrorRecord InvalidOperationException InvalidArgumentValue InvalidArgument 'InputObject' -TargetType 'PSObject' -Message $ExceptionMessage + $PSCmdlet.WriteError($ErrorRecord) + + } + + } + + } + + } + + End + { + + "[{0}] Processing $($_SVTCollection.count) SVT resources to remove." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + # Process SVT Resources + ForEach ($_svtObject in $_SVTCollection) + { + + if ($PSCmdlet.ShouldProcess($_svtObject.name,"Remove SVT from appliance '$($_svtObject.ApplianceConnection.Name)'")) + { + + "[{0}] Removing SVT '$($_svtObject.name)' from appliance '$($_svtObject.ApplianceConnection.Name)'." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + if ($PSBoundParameters['Force']) + { + + $_svtObject.uri += "?force=true" + + } + + Send-OVRequest -Uri $_svtObject.Uri -Method DELETE -AddHeader @{'If-Match' = $_svtObject.eTag } -Hostname $_svtObject.ApplianceConnection.Name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + elseif ($PSBoundParameters['WhatIf']) + { + + "[{0}] WhatIf Parameter was passed." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + } + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Get-OVStorageVolumeTemplatePolicy +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "default")] + [OutputType ([HPEOneView.Appliance.GlobalSetting])] + Param + ( + + [Parameter (Mandatory = $False)] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + # $_SVTPolicyCollection = [System.Collections.ArrayList]::new() + + } + + Process + { + + ForEach ($_appliance in $ApplianceConnection) + { + + "[{0}] Processing '$($_appliance.Name)' Appliance Connection [of $($ApplianceConnection.Count)]" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + "[{0}] Getting global setting value." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $_Policy = Send-OVRequest $applStorageVolumeTemplateRequiredPolicy -Hostname $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + [HPEOneView.Appliance.GlobalSetting]::new($_Policy.name, + $_Policy.value, + $_Policy.eTag, + $_Policy.created, + $_Policy.modified, + $_Policy.group, + $_Policy.settingCategory, + $_Policy.uri, + $_Policy.ApplianceConnection) + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Set-OVStorageVolumeTemplatePolicy +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding ()] + Param + ( + + [Parameter (Mandatory, ParameterSetName = "Enable")] + [Switch]$Enable, + + [Parameter (Mandatory, ParameterSetName = "Disable")] + [Switch]$Disable, + + [Parameter (Mandatory = $False, ParameterSetName = "Enable")] + [Parameter (Mandatory = $False, ParameterSetName = "Disable")] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $_SVTPolicyCollection = [System.Collections.ArrayList]::new() + + } + + Process + { + + ForEach ($_appliance in $ApplianceConnection) + { + + "[{0}] Processing '$($_appliance.Name)' Appliance Connection [of $($ApplianceConnection.Count)]" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_request = NewObject -GlobalSetting + + $_request.name = 'StorageVolumeTemplateRequired' + + switch ($PSCmdlet.ParameterSetName) + { + + 'Enable' + { + + "[{0}] User requested to ENABLE the policy" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_request.value = 'true' + + } + + 'Disable' + { + + "[{0}] User requested to DISABLE the policy" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_request.value = 'false' + + } + + } + + try + { + + $_updatedpolicy = Send-OVRequest -Uri $applStorageVolumeTemplateRequiredPolicy -Method PUT -Body $_request -Hostname $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $_updatedpolicy.PSObject.TypeNames.Insert(0,'HPEOneview.Appliance.GlobalSetting') + + [void]$_SVTPolicyCollection.Add($_updatedpolicy) + + } + + } + + End + { + + Return $_SVTPolicyCollection + + } + +} + +function Get-OVStorageVolume +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "Default")] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = "InputObject")] + [ValidateNotNullOrEmpty()] + [Alias ('ServerProfile', 'ServerProfileTemplate')] + [Object]$InputObject, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [ValidateNotNullOrEmpty()] + [Alias ('VolumeName')] + [String]$Name, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [ValidateNotNullOrEmpty()] + [Alias ('SVT')] + [object]$StorageVolumeTemplate, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Switch]$Available, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [ValidateNotNullOrEmpty()] + [String]$Label, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [ValidateNotNullOrEmpty()] + [Object]$Scope = "AllResourcesInScope", + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = "InputObject")] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + #$volumeCollection = [System.Collections.ArrayList]::new() + + } + + Process + { + + "[{0}] ParameterSetName: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $PSCmdlet.ParameterSetName | Write-Verbose + + if ($InputObject) + { + + "[{0}] InputObject category: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject.category | Write-Verbose + + switch ($InputObject.category) + { + + ${ResourceCategoryEnum.ServerProfile} + { + + "[{0}] Processing Server Profile: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject.name | Write-Verbose + "[{0}] Storage Volume Attachments: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject.sanStorage.volumeAttachments.Count | Write-Verbose + + ForEach ($_VolumeAttachment in $InputObject.sanStorage.volumeAttachments) + { + + Try + { + + $_StorageVolume = Send-OVRequest -Uri $_VolumeAttachment.volumeUri -HostName $InputObject.ApplianceConnection + + $_StorageVolume.PSobject.TypeNames.Insert(0,'HPEOneView.Storage.Volume') + + $_StorageVolume + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + 'storage-systems' + { + + "[{0}] Processing Storage System: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject.name | Write-Verbose + + "[{0}] Getting associated Storage Pools with system" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $_Uri = "{0}?filter=storageSystemUri EQ '{1}'&filter=isManaged EQ true" -f $StoragePoolsUri, $InputObject.uri + $_AssociatedPools = Send-OVRequest -Uri $_Uri -Hostname $InputObject.ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + "[{0}] Associated Storage Pools with system: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_AssociatedPools.count | Write-Verbose + + if ($_AssociatedPools.members) + { + + ForEach ($_AssociatedPool in $_AssociatedPools.members) + { + + "[{0}] Getting associated storage volumes with pool: " -f $MyInvocation.InvocationName.ToString().ToUpper(), $_AssociatedPool.name | Write-Verbose + + Try + { + + $_Uri = "{0}?filter=storagePoolUri EQ '{1}'" -f $StorageVolumesUri, $_AssociatedPool.uri + $_AssociatedVols = Send-OVRequest -Uri $_Uri -Hostname $InputObject.ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + "[{0}] Associated storage vols with pool: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_AssociatedVols.count | Write-Verbose + + if ($_AssociatedVols.members) + { + + $_AssociatedVols.members | ForEach-Object { + + $_.PSObject.TypeNames.Insert(0,'HPEOneView.Storage.Volume') + $_ + + } + + } + + } + + } + + } + + 'storage-pools' + { + + "[{0}] Processing Storage Pool: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject.name | Write-Verbose + + Try + { + + $_Uri = "{0}?filter=storagePoolUri EQ '{1}'" -f $StorageVolumesUri, $InputObject.uri + $_AssociatedVols = Send-OVRequest -Uri $_Uri -Hostname $InputObject.ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if ($_AssociatedVols.members) + { + + $_AssociatedVols.members | ForEach-Object { + + $_.PSObject.TypeNames.Insert(0,'HPEOneView.Storage.Volume') + $_ + + } + + } + + } + + default + { + + $ExceptionMessage = "The InputObject parameter value is not supported. Only Server Profile, Storage System and Storage Pool objects are supports." + $ErrorRecord = New-ErrorRecord ArgumentException InvalidArgumentType InvalidArgument 'InputObject' -TargetType $InputObject.gettype().Name -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + } + + else + { + + ForEach ($_appliance in $ApplianceConnection) + { + + "[{0}] Processing appliance {1} (of {2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name, $ApplianceConnection.Count | Write-Verbose + + $_Query = [System.Collections.ArrayList]::new() + + # Handle default cause of AllResourcesInScope + if ($Scope -eq 'AllResourcesInScope') + { + + "[{0}] Processing AllResourcesInScope." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_Scopes = $_appliance.ActivePermissions | Where-Object Active + + # If one scope contains 'AllResources' ScopeName "tag", then all resources should be returned regardless. + if ($_Scopes | Where-Object ScopeName -eq 'AllResources') + { + + $_ScopeNames = [String]::Join(', ', ($_Scopes | Where-Object ScopeName -eq 'AllResources').ScopeName) + + "[{0}] Scope(s) {1} is set to 'AllResources'. Will not add scope to URI query parameter." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_ScopeNames | Write-Verbose + + } + + # Process ApplianceConnection ActivePermissions collection + else + { + + Try + { + + $_ScopeQuery = Join-Scope $_Scopes + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + [Void]$_Query.Add(("({0})" -f $_ScopeQuery)) + + } + + } + + elseif ($Scope | Where-Object ScopeName -eq 'AllResources') + { + + $_ScopeNames = [String]::Join(', ', ($_Scopes | Where-Object ScopeName -eq 'AllResources').ScopeName) + + "[{0}] Scope(s) {1} is set to 'AllResources'. Will not add scope to URI query parameter." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_ScopeNames | Write-Verbose + + } + + elseif ($Scope -eq 'AllResources') + { + + "[{0}] Requesting scope 'AllResources'. Will not add scope to URI query parameter." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_ScopeNames | Write-Verbose + + } + + else + { + + Try + { + + $_ScopeQuery = Join-Scope $Scope + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + [Void]$_Query.Add(("({0})" -f $_ScopeQuery)) + + } + + if ($Name) + { + + "[{0}] Filtering for Name: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Name | Write-Verbose + + if ($Name.Contains('*')) + { + + [Void]$_Query.Add(("name%3A{0}" -f $Name.Replace("*", "%2A").Replace(',','%2C').Replace(" ", "?"))) + + } + + else + { + + [Void]$_Query.Add(("name:'{0}'" -f $Name)) + + } + + } + + if ($Label) + { + + "[{0}] Filtering for Label: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Label | Write-Verbose + + [Void]$_Query.Add(("labels:'{0}'" -f $Label)) + + } + + if ($PSBoundParameters['StorageVolumeTemplate']) + { + + "[{0}] Filtering for StorageVolumeTemplate." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + switch ($StorageVolumeTemplate.GetType().Name) + { + + 'String' + { + + Try + { + + $_StorageVolumeTemplate = Get-OVStorageVolumeTemplate -Name $StorageVolumeTemplate -ApplianceConnection $_appliance -ErrorAction Stop + + } + + Catch + { + + $PSCMdlet.ThrowTerminatingError($_) + + } + + } + + 'PSCustomObject' + { + + if ($StorageVolumeTemplate.category -ne 'storage-volume-templates') + { + + $ExceptionMessage = "The provided StorageVolumeTemplate {0} object is not the correct resource category Please check the value and try again." -f $StorageVolumeTemplate.Name + $ErrorRecord = New-ErrorRecord InvalidOperationException InvalidStorageVolumeTemplateResource InvalidArgument 'StorageVolumeTemplate' -TargetType $StorageVolumeTemplate.GetType().Name -Message $ExceptionMessage + $PSCMdlet.ThrowTerminatingError($ErrorRecord) + + } + + $_StorageVolumeTemplate = $StorageVolumeTemplate.PSObject.Copy() + + } + + } + + [Void]$_Query.Add(("volumeTemplateUri:'{0}'" -f $_StorageVolumeTemplate.uri)) + + } + + $_Category = 'category=storage-volumes' + + # Build the final URI + $_uri = '{0}?{1}&sort=name:asc&query={2}' -f $IndexUri, [String]::Join('&', $_Category), [String]::Join(' AND ', $_Query.ToArray()) + + Try + { + + $_ResourcesFromIndexCol = Get-AllIndexResources -Uri $_uri -ApplianceConnection $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if ($Available) + { + + "[{0}] Looking for available volumes to attach." -f $MyInvocation.InvocationName.ToString().ToUpper(), $Label | Write-Verbose + + if ($_ResourcesFromIndexCol -is [System.Collections.IEnumerable]) + { + + $_TempCollection = $_ResourcesFromIndexCol.Clone() + + } + + else + { + + $_TempCollection = $_ResourcesFromIndexCol.PSObject.Copy() + + } + + ForEach ($_member in $_TempCollection) + { + + if (-not $_member.isShareable) + { + + # Check to see if there is an existing volume attachment + Try + { + + $_uri = '{0}?childUri={1}&name=server_profiles_to_storage_volumes' -f $AssociationsUri, $_member.uri + + $_VolAttachments = Send-OVRequest -Uri $_uri -Hostname $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if ($_VolAttachments.count -gt 0) + { + + "[{0}] Volume attachment found for {1}. Removing from final collection." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_member.name | Write-Verbose + + $_ResourcesFromIndexCol = $_ResourcesFromIndexCol | Where-Object name -ne $_member.name + + } + + } + + } + + } + + if ($_ResourcesFromIndexCol.Count -eq 0) + { + + if ($Name) + { + + "[{0}] '{1}' Storage Volume found." -f $MyInvocation.InvocationName.ToString().ToUpper(), $Name | Write-Verbose + + $ExceptionMessage = "No Storage Volume with '{0}' name found on '{1}' appliance connection. Please check the name or use New-OVStorageVolume to create the volume." -f $Name, $_appliance.Name + $ErrorRecord = New-ErrorRecord HPEOneView.StorageVolumeResourceException StorageVolumeResourceNotFound ObjectNotFound 'Name' -Message $ExceptionMessage + $PSCmdlet.WriteError($ErrorRecord) + + } + + else + { + + "[{0}] No Storage Volumes found." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + } + + else + { + + ForEach ($_member in $_ResourcesFromIndexCol) + { + + $_member.PSObject.TypeNames.Insert(0,"HPEOneView.Storage.Volume") + + $_member + + } + + } + + } + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Get-OVStorageVolumeSnapShot +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding ()] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline)] + [ValidateNotNullOrEmpty()] + [Alias ('Name', 'Volume')] + [Object]$InputObject, + + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName)] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not($PSBoundParameters['InputObject'])) + { + + $PipelineInput = $true + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + } + + Process + { + + # Generate error Volume is not an object + if (-not($InputObject -is [PSCustomObject]) -and $InputObject.category -ne 'storage-volumes') + { + + $ErrorRecord = New-ErrorRecord HPEOneView.StorageVolumeResourceException InvalidStorageVolumeResource InvalidArgument 'Volume' -TargetType $Volume.GetType().Name -Message "The provided Volume Parameter value is not a supported type or object. Please provide a Storage Volume resource object and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + + "[{0}] Processing Storage Volume: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject.name | Write-Verbose + + $uri = $InputObject.Uri.ToString() + '/snapshots' + + # Send the query + Try + { + + $_VolumeSnapshots = Send-OVRequest -Uri $uri -appliance $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if (-not($_VolumeSnapshots.members)) + { + + "[{0}] No Storage Volume Snapshots found." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + else + { + + $_VolumeSnapshots.members | ForEach-Object { + + $_.PSObject.TypeNames.Insert(0,"HPEOneView.Storage.VolumeSnapshot") + + $_ + + } + + } + + } + + End + { + + '[{0}] Done.' -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function New-OVStorageVolumeSnapshot +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding ()] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline)] + [ValidateNotNullOrEmpty()] + [Alias ('Volume')] + [Object]$InputObject, + + [Parameter (Mandatory = $false)] + [String]$Name = '{volumeName}_{timestamp}', + + [Parameter (Mandatory = $false)] + [String]$Description, + + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName)] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not $PSBoundParameters['InputObject']) + { + + $PipelineInput = $true + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + } + + Process + { + + # Generate error Volume is not an object + if ($InputObject -isnot [PSCustomObject] -and $InputObject.category -ne 'storage-volumes') + { + + $ErrorRecord = New-ErrorRecord HPEOneView.StorageVolumeResourceException InvalidStorageVolumeResource InvalidArgument 'Volume' -TargetType $Volume.GetType().Name -Message "The provided Volume Parameter value is not a supported type or object. Please provide a Storage Volume resource object and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + "[{0}] Processing Storage Volume: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject.name | Write-Verbose + + # Validate the volume is a support volume to create a snapshot of + # Get Storage Pool and associated SS + Try + { + + $_AssociatedPool = Send-OVRequest -Uri $InputObject.storagePoolUri -Hostname $ApplianceConnection + $_AssociatedSS = Send-OVRequest -Uri $_AssociatedPool.storageSystemUri -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + # Validate SS family + if ($_AssociatedSS.family -ne 'StoreServ') + { + + $ExceptionMessage = "The Storage System {0} family ({1}) of the associated storage volume, {2}, is not a StoreServ system. Volume snapshots are supported with StoreServ class of storage systems." -f $_AssociatedSS.name, $_AssociatedPool.name, $InputObject.name + $ErrorRecord = New-ErrorRecord ArgumentException InvalidArgumentType InvalidArgument 'DataProtectionLevel' -TargetType $DataProtectionLevel.gettype().Name -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + $uri = $InputObject.Uri.ToString() + '/snapshots' + + # Send the query + Try + { + + $_VolSnapshot = NewObject -VolSnapshot + + $_VolSnapshot.name = $Name + $_VolSnapshot.description = $Description + + $_VolumeSnapshotResp = Send-OVRequest -Uri $uri -Method POST -Body $_VolSnapshot -appliance $ApplianceConnection + + } + + Catch + { + + # Return any task resources at this point, then generate error + $_VolumeSnapshotCollection + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if (-not $PSBoundParameters['Async']) + { + + $_VolumeSnapshotResp | Wait-OVTaskComplete + + } + + else + { + + $_VolumeSnapshotResp + + } + + } + + End + { + + '[{0}] Done.' -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Remove-OVStorageVolumeSnapshot +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (SupportsShouldProcess, ConfirmImpact = 'High')] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline)] + [ValidateNotNullOrEmpty()] + [Alias ('Snapshot')] + [Object]$InputObject, + + [Parameter (Mandatory = $false)] + [Switch]$Async, + + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName)] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not($PSBoundParameters['InputObject'])) + { + + $PipelineInput = $true + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + $_VolumeSnapshotCollection = [System.Collections.ArrayList]::new() + $_TaskCollection = [System.Collections.ArrayList]::new() + + } + + Process + { + + # Generate error Snapshot is not an object or correct object + if (-not($InputObject -is [PSCustomObject]) -and $InputObject.category -ne 'storage-volumes' -and (-not([RegEx]::Match($InputObject, '/snapshots/', $RegExInsensitiveFlag).Success))) + { + + $ErrorRecord = New-ErrorRecord HPEOneView.StorageVolumeResourceException InvalidStorageVolumeResource InvalidArgument 'InputObject' -TargetType $InputObject.GetType().Name -Message "The provided Volume Snapshot Parameter value is not a supported type or object. Please provide a Storage Volume Snapshot resource object and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + "[{0}] Received Storage Volume Snapshot: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject.name | Write-Verbose + + [void]$_VolumeSnapshotCollection.Add($InputObject) + + } + + End + { + + "[{0}] Processing {1} Storage Volume Snapshot resources to remove." -f $MyInvocation.InvocationName.ToString().ToUpper(),$_VolumeSnapshotCollection.count | Write-Verbose + + # Process Resources + ForEach ($_resource in $_VolumeSnapshotCollection) + { + + if ($PSCmdlet.ShouldProcess($_resource.ApplianceConnection.Name,("remove volume snapshot '{0}'" -f $_resource.name))) + { + + "[{0}] Removing resource '{1}' from appliance '{2}'." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_resource.name,$_resource.ApplianceConnection | Write-Verbose + + Try + { + + $_resp = Send-OVRequest -uri $_resource.Uri -Method DELETE -AddHeader @{'If-Match' = $_resource.eTag } -Hostname $_resource.ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + elseif ($PSBoundParameters['WhatIf']) + { + + "[{0}] WhatIf Parameter was passed." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + if (-not $PSBoundParameters['Async']) + { + + $_resp | Wait-OVTaskComplete + + } + + else + { + + $_resp + + } + + } + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function ConvertTo-OVStorageVolume +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding ()] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline)] + [ValidateNotNullOrEmpty ()] + [Alias ('Snapshot')] + [Object]$InputObject, + + [Parameter (Mandatory)] + [ValidateNotNullOrEmpty ()] + [String]$Name, + + [Parameter (Mandatory = $false)] + [ValidateNotNullOrEmpty ()] + [String]$Description, + + [Parameter (Mandatory = $false)] + [ValidateSet ('Private', 'Shared')] + [String]$SharingMode, + + [Parameter (Mandatory = $false)] + [Switch]$Async, + + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName)] + [ValidateNotNullorEmpty ()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not($PSBoundParameters['InputObject'])) + { + + $PipelineInput = $true + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + $_VolumeSnapshotTaskCollection = [System.Collections.ArrayList]::new() + + } + + Process + { + + # Generate error Snapshot is not an object or correct object + if (-not($InputObject -is [PSCustomObject]) -and $InputObject.category -ne 'storage-volumes' -and (-not([RegEx]::Match($InputObject, '/snapshots/', $RegExInsensitiveFlag).Success))) + { + + $ExceptionMessage = "The provided InputObject parameter value is not a supported type or object. Please provide a Storage Volume Snapshot resource object and try again." + $ErrorRecord = New-ErrorRecord HPEOneView.StorageVolumeResourceException InvalidStorageSnapshotResource InvalidArgument 'InputObject' -TargetType $InputObject.GetType().Name -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + "[{0}] Processing Storage Volume Snapshot: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject.name | Write-Verbose + + $_ConvertSnapshotToVol = NewObject -ConvertSnapshotToVol + $_ConvertSnapshotToVol.properties.name = $Name + $_ConvertSnapshotToVol.properties.description = $Description + $_ConvertSnapshotToVol.snapshotUri = $InputObject.Uri.ToString() + + # Get parent volume snapshotUri value + Try + { + + $_ParentVol = Send-OVRequest -Uri $InputObject.storageVolumeUri -Hostname $InputObject.ApplianceConnection.Name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $_ConvertSnapshotToVol.properties.snapshotPool = $_ParentVol.deviceSpecificAttributes.snapshotPoolUri + $_ConvertSnapshotToVol.properties.storagePool = $_ParentVol.storagePoolUri + $_ConvertSnapshotToVol.properties.provisioningType = $_ParentVol.provisioningType + + if (-not $_ParentVol.volumeTemplateUri) + { + + # Need to get root template from system via storage pool + try + { + + $_AssociatedPool = Send-OVRequest -Uri $_ParentVol.storagePoolUri -Hostname $InputObject.ApplianceConnection.Name + + "[{0}] Getting storage system root volume template." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + $_Uri = '{0}/templates?filter=isRoot EQ true' -f $_AssociatedPool.storageSystemUri + $_RootTemplate = (Send-OVRequest -Uri $_Uri -Hostname $InputObject.ApplianceConnection.Name).members[0] + + $_ConvertSnapshotToVol.templateUri = $_RootTemplate.uri + + } + + catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + else + { + + $_ConvertSnapshotToVol.templateUri = $_ParentVol.volumeTemplateUri + + } + + if (-not $PSBoundParameters['SharingMode']) + { + + $_ConvertSnapshotToVol.properties.isShareable = $_ParentVol.isShareable + + } + + else + { + + $_ConvertSnapshotToVol.properties.isShareable = $SharingMode.IsPresent + + } + + # Send the query + Try + { + + $_VolumeSnapshotResp = Send-OVRequest -Uri $StorageVolumeFromSnapshotUri -Method POST -Body $_ConvertSnapshotToVol -appliance $InputObject.ApplianceConnection.Name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if (-not $PSBoundParameters['Async']) + { + + $_VolumeSnapshotResp | Wait-OVTaskComplete + + } + + else + { + + $_VolumeSnapshotResp + + } + + } + + End + { + + '[{0}] Done.' -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function New-OVStorageVolume +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "default")] + Param + ( + + [Parameter (Mandatory, ParameterSetName = "default")] + [Parameter (Mandatory, ParameterSetName = "template")] + [ValidateNotNullOrEmpty()] + [Alias ("VolumeName")] + [String]$Name, + + [Parameter (Mandatory = $false, ParameterSetName = "default")] + [Parameter (Mandatory = $false, ParameterSetName = "template")] + [ValidateNotNullOrEmpty()] + [String]$Description, + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = "default")] + [ValidateNotNullOrEmpty()] + [Alias ("pool","poolName")] + [HPEOneView.Storage.StoragePool]$StoragePool, + + [Parameter (Mandatory = $false, ParameterSetName = "default")] + [Parameter (Mandatory = $false, ParameterSetName = "template")] + [ValidateNotNullOrEmpty()] + [HPEOneView.Storage.StoragePool]$SnapshotStoragePool, + + [Parameter (Mandatory = $false, ParameterSetName = "default")] + [ValidateNotNullOrEmpty()] + [object]$StorageSystem, + + [Parameter (Mandatory, ParameterSetName = "template")] + [ValidateNotNullOrEmpty()] + [Alias ('template','svt')] + [object]$VolumeTemplate, + + [Parameter (Mandatory = $false, ParameterSetName = "default")] + [Parameter (Mandatory = $false, ParameterSetName = "template")] + [ValidateScript({$_ -ge 1})] + [Alias ("size")] + [int64]$Capacity, + + [Parameter (Mandatory = $false, ParameterSetName = "default")] + [Parameter (Mandatory = $false, ParameterSetName = "template")] + [ALias ("ProvisionType")] + [ValidateSet ('Thin', 'Full', 'TPDD')] + [String]$ProvisioningType, + + [Parameter (Mandatory = $false, ParameterSetName = "default")] + [Parameter (Mandatory = $false, ParameterSetName = "template")] + [Bool]$EnableCompression, + + [Parameter (Mandatory = $false, ParameterSetName = "default")] + [Parameter (Mandatory = $false, ParameterSetName = "template")] + [Bool]$EnableDeduplication, + + [Parameter (Mandatory = $false, ParameterSetName = "default")] + [Parameter (Mandatory = $false, ParameterSetName = "template")] + [Switch]$Full, + + [Parameter (Mandatory = $false, ParameterSetName = "default")] + [Parameter (Mandatory = $false, ParameterSetName = "template")] + [Switch]$Shared, + + [Parameter (Mandatory = $false, ParameterSetName = "default")] + [Parameter (Mandatory = $false, ParameterSetName = "template")] + [HPEOneView.Storage.PerformancePolicy]$PerformancePolicy, + + [Parameter (Mandatory = $false, ParameterSetName = "default")] + [Parameter (Mandatory = $false, ParameterSetName = "template")] + [Bool]$EnableEncryption, + + [Parameter (Mandatory = $false, ParameterSetName = "default")] + [Parameter (Mandatory = $false, ParameterSetName = "template")] + [Bool]$CachePinning, + + [Parameter (Mandatory = $false, ParameterSetName = "default")] + [Parameter (Mandatory = $false, ParameterSetName = "template")] + [HPEOneView.Storage.VolumeSet]$VolumeSet, + + [Parameter (Mandatory = $false, ParameterSetName = "default")] + [Parameter (Mandatory = $false, ParameterSetName = "template")] + [Bool]$EnableIOPSLimit, + + [Parameter (Mandatory = $false, ParameterSetName = "default")] + [Parameter (Mandatory = $false, ParameterSetName = "template")] + [ValidateRange (256,4294967295)] + [Int]$IOPSLimit = 256, + + [Parameter (Mandatory = $false, ParameterSetName = "default")] + [Parameter (Mandatory = $false, ParameterSetName = "template")] + [Bool]$EnableDataTransferLimit, + + [Parameter (Mandatory = $false, ParameterSetName = "default")] + [Parameter (Mandatory = $false, ParameterSetName = "template")] + [Int]$DataTransferLimit, + + [Parameter (Mandatory = $false, ParameterSetName = "default")] + [Parameter (Mandatory = $false, ParameterSetName = "template")] + [HPEOneView.Storage.NimbleFolder]$Folder, + + [Parameter (Mandatory = $false, ParameterSetName = "default")] + [Parameter (Mandatory = $false, ParameterSetName = "template")] + [ValidateNotNullOrEmpty()] + [HPEOneView.Appliance.ScopeCollection[]]$Scope, + + [Parameter (Mandatory = $false, ParameterSetName = "default")] + [Parameter (Mandatory = $false, ParameterSetName = "template")] + [Switch]$Async, + + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = "default")] + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = "template")] + [ValidateNotNullorEmpty()] + [object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not($PSBoundParameters['StoragePool'])) + { + + $PipelineInput = $True + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + if ($PSBoundParameters['Thin']) + { + + $ExceptionMessage = 'The -Thin parameter is being deprecated. Please update your scripts to use the -ProvisioningType parameter instead.' + $ErrorRecord = New-ErrorRecord HPEOneView.Library.ParameterValidationException InvalidProvisionTypeParameter InvalidOperation 'StorageSystem' -Message $ExceptionMessage + $PSCmdlet.WriteError($ErrorRecord) + + $PSBoundParameters.Add('ProvisioningType', $StorageVolumeProvisioningTypeEnum['Thin']) + + } + + if ($PSBoundParameters['Full']) + { + + $ExceptionMessage = 'The -Full parameter is being deprecated. Please update your scripts to use the -ProvisioningType parameter instead.' + $ErrorRecord = New-ErrorRecord HPEOneView.Library.ParameterValidationException InvalidProvisionTypeParameter InvalidOperation 'StorageSystem' -Message $ExceptionMessage + $PSCmdlet.WriteError($ErrorRecord) + + $PSBoundParameters.Add('ProvisioningType', $StorageVolumeProvisioningTypeEnum['Full']) + + } + + if ($PSBoundParameters['ProvisioningType'] -eq 'TPDD') + { + + $ExceptionMessage = 'The -ProvisioningType "TPDD" value is being deprecated. Please update your script(s) to use the "Thin" value and -EnableCompression $True parameter.' + $ErrorRecord = New-ErrorRecord HPEOneView.Library.ParameterValidationException InvalidProvisionTypeParameter InvalidOperation 'StorageSystem' -Message $ExceptionMessage + $PSCmdlet.WriteError($ErrorRecord) + + $ProvisioningType = $StorageVolumeProvisioningTypeEnum['Thin'] + $PSBoundParameters.Add('EnableCompression', $True) + + } + + if ($PSBoundParameters['StorageSystem']) + { + + $ExceptionMessage = "The -StorageSystem is deprecated. Please update your script(s) to use Get-OVStoragePool to get the specific pool object." + $ErrorRecord = New-ErrorRecord HPEOneView.Library.ParameterValidationException InvalidProvisionTypeParameter InvalidOperation 'StorageSystem' -Message $ExceptionMessage + $PSCmdlet.WriteError($ErrorRecord) + + } + + # Need to generate an error + if ($PSBoundParameters['Family'] -eq 'Nimble' -and $PSBoundParameters['ProvisioningType'] -eq 'TPDD') + { + + $ExceptionMessage = "The provided ProvisioningType policy '{0}' is not supported by Nimble. Please update your script to use either 'Thin' or 'Full'. Setting ProvisioningType parameter to 'Thin'." -f $ProvisioningType + $ErrorRecord = New-ErrorRecord HPEOneView.Library.ParameterValidationException InvalidProvisionTypeParameter InvalidOperation 'ProvisioningType' -Message $ExceptionMessage + $PSCmdlet.WriteError($ErrorRecord) + + $ProvisioningType = $StorageVolumeProvisioningTypeEnum['Thin'] + + } + + $_AllowedNimbleParams = "PerformancePolicy", "LockPerformancePolicy", "EnableEncryption", "CachePinning", "VolumeSet", "EnableIOPSLimit", "IOPSLimit", "EnableDataTransferLimit", "DataTransferLimit", "Folder" + $_AllowedSSParams = "EnableCompression", "EnableDeduplication", "SnapshotStoragePool" + # $_AllowedSVParams = "DataProtectionLevel", "EnableAdaptiveOptimization" + $_NotAllowedNimbleParams = $_AllowedSSParams #+ $_AllowedSVParams + $_NotAllowedSSParams = $_AllowedNimbleParams #+ $_AllowedSVParams + $_NotAllowedVSParams = $_AllowedSSParams + $_AllowedNimbleParams + $_SafeParams = "Name", "Description", "StoragePool", "StorageSystem", "VolumeTemplate", "Capacity", "ProvisioningType", "Full", "Shared", "Scope", "Async", "ApplianceConnection" + + } + + Process + { + + $ExceptionMessageString = "The provided {0} parameter is not supported by the {1} storage family." + + $_newVolume = NewObject -StorageVolume + + # Check to see if Storage Volume Template Global Setting is enabled + Try + { + + "[{0}] Checking for SVT Global Policy." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_storageVolumeTemplateRequiredGlobalPolicy = (Send-OVRequest $applStorageVolumeTemplateRequiredPolicy -Hostname $ApplianceConnection).value + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if ($_storageVolumeTemplateRequiredGlobalPolicy -ieq "True" -and (-not $PSBoundParameters['VolumeTemplate'] -or -not $VolumeTemplate)) + { + + $ExceptionMessage = "Storage Volumes cannot be created without providing a Storage Volume Template due to global policy setting. Please provide a Storage Volume Template and try again." + $ErrorRecord = New-ErrorRecord HPEOneView.StorageVolumeResourceException StorageVolumeTemplateRequired InvalidArgument 'VolumeTemplate' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + # Figure out what type of Volume we will create + if ($PSBoundParameters['VolumeTemplate']) + { + + if ($VolumeTemplate.category -ne 'storage-volume-templates') + { + + $ExceptionMessage = "The value provided for VolumeTemplate is not the allowed resource type, storage-volume-templates." + $ErrorRecord = New-ErrorRecord HPEOneView.StorageVolumeTemplateResourceException InvalidStorageVolumeTemplateResource InvalidArgument 'VolumeTemplate' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + "[{0}] Storage Volume Template provided: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $VolumeTemplate.name | Write-Verbose + "[{0}] Storage Volume Template family: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $VolumeTemplate.family | Write-Verbose + + $_Family = $VolumeTemplate.family + + } + + # Storage Pool was provided + else + { + + "[{0}] No Storage Volume Template provided. Processing StoragePool." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if ($StoragePool -is [String]) + { + + "[{0}] Locating storage pool resource: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $StoragePool | Write-Verbose + + Try + { + + $StoragePool = GetStoragePool -Name $StoragePool -StorageSystem $StorageSystem -ApplianceConnection $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + # Get Storage System + Try + { + + $_StorageSystem = Send-OVRequest -Uri $StoragePool.storageSystemUri -Hostname $StoragePool.ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $_StoragePool = $StoragePool.PSObject.Copy() + + $_StoragePool | Add-Member -NotePropertyName family -NotePropertyValue $_StorageSystem.family + + "[{0}] Storage Pool family: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_StoragePool.family | Write-Verbose + + $_Family = $_StoragePool.family + + # Need to get the root ST since none was provided + Try + { + + $_Uri = "{0}/templates?query=isRoot EQ true" -f $_StoragePool.storageSystemUri + $_StorageSystemRootVolumeTemplate = Send-OVRequest -Uri $_Uri -ApplianceConnection $ApplianceConnection + $VolumeTemplate = $_StorageSystemRootVolumeTemplate.members[0] + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + # Look to see if $PSBoundParameters contains unallowed parameters + ForEach ($_Param in $PSBoundParameters.Keys) + { + + # First check if the param is not within the safe, allowed params for all + if ($_SafeParams -notcontains $_Param) + { + + $ExceptionMessage = $null + + switch ($_Family) + { + + 'Nimble' + { + + # Generate an error that the parameter is not supported by the storage system family + if ($_NotAllowedNimbleParams -contains $_Param) + { + + $ExceptionSource = 'Invalid{0}Parameter' -f $_Param + $ExceptionMessage = $ExceptionMessageString -f $_Param, $_Family + + } + + } + + 'StoreVirtual' + { + + # Generate an error that the parameter is not supported by the storage system family + if ($_NotAllowedVSParams -contains $_Param) + { + + $ExceptionSource = 'Invalid{0}Parameter' -f $_Param + $ExceptionMessage = $ExceptionMessageString -f $_Param, $_Family + + } + + } + + {'3Par', 'Primera', 'StoreServ' -contains $_} + { + + # Generate an error that the parameter is not supported by the storage system family + if ($_NotAllowedSSParams -contains $_Param) + { + + $ExceptionSource = 'Invalid{0}Parameter' -f $_Param + $ExceptionMessage = $ExceptionMessageString -f $_Param, $_Family + + } + + } + + } + + if (-not [String]::IsNullOrEmpty($ExceptionMessage)) + { + + $ErrorRecord = New-ErrorRecord HPEOneView.Library.ParameterValidationException $ExceptionSource InvalidOperation $_Param -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + } + + $_newVolume = NewObject -StorageVolume + + "[{0}] Setting volume template uri: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $VolumeTemplate.uri | Write-Verbose + + $_newVolume.templateUri = $VolumeTemplate.uri + + # Create properties hashtable specific to the volume template and associated storage system family + ForEach ($_Prop in ($VolumeTemplate.properties.PSObject.Members | Where-Object MemberType -eq 'NoteProperty')) + { + + $_PropName = $_Prop.Name + + "[{0}] Adding volume property to hashtable: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_PropName | Write-Verbose + $_newVolume.properties.Add($_PropName, $VolumeTemplate.properties.$_PropName.default) + + } + + # Set the values + switch ($_newVolume.properties.GetEnumerator().Name) + { + + # Common properties + 'name' + { + + "[{0}] Setting volume name: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Name | Write-Verbose + $_newvolume.properties.$_ = $Name + + } + + 'description' + { + + if ($PSBoundParameters['Description']) + { + + "[{0}] Setting volume description: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Description | Write-Verbose + $_newvolume.properties.$_ = $Description + + } + + } + + 'templateVersion' + { + + "[{0}] Setting volume {1}: {2}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_, $VolumeTemplate.version | Write-Verbose + $_newVolume.properties.$_ = $VolumeTemplate.version + + } + + 'storagePool' + { + + # If SVT enforces, set it + if ($VolumeTemplate.properties.$_.meta.locked -or -not $PSBoundParameters['StoragePool']) + { + + "[{0}] Volume Template enforces StoragePool: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $VolumeTemplate.properties.storagePool.default | Write-Verbose + + $_newvolume.properties.$_ = $VolumeTemplate.properties.$_.default + + } + + else + { + + "[{0}] Setting StoragePool: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_StoragePool.uri | Write-Verbose + + $_newvolume.properties.storagePool = $_StoragePool.uri + + } + + } + + 'size' + { + + if ($VolumeTemplate.properties.size.meta.locked -or (-not $PSBoundParameters['Capacity'] -and -not $VolumeTemplate.properties.size.meta.locked)) + { + + "[{0}] Volume Template enforces volume capacity: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $VolumeTemplate.properties.size.default | Write-Verbose + + $_newvolume.properties.size = $VolumeTemplate.properties.size.default + + } + + else + { + + $_newvolume.properties.size = $Capacity * 1GB + + } + + } + + 'provisioningType' + { + + if ($VolumeTemplate.properties.provisioningType.meta.locked -or (-not $PSBoundParameters['Full'] -and -not $PSBoundParameters['ProvisioningType'] -and -not $VolumeTemplate.properties.provisioningType.meta.locked)) + { + + "[{0}] Volume Template enforces volume provisioningType: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $VolumeTemplate.properties.provisioningType.default | Write-Verbose + $_newvolume.properties.provisioningType = $VolumeTemplate.properties.provisioningType.default + + } + + else + { + + if ($PSBoundParameters['ProvisioningType']) + { + + "[{0}] Setting volume provisioningType via ProvisioningType param: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $StorageVolumeProvisioningTypeEnum[$ProvisioningType] | Write-Verbose + + $_newvolume.properties.provisioningType = $StorageVolumeProvisioningTypeEnum[$ProvisioningType] + + } + + else + { + + "[{0}] Setting volume provisioningType via not full param: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $StorageVolumeProvisioningTypeEnum['Thin'] | Write-Verbose + + $_newvolume.properties.provisioningType = $StorageVolumeProvisioningTypeEnum['Thin'] + + } + + } + + } + + 'isShareable' + { + + if ($VolumeTemplate.properties.isShareable.meta.locked -or (-not $PSBoundParameters['Shared'] -and -not $VolumeTemplate.properties.isShareable.meta.locked)) + { + + "[{0}] Volume Template enforces volume shareable state: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $VolumeTemplate.properties.isShareable.default | Write-Verbose + + $_newvolume.properties.isShareable = $VolumeTemplate.properties.isShareable.default + + } + + else + { + + $_newvolume.properties.isShareable = $Shared.IsPresent + + } + + } + + # 3Par specific + 'snapshotPool' + { + + "[{0}] Family is StoreServ, attempting to set snapshot pool" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + # If SVT enforces, set it + if ($VolumeTemplate.properties.snapshotPool.meta.locked) + { + + "[{0}] Volume Template enforces Snapshot StoragePool: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $VolumeTemplate.properties.snapshotPool.default | Write-Verbose + + $_newvolume.properties.snapshotPool = $VolumeTemplate.properties.snapshotPool.default + + } + + else + { + + if ($PSBoundParameters['SnapshotStoragePool']) + { + + if ($SnapshotStoragePool -is [String]) + { + + try + { + + $SnapshotStoragePool = GetStoragePool -Name $SnapshotStoragePool -StorageSystem $StorageSystem -ApplianceConnection $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + "[{0}] Setting SnapshotStoragePool: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $SnapshotStoragePool.uri | Write-Verbose + + $_newvolume.properties.snapshotPool = $SnapshotStoragePool.uri + + } + + elseif (-not $PSBoundParameters['SnapshotStoragePool'] -and -not $PSBoundParameters['StoragePool']) + { + + "[{0}] Setting SnapshotStoragePool to StoragePool from Volume Template: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $VolumeTemplate.properties.snapshotPool.default | Write-Verbose + + $_newvolume.properties.snapshotPool = $VolumeTemplate.properties.snapshotPool.default + + } + + else + { + + "[{0}] Setting SnapshotStoragePool to StoragePool: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $StoragePool.uri | Write-Verbose + + $_newvolume.properties.snapshotPool = $StoragePool.uri + + } + + } + + } + + {'isDeduplicated', "isDataReductionEnabled" -contains $_} + { + + "[{0}] Family is StoreServ, attempting to set Deduplicated" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + # If SVT enforces, set it + if ($VolumeTemplate.properties.$_.meta.locked -or $PSBoundParameters.Keys -NotContains 'EnableDeduplication') + { + + "[{0}] Volume Template enforces Deduplicate: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $VolumeTemplate.properties.$_.default | Write-Verbose + + $_newvolume.properties.$_ = $VolumeTemplate.properties.$_.default + + }` + + else + { + + "[{0}] Setting Deduplicate: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $EnableDeduplication | Write-Verbose + + $_newvolume.properties.$_ = $EnableDeduplication + + } + + } + + 'isCompressed' + { + + "[{0}] Family is 3Par, attempting to set Compression" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + # If SVT enforces, set it + if ($VolumeTemplate.properties.$_.meta.locked -or $PSBoundParameters.Keys -NotContains 'EnableCompression') + { + + "[{0}] Volume Template enforces Compression: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $VolumeTemplate.properties.isCompressed.default | Write-Verbose + + $_newvolume.properties.$_ = $VolumeTemplate.properties.$_.default + + } + + else + { + + "[{0}] Setting compression: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $EnableCompression | Write-Verbose + + $_newvolume.properties.$_ = $EnableCompression + + } + + } + + # Nimble specific + 'performancePolicy' + { + + if ($VolumeTemplate.properties.performancePolicy.meta.locked) # -or (-not $PSBoundParameters['PerformancePolicy'] -and -not $VolumeTemplate.properties.performancePolicy.meta.locked)) + { + + "[{0}] Volume Template enforces performancePolicy state: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $VolumeTemplate.properties.PerformancePolicy.default | Write-Verbose + + $_newvolume.properties.performancePolicy = $VolumeTemplate.properties.performancePolicy.default + + } + + elseif (-not $PSBoundParameters['PerformancePolicy']) + { + + $_StorageSystemDefaultPerformancePolicy = $_StorageSystem.deviceSpecificAttributes.performancePolicies | ? name -eq $_StoragePool.name + + "[{0}] Volume Template does not enforce performancePolicy, setting default state: {1} ({2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_StorageSystemDefaultPerformancePolicy.name, $_StorageSystemDefaultPerformancePolicy.id | Write-Verbose + + $_newvolume.properties.performancePolicy = $_StorageSystemDefaultPerformancePolicy.id + + } + + else + { + + $_newvolume.properties.performancePolicy = $PerformancePolicy.Id + + } + + } + + 'folder' + { + + if ($VolumeTemplate.properties.folder.meta.locked -or (-not $PSBoundParameters['Folder'] -and -not $VolumeTemplate.properties.folder.meta.locked)) + { + + "[{0}] Volume Template enforces folder state: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $VolumeTemplate.properties.folder.default | Write-Verbose + + $_newvolume.properties.folder = $VolumeTemplate.properties.folder.default + + } + + else + { + + $_newvolume.properties.folder = $Folder.Id + + } + + } + + 'volumeSet' + { + + if ($VolumeTemplate.properties.volumeSet.meta.locked -or (-not $PSBoundParameters['VolumeSet'] -and -not $VolumeTemplate.properties.volumeSet.meta.locked)) + { + + "[{0}] Volume Template enforces volumeSet state: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $VolumeTemplate.properties.volumeSet.default | Write-Verbose + + $_newvolume.properties.volumeSet = $VolumeTemplate.properties.volumeSet.default + + } + + else + { + + $_newvolume.properties.volumeSet = $VolumeSet.Uri + + } + + } + + 'isEncrypted' + { + + if ($VolumeTemplate.properties.$_.meta.locked -or ($PSBoundParameters.Keys -notcontains 'EnableEncryption' -and -not $VolumeTemplate.properties.$_.meta.locked)) + { + + "[{0}] Volume Template enforces isEncrypted state: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $VolumeTemplate.properties.$_.default | Write-Verbose + + $_newvolume.properties.$_ = $VolumeTemplate.properties.$_.default + + } + + else + { + + $_newvolume.properties.$_ = $EnableEncryption + + } + + } + + 'isPinned' + { + + if ($VolumeTemplate.properties.$_.meta.locked -or ($PSBoundParameters.Keys -notcontains 'CachePinning' -and -not $VolumeTemplate.properties.$_.meta.locked)) + { + + "[{0}] Volume Template enforces {1} state: {2}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_, $VolumeTemplate.properties.$_.default | Write-Verbose + + $_newvolume.properties.$_ = $VolumeTemplate.properties.$_.default + + } + + else + { + + $_newvolume.properties.$_ = $EnableEncryption + + } + + } + + 'iopsLimit' + { + + if ($VolumeTemplate.properties.$_.meta.locked -or ($PSBoundParameters.Keys -notcontains 'EnableIOPSLimit' -and -not $VolumeTemplate.properties.$_.meta.locked)) + { + + "[{0}] Volume Template enforces {1} state: {2}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_, $VolumeTemplate.properties.$_.default | Write-Verbose + + $_newvolume.properties.$_ = $VolumeTemplate.properties.$_.default + + } + + else + { + + $_newvolume.properties.$_ = $IOPSLimit + + } + + } + + 'dataTransferLimit' + { + + if ($VolumeTemplate.properties.$_.meta.locked -or ($PSBoundParameters.Keys -notcontains 'EnableDataTransferLimit' -and -not $VolumeTemplate.properties.$_.meta.locked)) + { + + "[{0}] Volume Template enforces {1} state: {2}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_, $VolumeTemplate.properties.$_.default | Write-Verbose + + $_newvolume.properties.$_ = $VolumeTemplate.properties.$_.default + + } + + else + { + + $_newvolume.properties.$_ = $DataTransferLimit + + } + + } + + } + + if ($PSBoundParameters['Scope']) + { + + ForEach ($_Scope in $Scope) + { + + "[{0}] Adding resource to Scope: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_Scope.Name | Write-Verbose + + [void]$_newVolume.initialScopeUris.Add($_Scope.Uri) + + } + + } + + # Send the request + Try + { + + $_Resp = Send-OVRequest -Uri $StorageVolumesUri -Method POST -Body $_newVolume -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if (-Not $PSBoundParameters['Async']) + { + + $_Resp | Wait-OVTaskComplete + + } + + else + { + + $_Resp + + } + + } + + End + { + + '[{0}] Done.' -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function GetStoragePool +{ + + [CmdletBinding (DefaultParameterSetName = "default")] + Param + ( + + [Parameter (Mandatory, ParameterSetName = "default")] + [ValidateNotNullOrEmpty()] + [Alias ("pool","poolName",'Name', 'StoragePool')] + [Object]$InputObject, + + [Parameter (Mandatory = $False, ParameterSetName = "default")] + [object]$StorageSystem, + + [Parameter (Mandatory, ParameterSetName = "default")] + [ValidateNotNullorEmpty()] + [object]$ApplianceConnection + + ) + + Process + { + + switch ($InputObject.Gettype().Name) + { + + "String" + { + + # Parameter is correct URI + if ($InputObject.StartsWith($StoragePoolsUri)) + { + + "[{0}] StoragePool URI provided by caller." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + "[{0}] Sending request." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $_sp = Send-OVRequest -Uri $InputObject -Hostname $ApplianceConnection.Name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + # Parameter is incorrect URI value + elseif ($InputObject.StartsWith("/rest")) + { + + # Invalid Parameter value, generate terminating error. + $ExceptionMessage = "Invalid StoragePool Parameter value: {1}. Please correct and try again." -f $InputObject + $ErrorRecord = New-ErrorRecord HPEOneView.StorageVolumeResourceException InvalidArgumentValue InvalidArgument 'InputObject' -Message + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + # Parameter is Storage Pool name + else + { + + "[{0}] StoragePool Name provided by caller." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + # Get specific storage pool from provided StorageSystem + if ($InputObject) + { + + # First look for the StorageSystem Parameter value, and get the StoragePool by filtering on the StorageSystem value. + Try + { + + $_sp = Get-OVStoragePool -Name $InputObject -StorageSystem $StorageSystem -ApplianceConnection $ApplianceConnection -ErrorAction Stop + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + else + { + + Try + { + + $_sp = Get-OVStoragePool -Name $InputObject -ApplianceConnection $ApplianceConnection -ErrorAction Stop + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + # If multiple Storage Pool Resources are returned that are of the same name, generate error and indicate the -StorageSystem Parameter is needed. + # Validate that the storage pool object is unique and not a collection + if(($_sp | Measure-Object).Count -gt 1) + { + + "[{0}] Multiple Storage Pool resources of the name '$InputObject'. $($_sp.count) resources found." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $ErrorRecord = New-ErrorRecord InvalidOperationException InvalidStoragePoolResource ObjectNotFound 'InputObject' -TargetType 'Array' -Message "Multiple Storage Pools it the '$tmpStoragePool' name were found. Please use the -StorageSystem Parameter to specify the Storage System the Pool is associated with, or use the Get-OVStoragePool cmdlet to get the Storage Pool resource and pass as the -StoragePool Parameter value." + + # Generate Terminating Error + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + } + + 'StoragePool' + { + + $_sp = $InputObject + + } + + "PSCustomObject" + { + + # Validate the object + if ($InputObject.category -eq $ResourceCategoryEnum.StoragePool) + { + + # Check the StoragePool object to make sure the ApplianceConnection property matches the ApplianceConnection Parameter from caller + if ($InputObject.ApplianceConnection.Name -ne $ApplianceConnection.Name) + { + + $ErrorRecord = New-ErrorRecord HPEOneView.StorageVolumeResourceException InvalidStoragePoolObject InvalidArgument 'InputObject' -TargetType 'PSObject' -Message "The provided StoragePool object does not appear to originate from the same ApplianceConnection specified - ApplianceConnection: $($ApplianceConnection.Name) StorageVolume ApplianceConnection $($StorageVolume.ApplianceConnection.Name)." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + $_sp = $InputObject.PSObject.Copy() + + } + + else + { + + $ErrorRecord = New-ErrorRecord HPEOneView.StorageVolumeResourceException InvalidStoragePoolCategory InvalidArgument 'InputObject' -TargetType 'PSObject' -Message "Invalid StoragePool Parameter value. Expected Resource Category 'storage-pools', received '$($VolumeTemplate.category)'." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + } + + } + + End + { + + Return $_sp + + } + +} + +function Add-OVStorageVolume +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "default")] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = "default")] + [ValidateNotNullOrEmpty()] + [object]$StorageSystem, + + [Parameter (Mandatory = $false, ParameterSetName = "default")] + [Obsolete()] + [ValidateNotNullOrEmpty()] + [Alias ("volid","id","wwn")] + [String]$VolumeID, + + [Parameter (Mandatory, ParameterSetName = "default")] + [ValidateNotNullOrEmpty()] + [String]$StorageDeviceName, + + [Parameter (Mandatory, ParameterSetName = "default")] + [ValidateNotNullOrEmpty()] + [Alias ("Name")] + [String]$VolumeName, + + [Parameter (Mandatory = $false, ParameterSetName = "default")] + [String]$Description = "", + + [Parameter (Mandatory = $false, ParameterSetName = "default")] + [Switch]$Shared, + + [Parameter (Mandatory = $false, ParameterSetName = "default")] + [ValidateNotNullOrEmpty()] + [HPEOneView.Appliance.ScopeCollection[]]$Scope, + + [Parameter (Mandatory = $false, ParameterSetName = "default", ValueFromPipelineByPropertyName)] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not($PSBoundParameters['StorageSystem'])) + { + + $PipelineInput = $true + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + if ($PSBoundParameters['VolumeID']) + { + + Write-Warning 'The -VolumeID parameter is now deprecated and is no longer used.' + + } + + } + + Process + { + + + $_addVolume = NewObject -AddStorageVolume + $_addVolume.deviceVolumeName = $StorageDeviceName + $_addVolume.name = $VolumeName + $_addVolume.description = $Description + $_addVolume.isShareable = $Shared.IsPresent + + Switch ($StorageSystem.GetType().Name) + { + + "String" + { + + if ($StorageSystem.StartsWith($StorageSystemsUri)) + { + + "[{0}] StorageSystem URI provided by caller." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + "[{0}] Sending request." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $_ss = Send-OVRequest -Uri $StorageSystem -Hostname $ApplianceConnection.Name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + elseif ($StorageSystem.StartsWith("/rest")) + { + + # Invalid Parameter value, generate terminating error. + $ErrorRecord = New-ErrorRecord HPEOneView.StorageVolumeResourceException InvalidArgumentValue InvalidArgument 'StorageSystem' -Message "Invalid StorageSystem Parameter value: $($StorageSystem | out-string)" + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + else + { + + "[{0}] StorageSystem Name provided by caller." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + "[{0}] Sending request." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + # Get the storage volume template resource. Terminating error will throw from the Get-* if no resource is found. + Try + { + + $_ss = Get-OVStorageSystem -SystemName $StorageSystem -ApplianceConnection $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + "PSCustomObject" + { + + # Validate the object + if ($StorageSystem.category -eq $ResourceCategoryEnum.StorageSystem -and $StorageSystem.ApplianceConnection -eq $ApplianceConnection) + { + + "[{0}] Storage System Object provided: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), ($StorageSystem.name) | Write-Verbose + + $_ss = $StorageSystem.PSObject.Copy() + + } + + else + { + + $ExceptionMessage = "Invalid StorageSystem Parameter value. Expected Resource Category 'storage-systems', received '{0}'." -f $StorageSystem.category + $ErrorRecord = New-ErrorRecord HPEOneView.StorageVolumeResourceException InvalidStorageSystemCategory InvalidArgument 'StorageSystem' -TargetType PSObject -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + default + { + + $ExceptionMessage = "Invalid StorageSystem Parameter value object type. Only [PSCustomObject] or [String] values are allowed." + $ErrorRecord = New-ErrorRecord HPEOneView.StorageVolumeResourceException InvalidStorageSystemObject InvalidArgument 'StorageSystem' -TargetType $StorageSystem.GetType().Name -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + $_addVolume.storageSystemUri = $_ss.uri + + if ($PSBoundParameters['Scope']) + { + + ForEach ($_Scope in $Scope) + { + + "[{0}] Adding resource to Scope: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_Scope.Name | Write-Verbose + + [void]$_addVolume.initialScopeUris.Add($_Scope.Uri) + + } + + } + + "[{0}] Add Storage Volume Object: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), ($_addVolume | Out-String) | Write-Verbose + + # Send the request + Try + { + + $_Uri = '{0}/from-existing' -f $StorageVolumesUri + + Send-OVRequest -Uri $_Uri -Method POST -Body $_addVolume -Hostname $ApplianceConnection.Name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + #[void]$colStatus.Add($_resp) + + } + + End + { + + # Return $colStatus + '[{0}] Done.' -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Set-OVStorageVolume +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "default")] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = "default")] + [ValidateNotNullOrEmpty()] + [Alias ('SourceVolume')] + [Object]$InputObject, + + [Parameter (Mandatory = $false, ParameterSetName = "default")] + [ValidateNotNullOrEmpty()] + [Alias ('VolumeName')] + [String]$Name, + + [Parameter (Mandatory = $false, ParameterSetName = "default")] + [String]$Description, + + [Parameter (Mandatory = $false, ParameterSetName = "default")] + [ValidateScript ({$_ -ge 1})] + [Alias ("size")] + [int64]$Capacity, + + [Parameter (Mandatory = $false, ParameterSetName = "default")] + [ValidateNotNullOrEmpty()] + [Object]$SnapShotStoragePool, + + [Parameter (Mandatory = $false, ParameterSetName = "default")] + [Bool]$PermitAdaptiveOptimization, + + [Parameter (Mandatory = $false, ParameterSetName = "default")] + [Bool]$Shared, + + [Parameter (Mandatory = $false, ParameterSetName = "default", ValueFromPipelineByPropertyName)] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not($PSBoundParameters['InputObject'])) + { + + $PipelineInput = $True + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + $colStatus = [System.Collections.ArrayList]::new() + + } + + Process + { + + # Get Source Volume resource + Switch ($InputObject.GetType().Name) + { + + "String" + { + + # Parameter is correct URI + if ($InputObject.StartsWith($StorageVolumesUri)) + { + + "[{0}] Storage Volume URI provided by caller: $InputObject" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + "[{0}] Getting volume resource object" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $_InputObject = Send-OVRequest $InputObject -hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + # Parameter is incorrect URI value + elseif ($InputObject.StartsWith("/rest")) + { + + # Invalid Parameter value, generate terminating error. + $ErrorRecord = New-ErrorRecord HPEOneView.StorageVolumeResourceException InvalidArgumentValue InvalidArgument 'InputObject' -Message "Invalid Storage Volume Parameter value: $($InputObject | out-string). Please correct and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + # Parameter is Storage Pool name + else + { + + "[{0}] Storage Volume Name provided by caller." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $_InputObject = Get-OVStorageVolume $InputObject -ApplianceConnection $ApplianceConnection -ErrorAction Stop + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + "PSCustomObject" + { + + "[{0}] Storage Volume Object provided by caller." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + "[{0}] {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), ($InputObject | ConvertTo-Json -Depth 99) | Write-Verbose + + # Validate the object + if ('storage-volumes' -ne $InputObject.category) + { + + $ErrorRecord = New-ErrorRecord HPEOneView.StorageVolumeResourceException InvalidStoragePoolCategory InvalidArgument 'InputObject' -TargetType 'PSObject' -Message "Invalid Storage Volume Parameter value. Expected Resource Category 'storage-volumes', received '$($InputObject.category)'." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + $_InputObject = $InputObject.PSObject.Copy() + + } + + } + + "[{0}] ORIGINAL Storage Volume object properties: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), ($InputObject | out-string) | Write-Verbose + + # Get the Storage Pool object to identify the family + Try + { + + $_AssociatedStoragePool = Send-OVRequest -Uri $InputObject.storagePoolUri -Hostname $InputObject.ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + # Get the SVT associated with the Volume + if ($InputObject.volumeTemplateUri) + { + + Try + { + + $_SVT = Send-OVRequest -Uri $InputObject.volumeTemplateUri -Hostname $InputObject.ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + "[{0}] Volume is associated with Volume Template: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_SVT.name | Write-Verbose + + } + + # Volume Object updates + switch ($PSboundParameters.keys) + { + + 'Name' + { + + $_InputObject.name = $Name + + } + + 'Description' + { + + $_InputObject.description = $Description + + } + + 'Capacity' + { + + if (-not $_SVT.properties.size.meta.locked) + { + + [int64]$_Capacity = $Capacity * 1GB + + if ([int64]$_Capacity -gt [int64]$InputObject.provisionedCapacity) + { + + $_InputObject.provisionedCapacity = $_Capacity + + } + + # Generate Terminating Error + else + { + + $ExceptionMessage = "Invalid 'capacity' Storage Volume Parameter value. The value '{0}' is less than the original volume size '{1}'. Volume capacity cannot be reduced, only increased." -f [int64]$capacity, [int64]$InputObject.provisionedCapacity + $ErrorRecord = New-ErrorRecord HPEOneView.StorageVolumeResourceException InvalidStorageVolumeCapacityValue InvalidArgument 'Capacity' -TargetType 'Int' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + else + { + + $ExceptionMessage = "The associated Storage Volume Template does not allow modifying the Storage Volumes capacity." + $ErrorRecord = New-ErrorRecord HPEOneView.StorageVolumeResourceException UnableToModifyCapacity PermissionDenied 'Capacity' -TargetType 'Int' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + 'SnapShotStoragePool' + { + + if (-not $_SVT.properties.snapshotPool.meta.locked -and $_AssociatedStoragePool.family -ne 'StoreVirtual') + { + + Try + { + + $_SnapShotStoragePool = GetStoragePool -StoragePool $SnapShotStoragePool -ApplianceConnection $SnapShotStoragePool.ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $_InputObject.deviceSpecificAttributes.snapshotPoolUri = $_SnapShotStoragePool.uri + + } + + elseif ($_SVT.properties.snapshotPool.meta.locked) + { + + $ExceptionMessage = "The associated Storage Volume Template does not allow modifying the Snapshot Storage Pool resource." + $ErrorRecord = New-ErrorRecord HPEOneView.StorageVolumeResourceException UnableToModifySnapshotStoragePool PermissionDenied 'SnapShotStoragePool' -TargetType $SnapShotStoragePool.GetType().Name -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($_AssociatedStoragePool.family -eq 'StoreVirtual') + { + + $ExceptionMessage = "The associated Storage System family is a StoreVirtual system. Snapshot Storage Pool assignment is not supported." + $ErrorRecord = New-ErrorRecord HPEOneView.StorageVolumeResourceException UnsupportedStorageSystemFamily InvalidOperation 'SnapShotStoragePool' -TargetType $SnapShotStoragePool.GetType().Name -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + 'Shared' + { + + if (-not $_SVT.properties.isShareable.meta.locked) + { + + $_InputObject.shareable = [Bool]$Shared + + } + + else + { + + $ExceptionMessage = "The associated Storage Volume Template does not allow modifying the shareability of the Storage Volume resource." + $ErrorRecord = New-ErrorRecord HPEOneView.StorageVolumeResourceException UnableToModifyCapacity PermissionDenied 'Shared' -TargetType $Shared.GetType().Name -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + 'DataProtectionLevel' + { + + $_InputObject.deviceSpecificProperties.dataProtectionLevel = $DataProtectionLevelEnum[$DataProtectionLevel] + + } + + 'PermitAdaptiveOptimization' + { + + $_InputObject.deviceSpecificProperties.isAdaptiveOptimizationEnabled = $PermitAdaptiveOptimization + + } + + } + + "[{0}] Sending updated storage volume to appliance." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + Send-OVRequest -Uri $_InputObject.uri -Method PUT -Body $_InputObject -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Remove-OVStorageVolume +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (SupportsShouldProcess,ConfirmImpact = 'High')] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = "default")] + [ValidateNotNullOrEmpty()] + [Alias ('uri', 'name', 'StorageVolume')] + [Object]$InputObject, + + [Parameter (Mandatory = $false, ParameterSetName = "default")] + [Switch]$ExportOnly, + + [Parameter (Mandatory = $false)] + [Switch]$Async, + + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = "default")] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not($PSBoundParameters['InputObject'])) + { + + $PipelineInput = $True + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + $_TaskCollection = [System.Collections.ArrayList]::new() + $_VolumeCollection = [System.Collections.ArrayList]::new() + + } + + Process + { + + if ($PipelineInput -or $InputObject -is [PSCustomObject]) + { + + "[{0}] Storage Volume Object provided." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + "[{0}] object name: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject.name | Write-Verbose + "[{0}] object uri: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject.uri | Write-Verbose + "[{0}] object appliance connection: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject.ApplianceConnection.Name | Write-Verbose + "[{0}] object category: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject.category | Write-Verbose + + If ($InputObject.category -eq $ResourceCategoryEnum.StorageVolume) + { + + If (-not($InputObject.ApplianceConnection)) + { + + $ErrorRecord = New-ErrorRecord InvalidOperationException InvalidArgumentValue InvalidArgument "InputObject:$($InputObject.Name)" -TargetType PSObject -Message "The Storage Volume resource provided is missing the source ApplianceConnection property. Please check the object provided and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + [void]$_VolumeCollection.Add($InputObject) + + } + + else + { + + $ErrorRecord = New-ErrorRecord InvalidOperationException InvalidArgumentValue InvalidArgument "InputObject:$($InputObject.Name)" -TargetType PSObject -Message "The Storage Volume resource is not an expected category type [$($StorageVolume.category)]. Allowed resource category type is 'storage-volumes'. Please check the object provided and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + else + { + + foreach ($_vol in $InputObject) + { + + # Volume passed is a URI + if (($_vol -is [String]) -and [System.Uri]::IsWellFormedUriString($_vol,'Relative')) + { + + "[{0}] Received URI: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_vol | Write-Verbose + "[{0}] Getting Volume object" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (($ApplianceConnection | Measure-Object).Count -gt 1) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException MultipleApplianceConnections InvalidArgument 'ApplianceConnection' -Message 'The specified ApplianceConnection Parameter contains multiple Appliance Connections. This CMDLET only supports 1 Appliance Connection in the ApplianceConnect Parameter value when using a Storage Volume Template URI value. Please correct this and try again.' + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Try + { + + $_volObject = Send-OVRequest -Uri $_vol -ApplianceConnection $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + [void]$_VolumeCollection.Add($_volObject) + + } + + # Volume passed is the Name + elseif (($_vol -is [String]) -and (-not($_vol.startsWith("/rest")))) + { + + "[{0}] Received Name: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_vol | Write-Verbose + "[{0}] Getting Volume object" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + ForEach ($_appliance in $ApplianceConnection) + { + + "[{0}] Processing '$_appliance' Appliance Connection [of $($ApplianceConnection.count)]" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $_volObject = Get-OVStorageVolume -Name $_vol -ApplianceConnection $_appliance -ErrorAction Stop + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $_volObject | ForEach-Object { + + "[{0}] Adding '$($_.name)' Volume to collection." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + [void]$_VolumeCollection.Add($_) + + } + + } + + } + + # Volume passed is the object + elseif ($_vol -is [PSCustomObject] -and $_vol.category -ieq 'storage-volumes') + { + + "[{0}] Volume Object provided.)"-f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject.name | Write-Verbose + "[{0}] object name: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject.name | Write-Verbose + "[{0}] object uri: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject.uri | Write-Verbose + "[{0}] object appliance connection: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject.ApplianceConnection.Name | Write-Verbose + "[{0}] object category: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject.category | Write-Verbose + + [void]$_VolumeCollection.Add($_vol) + + } + + else + { + + $ErrorRecord = New-ErrorRecord InvalidOperationException InvalidArgumentValue InvalidArgument 'InputObject' -TargetType 'PSObject' -Message "Invalid Volume Parameter: $($_vol | Out-String)" + $PSCmdlet.WriteError($ErrorRecord) + + } + + } + + } + + } + + End + { + + "[{0}] Processing {1} Volume resources to remove." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_VolumeCollection.count | Write-Verbose + + # Process Volume Resources + ForEach ($_volObject in $_VolumeCollection) + { + + $_Uri = $_volObject.uri + + $_Operation = "Remove" + + $_AdditionalParams = [System.Collections.ArrayList]::new() + + if ($PSBoundParameters['Force']) + { + + [void]$_AdditionalParams.Add('force=true') + + } + + if ($PSBoundParameters['ExportOnly']) + { + + $_Operation += " Export only" + + [void]$_AdditionalParams.Add('suppressDeviceUpdates=true') + + } + + if ($_AdditionalParams.Count -gt 0) + { + + $_Uri = '{0}?{1}' -f $_Uri, [String]::Join('&', $_AdditionalParams.ToArray()) + + } + + $_RemoveMessage = "{0} Storage Volume from appliance '{1}'" -f $_Operation, $_volObject.ApplianceConnection + + if ($PSCmdlet.ShouldProcess($_volObject.name, $_RemoveMessage)) + { + + "[{0}] {1} Volume '{2}' and Export from appliance '{3}'." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_Operation, $_volObject.name, $_volObject.ApplianceConnection | Write-Verbose + + Try + { + + $_resp = Send-OVRequest -Uri $_Uri -Method DELETE -AddHeader @{'If-Match' = $_volObject.eTag } -Hostname $_volObject.ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if (-not $PSBoundParameters['Async']) + { + + $_resp | Wait-OVTaskComplete + + } + + else + { + + $_resp + + } + + } + + elseif ($PSBoundParameters['WhatIf']) + { + + "[{0}] WhatIf Parameter was passed." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + + + } + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Get-OVSanManager +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding ()] + Param + ( + + [Parameter (Mandatory = $false)] + [ValidateNotNullOrEmpty()] + [Alias ('SanManager')] + [String]$Name, + + [Parameter (Mandatory = $false)] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $SanManagerCollection = [System.Collections.ArrayList]::new() + + } + + Process + { + + ForEach ($_appliance in $ApplianceConnection) + { + + "[{0}] Processing '{1}' Appliance (of {2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name, $ApplianceConnection.Count | Write-Verbose + + $uri = '{0}?sort=name:asc' -f $fcSanManagersUri + + if ($Name) + { + + $uri = '{0}&query=name like "{1}"' -f $uri, $Name.Replace("*","%25").Replace("&","%26") + + } + + # Send Request + "[{0}] Getting list of SAN Managers" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $_sanManagers = Send-OVRequest -Uri $uri -Hostname $_appliance.Name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + # Generate Terminating Error if resource not found + if (-not($_sanManagers.members) -and $Name) + { + + "[{0}] Requested Managed SAN '{1}' not found on {2}." -f $MyInvocation.InvocationName.ToString().ToUpper(), $Name, $_appliance.Name | Write-Verbose + + $ExceptionMessage = "Request SAN Manager '{0}' not found on '{1}'. Please check the name and try again." -f $Name, $_appliance.Name + $ErrorRecord = New-ErrorRecord InvalidOperationException SanManagerResourceNotFound ObjectNotFound 'SanManager' -Message $ExceptionMessage + + # Generate Terminating Error + $PSCmdlet.WriteError($ErrorRecord) + + } + + elseif (-not($_sanManagers.members)) + { + + "[{0}] No SAN Managers found." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + else + { + + $_sanManagers.members | ForEach-Object { + + $_.PSObject.TypeNames.Insert(0,"HPEOneView.Storage.SanManager") + + [void]$SanManagerCollection.Add($_) + + } + + } + + } + + } + + End + { + + Return $SanManagerCollection + + } + +} + +function Add-OVSanManager +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "Brocade")] + Param + ( + + [Parameter (Mandatory, ParameterSetName = "HPCisco")] + [Parameter (Mandatory, ParameterSetName = "Brocade")] + [ValidateSet ("Brocade", "BNA", "Brocade Network Advisor", "BrocadeFOS", "FOS", "HP", "HPE", "Cisco")] + [String]$Type, + + [Parameter (Mandatory, ParameterSetName = "HPCisco")] + [Parameter (Mandatory, ParameterSetName = "Brocade")] + [ValidateNotNullOrEmpty()] + [String]$Hostname, + + [Parameter (Mandatory = $false, ParameterSetName = "HPCisco")] + [Parameter (Mandatory = $false, ParameterSetName = "Brocade")] + [ValidateNotNullOrEmpty()] + [ValidateRange(1,65535)] + [Int]$Port = 0, + + [Parameter (Mandatory = $false, ParameterSetName = "Brocade")] + [Obsolete()] + [ValidateNotNullOrEmpty()] + [String]$Username, + + [Parameter (Mandatory = $false, ParameterSetName = "Brocade")] + [Obsolete()] + [ValidateNotNullOrEmpty()] + [Object]$Password, + + [Parameter (Mandatory = $false, ParameterSetName = "Brocade")] + [ValidateNotNullOrEmpty()] + [PSCredential]$Credential, + + [Parameter (Mandatory, ParameterSetName = "HPCisco")] + [String]$SnmpUserName, + + [Parameter (Mandatory = $false, ParameterSetName = "HPCisco")] + [ValidateSet ("None","AuthOnly","AuthAndPriv")] + [ValidateNotNullOrEmpty()] + [String]$SnmpAuthLevel = "None", + + [Parameter (Mandatory = $false, ParameterSetName = "HPCisco")] + [ValidateSet ("sha","md5")] + [ValidateNotNullOrEmpty()] + [String]$SnmpAuthProtocol, + + [Parameter (Mandatory = $false, ParameterSetName = "HPCisco")] + [ValidateNotNullOrEmpty()] + [Object]$SnmpAuthPassword, + + [Parameter (Mandatory = $false, ParameterSetName = "HPCisco")] + [ValidateSet ("aes-128","des56","3des")] + [ValidateNotNullOrEmpty()] + [String]$SnmpPrivProtocol, + + [Parameter (Mandatory = $false, ParameterSetName = "HPCisco")] + [ValidateNotNullOrEmpty()] + [Object]$SnmpPrivPassword, + + [Parameter (Mandatory = $false, ParameterSetName = "Brocade")] + [Switch]$UseSsl, + + [Parameter (Mandatory = $false, ParameterSetName = "HPCisco")] + [Parameter (Mandatory = $false, ParameterSetName = "Brocade")] + [Switch]$Async, + + [Parameter (Mandatory = $false, ParameterSetName = "HPCisco")] + [Parameter (Mandatory = $false, ParameterSetName = "Brocade")] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $TaskCollection = [System.Collections.ArrayList]::new() + + if ($SnmpAuthLevel -eq "AuthOnly" -and + (-not $SnmpAuthProtocol -or + -not $SnmpAuthPassword)) + { + + # Generate Terminateing error + $ErrorRecord = New-ErrorRecord HPEOneView.SanManagerResourceException MissingRequiredParameters InvalidArgument 'Add-OVSanManager' -Message "The -SnmpAuthLevel Parameter was set to 'AuthOnly', but did not include both -SnmpAuthProtocol and -SnmpAuthPassword Parameters." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + if ($SnmpAuthLevel -eq "AuthAndPriv" -and ( + -not $SnmpAuthProtocol -or + -not $SnmpAuthPassword -or + -not $SnmpPrivProtocol -or + -not $SnmpPrivPassword )) + { + + # Generate Terminateing error + $ErrorRecord = New-ErrorRecord HPEOneView.SanManagerResourceException MissingRequiredParameters InvalidArgument 'Add-OVSanManager' -Message "The -SnmpAuthLevel Parameter was set to 'AuthAndPriv', but did not include -SnmpAuthProtocol, -SnmpAuthPassword, -SnmpPrivProtocol and -SnmpPrivPassword Parameters." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + # Cisco MDS/Nexus SNMP Auth Parameter validation + if ($type -eq 'Cisco' -and $SnmpAuthLevel -eq 'None') + { + + $ErrorRecord = New-ErrorRecord HPEOneView.SanManagerResourceException UnsupportedSnmpAuthLevel InvalidArgument 'SnmpAuthLevel' -Message "The -SnmpAuthLevel Parameter value $($SnmpAuthLevel) is invalid for configuring a Cisco SAN Manager. Please specify either 'AuthOnly' or 'AuthAndPriv' and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + # Cisco MDS/Nexus SNMP Auth Parameter validation + if ($type -eq 'Cisco' -and $SnmpPrivProtocol -eq '3DES') + { + + $ErrorRecord = New-ErrorRecord HPEOneView.SanManagerResourceException UnsupportedSnmpPrivProtocol InvalidArgument 'SnmpPrivProtocol' -Message "The -SnmpPrivProtocol Parameter value $($SnmpPrivProtocol) is invalid for configuring a Cisco SAN Manager. Please specify either 'des56' or 'aes-128' and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + if ($Password -is [System.Security.SecureString]) + { + + $Password = [Runtime.InteropServices.Marshal]::PtrToStringBSTR([Runtime.InteropServices.Marshal]::SecureStringToBSTR($Password)) + + } + + if ($SnmpPrivPassword -is [SecureString]) + { + + $SnmpPrivPassword = [Runtime.InteropServices.Marshal]::PtrToStringBSTR([Runtime.InteropServices.Marshal]::SecureStringToBSTR($SnmpPrivPassword)) + + } + + if ($SnmpAuthPassword -is [SecureString]) + { + + $SnmpAuthPassword = [Runtime.InteropServices.Marshal]::PtrToStringBSTR([Runtime.InteropServices.Marshal]::SecureStringToBSTR($SnmpAuthPassword)) + + } + + if ($PSBoundParameters['Username']) + { + + Write-Warning "The -Username and -Password parameters are deprecated. Please transition your scripts to using the -Credential parameter." + + $_Username = $Username.clone() + + if ($Password -is [SecureString]) + { + + $_Password = [Runtime.InteropServices.Marshal]::PtrToStringBSTR([Runtime.InteropServices.Marshal]::SecureStringToBSTR($Password)) + + } + + else + { + + $_Password = $Password.Clone() + + } + + $Credential = [System.Management.Automation.PSCredential]::new($_Username, (ConvertTo-SecureString -String $_Password -AsPlainText -Force)) + + } + + if ('Brocade','BNA','Brocade Network Advisor' -contains $Type) + { + + $Message = "WARNING: {0} is obsolete and will be removed in the next major library release." + + Microsoft.PowerShell.Utility\Write-Host $Message -ForegroundColor Yellow + + } + + } + + Process + { + + ForEach ($_appliance in $ApplianceConnection) + { + + "[{0}] Processing {1} (of {2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name, $ApplianceConnection.Count | Write-Verbose + + if ($Type -eq 'HP') { $Type = 'HPE' } + + "[{0}] SAN Manager Type requested: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Type | Write-Verbose + + #Basic SAN Manager Object + $_sanmanager = NewObject -SanManager + + $_sanmanagerhostconnectinfo = NewObject -SanManagerConnectInfo + $_sanmanagerhostconnectinfo.name = "Host" + $_sanmanagerhostconnectinfo.Value = $Hostname + [void]$_sanmanager.connectionInfo.Add($_sanmanagerhostconnectinfo) + + # Get SAN Manager Providers + "[{0}] Getting available SAN Manager Providers" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $_SanManagerProviders = Send-OVRequest -Uri $FcSanManagerProvidersUri -Hostname $_appliance.Name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + switch ($type) + { + + { @('Brocade','BNA','Brocade Network Advisor') -contains $_ } + { + + if ($Port -eq 0) + { + + $Port = 5989 + + } + + $_SanManagerProviderUri = ($_SanManagerProviders.members | Where-Object name -eq 'Brocade San Plugin').deviceManagersUri + + $_sanmanagerhostconnectinfo = NewObject -SanManagerConnectInfo + $_sanmanagerhostconnectinfo.name = "Username" + $_sanmanagerhostconnectinfo.Value = $Credential.Username + [void]$_sanmanager.connectionInfo.Add($_sanmanagerhostconnectinfo) + + $_sanmanagerhostconnectinfo = NewObject -SanManagerConnectInfo + $_sanmanagerhostconnectinfo.name = "Password" + $_sanmanagerhostconnectinfo.Value = [Runtime.InteropServices.Marshal]::PtrToStringBSTR([Runtime.InteropServices.Marshal]::SecureStringToBSTR($Credential.Password)) + [void]$_sanmanager.connectionInfo.Add($_sanmanagerhostconnectinfo) + + $_sanmanagerhostconnectinfo = NewObject -SanManagerConnectInfo + $_sanmanagerhostconnectinfo.name = "UseSsl" + $_sanmanagerhostconnectinfo.Value = [Bool]$UseSsl + [void]$_sanmanager.connectionInfo.Add($_sanmanagerhostconnectinfo) + + $_sanmanagerhostconnectinfo = NewObject -SanManagerConnectInfo + $_sanmanagerhostconnectinfo.name = "Port" + $_sanmanagerhostconnectinfo.Value = $Port + [void]$_sanmanager.connectionInfo.Add($_sanmanagerhostconnectinfo) + + } + + { "BrocadeFOS", "FOS" -contains $_ } + { + + $_SanManagerProviderUri = ($_SanManagerProviders.members | Where-Object name -eq 'FabricOS San Plugin').deviceManagersUri + + $_sanmanagerhostconnectinfo = NewObject -SanManagerConnectInfo + $_sanmanagerhostconnectinfo.name = "Username" + $_sanmanagerhostconnectinfo.Value = $Credential.Username + [void]$_sanmanager.connectionInfo.Add($_sanmanagerhostconnectinfo) + + $_sanmanagerhostconnectinfo = NewObject -SanManagerConnectInfo + $_sanmanagerhostconnectinfo.name = "Password" + $_sanmanagerhostconnectinfo.Value = [Runtime.InteropServices.Marshal]::PtrToStringBSTR([Runtime.InteropServices.Marshal]::SecureStringToBSTR($Credential.Password)) + [void]$_sanmanager.connectionInfo.Add($_sanmanagerhostconnectinfo) + + $_sanmanagerhostconnectinfo = NewObject -SanManagerConnectInfo + $_sanmanagerhostconnectinfo.name = "UseHttps" + $_sanmanagerhostconnectinfo.Value = [Bool]$UseSsl + [void]$_sanmanager.connectionInfo.Add($_sanmanagerhostconnectinfo) + + } + + { @("HPE","Cisco") -contains $_ } + { + + if ($Port -eq 0) + { + + $Port = 161 + + } + + $_SanManagerProviderUri = ($_SanManagerProviders.members | Where-Object name -eq ($Type + ' San Plugin')).deviceManagersUri + + $_sanmanagerhostconnectinfo = NewObject -SanManagerConnectInfo + $_sanmanagerhostconnectinfo.name = "SnmpPort" + $_sanmanagerhostconnectinfo.Value = [Int]$Port + [void]$_sanmanager.connectionInfo.Add($_sanmanagerhostconnectinfo) + + $_sanmanagerhostconnectinfo = NewObject -SanManagerConnectInfo + $_sanmanagerhostconnectinfo.name = "SnmpUserName" + $_sanmanagerhostconnectinfo.Value = $SnmpUserName + [void]$_sanmanager.connectionInfo.Add($_sanmanagerhostconnectinfo) + + $_sanmanagerhostconnectinfo = NewObject -SanManagerConnectInfo + $_sanmanagerhostconnectinfo.name = "SnmpAuthLevel" + $_sanmanagerhostconnectinfo.Value = $SnmpAuthLevelEnum[$SnmpAuthLevel].ToUpper() + [void]$_sanmanager.connectionInfo.Add($_sanmanagerhostconnectinfo) + + if ($SnmpAuthLevel -ne "None") + { + + $_sanmanagerhostconnectinfo = NewObject -SanManagerConnectInfo + $_sanmanagerhostconnectinfo.name = "SnmpAuthProtocol" + $_sanmanagerhostconnectinfo.Value = $SnmpAuthProtocolEnum[$SnmpAuthProtocol] + [void]$_sanmanager.connectionInfo.Add($_sanmanagerhostconnectinfo) + + $_sanmanagerhostconnectinfo = NewObject -SanManagerConnectInfo + $_sanmanagerhostconnectinfo.name = "SnmpAuthString" + $_sanmanagerhostconnectinfo.Value = $SnmpAuthPassword + [void]$_sanmanager.connectionInfo.Add($_sanmanagerhostconnectinfo) + + } + + if ($SnmpAuthLevel -eq "AuthAndPriv") + { + + $_sanmanagerhostconnectinfo = NewObject -SanManagerConnectInfo + $_sanmanagerhostconnectinfo.name = "SnmpPrivProtocol" + $_sanmanagerhostconnectinfo.Value = $SnmpPrivProtocolEnum[$SnmpPrivProtocol] + [void]$_sanmanager.connectionInfo.Add($_sanmanagerhostconnectinfo) + + $_sanmanagerhostconnectinfo = NewObject -SanManagerConnectInfo + $_sanmanagerhostconnectinfo.name = "SnmpPrivString" + $_sanmanagerhostconnectinfo.Value = $SnmpPrivPassword + [void]$_sanmanager.connectionInfo.Add($_sanmanagerhostconnectinfo) + + } + + } + + } + + "[{0}] SAN Manager Provider URI: $($_SanManagerProviderUri)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + try + { + + $resp = Send-OVRequest $_SanManagerProviderUri POST $_sanmanager -Hostname $_appliance.Name + + "[{0}] Received async task, calling Wait-OVTaskComplete" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $resp = Wait-OVTaskComplete $resp + + } + + catch + { + + if ($_.FullyQualifiedErrorId -eq 'RESOURCE_CONFLICT_ERROR') + { + + $ErrorRecord = New-ErrorRecord HPEOneView.SanManagerResourceException SanManagerAlreadyExists ResourceExists 'Hostname' -Message "The SAN Manager $($Hostname) already exists on appliance $($_appliance.Name)." -InnerException $_.Exception + + } + + else + { + + $ErrorRecord = $_ + + } + + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + [void]$TaskCollection.Add($resp) + + } + + } + + End + { + + Return $TaskCollection + + } + +} + +function Set-OVSanManager +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = 'BNA')] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = "HPCisco")] + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = "BNA")] + [Alias ('name','Resource')] + [ValidateNotNullOrEmpty()] + [object]$InputObject, + + [Parameter (Mandatory = $false, ParameterSetName = "HPCisco")] + [Parameter (Mandatory = $false, ParameterSetName = "BNA")] + [ValidateNotNullOrEmpty()] + [String]$Hostname, + + [Parameter (Mandatory = $false, ParameterSetName = "HPCisco")] + [Parameter (Mandatory = $false, ParameterSetName = "BNA")] + [ValidateNotNullOrEmpty()] + [ValidateRange(1,65535)] + [Int]$Port = 0, + + [Parameter (Mandatory, ParameterSetName = "HPCisco")] + [Parameter (Mandatory, ParameterSetName = "BNA")] + [ValidateNotNullOrEmpty()] + [String]$Username, + + [Parameter (Mandatory, ParameterSetName = "HPCisco")] + [Parameter (Mandatory, ParameterSetName = "BNA")] + [ValidateNotNullOrEmpty()] + [Object]$Password, + + [Parameter (Mandatory = $false, ParameterSetName = "HPCisco")] + [String]$SnmpUserName, + + [Parameter (Mandatory = $false, ParameterSetName = "HPCisco")] + [ValidateSet ("None","AuthOnly","AuthAndPriv")] + [ValidateNotNullOrEmpty()] + [String]$SnmpAuthLevel = "None", + + [Parameter (Mandatory = $false, ParameterSetName = "HPCisco")] + [ValidateSet ("sha","md5")] + [ValidateNotNullOrEmpty()] + [String]$SnmpAuthProtocol, + + [Parameter (Mandatory = $false, ParameterSetName = "HPCisco")] + [ValidateNotNullOrEmpty()] + [Object]$SnmpAuthPassword, + + [Parameter (Mandatory = $false, ParameterSetName = "HPCisco")] + [ValidateSet ("aes-128","des56","3des")] + [ValidateNotNullOrEmpty()] + [String]$SnmpPrivProtocol, + + [Parameter (Mandatory = $false, ParameterSetName = "HPCisco")] + [ValidateNotNullOrEmpty()] + [Object]$SnmpPrivPassword, + + [Parameter (Mandatory = $false, ParameterSetName = "BNA")] + [Switch]$EnableSsl, + + [Parameter (Mandatory = $false, ParameterSetName = "BNA")] + [Switch]$DisableSsl, + + [Parameter (Mandatory = $false, ParameterSetName = "HPCisco")] + [Parameter (Mandatory = $false, ParameterSetName = "BNA")] + [Switch]$Async, + + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = "HPCisco")] + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = "BNA")] + [ValidateNotNullorEmpty()] + [object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not($PSBoundParameters['InputObject'])) + { + + $PipelineInput = $True + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + $_ResourceUpdateStatus = [System.Collections.ArrayList]::new() + + } + + Process + { + + switch ($InputObject.GetType().Name) + { + + 'PSCustomObject' + { + + "[$($MyInvocation.InvocationName.ToString().ToUpper())] Object received: {0}" -f ($InputObject | Out-String) | Write-Verbose + + # Generate error if wrong resource type + if ($InputObject.category -ne 'fc-device-managers') + { + + $ErrorRecord = New-ErrorRecord HPEOneView.SanManagerResourceException InvalidSanManagerResource InvalidArgument 'InputObject' -TargetType 'PSObject' -Message ("The provided Resource object is not a SAN Manager resource. Expected resource category 'fc-device-managers'. Received reource category {0}. Please check the value and try again." -f $InputObject.category) + + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + # Generate error if wrong resource type + if (-not($InputObject.ApplianceConnection)) + { + + $ErrorRecord = New-ErrorRecord HPEOneView.SanManagerResourceException InvalidSanManagerResource InvalidArgument 'InputObject' -TargetType 'PSObject' -Message "The provided Resource object is missing the required ApplianceConnection property. Please check the value and try again." + + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + 'String' + { + + "[$($MyInvocation.InvocationName.ToString().ToUpper())] Getting SAN Manager by resource Name: {0}" -f $InputObject | Write-Verbose + + Try + { + + $InputObject = Get-OVSanManager -Name $InputObject -ApplianceConnection $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + + } + + } + + $_UpdatedSanManager = [PSCustomObject]@{ + connectionInfo = [System.Collections.ArrayList]::new() + } + + switch ($PSBoundParameters.keys) + { + + 'Hostname' + { + + [void]$_UpdatedSanManager.connectionInfo.Add(@{name = "Host"; value = $Hostname}) + + } + + 'Port' + { + + [void]$_UpdatedSanManager.connectionInfo.Add(@{name = "Port"; value = $Port}) + + } + + 'Username' + { + + [void]$_UpdatedSanManager.connectionInfo.Add(@{name = "Username"; value = $Username}) + + } + + 'Password' + { + + if ($Password -is [SecureString]) + { + + $Password = [Runtime.InteropServices.Marshal]::PtrToStringBSTR([Runtime.InteropServices.Marshal]::SecureStringToBSTR($Password)) + + } + + [void]$_UpdatedSanManager.connectionInfo.Add(@{name = "Password"; value = $Password}) + + } + + 'SnmpUserName' + { + + [void]$_UpdatedSanManager.connectionInfo.Add(@{name = "SnmpUserName"; value = $SnmpUserName}) + + } + + 'SnmpAuthLevel' + { + + [void]$_UpdatedSanManager.connectionInfo.Add(@{name = "SnmpAuthLevel"; value = $SnmpAuthLevel}) + + } + + 'SnmpAuthProtocol' + { + + [void]$_UpdatedSanManager.connectionInfo.Add(@{name = "SnmpAuthProtocol"; value = $SnmpAuthProtocol}) + + } + + 'SnmpAuthPassword' + { + + if ($SnmpAuthPassword -is [SecureString]) + { + + $SnmpAuthPassword = [Runtime.InteropServices.Marshal]::PtrToStringBSTR([Runtime.InteropServices.Marshal]::SecureStringToBSTR($SnmpAuthPassword)) + + } + + [void]$_UpdatedSanManager.connectionInfo.Add(@{name = "SnmpAuthPassword"; value = $SnmpAuthPassword}) + + } + + 'SnmpPrivProtocol' + { + + [void]$_UpdatedSanManager.connectionInfo.Add(@{name = "SnmpPrivProtocol"; value = $SnmpPrivProtocol}) + + } + + 'SnmpPrivPassword' + { + + if ($SnmpPrivPassword -is [SecureString]) + { + + $SnmpPrivPassword = [Runtime.InteropServices.Marshal]::PtrToStringBSTR([Runtime.InteropServices.Marshal]::SecureStringToBSTR($SnmpPrivPassword)) + + } + + [void]$_UpdatedSanManager.connectionInfo.Add(@{name = "SnmpPrivPassword"; value = $SnmpPrivPassword}) + + } + + 'DisableSsl' + { + + [void]$_UpdatedSanManager.connectionInfo.Add(@{name = "UseSsl"; value = $false}) + + } + + 'EnableSsl' + { + + [void]$_UpdatedSanManager.connectionInfo.Add(@{name = "UseSsl"; value = $true}) + + } + + } + + # Add missing ConnectionInfo properties to complete request + if (-not $PSBoundParameters['Hostname']) + { + + [void]$_UpdatedSanManager.connectionInfo.Add(@{name = "Host"; value = ($InputObject.connectionInfo | Where-Object Name -eq Host).value}) + + } + + if (-not $PSBoundParameters['Port']) + { + + [void]$_UpdatedSanManager.connectionInfo.Add(@{name = "Port"; value = ($InputObject.connectionInfo | Where-Object Name -eq Port).value}) + + } + + if (-not $PSBoundParameters['EnableSsl'] -and -not $PSBoundParameters['DisableSsl'] -and $InputObject.providerDisplayName -eq 'Brocade Network Advisor') + { + + [void]$_UpdatedSanManager.connectionInfo.Add(@{name = "UseSsl"; value = ($InputObject.connectionInfo | Where-Object Name -eq UseSsl).value}) + + } + + "[$($MyInvocation.InvocationName.ToString().ToUpper())] Updated SAN Manager: {0}" -f ($_UpdatedSanManager | out-string) | Write-Verbose + + "[{0}] Sending request" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $resp = Send-OVRequest -Uri $InputObject.uri -Method PUT -Body $_UpdatedSanManager -ApplianceConnection $InputObject.ApplianceConnection.Name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if (-not $PSBoundParameters['Async']) + { + + $resp | Wait-OVTaskComplete + + } + + else + { + + $resp + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Update-OVSanManager +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding ()] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline)] + [ValidateNotNullOrEmpty()] + [Alias ('Name','SANManager')] + [Object]$InputObject, + + [Parameter (ValueFromPipelineByPropertyName, Mandatory = $false)] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not($PSBoundParameters['InputObject'])) + { + + $PipelineInput = $True + + } + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection -is [HPEOneView.Appliance.Connection]) -and (-not($ApplianceConnection -is [System.String])) -and (-not($PipelineInput))) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException InvalidApplianceConnectionDataType InvalidArgument 'ApplianceConnection' -Message 'The specified ApplianceConnection Parameter is not type [HPEOneView.Appliance.Connection] or [System.String]. Please correct this value and try again.' + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif (($ApplianceConnection | Measure-Object).Count -gt 1 -and (-not($PipelineInput))) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException MultipleApplianceConnections InvalidArgument 'ApplianceConnection' -Message 'The specified ApplianceConnection Parameter contains multiple Appliance Connections. This CMDLET only supports 1 Appliance Connection in the ApplianceConnect Parameter value. Please correct this and try again.' + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif (-not($PipelineInput)) + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -TargetType $ApplianceConnection.GetType().Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_.Exception) + + } + + } + + $_SanManagerRefreshCollection = [System.Collections.ArrayList]::new() + + } + + Process + { + + $request = [PsCustomObject]@{refreshState = "RefreshPending"} + + # Validate input object type + # Checking if the input is System.String and is NOT a URI + if ($InputObject -is [String]) + { + + "[{0}] SANManager Name: $($SANManager)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $SANManager = Get-OVSanManager $SANManager -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + # Checking if the input is PSCustomObject, and the category type is server-profiles, which could be passed via pipeline input + elseif (($InputObject -is [System.Management.Automation.PSCustomObject]) -and ($InputObject.category -ieq "fc-device-managers")) + { + + "[$($MyInvocation.InvocationName.ToString().ToUpper())] SANManager is an object: {0}" -f $InputObject.name | Write-Verbose + + } + + else + { + + $ErrorRecord = New-ErrorRecord InvalidOperationException InvalidArgumentValue InvalidArgument 'InputObject' -TargetType $InputObject.GetType().Name -Message "The Parameter 'InputObject' value is invalid. Please validate the 'InputObject' Parameter value you passed and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + if ($InputObject.isInternal) + { + + "[$($MyInvocation.InvocationName.ToString().ToUpper())] '{0}' SAN Manager is internal. Skipping." -f $InputObject.name | Write-Verbose + + } + + else + { + + "[$($MyInvocation.InvocationName.ToString().ToUpper())] Refreshing SAN Manager resource: {0}" -f $InputObject.name | Write-Verbose + + Try + { + + $_resp = Send-OVRequest $InputObject.uri PUT $request -Hostname $ApplianceConnection.Name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $_resp + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Remove-OVSanManager +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (SupportsShouldProcess,ConfirmImpact = 'High')] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline)] + [ValidateNotNullOrEmpty()] + [Alias ('Name','SanManager')] + [object]$InputObject, + + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName)] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not($PSboundParameters['InputObject'])) + { + + $PipelineInput = $True + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + $_TaskCollection = [System.Collections.ArrayList]::new() + $_SanManagerCollection = [System.Collections.ArrayList]::new() + + } + + Process + { + + if ($PipelineInput -or $InputObject -is [PSCustomObject]) + { + + "[{0}] Processing Pipeline input" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + "[{0}] San Manager Object provided." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + "[{0}] object name: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject.name | Write-Verbose + "[{0}] object uri: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject.uri | Write-Verbose + "[{0}] object appliance connection: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject.ApplianceConnection.Name | Write-Verbose + "[{0}] object category: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject.category | Write-Verbose + + If ('fc-device-managers' -contains $InputObject.category) + { + + If (-not($InputObject.ApplianceConnection)) + { + + $ErrorRecord = New-ErrorRecord HPEOneView.SanManagerResourceException InvalidArgumentValue InvalidArgument "SanManager:$($InputObject.Name)" -TargetType PSObject -Message "The SanManager object resource provided is missing the source ApplianceConnection property. Please check the object provided and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + [void]$_SanManagerCollection.Add($InputObject) + + } + + else + { + + $ErrorRecord = New-ErrorRecord HPEOneView.SanManagerResourceException InvalidArgumentValue InvalidArgument "SanManager:$($InputObject.Name)" -TargetType PSObject -Message "The SanManager object resource is not an expected category type [$($InputObject.category)]. The allowed resource category type is 'fc-device-managers'. Please check the object provided and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + else + { + + # Need to handle Name versus URI + ForEach ($_appliance in $ApplianceConnection) + { + + "[{0}] Processing Appliance $($_appliance.Name) (of $($ApplianceConnection.Count))" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + "[{0}] Processing SanManager Name $($InputObject)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $_SanManager = Get-OVSanManager $InputObject -ApplianceConnection $_appliance + + $_SanManager | ForEach-Object { + + [void]$_SanManagerCollection.Add($_) + + } + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + } + + End + { + + "[{0}] Begin resource removal process." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + foreach ($_sm in $_SanManagerCollection) + { + + if ($PSCmdlet.ShouldProcess($_sm.name,"Remove SAN Manager from appliance '$($_sm.ApplianceConnection.Name)'")) + { + + + Try + { + + $_task = Send-OVRequest -Uri $_sm.uri -Method DELETE -AddHeader @{'If-Match' = $_sm.eTag } -Hostname $_sm.ApplianceConnection.Name + + [void]$_TaskCollection.Add($_task) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + elseif ($PSBoundParameters['WhatIf']) + { + + "[{0}] Caller passed -WhatIf Parameter." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + else + { + + "[{0}] Caller selected NO to confirmation prompt." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + } + + Return $_TaskCollection + + } + +} + +function Get-OVManagedSan +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding ()] + Param + ( + + [Parameter (Mandatory = $false)] + [ValidateNotNullOrEmpty()] + [Alias ('Fabric')] + [String]$Name, + + [Parameter (Mandatory = $false)] + [ValidateNotNullOrEmpty()] + [String]$Label, + + [Parameter (Mandatory = $false)] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $ManagedSansCollection = [System.Collections.ArrayList]::new() + + } + + Process + { + + ForEach ($_appliance in $ApplianceConnection) + { + + "[{0}] Processing '{1}' Appliance (of {2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name, $ApplianceConnection.Count | Write-Verbose + + if ($PSBoundParameters['Label']) + { + + $_uri = '{0}?category:fc-sans&query=labels:{1}' -f $IndexUri, $Label + + Try + { + + $_IndexMembers = Send-OVRequest -Uri $_uri -Hostname $_appliance + + # Loop through all found members and get full SVT object + ForEach ($_member in $_IndexMembers.members) + { + + Try + { + + $_member = Send-OVRequest -Uri $_member.uri -Hostname $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $_member.PSObject.TypeNames.Insert(0,"HPEOneView.Storage.ManagedSan") + + $_member + + } + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + else + { + + $uri = $fcManagedSansUri + '?sort=name:asc' + + if ($Name) + { + + $Name = $Name -replace ("[*]","%25") -replace ("[&]","%26") + + $uri += "&query=lower(name) like '{0}'" -f $Name.ToLower() + + } + + "[{0}] Getting list of Managed SANs" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $_managedSans = Send-OVRequest $uri -Hostname $_appliance.Name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if ($_managedSans.count -eq 0 -and $Name) + { + + "[{0}] Requested Managed SAN '{1}' not found." -f $MyInvocation.InvocationName.ToString().ToUpper(), $Name | Write-Verbose + + $ExceptionMessage = "Request Managed SAN '{0}' not found on appliance {1}. Please check the name and try again." -f $Name, $_appliance + $ErrorRecord = New-ErrorRecord InvalidOperationException ManagedSanResourceNotFound ObjectNotFound 'Name' -Message $ExceptionMessage + + # Generate Terminating Error + $PSCmdlet.WriteError($ErrorRecord) + + } + + else + { + + $_managedSans.members | ForEach-Object { + + $_.PSObject.TypeNames.Insert(0,"HPEOneView.Storage.ManagedSan") + + [void]$ManagedSansCollection.Add($_) + + } + + } + + } + + } + + } + + End + { + + return $ManagedSansCollection + + } + +} + +function Set-OVManagedSan +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "Enable")] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = "Enable")] + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = "Disable")] + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = "DisableAlias")] + [ValidateNotNullOrEmpty()] + [Alias ('Fabric','Name','ManagedSan','Resource')] + [object]$InputObject, + + [Parameter (Mandatory = $false, ParameterSetName = "Enable")] + [Parameter (Mandatory = $false, ParameterSetName = "DisableAlias")] + [Alias ('ZoningEnable','Enable')] + [Switch]$EnableAutomatedZoning, + + [Parameter (Mandatory = $false, ParameterSetName = "Disable")] + [Alias ('ZoningDisable','Disable')] + [Switch]$DisableAutomatedZoning, + + [Parameter (Mandatory, ParameterSetName = "Enable")] + [Parameter (Mandatory, ParameterSetName = "Disable")] + [Parameter (Mandatory = $false, ParameterSetName = "DisableAlias")] + [ValidateSet ('NoZoning', 'SingleInitiatorAllTargets','SingleInitiatorSingleStorageSystem','SingleInitiatorSingleTarget')] + [ValidateNotNullOrEmpty()] + [String]$ZoningPolicy = 'SingleInitiatorAllTargets', + + [Parameter (Mandatory = $false, ParameterSetName = "Enable")] + [Obsolete()] + [Switch]$EnableAliasing, + + [Parameter (Mandatory = $false, ParameterSetName = "DisableAlias")] + [Obsolete()] + [Switch]$DisableAliasing, + + [Parameter (Mandatory = $false, ParameterSetName = "Enable")] + [ValidateNotNullOrEmpty()] + [String]$InitiatorNameFormat, + + [Parameter (Mandatory = $false, ParameterSetName = "Enable")] + [ValidateNotNullOrEmpty()] + [String]$TargetGroupNameFormat, + + [Parameter (Mandatory = $false, ParameterSetName = "Enable")] + [ValidateNotNullOrEmpty()] + [bool]$DisableTargetGroupAliasing, + + [Parameter (Mandatory = $false, ParameterSetName = "Enable")] + [ValidateNotNullOrEmpty()] + [String]$TargetNameFormat, + + [Parameter (Mandatory = $false, ParameterSetName = "Enable")] + [ValidateNotNullOrEmpty()] + [String]$ZoneNameFormat, + + [Parameter (Mandatory = $false, ParameterSetName = "Enable")] + [Bool]$UpdateZoneNames, + + [Parameter (Mandatory = $false, ParameterSetName = "Enable")] + [Bool]$UpdateInitiatorAliases, + + [Parameter (Mandatory = $false, ParameterSetName = "Enable")] + [Bool]$UpdateTargetAliases, + + [Parameter (Mandatory = $false, ParameterSetName = "Enable")] + [Bool]$UpdateTargetGroupAliases, + + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = "Enable")] + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = "Disable")] + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = "DisableAlias")] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not($PSBoundParameters['InputObject'])) + { + + $PipelineInput = $True + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + $_ResourceUpdateStatus = [System.Collections.ArrayList]::new() + + if ($PSBoundParameters.Keys -Contains 'EnableAutomatedZoning') + { + + Write-Warning "the -EnableAutomatedZoning parameter is being deprecated. Please update your scripts to use the -ZoningPolicy parameter." + + } + + if ($PSBoundParameters.Keys -Contains 'DisableAutomatedZoning') + { + + Write-Warning "the -DisableAutomatedZoning parameter is being deprecated. Please update your scripts to use the -ZoningPolicy parameter." + + } + + } + + Process + { + + switch ($InputObject.GetType().Name) + { + + 'PSCustomObject' + { + + "[{0}] Object received: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), ($InputObject | Out-String) | Write-Verbose + + # Generate error if wrong resource type + if ($InputObject.category -ne $ResourceCategoryEnum.ManagedSAN) + { + + $ExceptionMessage = "The provided Resource object is not a Managed SAN resource. Expected resource category '{0}'. Received reource category '{1}'. Please check the value and try again." -f $ResourceCategoryEnum.ManagedSAN, $InputObject.category + $ErrorRecord = New-ErrorRecord HPEOneView.ManagedSanResourceException InvalidManagedSanResource InvalidArgument 'InputObject' -TargetType 'PSObject' -Message $ExceptionMessage + + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + # Generate error if wrong resource type + if (-not($InputObject.ApplianceConnection)) + { + + $ExceptionMessage = "The provided Resource object is missing the required ApplianceConnection property. Please check the value and try again." + $ErrorRecord = New-ErrorRecord HPEOneView.SanManagerResourceException InvalidSanManagerResource InvalidArgument 'InputObject' -TargetType 'PSObject' -Message $ExceptionMessage + + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + $_InputObject = $InputObject.PSObject.Copy() + + } + + 'String' + { + + "[{0}] Getting Managed SAN by resource Name: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject | Write-Verbose + + Try + { + + $_InputObject = Get-OVManagedSan -Name $InputObject -ApplianceConnection $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + if ($_InputObject.isInternal) + { + + $ExceptionMessage = "The provided Resource object '{0}' is an Internal SAN Manager and unsupported with this Cmdlet. Please check the value and try again." -f $InputObject.name + $ErrorRecord = New-ErrorRecord HPEOneView.SanManagerResourceException InvalidSanManagerResource InvalidArgument 'InputObject' -TargetType 'PSObject' -Message $ExceptionMessage + + $PSCmdlet.WriteError($ErrorRecord) + + } + + else + { + + # common function to validate naming policies that include variables + function ValidateNamingPolicy ([string]$Type, [string]$PolicyValue) + { + + # Allowed variable names + [Array]$AllowedZoneNamingVariables = "hostName", "initiatorName", "initiatorWwn", "storageSystemName", "targetName", "targetGroupName" + [Array]$AllowedInitiatorNameFormatVariables = 'hostName', 'initiatorName', 'initiatorWwn' + [Array]$AllowedTargetAliasFormatVariables = 'storageSystemName','targetName', 'targetLabel', 'targetGroupName' + [Array]$AllowedTargetGroupNameFormatVariables = 'storageSystemName','targetGroupName' + + # Allowed variables based on the zoning policy + $AllowedVariablesBasedOnZonePolicyType = [PSCustomObject]@{ + SingleInitiatorAllTargets = [PSCustomObject]@{ + AllowedZongPolicyvariables = 'hostName', 'initiatorName', 'initiatorWwn', 'targetGroupName' + AllowedInitiatorAliasFormatVariables = 'hostName', 'initiatorName', 'initiatorWwn'; + AllowedTargetAliasFormatVariables = 'storageSystemName', 'targetName', 'targetLabel', 'targetGroupName'; + AllowedTargetGroupFormatVariables = 'storageSystemName', 'targetGroupName' + }; + SingleInitiatorSingleStorageSystem = [PSCustomObject]@{ + AllowedZongPolicyvariables = 'hostName', 'initiatorName', 'initiatorWwn', 'targetGroupName', 'storageSystemName'; + AllowedInitiatorAliasFormatVariables = 'hostName', 'initiatorName', 'initiatorWwn'; + AllowedTargetAliasFormatVariables = 'storageSystemName', 'targetName', 'targetLabel', 'targetGroupName'; + AllowedTargetGroupFormatVariables = 'storageSystemName', 'targetGroupName' + }; + SingleInitiatorSingleTarget = [PSCustomObject]@{ + AllowedZongPolicyvariables = 'hostName', 'initiatorName', 'initiatorWwn', 'targetGroupName', 'storageSystemName', 'targetName'; + AllowedInitiatorAliasFormatVariables = 'hostName', 'initiatorName', 'initiatorWwn'; + AllowedTargetAliasFormatVariables = 'storageSystemName', 'targetName', 'targetLabel', 'targetGroupName'; + AllowedTargetGroupFormatVariables = 'NONE' + } + } + + # Need to validate what the user provided, looking for variables that are not allowed + $Found = $EmbeddedVariableNameRegEx.Matches($PolicyValue) + + # Loop through the results looking for invalid value if the ZoningPolicy doesn't support the variable + ForEach ($match in $Found) + { + + $ExceptionMessage = $null + + $ValidateVariable = '{' + $match.Groups['variable'].Value + '}' + + switch ($Type) + { + + 'ZoneNameFormat' + { + + if (-not $AllowedZoneNamingVariables.Contains($match.Groups['variable'].Value)) + { + + $ExceptionMessage = "The variable '{0}' is not allowed, as it is not an approved ZoneNameFormat variable. Please ensure any embedded variable is from these values: '{1}{2}{3}'" -f $ValidateVariable, '{', [String]::Join("}', '{", $AllowedZoneNamingVariables), '}' + $ErrorRecord = New-ErrorRecord HPEOneView.SanManagerResourceException InvalidSanManagerResource InvalidArgument 'ZoneNameFormat' -Message $ExceptionMessage + + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + # Validate variables based on the zone policy type + if (-not $AllowedVariablesBasedOnZonePolicyType.$ZoningPolicy.AllowedZongPolicyvariables.Contains($match.Groups['variable'].Value)) + { + + $ExceptionMessage = "The variable '{0}' is not allowed variable based on the zone name policy '{1}'. Please ensure any embedded variable is from these values: '{2}{3}{4}'" -f $ValidateVariable, $ZoningPolicy, '{', [String]::Join("}', '{", $AllowedVariablesBasedOnZonePolicyType.$ZoningPolicy.AllowedZongPolicyvariables), '}' + $ErrorRecord = New-ErrorRecord HPEOneView.SanManagerResourceException InvalidSanManagerResource InvalidArgument 'ZoneNameFormat' -Message $ExceptionMessage + + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + 'InitiatorNameFormat' + { + + # FIrst validate allowed variables + if (-not $AllowedInitiatorNameFormatVariables.Contains($match.Groups['variable'].Value)) + { + + $ExceptionMessage = "The variable '{0}' is not allowed, as it is not an approved InitiatorNameFormat variable. Please ensure any embedded variable is from these values: '{1}{2}{3}'" -f $ValidateVariable, '{', [String]::Join("}', '{", $AllowedZoneNamingVariables), '}' + $ErrorRecord = New-ErrorRecord HPEOneView.SanManagerResourceException InvalidSanManagerResource InvalidArgument 'InitiatorNameFormat' -Message $ExceptionMessage + + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + # Then validate allowed variables based on $ZoningPolicy (Cmdlet parameter) + if (-not $AllowedVariablesBasedOnZonePolicyType.$ZoningPolicy.AllowedInitiatorAliasFormatVariables.Contains($match.Groups['variable'].Value)) + { + + $ExceptionMessage = "The variable '{0}' is not allowed variable based on the zone name policy '{1}'. Please ensure any embedded variable is from these values: '{2}{3}{4}'" -f $ValidateVariable, $ZoningPolicy, '{', [String]::Join("}', '{", $AllowedVariablesBasedOnZonePolicyType.$ZoningPolicy.AllowedInitiatorAliasFormatVariables), '}' + $ErrorRecord = New-ErrorRecord HPEOneView.SanManagerResourceException InvalidSanManagerResource InvalidArgument 'InitiatorNameFormat' -Message $ExceptionMessage + + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + 'TargetNameFormat' + { + + # First validate allowed variables + if (-not $AllowedTargetAliasFormatVariables.Contains($match.Groups['variable'].Value)) + { + + $ExceptionMessage = "The variable '{0}' is not allowed, as it is not an approved TargetNameFormat variable. Please ensure any embedded variable is from these values: '{1}{2}{3}'" -f $ValidateVariable, '{', [String]::Join("}', '{", $AllowedZoneNamingVariables), '}' + $ErrorRecord = New-ErrorRecord HPEOneView.SanManagerResourceException InvalidSanManagerResource InvalidArgument 'TargetNameFormat' -Message $ExceptionMessage + + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + # Then validate allowed variables based on $ZoningPolicy (Cmdlet parameter) + if (-not $AllowedVariablesBasedOnZonePolicyType.$ZoningPolicy.AllowedTargetAliasFormatVariables.Contains($match.Groups['variable'].Value)) + { + + $ExceptionMessage = "The variable '{0}' is not allowed variable based on the zone name policy '{1}'. Please ensure any embedded variable is from these values: '{2}{3}{4}'" -f $ValidateVariable, $ZoningPolicy, '{', [String]::Join("}', '{", $AllowedVariablesBasedOnZonePolicyType.$ZoningPolicy.AllowedTargetAliasFormatVariables), '}' + $ErrorRecord = New-ErrorRecord HPEOneView.SanManagerResourceException InvalidSanManagerResource InvalidArgument 'TargetNameFormat' -Message $ExceptionMessage + + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + 'TargetGroupNameFormat' + { + + # FIrst validate allowed variables + if (-not $AllowedTargetGroupNameFormatVariables.Contains($match.Groups['variable'].Value)) + { + + $ExceptionMessage = "The variable '{0}' is not allowed, as it is not an approved TargetGroupNameFormat variable. Please ensure any embedded variable is from these values: '{1}{2}{3}'" -f $ValidateVariable, '{', [String]::Join("}', '{", $AllowedZoneNamingVariables), '}' + $ErrorRecord = New-ErrorRecord HPEOneView.SanManagerResourceException InvalidSanManagerResource InvalidArgument 'TargetGroupNameFormat' -Message $ExceptionMessage + + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + # TargetGroupNameFormat is now allowed when zoning policy is SingleInitiatorSingleTarget + if ($ZoningPolicy = 'SingleInitiatorSingleTarget') + { + + $ExceptionMessage = "Defining a TargetGroupNameFormat is not allowed witht he zoning policy is set to '{0}'." -f $ZoningPolicy + $ErrorRecord = New-ErrorRecord HPEOneView.SanManagerResourceException InvalidSanManagerResource InvalidArgument 'TargetGroupNameFormat' -Message $ExceptionMessage + + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + } + + } + + } + + "[{0}] Processing '{1}'" -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject.name | Write-Verbose + + # Disable zoning + if ($DisableAutomatedZoning.IsPresent -or $ZoningPolicy -eq 'NoZoning') + { + + '[{0}] Disabling zoning for the managed SAN.' -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_InputObject.sanPolicy.zoningPolicy = "NoZoning" + + # Need to disable Aliasing Support as well with the request + $_InputObject.sanPolicy.enableAliasing = $false + + } + + else + { + + '[{0}] Enable zoning for the managed SAN.' -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_InputObject.sanPolicy.zoningPolicy = $ZoningPolicy + + # Support zoning, but not alias management + if ($DisableAliasing.IsPresent) + { + + '[{0}] Disabling alias management for the managed SAN.' -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_InputObject.sanPolicy.enableAliasing = $false + + } + + # Support zoning and alias management + elseif ($EnableAliasing.IsPresent -or $ZoningPolicy -ne 'NoZoning') + { + + '[{0}] Enabling alias management for the managed SAN.' -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_InputObject.sanPolicy.enableAliasing = $True + + switch ($PSBoundParameters.Keys) + { + + 'UpdateZoneNames' { $_InputObject.sanPolicy.renameZones = $UpdateZoneNames } + 'UpdateInitiatorAliases' { $_InputObject.sanPolicy.renameInitiatorAliases = $UpdateInitiatorAliases } + 'UpdateTargetAliases' { $_InputObject.sanPolicy.renameTargetAliases = $UpdateTargetAliases } + + } + + if ($PSBoundParameters['ZoneNameFormat']) + { + + '[{0}] Validating ZoneNameFormat value.' -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + try + { + + ValidateNamingPolicy -Type ZoneNameFormat -PolicyValue $TargetNameFormat | Out-Null + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $_InputObject.sanPolicy.zoneNameFormat = $ZoneNameFormat + + } + + if ($PSBoundParameters['InitiatorNameFormat']) + { + + '[{0}] Validating InitiatorNameFormat value.' -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + try + { + + ValidateNamingPolicy -Type InitiatorNameFormat -PolicyValue $InitiatorNameFormat | Out-Null + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $_InputObject.sanPolicy.initiatorNameFormat = $InitiatorNameFormat + + } + + if ($PSBoundParameters['TargetGroupNameFormat']) + { + + '[{0}] Validating TargetGroupNameFormat value.' -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + try + { + + ValidateNamingPolicy -Type TargetGroupNameFormat -PolicyValue $TargetGroupNameFormat | Out-Null + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $_InputObject.sanPolicy.targetGroupNameFormat = $TargetGroupNameFormat + $_InputObject.sanPolicy.enableGroupAliasing = $True + + } + + if ($PSBoundParameters['TargetNameFormat']) + { + + '[{0}] Validating TargetNameFormat value.' -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + try + { + + ValidateNamingPolicy -Type TargetNameFormat -PolicyValue $TargetNameFormat | Out-Null + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $_InputObject.sanPolicy.targetNameFormat = $TargetNameFormat + + } + + if ($PSBoundParameters['DisableTargetGroupAliasing']) + { + + if ($DisableTargetGroupAliasing -and -not $PSBoundParameters['TargetGroupNameFormat'] -and [String]::IsNullOrEmpty($_InputObject.sanPolicy.targetGroupNameFormat)) + { + + # Generate error that targetgroup is not being disabled, and + $ExceptionMessage = "Enabling TargetGroupAliasing also requires the TargetGroupNameFormat parameter to have a defined value." + $ErrorRecord = New-ErrorRecord HPEOneView.SanManagerResourceException InvalidSanManagerResource InvalidArgument 'TargetGroupNameFormat' -Message $ExceptionMessage + + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + else + { + + $_InputObject.sanPolicy.enableGroupAliasing = $DisableTargetGroupAliasing + + } + + } + + } + + # Default zone name format + else + { + + switch ($ZoningPolicy) + { + + 'SingleInitiatorAllTargets' + { + + $_InputObject.sanPolicy.zoneNameFormat = "{hostName}_{initiatorName}" + + } + + 'SingleInitiatorSingleStorageSystem' + { + + $_InputObject.sanPolicy.zoneNameFormat = "{hostName}_{initiatorName}_{storageSystemName}" + + } + + 'SingleInitiatorSingleTarget' + { + + $_InputObject.sanPolicy.zoneNameFormat = "{hostName}_{initiatorName}_{storageSystemName}_{targetGroupName}" + + } + + } + + } + + } + + "[{0}] Updated Managed SAN Object: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), ($_InputObject | ConvertTo-Json -Depth 99 | out-string) | Write-Verbose + + Try + { + + $_InputObject = $_InputObject | Select * -Exclude created, modified + + $_Resp = Send-OVRequest -Uri $_InputObject.uri -Method PUT -Body $_InputObject -AddHeader @{'if-match' = $_InputObject.eTag} -Hostname $InputObject.ApplianceConnection.Name + + $_Resp | ForEach-Object { $_.PSObject.TypeNames.Insert(0,'HPEOneView.Storage.ManagedSan') } + + [void]$_ResourceUpdateStatus.Add($_Resp) + + } + + Catch + { + + $_ResourceUpdateStatus + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + End + { + + Return $_ResourceUpdateStatus + + } + +} + +function Show-OVSanEndpoint +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = 'Default')] + Param + ( + + [Parameter (Mandatory = $False, ValueFromPipeline, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [Object]$SAN, + + [Parameter (Mandatory, ParameterSetName = 'WWN')] + [ValidateNotNullOrEmpty()] + [String]$WWN, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [Parameter (Mandatory = $false, ParameterSetName = 'WWN')] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $_SANEndpointCol = [System.Collections.ArrayList]::new() + + } + + Process + { + + $uri = $SanEndpoints + + if ($SAN) + { + + switch ($SAN.GetType().Name) + { + + + 'String' + { + + $uri += '?query=sanName eq "{0}"' -f $SAN + + } + + 'PSCustomObject' + { + + $uri += '?query=sanName eq "{0}"' -f $SAN.name + + } + + } + + Try + { + + $_resp = Send-OVRequest $uri -Hostname $ApplianceConnection + + $_resp.members | ForEach-Object { + + $_.PSObject.TypeNames.Insert(0,'HPEOneView.Storage.San.Endpoint') + + [void]$_SANEndpointCol.Add($_) + + } + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + else + { + + if ($WWN) + { + + $uri += '?query=wwn eq "{0}"' -f $WWN + + } + + if ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + ForEach ($_appliance in $ApplianceConnection) + { + + + Try + { + + $_resp = Send-OVRequest $uri -Hostname $_appliance + + $_resp.members | ForEach-Object { + + $_.PSObject.TypeNames.Insert(0,'HPEOneView.Storage.San.Endpoint') + + [void]$_SANEndpointCol.Add($_) + + } + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $_resp = Send-OVRequest $uri -Hostname $ApplianceConnection + + $_resp.members | ForEach-Object { + + $_.PSObject.TypeNames.Insert(0,'HPEOneView.Storage.San.Endpoint') + + [void]$_SANEndpointCol.Add($_) + + } + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + } + + End + { + + Return $_SANEndpointCol + + } + +} + +function Get-OVSanZone +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName='Default')] + + Param + ( + + [Parameter (Mandatory = $false, ValueFromPipeline, ParameterSetName = 'Default')] + [ValidateNotNullorEmpty()] + [Object]$ManagedSan, + + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = 'Default')] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $_FCZoneCollection = [System.Collections.ArrayList]::new() + + } + + Process + { + + if ($PSBoundParameters['ManagedSan']) + { + + Switch ($ManagedSan.GetType().Name) + { + + 'PSCustomObject' + { + + if ($ManagedSan.category -ne 'fc-sans') + { + + $ExceptionMessage = "The ManagedSan resource '{0}' is not an allowed resource category." -f $ManagedSan.category + $ErrorRecord = New-ErrorRecord HPEOneView.ManagedSanResourceException InvalidManagedSanObject InvalidArgument 'ManagedSan' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + else + { + + Try + { + + $_resp = Send-OVRequest $ManagedSan.zonesUri -Hostname $ManagedSan.ApplianceConnection.Name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + ForEach ($_MemberZone in $_resp.members) + { + + $_ZoneObject = NewObject -FCZone + + $_ZoneObject.PSObject.TypeNames.Insert(0,'HPEOneView.Storage.ManagedSan.Zone') + + $_ZoneObject.Name = $_MemberZone.name + $_ZoneObject.State = $_MemberZone.state + $_ZoneObject.Status = $_MemberZone.status + $_ZoneObject.ManagedSan = $_MemberZone.sanName + $_ZoneObject.Created = $_MemberZone.created + $_ZoneObject.Modified = $_MemberZone.modified + $_ZoneObject.ApplianceConnection = $ManagedSan.ApplianceConnection + + Try + { + + $_Aliases = Send-OVRequest $_MemberZone.AliasesUri -Hostname $ManagedSan.ApplianceConnection.Name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + ForEach ($_AliasMember in $_Aliases.members) + { + + $_Alias = NewObject -FCAlias + + $_Alias.PSObject.TypeNames.Insert(0,'HPEOneView.Storage.ManagedSan.Zone.Alias') + + $_Alias.Name = $_AliasMember.name + $_Alias.WWN = $_AliasMember.members + + [void]$_ZoneObject.Members.Add($_Alias) + + } + + [void]$_FCZoneCollection.Add($_ZoneObject) + + } + + } + + } + + default + { + + $ExceptionMessage = "The ManagedSan resource data type '{0}' is not an PSCustomObject." -f $ManagedSan.GetType().FullName + $ErrorRecord = New-ErrorRecord HPEOneView.ManagedSanResourceException InvalidManagedSanValue InvalidArgument 'ManagedSan' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + } + + else + { + + ForEach ($_appliance in $ApplianceConnection) + { + + Try + { + + $_resp = Send-OVRequest $FcZonesUri -Hostname $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + ForEach ($_MemberZone in $_resp.members) + { + + $_ZoneObject = NewObject -FCZone + + $_ZoneObject.PSObject.TypeNames.Insert(0,'HPEOneView.Storage.ManagedSan.Zone') + + $_ZoneObject.Name = $_MemberZone.name + $_ZoneObject.State = $_MemberZone.state + $_ZoneObject.Status = $_MemberZone.status + $_ZoneObject.ManagedSan = $_MemberZone.sanName + $_ZoneObject.Created = $_MemberZone.created + $_ZoneObject.Modified = $_MemberZone.modified + $_ZoneObject.ApplianceConnection = [PSCustomObject]@{Name = $_appliance.Name; ID = $_appliance.ID} + + Try + { + + $_Aliases = Send-OVRequest $_MemberZone.AliasesUri -Hostname $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + ForEach ($_AliasMember in $_Aliases.members) + { + + $_Alias = NewObject -FCAlias + + $_Alias.PSObject.TypeNames.Insert(0,'HPEOneView.Storage.ManagedSan.Zone.Alias') + + $_Alias.Name = $_AliasMember.name + $_Alias.WWN = $_AliasMember.members + + [void]$_ZoneObject.Members.Add($_Alias) + + } + + [void]$_FCZoneCollection.Add($_ZoneObject) + + } + + } + + } + + } + + End + { + + Return $_FCZoneCollection + + } + +} + +function Get-OVDriveEnclosure +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName='Default')] + + Param + ( + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullorEmpty()] + [String]$Name, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $_DriveEnclosureCollection = [System.Collections.ArrayList]::new() + + } + + Process + { + + ForEach ($_appliance in $ApplianceConnection) + { + + if ($_appliance.ApplianceType -ne 'Composer') + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.ComposerNodeException InvalidOperation InvalidOperation 'ApplianceConnection' -Message ('The ApplianceConnection {0} is not a Synergy Composer. This Cmdlet is only supported with Synergy Composers.' -f $_appliance.Name) + $PSCmdlet.WriteError($ErrorRecord) + + } + + else + { + + if ($PSBoundParameters['Label']) + { + + $_uri = '{0}?category:drive-enclosures&query=labels:{1}' -f $IndexUri, $Label + + Try + { + + $_IndexMembers = Send-OVRequest -Uri $_uri -Hostname $_appliance + + # Loop through all found members and get full SVT object + ForEach ($_member in $_IndexMembers.members) + { + + Try + { + + $_member = Send-OVRequest -Uri $_member.uri -Hostname $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $_member.PSObject.TypeNames.Insert(0,"HPEOneView.Storage.DriveEnclosure") + + $_member.driveBays | ForEach-Object { + + $_.PSObject.TypeNames.Insert(0,"HPEOneView.Storage.DriveEnclosure.DriveBay") + + if ($_.drive) + { + + $_.drive.PSObject.TypeNames.Insert(0,'HPEOneView.Storage.DriveEnclosure.DriveBay.Drive') + + } + + } + + $_member.ioAdapters | ForEach-Object { $_.PSObject.TypeNames.Insert(0,"HPEOneView.Storage.DriveEnclosure.IoAdapter") } + + $_member + + } + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + else + { + + $uri = $DriveEnclosureUri + + if ($PSBoundParameters['Name']) + { + + $_operator = '=' + + if ([RegEx]::Match($Name, '\*|\?', $RegExInsensitiveFlag).Success) + { + + $_operator = 'matches' + + } + + $uri += "?filter=name {0} '{1}'&sort:asc" -f $_operator, $name.Replace('*','%25') + + } + + Write-Verbose ("[$($MyInvocation.InvocationName.ToString().ToUpper())] Processing {0} Connection" -f $_appliance.Name) + + "[{0}] Sending request" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $_DriveEnclosures = Send-OVRequest -uri $uri -Hostname $_appliance.Name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if ($_DriveEnclosures.count -eq 0 -and (-not ($Name))) + { + + "[{0}] No unmanaged devices found." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + elseif ($_DriveEnclosures.count -eq 0 -and $PSBoundParameters['Name']) + { + + "[{0}] No drive enclosure reousrces with name found." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $ExceptionMessage = "The '{0}' Drive Enclosure resource was not found on '{1}' Appliance. Please check the name and try again." -f $Name, $_appliance.Name + $ErrorRecord = New-ErrorRecord HPEOneView.UnmanagedDeviceResourceException UnmangedDeviceResouceNotFound ObjectNotFound 'Name' -Message $ExceptionMessage + $PSCmdlet.WriteError($ErrorRecord) + + } + + else + { + + $_DriveEnclosures.members | ForEach-Object { + + $_.PSObject.TypeNames.Insert(0,"HPEOneView.Storage.DriveEnclosure") + + $_.driveBays | ForEach-Object { + + $_.PSObject.TypeNames.Insert(0,"HPEOneView.Storage.DriveEnclosure.DriveBay") + + if ($_.drive) + { + + $_.drive.PSObject.TypeNames.Insert(0,'HPEOneView.Storage.DriveEnclosure.DriveBay.Drive') + + } + + } + + $_.ioAdapters | ForEach-Object { $_.PSObject.TypeNames.Insert(0,"HPEOneView.Storage.DriveEnclosure.IoAdapter") } + + $_ + + } + + } + + } + + } + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Get-OVAvailableDriveType +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName='Default')] + + Param + ( + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = 'Default')] + [ValidateNotNullorEmpty()] + [Object]$InputObject, + + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = 'Default')] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not $PSBoundParameters['InputObject']) + { + + $PipelineInput = $true + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not $ApplianceConnection) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + } + + Process + { + + if (($ConnectedSessions | Where-Object Name -eq $InputObject.ApplianceConnection.Name).ApplianceType -ne 'Composer') + { + + $ExceptionMessage = 'The ApplianceConnection {0} is not a Synergy Composer. This Cmdlet is only supported with Synergy Composers.' -f $ApplianceConnection.Name + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.ComposerNodeException InvalidOperation InvalidOperation 'ApplianceConnection' -Message $ExceptionMessage + $PSCmdlet.WriteError($ErrorRecord) + + } + + else + { + + switch ($InputObject.category) + { + + 'sas-logical-interconnects' + { + + $_SasLogicalInterconnect = $InputObject.PSObject.Copy() + $_TmpCollection = [System.Collections.ArrayList]::new() + + "[{0}] SAS Logical Interconnect provided: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_SasLogicalInterconnect.name | Write-Verbose + "[{0}] Getting all associated drive enclosures: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_SasLogicalInterconnect.driveEnclosureUris.count | Write-Verbose + + ForEach ($_DriveEnclosureUri in $_SasLogicalInterconnect.driveEnclosureUris) + { + + Try + { + + $_DriveEnclosure = Send-OVRequest -uri $_DriveEnclosureUri -Hostname $ApplianceConnection + + $_DriveEnclosure | Add-Member -NotePropertyName sasLogicalInterconnectName -NotePropertyValue $_SasLogicalInterconnect.name + + [void]$_TmpCollection.Add($_DriveEnclosure) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $InputObject = $_TmpCollection + + } + + 'drive-enclosures' + { + + "[{0}] Drive Enclosure provided: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject.name | Write-Verbose + + $_uri = "{0}?category=sas-logical-interconnects&start=0&count=-1&name=DRIVE_ENCLOSURE_TO_SAS_LOGICAL_INTERCONNECT&parentUri={1}" -f $IndexAssociatedResourcesUri, $InputObject.uri + + Try + { + + $_associatedogicalInterconnect = Send-OVRequest -uri $_uri -Hostname $ApplianceConnection + + $InputObject | Add-Member -NotePropertyName sasLogicalInterconnectName -NotePropertyValue $_associatedogicalInterconnect.members[0].childResource.name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + # //TODO: Need to enhance this to support server hardware or server profiles that will then report available drives from the potential SAS LI's, and map to + # specific mezz adapters. + # Should this also be tied to a SPT? Need to figure out the flow to discover. + + default + { + + # Generate error due to invalid object + if ($Inputobject -is [PSCustomObject]) + { + + $_InputObjectName = $InputObject.name + + } + + else + { + + $_InputObjectName = $InputObject + + } + + $ExceptionMessage = "The specified '{0}' InputObject parameter value is not supported type. Only SAS Logical Interconnect or Disk Drive resources are allowed." -f $_InputObjectName + $ErrorRecord = New-ErrorRecord HPEOneView.InputObjectResourceException InvalidInputObjectResource InvalidArgument "InputObject" -TargetType $InputObject.GetType().Name -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + ForEach ($_DriveEnclosure in $InputObject) + { + + "[{0}] Processing drive enclosure: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_DriveEnclosure.name | Write-Verbose + + $_uri = "{0}?category=drives&start=0&count=-1&userQuery='{1} AND available=yes'" -f $IndexUri, $_DriveEnclosure.uri + + Try + { + + $_AvailableDrives = Send-OVRequest -uri $_uri -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $_TempDriveCollection = [System.Collections.ArrayList]::new() + + ForEach ($_MemberDrive in $_AvailableDrives.members) + { + + $_AvailableDrive = $null + + '[{0}] Collecting: {1} Type {2} Capacity' -f $MyInvocation.InvocationName.ToString().ToUpper(), ($_MemberDrive.attributes.interfaceType + $_MemberDrive.attributes.mediaType), $_MemberDrive.attributes.capacityInGb | Write-Verbose + + # Filter for the number of drives based on combined interfaceType and interfaceMedia + [Array]$NumberOfDrives = $_AvailableDrives.members | Where-Object { $_.attributes.interfaceType -eq $_MemberDrive.attributes.interfaceType -and $_.attributes.mediaType -eq $_MemberDrive.attributes.mediaType -and $_.attributes.capacityInGb -eq $_MemberDrive.attributes.capacityInGb } + + # Create temporary drive object to store values for compare and new object + $_DriveAttributes = [PSCustomObject]@{Type = ($_MemberDrive.attributes.interfaceType + $_MemberDrive.attributes.mediaType); Count = $NumberOfDrives.Count; Capacity = [Convert]::ToInt32($_MemberDrive.attributes.capacityInGb)} + + if ((-not ($_TempDriveCollection.Type | Where-Object { $_ -contains $_DriveAttributes.Type})) -or (($_TempDriveCollection.Type | Where-Object { $_ -contains $_DriveAttributes.Type}) -and -not ($_TempDriveCollection | Where-Object { $_.Capacity -contains $_DriveAttributes.Capacity}))) + { + + '[{0}] Adding drive type {1} and capacity {2} to collection' -f $MyInvocation.InvocationName.ToString().ToUpper(), $_DriveAttributes.Type, $_DriveAttributes.Capacity | Write-Verbose + + $_AvailableDrive = [HPEOneView.Storage.AvailableDriveType]::new($_DriveAttributes.Type, + $_DriveAttributes.Capacity, + $_DriveAttributes.Count, + $_DriveEnclosure.name, + $_DriveEnclosure.sasLogicalInterconnectName, + $_DriveEnclosure.ApplianceConnection) + + [Void]$_TempDriveCollection.Add($_AvailableDrive) + + } + + } + + $_TempDriveCollection | Sort-Object Type, Capacity + + } + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function BuildDrive +{ + + [CmdletBinding (DefaultParameterSetName='Default')] + + Param + ( + + [Parameter (Mandatory, ParameterSetName = 'Default')] + [ValidateNotNullorEmpty()] + [Object]$Drive, + + [Parameter (Mandatory, ParameterSetName = 'Default')] + [ValidateNotNullorEmpty()] + [Object]$DriveEnclosure, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullorEmpty()] + [Object]$AssociatedLogicalJBOD + + ) + + if ($PSBoundParameters['AssociatedLogicalJBOD']) + { + + return [HPEOneView.Storage.Drive]::new($Drive.name, + $Drive.state, + $Drive.status, + $DriveEnclosure.name, + $DriveEnclosure.uri, + $Drive.serialNumber, + $Drive.model, + $Drive.deviceInterface, + $Drive.driveMedia, + $Drive.capacity, + $AuthenticDriveEnum[$Drive.authentic], + $Drive.firmwareVersion, + $Drive.linkRateInGbs, + $Drive.drivePaths, + $Drive.blockSize, + $Drive.rotationalRpms, + $Drive.wwid, + $Drive.eraseSupport, + $Drive.eraseStatus, + $Drive.tempurature, + $AssociatedLogicalJBOD.name, + $AssociatedLogicalJBOD.uri, + $Drive.driveBayUri, + $DriveEnclosure.SasLogicalInterconnect.name, + $DriveEnclosure.SasLogicalInterconnect.uri, + $DriveEnclosure.ApplianceConnection) + + } + + else + { + + return [HPEOneView.Storage.Drive]::new($Drive.name, + $Drive.state, + $Drive.status, + $DriveEnclosure.name, + $DriveEnclosure.uri, + $Drive.serialNumber, + $Drive.model, + $Drive.deviceInterface, + $Drive.driveMedia, + $Drive.capacity, + $AuthenticDriveEnum[$Drive.authentic], + $Drive.firmwareVersion, + $Drive.linkRateInGbs, + $Drive.drivePaths, + $Drive.blockSize, + $Drive.rotationalRpms, + $Drive.wwid, + $Drive.eraseSupport, + $Drive.eraseStatus, + $Drive.tempurature, + $Drive.driveBayUri, + $DriveEnclosure.SasLogicalInterconnect.name, + $DriveEnclosure.SasLogicalInterconnect.uri, + $DriveEnclosure.ApplianceConnection) + + } + +} + +function Get-OVDriveEnclosureInventory +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName='Default')] + [OutputType([HPEOneView.Storage.Drive])] + Param + ( + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [Parameter (Mandatory = $false, ParameterSetName = 'Assigned')] + [ValidateNotNullorEmpty()] + [String]$Name, + + [Parameter (Mandatory = $false, ValueFromPipeline, ParameterSetName = 'Default')] + [Parameter (Mandatory = $false, ValueFromPipeline, ParameterSetName = 'Assigned')] + [ValidateScript({if ($ResourceCategoryEnum.DriveEnclosure -ne $_.category) { Throw 'The provided DriveEnclosure value is not a valid HPE Synergy Drive Enclosure.' } else { $True }})] + [Object]$DriveEnclosure, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [Parameter (Mandatory = $false, ParameterSetName = 'Assigned')] + [ValidateScript({if ($ResourceCategoryEnum.SasLogicalInterconnect -ne $_.category) { Throw 'The provided DriveEnclosure value is not a valid HPE Synergy SAS Logical Interconnect.' } else { $True }})] + [Object]$SasLogicalInterconnect, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullorEmpty()] + [Int]$Count, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullorEmpty()] + [Switch]$Available, + + [Parameter (Mandatory = $false, ParameterSetName = 'Assigned')] + [ValidateNotNullorEmpty()] + [Switch]$Assigned, + + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = 'Default')] + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = 'Assigned')] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not $PSBoundParameters['InputObject']) + { + + $PipelineInput = $true + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not $ApplianceConnection) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + } + + Process + { + + ForEach ($_appliance in $ApplianceConnection) + { + + $FinalDrivesCollection = [System.Collections.ArrayList]::new() + + "[{0}] Processing appliance {1} (of {2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name, $ApplianceConnection.Count | Write-Verbose + + $_Cache = [System.Collections.ArrayList]::new() + $_Query = [System.Collections.ArrayList]::new() + $_UserQUery = $_Count = $null + + # To support SASLI, user should supply SASLI Object + if ($PSBoundParameters['SasLogicalInterconnect']) + { + + $AllDrives = @{ members = [System.Collections.ArrayList]::new() } + + Try + { + + # Get associated Drive Enclosures with SASLI + $Uri = '{0}?name=DRIVE_ENCLOSURE_TO_SAS_LOGICAL_INTERCONNECT&childUri={1}' -f $AssociationsUri, $SasLogicalInterconnect.uri + $associatedDriveEnclosures = Get-AllIndexResources -Uri $Uri -ReturnParent -ApplianceConnection $_appliance + + ForEach ($_driveEnclosure in $associatedDriveEnclosures) + { + + $_driveEnclosure | Add-Member -NotePropertyName SasLogicalInterconnect -NotePropertyValue $associatedSasLI + + # Ddding Enclosure and SASLI to cache + [void]$_Cache.Add($_driveEnclosure) + + # Build $AllDrives collection from every Enclosure + # Maybe use -Match or [RegEx]::Match() to support $PSBoundParameter['Name'] filtering? + ForEach ($driveBay in $_driveEnclosure.driveBays) + { + + $driveUriStringArray = $driveBay.drive.uri.Split("/") + $driveBay.drive.uri = "/rest/{0}/{1}" -f $driveUriStringArray[-2], $driveUriStringArray[-1] + + $driveBay.drive | Add-Member -NotePropertyName attributes -NotePropertyValue @{ driveEnclosureUri = $_driveEnclosure.uri } + $driveBay.drive | Add-Member -NotePropertyName driveBayUri -NotePropertyValue $driveBay.uri + + [void]$AllDrives.members.Add($driveBay.drive) + + } + + } + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + else + { + + if ($PSBoundParameters['Name']) + { + + "[{0}] Filtering for Name: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Name | Write-Verbose + + if ($Name.Contains('*')) + { + + [Void]$_Query.Add(("name%3A{0}" -f $Name.Replace("*", "%2A").Replace(',','%2C').Replace(" ", "?"))) + + } + + else + { + + [Void]$_Query.Add(("name:'{0}'" -f $Name)) + + } + + } + + if ($PSBoundParameters['DriveEnclosure']) + { + + "[{0}] Filtering for drive enclosure: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $DriveEnclosure.name | Write-Verbose + + $_UserQuery = "&userQuery='{0}'" -f $DriveEnclosure.uri + + } + + if ($PSBoundParameters['Count']) + { + + "[{0}] Filtering for number of drives: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Count | Write-Verbose + + $_Count = "&count={0}" -f $Count + + } + + $_Category = 'category={0}' -f $ResourceCategoryEnum.Drive + + # Build the final URI + $_uri = '{0}?{1}&sort=name:asc&query={2}{3}{4}' -f $IndexUri, [String]::Join('&', $_Category), [String]::Join(' AND ', $_Query.ToArray()), $_UserQuery, $_Count + + Try + { + + $AllDrives = Send-OVRequest -Uri $_uri -Hostname $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + # Then rest of the logic is fine + ForEach ($drive in ($AllDrives.members | Sort-Object $DriveCollectionSortExpression)) + { + + # Resource is not in cache + if (-not ($_Cache | ? uri -eq $drive.attributes.driveEnclosureUri)) + { + + "[{0}] Drive Enclosure is not cache." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + # Get associated driveEnclosure + Try + { + + $associatedDriveEnclosure = Send-OVRequest -Uri $drive.attributes.driveEnclosureUri -Hostname $_appliance + + # Get the associated SAS LI + $Uri = '{0}?name=DRIVE_ENCLOSURE_TO_SAS_LOGICAL_INTERCONNECT&parentUri={1}' -f $AssociationsUri, $associatedDriveEnclosure.uri + $associatedSasLI = Get-AllIndexResources -Uri $Uri -ApplianceConnection $_appliance + + $associatedDriveEnclosure | Add-Member -NotePropertyName SasLogicalInterconnect -NotePropertyValue $associatedSasLI + + [void]$_Cache.Add($associatedDriveEnclosure) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + else + { + + "[{0}] Drive Enclosure is in cache." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $associatedDriveEnclosure = $_Cache | ? uri -eq $drive.attributes.driveEnclosureUri + + } + + if ($drive.type -ne $DriveType) + { + + $associatedDriveBay = $associatedDriveEnclosure.driveBays | ? { $_.drive.name -eq $drive.name } + + $associatedDriveBay.drive | Add-Member -NotePropertyName driveBayUri -NotePropertyValue $associatedDriveBay.uri + + $fullDriveDetails = $associatedDriveBay.drive + + } + + else + { + + $fullDriveDetails = $drive + + } + + # Get the physical drive drive bay association + Try + { + + $uri = '{0}?name=DRIVE_BAY_TO_DRIVE_ASSOC&childUri={1}' -f $AssociationsUri, $drive.uri + $DriveBayAssociationUri = (Send-OVRequest -Uri $uri -Hostname $_appliance).members.parentUri + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + # Look for drive bay to ljbod association to indicate the drive is in use + # This is for all SY generations + Try + { + + $uri = '{0}?name=SAS_LOGICAL_JBOD_TO_DRIVEBAYS_ASSOCIATION&childUri={1}' -f $AssociationsUri, $DriveBayAssociationUri + $AssociatedLJbodUri = (Send-OVRequest -Uri $uri -Hostname $_appliance).members.parentUri + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if (($PSBoundParameters['Available'] -and [String]::IsNullOrEmpty($AssociatedLJbodUri)) -or (-not $PSBoundParameters['Assigned'] -and [String]::IsNullOrEmpty($AssociatedLJbodUri))) + { + + "[{0}] Drive is not associated with a Logical JBOD." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + BuildDrive -Drive $fullDriveDetails -DriveEnclosure $associatedDriveEnclosure + + } + + elseif (($PSBoundParameters['Assigned'] -and -not [String]::IsNullOrEmpty($AssociatedLJbodUri)) -or (-not [String]::IsNullOrEmpty($AssociatedLJbodUri) -and -not $PSBoundParameters['Available'])) + { + + "[{0}] Drive is associated with a Logical JBOD. Getting LJBOD object." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + # Resource is not in cache + if (-not ($_Cache | ? uri -eq $AssociatedLJbodUri)) + { + + "[{0}] Logical JBOD is not cache." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + # Get associated driveEnclosure + Try + { + + $AssociatedLJbod = Send-OVRequest -Uri $AssociatedLJbodUri -Hostname $_appliance + + [void]$_Cache.Add($AssociatedLJbod) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + else + { + + "[{0}] Logical JBOD is in cache." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $AssociatedLJbod = $_Cache | ? uri -eq $AssociatedLJbodUri + + } + + BuildDrive -Drive $fullDriveDetails -DriveEnclosure $associatedDriveEnclosure -AssociatedLogicalJBOD $AssociatedLJbod + + } + + } + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Get-OVLogicalJBOD +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName='Default')] + [OutputType ([HPEOneView.Storage.LogicalJBOD])] + Param + ( + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullorEmpty()] + [String]$Name, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [ValidateNotNullOrEmpty()] + [Object]$Scope = "AllResourcesInScope", + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [String]$Label, + + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = 'Default')] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not $PSBoundParameters['InputObject']) + { + + $PipelineInput = $true + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not $ApplianceConnection) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + } + + Process + { + + ForEach ($_appliance in $ApplianceConnection) + { + + "[{0}] Processing appliance {1} (of {2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name, $ApplianceConnection.Count | Write-Verbose + + $_Query = [System.Collections.ArrayList]::new() + + # Handle default cause of AllResourcesInScope + if ($Scope -eq 'AllResourcesInScope') + { + + "[{0}] Processing AllResourcesInScope." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_Scopes = $_appliance.ActivePermissions | Where-Object Active + + # If one scope contains 'AllResources' ScopeName "tag", then all resources should be returned regardless. + if ($_Scopes | Where-Object ScopeName -eq 'AllResources') + { + + $_ScopeNames = [String]::Join(', ', ($_Scopes | Where-Object ScopeName -eq 'AllResources').ScopeName) + + "[{0}] Scope(s) {1} is set to 'AllResources'. Will not add scope to URI query parameter." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_ScopeNames | Write-Verbose + + } + + # Process ApplianceConnection ActivePermissions collection + else + { + + Try + { + + $_ScopeQuery = Join-Scope $_Scopes + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + [Void]$_Query.Add(("({0})" -f $_ScopeQuery)) + + } + + } + + elseif ($Scope | Where-Object ScopeName -eq 'AllResources') + { + + $_ScopeNames = [String]::Join(', ', ($_Scopes | Where-Object ScopeName -eq 'AllResources').ScopeName) + + "[{0}] Scope(s) {1} is set to 'AllResources'. Will not add scope to URI query parameter." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_ScopeNames | Write-Verbose + + } + + elseif ($Scope -eq 'AllResources') + { + + "[{0}] Requesting scope 'AllResources'. Will not add scope to URI query parameter." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_ScopeNames | Write-Verbose + + } + + else + { + + Try + { + + $_ScopeQuery = Join-Scope $Scope + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + [Void]$_Query.Add(("({0})" -f $_ScopeQuery)) + + } + + if ($Name) + { + + "[{0}] Filtering for Name: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Name | Write-Verbose + + if ($Name.Contains('*')) + { + + [Void]$_Query.Add(("name%3A{0}" -f $Name.Replace("*", "%2A").Replace(',','%2C').Replace(" ", "?"))) + + } + + else + { + + [Void]$_Query.Add(("name:'{0}'" -f $Name)) + + } + + } + + if ($Label) + { + + "[{0}] Filtering for Label: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Label | Write-Verbose + + [Void]$_Query.Add(("labels:'{0}'" -f $Label)) + + } + + $_Category = 'category={0}' -f $ResourceCategoryEnum.LogicalJBOD + + # Build the final URI + $_uri = '{0}?{1}&sort=name:asc&query={2}' -f $IndexUri, [String]::Join('&', $_Category), [String]::Join(' AND ', $_Query.ToArray()) + + Try + { + + [Array]$_ResourcesFromIndexCol = Get-AllIndexResources -Uri $_uri -ApplianceConnection $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if ($_ResourcesFromIndexCol.Count -eq 0) + { + + if ($Name) + { + + "[{0}] '{1}' LogicalJBOD found." -f $MyInvocation.InvocationName.ToString().ToUpper(), $Name | Write-Verbose + + $ExceptionMessage = "No LogicalJBOD with '{0}' name found on '{1}' appliance connection. Please check the name or use New-OVStorageVolume to create the volume." -f $Name, $_appliance.Name + $ErrorRecord = New-ErrorRecord HPEOneView.StorageVolumeResourceException StorageVolumeResourceNotFound ObjectNotFound 'Name' -Message $ExceptionMessage + $PSCmdlet.WriteError($ErrorRecord) + + } + + else + { + + "[{0}] No LogicalJBODs found." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + } + + else + { + + ForEach ($_member in $_ResourcesFromIndexCol) + { + + $drives = [System.Collections.Generic.List[HPEOneView.Storage.Drive]]::new() + + # Get associated Server Profile Attachment, if one exists + Try + { + + $associatedServerProfileAttachment = $null + + $Uri = '{0}?childUri={1}&name=SAS_LJBOD_ATTACHMENT_TO_SAS_LJBOD_ASSOCIATION' -f $AssociationsUri, $_member.uri + $associatedLJBODAttachment = Get-AllIndexResources -Uri $Uri -ReturnParent -ApplianceConnection $_appliance + + if ($null -ne $associatedLJBODAttachment) + { + + $associatedServerProfileAttachment = Send-OVRequest -Uri $associatedLJBODAttachment.serverProfileUri -Hostname $_appliance + + } + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + Try + { + + $Uri = "{0}?parentUri={1}&name=SAS_LOGICAL_JBOD_TO_DRIVEBAYS_ASSOCIATION" -f $AssociationsUri, $_member.uri + $LogicalDrives = Send-OVRequest -Uri $Uri -Hostname $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + # Loop through members to get the drive enclosure + ForEach ($logicalDrive in $LogicalDrives.members) + { + + $driveBayUri = $logicalDrive.childUri + + # Loop through each logical drive, childUri, and then get the associated drive enclosure + Try + { + + $Uri = "{0}?childUri={1}&name=DRIVE_ENCLOSURE_TO_DRIVE_BAY_ASSOC" -f $AssociationsUri, $logicalDrive.childUri + + $associatedDriveEnclosure = Get-AllIndexResources -Uri $Uri -ReturnParent -ApplianceConnection $_appliance + + # Get the associated SAS LI + $Uri = '{0}?name=DRIVE_ENCLOSURE_TO_SAS_LOGICAL_INTERCONNECT&parentUri={1}' -f $AssociationsUri, $associatedDriveEnclosure.uri + $associatedSasLI = Get-AllIndexResources -Uri $Uri -ApplianceConnection $_appliance + + $associatedDriveEnclosure | Add-Member -NotePropertyName SasLogicalInterconnect -NotePropertyValue $associatedSasLI + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + # Now, locate the drive in driveBays + $drive = ($associatedDriveEnclosure.driveBays | ? uri -eq $logicalDrive.childUri).drive + + $drive | Add-Member -NotePropertyName driveBayUri -NotePropertyValue $driveBayUri + + $driveClassObject = BuildDrive -Drive $drive -DriveEnclosure $associatedDriveEnclosure -AssociatedLogicalJBOD $_member + + [void]$drives.Add($driveClassObject) + + } + + [HPEOneView.Storage.LogicalJBOD]::new($_member.name, + $_member.state, + $_member.stateReason, + $_member.refreshState, + $_member.status, + $_member.numPhysicalDrives, + $_member.minSizeGB, + $_member.maxSizeGB, + $_member.driveTechnology.deviceInterface, + $_member.driveTechnology.driveMedia, + $Drives, + $_member.eraseData, + $_member.etag, + $_member.created, + $_member.modified, + $associatedServerProfileAttachment.name, + $associatedServerProfileAttachment.uri, + $_member.uri, + $_member.scopesUri, + $_member.applianceConnection) + + } + + } + + + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function New-OVLogicalJBOD +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName='DriveType')] + Param + ( + + [Parameter (Mandatory, ParameterSetName = 'DriveType')] + [Parameter (Mandatory, ParameterSetName = 'DriveSizeAndTechnology')] + [Parameter (Mandatory, ParameterSetName = 'SpcificDrives')] + [ValidateNotNullorEmpty()] + [String]$Name, + + [Parameter (Mandatory = $false, ParameterSetName = 'DriveType')] + [Parameter (Mandatory = $false, ParameterSetName = 'DriveSizeAndTechnology')] + [Parameter (Mandatory = $false, ParameterSetName = 'SpcificDrives')] + [ValidateNotNullorEmpty()] + [String]$Description, + + [Parameter (Mandatory, ParameterSetName = "DriveType")] + [Parameter (Mandatory, ParameterSetName = "DriveSizeAndTechnology")] + [Alias ('SasLogicalInterconnect', 'Enclosure', 'Frame')] + [Object]$InputObject, + + [Parameter (Mandatory = $false , ParameterSetName = "DriveType")] + [Parameter (Mandatory = $false , ParameterSetName = "DriveSizeAndTechnology")] + [ValidateNotNullOrEmpty()] + [Int]$NumberofDrives = 1, + + [Parameter (Mandatory, ParameterSetName = "DriveType")] + [ValidateSet ('SAS', 'SATA', 'SASSSD', 'SATASSD')] + [String]$DriveType = 'SAS', + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = "DriveSizeAndTechnology")] + [ValidateNotNullOrEmpty()] + [HPEOneView.Storage.AvailableDriveType]$AvailableDriveType, + + [Parameter (Mandatory = $false, ParameterSetName = "DriveType")] + [ValidateNotNullOrEmpty()] + [Int]$MinDriveSize, + + [Parameter (Mandatory = $False, ParameterSetName = "DriveType")] + [ValidateNotNullOrEmpty()] + [Int]$MaxDriveSize, + + [Parameter (Mandatory = $false, ParameterSetName = 'SpcificDrives')] + [ValidateNotNullorEmpty()] + [HPEOneView.Storage.Drive[]]$Drives, + + [Parameter (Mandatory = $False, ParameterSetName = "DriveType")] + [Parameter (Mandatory = $False, ParameterSetName = "DriveSizeAndTechnology")] + [Parameter (Mandatory = $False, ParameterSetName = "SpcificDrives")] + [ValidateNotNullOrEmpty()] + [Bool]$EraseDataOnDelete = $false, + + [Parameter (Mandatory = $False, ParameterSetName = "DriveType")] + [Parameter (Mandatory = $False, ParameterSetName = "DriveSizeAndTechnology")] + [Parameter (Mandatory = $False, ParameterSetName = "SpcificDrives")] + [ValidateNotNullOrEmpty()] + [HPEOneView.Appliance.ScopeCollection[]]$Scope, + + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = 'Default')] + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = 'DriveSizeAndTechnology')] + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = 'SpcificDrives')] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not $ApplianceConnection) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + Process + { + + # Need to check if appliance connection is Composer + + if ($ApplianceConnection.ApplianceType -ne 'Composer') + { + + $ExceptionMessage = 'The ApplianceConnection {0} is an HPE OneView Virtual Machine Appliance, which does not support SAS Logical resources.' -f $ApplianceConnection + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.ComposerNodeException InvalidOperation InvalidOperation 'ApplianceConnection' -Message $ExceptionMessage + $PSCmdlet.WriteError($ErrorRecord) + + } + + else + { + + Switch ($PSCmdlet.ParameterSetName) + { + + {'DriveType', 'DriveSizeAndTechnology' -contains $_} + { + + $_NewLogicalJBOD = NewObject -LogicalSASJbod + + $_NewLogicalJBOD.numPhysicalDrives = $NumberofDrives + + if ($PSCmdlet.ParameterSetName -eq 'DriveType') + { + + $_NewLogicalJBOD.minSizeGB = $MinDriveSize + $_NewLogicalJBOD.maxSizeGB = if (-not $PSBoundParameters['MaxDriveSize']) { $MinDriveSize } Else { $MaxDriveSize } + $_NewLogicalJBOD.driveTechnology.deviceInterface = $LogicalDriveInterfaceEnum.$DriveType + $_NewLogicalJBOD.driveTechnology.driveMedia = $LogicalDriveMediaEnum.$DriveType + + } + + else + { + + $_NewLogicalJBOD.minSizeGB = $AvailableDriveType.MinDriveSize + $_NewLogicalJBOD.maxSizeGB = $AvailableDriveType.MaxDriveSize + $_NewLogicalJBOD.driveTechnology.deviceInterface = $AvailableDriveType.DriveType + $_NewLogicalJBOD.driveTechnology.driveMedia = $AvailableDriveType.Media # NEED TO VALIDATE + + } + + # Process SAS LI and Enclosure + ForEach ($item in $InputObject) + { + + if ($item.category -eq $ResourceCategoryEnum.Enclosure) + { + + ForEach ($deviceBay in ($InputObject.deviceBays | ? uri -match $DriveEnclosureUri)) + { + + # Do not add the URI again, if the drive enclosure has already been added + if (-not $_NewLogicalJBOD.driveEnclosureUris.Contains($deviceBay.deviceUri)) + { + + [void]$_NewLogicalJBOD.driveEnclosureUris.Add($deviceBay.deviceUri) + + } + + } + + if ($_NewLogicalJBOD.driveEnclosureUris.Count -eq 0) + { + + $ExceptionMessage = "The provided Synergy Frame '{0}' does not contain any SAS drive enclosures." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + elseif ($item.category -eq $ResourceCategoryEnum.SasLogicalInterconnect) + { + + ForEach ($driveEnclUri in $item.driveEnclosureUris) + { + + [void]$_NewLogicalJBOD.driveEnclosureUris.Add($driveEnclUri) + + } + + } + + elseif ($item.category -eq $ResourceCategoryEnum.DriveEnclosure) + { + + [void]$_NewLogicalJBOD.driveEnclosureUris.Add($item.uri) + + } + + else + { + + $ExceptionMessage = "The provided item '{0}' in -InputObjects parameter is not a valid SAS Logical Interconnect or Enclosure device" + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + } + + } + + $_NewLogicalJBOD.eraseData = $EraseDataOnDelete + + } + + 'SpcificDrives' + { + + $_NewLogicalJBOD = NewObject -LogicalSASJbodSpecificDrives + + ForEach ($drive in $Drives) + { + + # Throw error that the drive is already allocated to an existing LogicalJBOD + if (-not [String]::IsNullOrEmpty($drive.LogicalJbodName)) + { + + $ExceptionMessage = "Drive '{1}' is already assigned to '{2}' LogicalJBOD." -f $drive.Name, $drive.LogicalJBODName + + "[{0}] {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $ExceptionMessage | Write-Verbose + + $ErrorRecord = New-ErrorRecord HPEOneView.Library.ParameterValidationException InvalidDrivesParameter InvalidOperation 'Drives' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + if ($PSBoundParameters['EraseDataOnDelete']) + { + + if ($drive.EraseSupport) + { + + $_NewLogicalJBOD.eraseData = $EraseDataOnDelete + + } + + else + { + + "[{0}] Drive '{1}' does not support erase data on delete policy." -f $MyInvocation.InvocationName.ToString().ToUpper(), $drive.Name | Write-Verbose + + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + "[{0}] Adding drive '{1} ({2})' to logical JBOD." -f $MyInvocation.InvocationName.ToString().ToUpper(), $drive.Name, $drive.DriveBayUri | Write-Verbose + + [void]$_NewLogicalJBOD.driveBayUris.Add($drive.DriveBayUri) + + } + + } + + } + + if ($PSBoundParameters['Scope']) + { + + ForEach ($_scope in $Scope) + { + + "[{0}] Adding logical JBOD to scope '{1} ({2})'." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_scope.Name, $_scope.Uri | Write-Verbose + + [void]$_NewLogicalJBOD.initialScopeUris.Add($_scope.Uri) + + } + + } + + $_NewLogicalJBOD.name = $Name + $_NewLogicalJBOD.description = $Description + + Try + { + + Send-OVRequest -Uri $SasLogicalJBODUri -Method POST -Body $_NewLogicalJBOD -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Set-OVLogicalJBOD +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "default")] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = "default")] + [ValidateNotNullOrEmpty()] + [HPEOneView.Storage.LogicalJBOD[]]$InputObject, + + [Parameter (Mandatory = $false, ParameterSetName = "default")] + [Switch]$DisableEraseData, + + [Parameter (Mandatory = $false, ParameterSetName = "default")] + [Switch]$ClearMetadata, + + [Parameter (Mandatory = $false, ParameterSetName = "default")] + [Switch]$Async, + + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = "default")] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not($PSBoundParameters['InputObject'])) + { + + $PipelineInput = $True + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + $_PowerDeviceCollection = [System.Collections.ArrayList]::new() + + } + + Process + { + + "[{0}] Begin resource removal process." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + foreach ($_resource in $InputObject) + { + + $_patchOperations = [System.Collections.ArrayList]::new() + + if ($PSBoundParameters['DisableEraseData']) + { + + $_patchOperation = NewObject -PatchOperation + $_patchOperation.op = "replace" + $_patchOperation.path = "/eraseData" + $_patchOperation.value = $false + + [void]$_patchOperations.Add($_patchOperation) + + } + + if ($PSBoundParameters['ClearMetadata']) + { + + $_patchOperation = NewObject -PatchOperation + $_patchOperation.op = "replace" + $_patchOperation.path = "/clearMetadata" + $_patchOperation.value = $true + + [void]$_patchOperations.Add($_patchOperation) + + } + + if ($_patchOperations.Count -gt 0) + { + + Try + { + + $_task = Send-OVRequest -Uri $_resource.uri -Method PATCH -Body $_patchOperations -AddHeader @{'If-Match' = $_resource.eTag } -Hostname $_resource.ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if ($PSBoundParameters['Async']) + { + + $_task + + } + + else + { + + $_task | Wait-OVTaskComplete + + } + + } + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Remove-OVLogicalJBOD +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "default", SupportsShouldProcess,ConfirmImpact = 'High')] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = "default")] + [ValidateNotNullOrEmpty()] + [HPEOneView.Storage.LogicalJBOD[]]$InputObject, + + [Parameter (Mandatory = $false, ParameterSetName = "default")] + [Switch]$Force, + + [Parameter (Mandatory = $false, ParameterSetName = "default")] + [Switch]$Async, + + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = "default")] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not($PSBoundParameters['InputObject'])) + { + + $PipelineInput = $True + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + $_PowerDeviceCollection = [System.Collections.ArrayList]::new() + + } + + Process + { + + "[{0}] Begin resource removal process." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + foreach ($_resource in $InputObject) + { + + Write-Warning "Deleting this logical JBOD may result in data loss. To preserve this data (if any), backup the drives before deleting." + + if ($PSCmdlet.ShouldProcess($_resource.name, "Remove from appliance '$($_resource.ApplianceConnection)'")) + { + + Try + { + + $_task = Send-OVRequest -Uri $_resource.uri -Method DELETE -AddHeader @{'If-Match' = $_resource.eTag } -Hostname $_resource.ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if ($PSBoundParameters['Async']) + { + + $_task + + } + + else + { + + $_task | Wait-OVTaskComplete + + } + + } + + elseif ($PSBoundParameters['WhatIf']) + { + + "[{0}] Caller passed -WhatIf Parameter." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + else + { + + "[{0}] Caller selected NO to confirmation prompt." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +####################################################### +# Unmanaged Devices: +# + +function Get-OVUnmanagedDevice +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName='Default')] + + Param + ( + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullorEmpty()] + [String]$Name, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [Alias ('report')] + [Switch]$List, + + [Parameter (Mandatory = $false)] + [ValidateNotNullOrEmpty()] + [String]$Label, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + if ($PSBoundParameters['List']) + { + + Write-Warning "The List Parameter has been deprecated. The CMDLET will now display object data in Format-List view." + + } + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $_UnmanagedDevicesCollection = [System.Collections.ArrayList]::new() + + $uri = $UnmanagedDevicesUri + + if ($PSBoundParameters['Name']) + { + + if ($Name.Contains('*')) + { + + $uri += "&filter=name matches '{0}'" -f $Name.Replace('*','%25') + + } + + else + { + + $uri += "&filter=name EQ '{0}'" -f $Name + + } + + } + + } + + Process + { + + ForEach ($_appliance in $ApplianceConnection) + { + + if ($PSBoundParameters['Label']) + { + + $_uri = '{0}?category:unmanaged-devices&query=labels:{1}' -f $IndexUri, $Label + + Try + { + + $_IndexMembers = Send-OVRequest -Uri $_uri -Hostname $_appliance + + # Loop through all found members and get full SVT object + ForEach ($_member in $_IndexMembers.members) + { + + Try + { + + $_member = Send-OVRequest -Uri $_member.uri -Hostname $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $_member.PSObject.TypeNames.Insert(0,'HPEOneView.UnmanagedResource') + + $_member + + } + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + else + { + + "[{0}] Sending request" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $_UnmanagedDevices = Send-OVRequest $uri -Hostname $_appliance.Name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if ($_UnmanagedDevices.count -eq 0 -and (-not($Name))) + { + + "[{0}] No unmanaged devices found." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + elseif ($_UnmanagedDevices.count -eq 0 -and $Name) + { + + + "[{0}] No unmanaged devices with name found." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $ExceptionMessage = "The '{0}' Unmanaged Device resource was not found on '{1}' Appliance. Please check the name and try again." -f $Name, $_appliance.Name + $ErrorRecord = New-ErrorRecord HPEOneView.UnmanagedDeviceResourceException UnmangedDeviceResouceNotFound ObjectNotFound 'Name' -Message $ExceptionMessage + $PSCmdlet.WriteError($ErrorRecord) + + } + + else + { + + $_UnmanagedDevices.members | ForEach-Object { + + $_.PSObject.TypeNames.Insert(0,"HPEOneView.UnmanagedResource") + + $_ + + } + + } + + } + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function New-OVUnmanagedDevice +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName='Default')] + + Param + ( + + [Parameter (Mandatory, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [String]$Name, + + [Parameter (Mandatory, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [String]$Model, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [Int]$Height = 1, + + [Parameter (Mandatory, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [Int]$MaxPower, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [String]$MacAddress, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateScript({if (-not([Net.IPAddress]::TryParse($_,[ref]$null))) { Throw 'The provided IPv4Address value does not appear to be a valid IPv4 Address.' } else { $True }})] + [String]$IPv4Address, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateScript({if (-not([Net.IPAddress]::TryParse($_,[ref]$null))) { Throw 'The provided IPv6Address value does not appear to be a valid IPv6 Address.' } else { $True }})] + [String]$IPv6Address, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $_UnmanagedDeviceCreateResults = [System.Collections.ArrayList]::new() + } + + Process + { + + $_NewDevice = NewObject -UnmanagedDevice + + [String]$_NewDevice.name = $Name + [String]$_NewDevice.model = $Model + [Int]$_NewDevice.height = $Height + [String]$_NewDevice.mac = $MacAddress + [String]$_NewDevice.IPv4Address = $IPv4Address + [String]$_NewDevice.IPv6Address = $IPv6Address + [Int]$_NewDevice.maxPwrConsumed = $MaxPower + + # "[{0}] New Unmanaged Device: $($newDevice)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + "[{0}] Sending request" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $_resp = Send-OVRequest -Uri $unmanagedDevicesUri -Method POST -Body $_NewDevice -Hostname $ApplianceConnection.Name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $_resp | ForEach-Object { $_.PSObject.TypeNames.Insert(0,"HPEOneView.UnmanagedResource") } + + [void]$_UnmanagedDeviceCreateResults.Add($_resp) + + } + + End + { + + Return $_UnmanagedDeviceCreateResults + + } + +} + +function Remove-OVUnmanagedDevice +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "default",SupportsShouldProcess,ConfirmImpact = 'High')] + + Param + ( + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = "default")] + [ValidateNotNullOrEmpty()] + [Alias ("uri","name")] + [object]$UnmanagedDevice, + + [Parameter (Mandatory = $false, ParameterSetName = "default")] + [Switch]$force, + + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = "default")] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not($PSBoundParameters['UnmanagedDevice'])) + { + + $PipelineInput = $True + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + $_TaskCollection = [System.Collections.ArrayList]::new() + $_UnmanagedDeviceCollection = [System.Collections.ArrayList]::new() + + } + + Process + { + + if ($PipelineInput) + { + + "[{0}] Processing Pipeline input" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + "[{0}] User Object provided." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + "[{0}] object name: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject.name | Write-Verbose + "[{0}] object uri: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject.uri | Write-Verbose + "[{0}] object appliance connection: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject.ApplianceConnection.Name | Write-Verbose + "[{0}] object category: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject.category | Write-Verbose + + If ('unmanaged-devices' -contains $UnmanagedDevice.category) + { + + If (-not($UnmanagedDevice.ApplianceConnection)) + { + + $ErrorRecord = New-ErrorRecord HPEOneView.UnmanagedDeviceResourceException InvalidArgumentValue InvalidArgument "UnmanagedDevice:$($UnmanagedDevice.Name)" -TargetType PSObject -Message "The UnmanagedDevice object resource provided is missing the source ApplianceConnection property. Please check the object provided and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + [void]$_UnmanagedDeviceCollection.Add($UnmanagedDevice) + + } + + else + { + + $ErrorRecord = New-ErrorRecord InvalidOperationException InvalidArgumentValue InvalidArgument "UnmanagedDevice:$($UnmanagedDevice.Name)" -TargetType PSObject -Message "The UnmanagedDevice object resource is not an expected category type [$($UnmanagedDevice.category)]. The allowed resource category type is 'unmanaged-devices'. Please check the object provided and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + else + { + + ForEach ($_appliance in $ApplianceConnection) + { + + "[{0}] Processing Appliance $($_appliance.Name) (of $($ApplianceConnection.Count))" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + "[{0}] Processing Unmanaged Device Name $($UnmanagedDevice)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $_UnmanagedDevice = Get-OVUnmanagedDevice $UnmanagedDevice -ApplianceConnection $_appliance + + $_UnmanagedDevice | ForEach-Object { + + [void]$_UnmanagedDeviceCollection.Add($_) + + } + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + } + + End + { + + "[{0}] Processing $($_UnmanagedDeviceCollection.count) object resources to remove." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + # Process Unmanaged Device Resources + ForEach ($_device in $_UnmanagedDeviceCollection) + { + + if ($PSCmdlet.ShouldProcess($_device.ApplianceConnection.Name,"Remove Unmanaged Device '$($_device.name)' from appliance")) + { + + "[{0}] Removing Unmanaged Device '$($_device.name)' from appliance '$($_device.ApplianceConnection.Name)'." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $_resp = Send-OVRequest -Uri $_device.Uri -Method DELETE -AddHeader @{'If-Match' = $_device.eTag } -Hostname $_device.ApplianceConnection + + $_resp | Add-Member -NotePropertyName Name -NotePropertyValue $_device.name + + $_resp + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + elseif ($PSBoundParameters['WhatIf']) + { + + "[{0}] WhatIf Parameter was passed." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + } + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +####################################################### +# Power Delivery Devices +# + +function Get-OVPowerDevice +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding ()] + Param + ( + + [Parameter (Mandatory = $false)] + [ValidateNotNullOrEmpty()] + [String]$Name, + + [Parameter (Mandatory = $false)] + [ValidateSet ('HPIpduCore', 'HPIpduAcModule', 'LoadSegment', 'HPIpduOutletBar', 'HPIpduOutlet')] + [Array]$Type, + + [Parameter (Mandatory = $false)] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + Process + { + + ForEach ($_appliance in $ApplianceConnection) + { + + $_Query = [System.Collections.ArrayList]::new() + + # Commented out until corect Index API call can be found + # if ($Type) + # { + + # ForEach ($_type in $Type) + # { + + # $_queryvalue = "pdd_type:'{0}'" -f $_type + # # $_queryvalue = "deviceType:'{0}'" -f $_type + # [void]$_Query.Add($_queryvalue) + + # } + + # } + + if ($Name) + { + + "[{0}] Filtering for Name: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Name | Write-Verbose + + if ($Name.Contains('*')) + { + + [Void]$_Query.Add(("name%3A{0}" -f $Name.Replace("*", "%2A").Replace(',','%2C').Replace(" ", "?"))) + + } + + else + { + + [Void]$_Query.Add(("name:'{0}'" -f $Name)) + + } + + } + + $_Category = 'category=power-devices' + + # Build the final URI + $_uri = '{0}?{1}&sort=name:asc&query={2}' -f $IndexUri, [String]::Join('&', $_Category), [String]::Join(' AND ', $_Query.ToArray()) + + Try + { + + [Array]$_ResourcesFromIndexCol = Get-AllIndexResources -Uri $_uri -ApplianceConnection $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if ($_ResourcesFromIndexCol.Count -eq 0) + { + + if ($Name) + { + + "[{0}] '{1}' Power Device not found." -f $MyInvocation.InvocationName.ToString().ToUpper(), $Name | Write-Verbose + + $ExceptionMessage = "No power device with '{0}' name found on '{1}' appliance connection. Please check the name or use New-OVStorageVolume to create the volume." -f $Name, $_appliance.Name + $ErrorRecord = New-ErrorRecord HPEOneView.StorageVolumeResourceException StorageVolumeResourceNotFound ObjectNotFound 'Name' -Message $ExceptionMessage + $PSCmdlet.WriteError($ErrorRecord) + + } + + else + { + + "[{0}] No Power Device found." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + } + + else + { + + if ($Type) + { + + "[{0}] Filtering for {1} device type." -f $MyInvocation.InvocationName.ToString().ToUpper(), [String]::Join(', ', $Type) | Write-Verbose + + $_ResourcesFromIndexCol = $_ResourcesFromIndexCol | Where-Object { $Type -contains $_.deviceType } + + } + + ForEach ($_member in ($_ResourcesFromIndexCol | Sort-Object name, deviceType)) + { + + switch ($_member.deviceType) + { + + 'HPIpduCore' + { + + $_member.psobject.typenames.Insert(0,"HPEOneView.PowerDeliveryDevice") + + } + + 'HPIpduAcModule' + { + + $_member.psobject.typenames.Insert(0,"HPEOneView.PowerDeliveryDevice.PduAcModule") + + } + + 'LoadSegment' + { + + $_member.psobject.typenames.Insert(0,"HPEOneView.PowerDeliveryDevice.LoadSegment") + + } + + 'HPIpduOutletBar' + { + + $_member.psobject.typenames.Insert(0,"HPEOneView.PowerDeliveryDevice.OutletBar") + + } + + 'HPIpduOutlet' + { + + # Get power state + Try + { + + $_PowerState = Send-OVRequest -Uri ($_member.uri + '/powerState') -ApplianceConnection $_member.ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $_member | Add-Member -NotePropertyName power -NotePropertyValue $_PowerState -Force + + $_member.psobject.typenames.Insert(0,"HPEOneView.PowerDeliveryDevice.Outlet") + + } + + } + + $_member + + } + + } + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Add-OVPowerDevice +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (SupportsShouldProcess, ConfirmImpact = "High")] + Param + ( + + [Parameter (Mandatory)] + [ValidateNotNullOrEmpty()] + [String]$Hostname, + + [Parameter (Mandatory = $false)] + [Obsolete()] + [ValidateNotNullOrEmpty()] + [String]$Username, + + [Parameter (Mandatory = $false)] + [Obsolete()] + [ValidateNotNullOrEmpty()] + [Object]$Password, + + [Parameter (Mandatory = $false)] + [ValidateNotNullOrEmpty()] + [PSCredential]$Credential, + + [Parameter (Mandatory = $false)] + [Switch]$Async, + + [Parameter (Mandatory = $false)] + [Switch]$TrustLeafCertificate, + + [Parameter (Mandatory = $false)] + [Switch]$Force, + + [Parameter (Mandatory = $false)] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + if ($PSBoundParameters['Username']) + { + + Write-Warning "The -Username parameter will be deprecated in a future release. Please transition to using the -Credental Parameter." + + } + + if ($PSBoundParameters['Password']) + { + + Write-Warning "The -Username parameter will be deprecated in a future release. Please transition to using the -Credental Parameter." + + } + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + if ($ApplianceConnection.Count -gt 1) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException MultipleApplianceConnections InvalidArgument 'ApplianceConnection' -Message 'The specified ApplianceConnection Parameter contains multiple Appliance Connections. This CMDLET only supports 1 Appliance Connection in the ApplianceConnect Parameter value. Please correct this and try again.' + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + if (-not($PSBoundParameters['Password']) -and $PSBoundParameters['Username']) + { + + do + { + + $securepass = Read-Host 'Password' -AsSecureString + $securepass2 = Read-Host 'Confirm Password' -AsSecureString + $_DecryptPassword = [Runtime.InteropServices.Marshal]::PtrToStringBSTR([Runtime.InteropServices.Marshal]::SecureStringToBSTR($securepass)) + $_DecryptPassword2 = [Runtime.InteropServices.Marshal]::PtrToStringBSTR([Runtime.InteropServices.Marshal]::SecureStringToBSTR($securepass2)) + + if ($_DecryptPassword -ne $_DecryptPassword2) + { + + Write-Host "Passwords do not match!" -BackgroundColor Red + + } + + } until ($_DecryptPassword -eq $_DecryptPassword2) + + } + + elseif ($Password -is [SecureString]) + { + + $_DecryptPassword = [Runtime.InteropServices.Marshal]::PtrToStringBSTR([Runtime.InteropServices.Marshal]::SecureStringToBSTR($Password)) + + } + + elseif ($PSBoundParameters['Password']) + { + + $_DecryptPassword = $Password + + } + + elseif ($PSBoundParameters['Credential']) + { + + $Username = $Credential.Username + $_DecryptPassword = [Runtime.InteropServices.Marshal]::PtrToStringBSTR([Runtime.InteropServices.Marshal]::SecureStringToBSTR($Credential.Password)) + + } + + else + { + + $ExceptionMessage = 'Please provide valid credentials using either -Username/-Password or -Credential parameters.' + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.LdapAuthenticationException NoValidCredentialParameters AuthenticationError "ApplianceConnection" -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + $colStatus = [System.Collections.ArrayList]::new() + + } + + Process + { + + # Locate the Enclosure Group specified + "[{0}] - Starting" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if ($PSBoundParameters['TrustLeafCertificate']) + { + + "[{0}] Caller provide the -TrustLeafCertificate switch. Adding SSL certificate to appliance trust store." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + "[{0}] Getting SSL certificate." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + # This is not an async task operation + Try + { + + $_uri = '{0}/{1}' -f $RetrieveHttpsCertRemoteUri, $Hostname + + $_DeviceCertificate = Send-OVRequest -Uri $_uri -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $_DeviceCertificateToImport = NewObject -CertificateToImport + $_DeviceCertificateToImport.certificateDetails[0].base64Data = $_DeviceCertificate.certificateDetails.base64Data + $_DeviceCertificateToImport.certificateDetails[0].aliasName = $_DeviceCertificate.certificateDetails.commonName + + Try + { + + "[{0}] Adding SSL certificate to appliance trust store." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_uri = '{0}' -f $ApplianceTrustedSslHostStoreUri + + $_TaskResults = Send-OVRequest -Uri $_uri -Method POST -Body $_DeviceCertificateToImport -Hostname $ApplianceConnection | Wait-OVTaskComplete + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if ($_TaskResults.taskErrors) + { + + "[{0}] Task errors adding SSL certificate." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if ($_TaskResults.taskErrors.errorCode -eq '409' -and [RegEx]::Match($_TaskResults.taskErrors.message, 'The certificate already exists for the alias', $RegExInsensitiveFlag).Success) + { + + "[{0}] Certificate already exists." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + else + { + + + $ErrorRecord = New-ErrorRecord InvalidOperationException $_TaskResults.taskErrors.errorCode InvalidResult 'Hostname' -Message $_TaskResults.taskErrors.message + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + } + + $_import = NewObject -PowerDeliveryDeviceAdd + + $_import.hostname = $Hostname + $_import.username = $Username + $_import.password = $_DecryptPassword + $_import.force = $Force.IsPresent + + "[{0}] - Sending request to add iPDU." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $_resp = Send-OVRequest -Uri $PowerDevicesDiscoveryUri -Method POST -Body $_import -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + # Wait for task to get into Starting stage + Try + { + + $_resp = Wait-OVTaskStart $_resp + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + "[{0}] Task response: {1} ({2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_resp.taskState, $_resp.erroCode | Write-Verbose + + # Check to see if the task errored, which should be in the Task Validation stage + if ($_resp.taskState -ne "Running" -and $_resp.taskState -eq "Error" -and $_resp.stateReason -eq "ValidationError") + { + + "[{0}] Task error found {1} {2} " -f $MyInvocation.InvocationName.ToString().ToUpper(), $resp.taskState, $resp.stateReason | Write-Verbose + + if ($_resp.taskErrors | Where-Object { 'UNABLE_TO_VERIFY_CERTIFICATE', "CERTIFICATE_UNTRUSTED"-contains $_.errorCode }) + { + + $ExceptionMessage = 'The leaf certificate for {0} is untrusted by the appliance. Either provide the -TrustLeafCertificate parameter or manually add the certificate using the Add-OVApplianceTrustedCertificate Cmdlet.' -f $Hostname + $ErrorRecord = New-ErrorRecord InvalidOperationException UntrustedLeafCertificate InvalidResult 'Hostname' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + } + + if ($_resp.taskerrors | Where-Object { $_.errorCode -eq "PDD_IPDU_TRAPRECEIVERACCOUNT_TAKEN" }) + { + + $_errorMessage = $_resp.taskerrors | Where-Object { $_.errorCode -eq "PDD_IPDU_TRAPRECEIVERACCOUNT_TAKEN" } + + $_externalManagerIP = $_errorMessage.data.mgmtSystemIP + + Try + { + + $_externalManagerFQDN = [System.Net.DNS]::GetHostByAddress($_externalManagerIP) + + } + + Catch + { + + "[{0}] Couldn't resolve {1} to FQDN [{2}]." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_externalManagerIP, $_.Exception.Message | Write-Verbose + + $_externalManagerFQDN = [PSCustomObject]@{HostName = $_externalManagerIP} + + } + + "[{0}] Found iPDU '{1} is already being managed by {2}." -f $MyInvocation.InvocationName.ToString().ToUpper(), $Hostname, $_externalManagerIP | Write-Verbose + + "[{0}] {1} resolves to {2}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_externalManagerIP, $_externalManagerFQDN.HostName | Write-Verbose + + "[{0}] iPDU '{1}' is already claimed by another management system {2} ({3})." -f $MyInvocation.InvocationName.ToString().ToUpper(), $Hostname, $_externalManagerIP, $_externalManagerFQDN.HostName | Write-Verbose + + if ($Force -and $PSCmdlet.ShouldProcess($Hostname,"iPDU is already claimed by another management system $_externalManagerIP ($($_externalManagerFQDN.HostName)). Force add?")) + { + + "[{0}] - iPDU is being claimed due to user chosing YES to force add." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $import.force = $true + + Try + { + + $_resp = Send-OVRequest -Uri $PowerDevicesDiscoveryUri -Method POST -Body $_import -Hostnamme $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + elseif ($PSCmdlet.ShouldProcess($Hostname,"iPDU is already claimed by another management system $_externalManagerIP ($($_externalManagerFQDN.HostName)). Force add?")) + { + + "[{0}] - iPDU is being claimed due to user chosing YES to force add." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $import.force = $true + + Try + { + + $_resp = Send-OVRequest -Uri $PowerDevicesDiscoveryUri -Method POST -Body $_import -Hostnamme $ApplianceConnection.Name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + else + { + + if ($PSBoundParameters['whatif'].ispresent) + { + + "[{0}] -WhatIf was passed, would have force added '$Hostname' iPDU to appliance." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_resp = $null + + } + + else + { + + # If here, user chose "No", End Processing + + "[{0}] Not importing iPDU {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Hostname | Write-Verbose + + $_resp = $Null + + } + + } + + } + + elseif ($_resp.taskErrors) + { + + $_errorMessage = $_resp.taskErrors + + if ($_errorMessage -is [System.Collections.IEnumerable]) + { + + # Loop to find a Message value that is not blank. + $displayMessage = $_errorMessage.message | Where-Object { $null -ne $_ } + + $ErrorRecord = New-ErrorRecord InvalidOperationException 'InvalidResultAddingPDU' InvalidResult 'Hostname' -Message $displayMessage + + } + + else + { + + $ErrorRecord = New-ErrorRecord InvalidOperationException $errorMessage.errorCode InvalidResult 'Hostname' -Message ($_errorMessage.details + " " + $_errorMessage.message) + + } + + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + if (-not $PSBoundParameters['Async']) + { + + $_resp | Wait-OVTaskComplete + + } + + else + { + + $_resp + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +# // TODO: DEVELOP DOCUMENTATION TEST +function New-OVPowerDevice +{ + + Throw "Not implemented." + +} + +# // TODO: DEVELOP DOCUMENTATION TEST +function Start-OVPowerDevice +{ + + Throw "Not implemented." + + # Only allow HPIpduOutlet deviceType + +} + +# // TODO: DEVELOP DOCUMENTATION TEST +function Stop-OVPowerDevice +{ + + Throw "Not implemented." + + # Only allow HPIpduOutlet deviceType + +} + +function Remove-OVPowerDevice +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "default",SupportsShouldProcess,ConfirmImpact = 'High')] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = "default")] + [ValidateNotNullOrEmpty()] + [Alias ("uri", "name", 'PowerDevice')] + [object]$InputObject, + + [Parameter (Mandatory = $false, ParameterSetName = "default")] + [Switch]$Force, + + [Parameter (Mandatory = $false, ParameterSetName = "default")] + [Switch]$Async, + + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = "default")] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not($PSBoundParameters['InputObject'])) + { + + $PipelineInput = $True + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + $_PowerDeviceCollection = [System.Collections.ArrayList]::new() + + } + + Process + { + + if ($PipelineInput) + { + + "[{0}] Processing Pipeline input" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + "[{0}] PowerDevice Object provided." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + "[{0}] object name: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject.name | Write-Verbose + "[{0}] object uri: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject.uri | Write-Verbose + "[{0}] object appliance connection: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject.ApplianceConnection.Name | Write-Verbose + "[{0}] object category: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject.category | Write-Verbose + + If ('power-devices' -contains $InputObject.category) + { + + If (-not $InputObject.ApplianceConnection) + { + + $ExceptionMessage = "The PowerDevice object resource provided is missing the source ApplianceConnection property. Please check the object provided and try again." + $ErrorRecord = New-ErrorRecord HPEOneView.PowerDeviceResourceException InvalidArgumentValue InvalidArgument "InputObject" -TargetType PSObject -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + [void]$_PowerDeviceCollection.Add($InputObject) + + } + + else + { + + $ExceptionMessage = "The PowerDevice object resource is not an expected category type [{0}]. The allowed resource category type is 'power-devices'. Please check the object provided and try again." -f $InputObject.category + $ErrorRecord = New-ErrorRecord HPEOneView.PowerDeviceResourceException InvalidArgumentValue InvalidArgument "InputObject" -TargetType PSObject -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + else + { + + ForEach ($_appliance in $ApplianceConnection) + { + + "[{0}] Processing Appliance {1} (of {2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name, $ApplianceConnection.Count | Write-Verbose + + "[{0}] Processing Power Device Name: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject | Write-Verbose + + Try + { + + $_PowerDevice = Get-OVPowerDevice -Name $PowerDevice -ErrorAction Stop -ApplianceConnection $_appliance + + $_PowerDevice | ForEach-Object { + + [void]$_PowerDeviceCollection.Add($_) + + } + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + } + + End + { + + "[{0}] Begin resource removal process." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + foreach ($_PowerDevice in $_PowerDeviceCollection) + { + + if ($PSCmdlet.ShouldProcess($_PowerDevice.name,"Remove Power Device from appliance '$($_PowerDevice.ApplianceConnection.Name)'")) + { + + Try + { + + $_task = Send-OVRequest -Uri $_PowerDevice.uri -Method DELETE -AddHeader @{'If-Match' = $_PowerDevice.eTag } -Hostname $_PowerDevice.ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if ($PSBoundParameters['Async']) + { + + $_task + + } + + else + { + + $_task | Wait-OVTaskComplete + + } + + } + + elseif ($PSBoundParameters['WhatIf']) + { + + "[{0}] Caller passed -WhatIf Parameter." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + else + { + + "[{0}] Caller selected NO to confirmation prompt." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + } + + } + +} + +function Get-OVPowerPotentialDeviceConnection +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "default")] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = "default")] + [ValidateNotNullOrEmpty()] + [Alias ("uri","name")] + [object]$PowerDevice, + + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = "default")] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not($PSBoundParameters['PowerDevice'])) + { + + $PipelineInput = $True + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + $_PowerDeviceCollection = [System.Collections.ArrayList]::new() + + } + + Process + { + + if ($PipelineInput) + { + + "[{0}] Processing Pipeline input" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + "[{0}] PowerDevice Object provided." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + "[{0}] object name: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject.name | Write-Verbose + "[{0}] object uri: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject.uri | Write-Verbose + "[{0}] object appliance connection: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject.ApplianceConnection.Name | Write-Verbose + "[{0}] object category: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject.category | Write-Verbose + + If ('power-devices' -contains $PowerDevice.category) + { + + If (-not($PowerDevice.ApplianceConnection)) + { + + $ErrorRecord = New-ErrorRecord HPEOneView.PowerDeviceResourceException InvalidArgumentValue InvalidArgument "PowerDevice:$($PowerDevice.Name)" -TargetType PSObject -Message "The PowerDevice object resource provided is missing the source ApplianceConnection property. Please check the object provided and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Try + { + + $_resp = Send-OVRequest ($powerDevicePotentialConnections + $PowerDevice.uri) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if ($_resp) + { + + $_resp | ForEach-Object { + + $_.PSObject.TypeNames.Insert(0,'HPEOneView.PowerDevice.PotentialPowerConnection') + + [void]$_PowerDeviceCollection.Add($_) + + } + + } + + } + + else + { + + $ErrorRecord = New-ErrorRecord HPEOneView.PowerDeviceResourceException InvalidArgumentValue InvalidArgument "PowerDevice:$($PowerDevice.Name)" -TargetType PSObject -Message "The PowerDevice object resource is not an expected category type [$($PowerDevice.category)]. The allowed resource category type is 'power-devices'. Please check the object provided and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + else + { + + ForEach ($_appliance in $ApplianceConnection) + { + + "[{0}] Processing Appliance $($_appliance.Name) (of $($ApplianceConnection.Count))" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + "[{0}] Processing Power Device Name $($PowerDevice)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $_PowerDevice = Get-OVPowerDevice $PowerDevice -ApplianceConnection $_appliance + + $_resp = $_PowerDevice | ForEach-Object { Send-OVRequest ($powerDevicePotentialConnections + $_.uri) } + + $_resp | ForEach-Object { + + $_.PSObject.TypeNames.Insert(0,'HPEOneView.PowerDevice.PotentialPowerConnection') + + [void]$_PowerDeviceCollection.Add($_) + + } + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + } + + End + { + + Return $_PowerDeviceCollection + + } + +} + +# // TODO: DEVELOP DOCUMENTATION TEST +function Add-OVPowerDeviceConnection +{ + + Throw "Not implemented." + +} + +####################################################### +# Networking and Connections +# + +function New-OVNetwork +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "Ethernet")] + Param + ( + + [Parameter (Mandatory, ParameterSetName = "FC")] + [Parameter (Mandatory, ParameterSetName = "FCOE")] + [Parameter (Mandatory, ParameterSetName = "VLANIDRange")] + [Parameter (Mandatory, ParameterSetName = "Ethernet")] + [ValidateNotNullOrEmpty()] + [String]$Name, + + [Parameter (Mandatory, ParameterSetName = "FC")] + [Parameter (Mandatory, ParameterSetName = "FCOE")] + [Parameter (Mandatory = $false, ParameterSetName = "VLANIDRange")] + [Parameter (Mandatory = $false, ParameterSetName = "Ethernet")] + [ValidateSet ("Ethernet", "FC", "FibreChannel", "Fibre Channel", "FCoE", "RoCE")] + [String]$Type = "Ethernet", + + [Parameter (Mandatory, ParameterSetName = "FCOE")] + [Parameter (Mandatory = $false, ParameterSetName = "Ethernet")] + [validaterange(1,4095)] + [int32]$VlanId, + + [Parameter (Mandatory = $false, ParameterSetName = "Ethernet")] + [Parameter (Mandatory = $false, ParameterSetName = "VLANIDRange")] + [ValidateNotNullOrEmpty()] + [Object[]]$NetworkSet, + + [Parameter (Mandatory = $false, ParameterSetName = "Ethernet")] + [ValidateNotNullOrEmpty()] + [Object]$Subnet, + + [Parameter (Mandatory, ParameterSetName = "VLANIDRange")] + [String]$VlanRange, + + [Parameter (Mandatory = $false, ParameterSetName = "Ethernet")] + [Parameter (Mandatory = $false, ParameterSetName = "VLANIDRange")] + [ValidateSet ('Untagged','Tagged','Tunnel', IgnoreCase = $False)] + [String]$VLANType = "Tagged", + + [Parameter (Mandatory = $false, ParameterSetName = "Ethernet")] + [Parameter (Mandatory = $false, ParameterSetName = "VLANIDRange")] + [ValidateSet ("General", "Management", "VMMigration", "FaultTolerance", 'ISCSI', IgnoreCase = $False)] + [String]$Purpose = "General", + + [Parameter (Mandatory = $false, ParameterSetName = "Ethernet")] + [Parameter (Mandatory = $false, ParameterSetName = "VLANIDRange")] + [boolean]$SmartLink = $true, + + [Parameter (Mandatory = $false, ParameterSetName = "Ethernet")] + [Parameter (Mandatory = $false, ParameterSetName = "VLANIDRange")] + [boolean]$PrivateNetwork = $false, + + [Parameter (Mandatory = $false, ParameterSetName = "Ethernet")] + [Parameter (Mandatory = $false, ParameterSetName = "VLANIDRange")] + [Parameter (Mandatory = $false, ParameterSetName = "FCOE")] + [Parameter (Mandatory = $false, ParameterSetName = "FC")] + [ValidateRange(2,50000)] + [int32]$TypicalBandwidth = 2500, + + [Parameter (Mandatory = $false, ParameterSetName = "Ethernet")] + [Parameter (Mandatory = $false, ParameterSetName = "VLANIDRange")] + [Parameter (Mandatory = $false, ParameterSetName = "FCOE")] + [Parameter (Mandatory = $false, ParameterSetName = "FC")] + [ValidateRange(100,50000)] + [int32]$MaximumBandwidth = 20000, + + [Parameter (Mandatory = $false, ParameterSetName = "FC")] + [ValidateNotNullOrEmpty()] + [int32]$LinkStabilityTime = 30, + + [Parameter (Mandatory = $false, ParameterSetName = "FC")] + [boolean]$AutoLoginRedistribution = $False, + + [Parameter (Mandatory = $false, ParameterSetName = "FC")] + [ValidateSet ("FabricAttach","FA", "DirectAttach","DA")] + [String]$FabricType = "FabricAttach", + + [Parameter (Mandatory = $false, ParameterSetName = "FC", ValueFromPipeline)] + [Parameter (Mandatory = $false, ParameterSetName = "FCOE", ValueFromPipeline)] + [ValidateNotNullOrEmpty()] + [object]$ManagedSan, + + [Parameter (Mandatory = $false, ParameterSetName = "Ethernet")] + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = "FC")] + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = "FCOE")] + [Parameter (Mandatory = $false, ParameterSetName = "VLANIDRange")] + [Parameter (Mandatory = $false, ParameterSetName = "importFile")] + [ValidateNotNullOrEmpty()] + [HPEOneView.Appliance.ScopeCollection[]]$Scope, + + [Parameter (Mandatory = $false, ParameterSetName = "Ethernet")] + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = "FC")] + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = "FCOE")] + [Parameter (Mandatory = $false, ParameterSetName = "VLANIDRange")] + [Parameter (Mandatory = $false, ParameterSetName = "importFile")] + [Switch]$Async, + + [Parameter (Mandatory = $false, ParameterSetName = "Ethernet")] + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = "FC")] + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = "FCOE")] + [Parameter (Mandatory = $false, ParameterSetName = "VLANIDRange")] + [Parameter (Mandatory = $false, ParameterSetName = "importFile")] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default), + + [Parameter (Mandatory, ParameterSetName = "importFile")] + [Alias ("i", "import")] + [ValidateNotNullOrEmpty()] + [String]$ImportFile + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $colStatus = [System.Collections.ArrayList]::new() + + # Validate Ethernet VLAN ID Setting if Type = 'Tagged' + if ($PSBoundParameters['VLANType'] -eq 'Tunnel') + { + + if ($PSBoundParameters['Subnet']) + { + + # Generate Error + $ExceptionMessage = "The -VLANType parameter 'Tunnel' cannot be assigned to a subnet. Remove the -Subnet parameter and try again." + $ErrorRecord = New-ErrorRecord HPEOneView.NetworkResourceException InvalidNetworkTypeOperation InvalidOperation 'VLANType' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + if ($PSBoundParameters['NetworkSet']) + { + + # Generate Error + $ExceptionMessage = "The -VLANType parameter 'Tunnel' cannot be assigned to a NetworkSet. Remove the -NetworkSet parameter and try again." + $ErrorRecord = New-ErrorRecord HPEOneView.NetworkResourceException InvalidNetworkTypeOperation InvalidOperation 'VLANType' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + elseif ($PSBoundParameters['VLANType'] -eq 'Untagged' -and $PSBoundParameters['NetworkSet']) + { + + # Generate Error + $ExceptionMessage = "The -VLANType parameter 'Untagged' cannot be assigned to a NetworkSet. Remove the -NetworkSet parameter and try again." + $ErrorRecord = New-ErrorRecord HPEOneView.NetworkResourceException InvalidNetworkTypeOperation InvalidOperation 'VLANType' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + # Validate allowed parameters + if ($Type -eq 'RoCE') + { + + if ($PSBoundParameters['SmartLink']) + { + + # Generate Error + $ExceptionMessage = "The SmartLink parameter is not supported with RoCE network type. RoCE networks are always smart link enbaled." + $ErrorRecord = New-ErrorRecord HPEOneView.NetworkResourceException InvalidParameter InvalidOperation 'SmartLink' -Message $ExceptionMessage + $PSCmdlet.WriteError($ErrorRecord) + + } + + if ($PSBoundParameters['Purpose']) + { + + # Generate Error + $ExceptionMessage = "The Purpose parameter is not supported with RoCE network type and will be ignored." + $ErrorRecord = New-ErrorRecord HPEOneView.NetworkResourceException InvalidParameter InvalidOperation 'Purpose' -Message $ExceptionMessage + $PSCmdlet.WriteError($ErrorRecord) + + } + + if ($PSBoundParameters['Subnet']) + { + + # Generate Error + $ExceptionMessage = "The Subnet parameter is not supported with RoCE network type." + $ErrorRecord = New-ErrorRecord HPEOneView.NetworkResourceException InvalidParameter InvalidOperation 'Subnet' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + } + + Process + { + + # Validate Ethernet VLAN ID Setting if Type = 'Tagged' + if ($PSBoundParameters['VLANType'] -eq 'Tagged' -and (-not($PSBoundParameters['VLANID']))) + { + + # Generate Error + $ExceptionMessage = "The -VLANType Parameter was used to specify a 'Tagged' Network, however the -VLANID Parameter was not provided. Please provide a VLANID to the Network resource you are creating." + $ErrorRecord = New-ErrorRecord HPEOneView.NetworkResourceException InvalidNetworkTypeOperation InvalidOperation 'VLANType' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + # Validate Ethernet VLAN ID Setting if Network Type is FCoE + if ($PSBoundParameters['Type'] -eq 'FCoE' -and (-not($PSBoundParameters['VlanId']))) + { + + # Generate Error + $ExceptionMessage = "The -Type Parameter was used to specify a 'FCoE' Network, however the -VLANID Parameter was not provided. Please provide a VLANID to the Network resource you are creating." + $ErrorRecord = New-ErrorRecord HPEOneView.NetworkResourceException InvalidNetworkTypeOperation InvalidOperation 'Type' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + ForEach ($_appliance in $ApplianceConnection) + { + + "[{0}] Resolved Parameter Set Name: $($PSCmdlet.ParameterSetName)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + "[{0}] Processing CMDLET for '$($_appliance.name)' appliance." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + If ($ImportFile) + { + + try + { + + $network = [String]::Join("", (Get-Content $importfile -ErrorAction Stop)) | convertfrom-json -ErrorAction Stop + + } + + catch [System.Management.Automation.ItemNotFoundException] + { + + $ErrorRecord = New-ErrorRecord System.Management.Automation.ItemNotFoundException InputFileNotFound ObjectNotFound 'New-OVNetwork' -Message "$importFile not found. Please check the filename or path is valid and try again." + + # Generate Terminating Error + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + catch [System.ArgumentException] + { + + $ErrorRecord = New-ErrorRecord System.ArgumentException InvalidJSON ParseError 'New-OVNetwork' -Message "JSON incorrect or invalid within '$importFile' input file." + + # Generate Terminating Error + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + else + { + + "[{0}] Network Type Requested: $($Type)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + switch ($Type) + { + + "Ethernet" + { + + if (-not($PSBoundParameters['VlanRange'])) + { + + "[{0}] Creating '$name' Ethernet Network" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $Network = NewObject -EthernetNetwork + + $Network.vlanId = $VlanId + $Network.ethernetNetworkType = $VLANType + + if (($ApplianceConnection | ? ConnectionID -eq $_appliance.ConnectionId).ApplianceType -ne "VMA") + { + + $Network.purpose = $EthernetNetworkPurposeEnum[$Purpose] + $Network.name = $Name + $Network.smartLink = $SmartLink + $Network.privateNetwork = $PrivateNetwork + + } + + if ($PSBoundParameters['Subnet'] -and ($ApplianceConnection | ? ConnectionID -eq $_appliance.ConnectionId).ApplianceType -ne "VMA") + { + + ForEach ($_subnet in $Subnet) + { + + "[{0}] Subnet {1} was provided, validating." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_subnet.networkId | Write-Verbose + + # Genrate Error + if (-not($_subnet -is [PSCustomObject])) + { + + $Message = 'The Subnet Parameter value is not an Object. Please provide a valid Object by using the Get-OVAddressPoolSubnet Cmdlet.' + $ErrorRecord = New-ErrorRecord HPEOneView.NetworkResourceException InvalidSubnetValue InvalidArgument 'Subnet' -TargetType $_subnet.Gettype().Name -Message $Message + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + # Genrate Error, invalid object type + if ($ResourceCategoryEnum.IPv4Subnet, $ResourceCategoryEnum.IPv6Subnet -notcontains $_subnet.category) + { + + $Message = "The Subnet Parameter value is not a valid IP Subnet object. The object category provided was {0}. Please provide a valid Object by using the Get-OVAddressPoolSubnet Cmdlet." -f $Subnet.category + $ErrorRecord = New-ErrorRecord HPEOneView.NetworkResourceException InvalidSubnetObject InvalidArgument 'Subnet' -TargetType 'PSObject' -Message $Message + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + # Invalid object for the appliance connection + if ($_subnet.ApplianceConnection.Name -ne $_appliance.Name) + { + + $Message = "The Subnet Parameter value is missing the 'ApplianceConnection' property. Please provide a valid Object by using the Get-OVAddressPoolSubnet Cmdlet." + $ErrorRecord = New-ErrorRecord HPEOneView.NetworkResourceException InvalidNetworkTypeOperation InvalidOperation 'Subnet' -TargetType 'PSObject' -Message $Message + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + switch ($_subnet.category) + { + + $ResourceCategoryEnum.IPv4Subnet + { + + # Generate error that there are more than 1 IPv4 subnets provided, and only a singular subnet per type is allowed. + if (-not [String]::IsNullOrEmpty($network.subnetUri)) + { + + $Message = "The Subnet parameter contains more than 1 IPv4 subnet. Only a single IPv4 address pool can be assigned to an Ethernet network." + $ErrorRecord = New-ErrorRecord HPEOneView.NetworkResourceException InvalidSubnetOperation InvalidOperation 'Subnet' -TargetType 'PSObject' -Message $Message + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + $network.subnetUri = $_subnet.uri + + } + + $ResourceCategoryEnum.IPv6Subnet + { + + # Generate error that there are more than 1 IPv4 subnets provided, and only a singular subnet per type is allowed. + if (-not [String]::IsNullOrEmpty($network.ipv6SubnetUri)) + { + + $Message = "The Subnet parameter contains more than 1 IPv6 subnet. Only a single IPv6 address pool can be assigned to an Ethernet network." + $ErrorRecord = New-ErrorRecord HPEOneView.NetworkResourceException InvalidSubnetOperation InvalidOperation 'Subnet' -TargetType 'PSObject' -Message $Message + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + $network.ipv6SubnetUri = $_subnet.uri + + } + + } + + } + + } + + } + + else + { + + "[{0}] Creating bulk '{1}' + '{2}' Ethernet Networks" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Name, $VlanRange | Write-Verbose + + $network = NewObject -BulkEthernetNetworks + + $network.vlanIdRange = $VlanRange + $network.purpose = $EthernetNetworkPurposeEnum[$Purpose] + $network.namePrefix = $Name + $network.smartLink = $SmartLink + $network.privateNetwork = $PrivateNetwork + $network.bandwidth.typicalBandwidth = $TypicalBandwidth + $network.bandwidth.maximumBandwidth = $MaximumBandwidth + + if ($PSBoundParameters['NetworkSet']) + { + + ForEach ($_netset in $NetworkSet) + { + + "[{0}] NetworkSet {1} was provided, validating." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_netset.name | Write-Verbose + + # Genrate Error + if (-not($_netset -is [PSCustomObject])) + { + + $Message = 'The NetworkSet Parameter value is not an Object. Please provide a valid Object by using the Get-OVNetworkSet Cmdlet.' + $ErrorRecord = New-ErrorRecord HPEOneView.NetworkResourceException InvalidHPOVNetworkSetValue InvalidArgument 'NetworkSet' -TargetType $_subnet.Gettype().Name -Message $Message + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + # Genrate Error, invalid object type + if ($ResourceCategoryEnum.NetworkSet -ne $_netset.category) + { + + $Message = "The NetworkSet Parameter value is not a valid IP Subnet object. The object category provided was {0}. Please provide a valid Object by using the Get-OVNetworkSet Cmdlet." -f $Subnet.category + $ErrorRecord = New-ErrorRecord HPEOneView.NetworkResourceException InvalidHPOVNetworkSetObject InvalidArgument 'NetworkSet' -TargetType 'PSObject' -Message $Message + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + # Invalid object for the appliance connection + if ($_netset.ApplianceConnection.Name -ne $_appliance.Name) + { + + $Message = "The NetworkSet Parameter value is missing the 'ApplianceConnection' property. Please provide a valid Object by using the Get-OVNetworkSet Cmdlet." + $ErrorRecord = New-ErrorRecord HPEOneView.NetworkResourceException InvalidNetworkTypeOperation InvalidOperation 'NetworkSet' -TargetType 'PSObject' -Message $Message + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + [void]$network.networkSetUris.Add($_netset.uri) + + } + + } + + } + + } + + { @("FC","FibreChannel","Fibre Channel") -contains $_ } + { + + "[{0}] Creating '$name' FC Network" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $network = NewObject -FCNetwork + + $network.name = $Name + $network.linkStabilityTime = $linkStabilityTime + $network.autoLoginRedistribution = $autoLoginRedistribution + $network.fabricType = $FCNetworkFabricTypeEnum[$FabricType] + $network.connectionTemplateUri = $null + + Try + { + + $network.managedSanUri = if ($ManagedSan) { (VerifyManagedSan $ManagedSan $_appliance) } else { $null } + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + # If maxbandiwdth value isn't specified, 10Gb is the default value, must change to 8Gb + if ( $maximumBandwidth -eq 10000 ){ $maximumBandwidth = 8000 } + + } + + "FCOE" + { + + "[{0}] Creating '$name' FCOE Network" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $network = NewObject -FCoENetwork + + $network.name = $Name + $network.vlanId = $vlanId + $network.connectionTemplateUri = $null + + Try + { + + $network.managedSanUri = if ($ManagedSan) { (VerifyManagedSan $ManagedSan $_appliance) } else { $null } + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + 'ROCE' + { + + "[{0}] Creating '$name' RoCE Network" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $Network = NewObject -RoCENetwork + + $Network.vlanId = $VlanId + $Network.ethernetNetworkType = $VLANType + $Network.name = $Name + $Network.privateNetwork = $PrivateNetwork + + } + + } + + } + + # Validate the appliance connection and the type. If VMA and not FC network, generate terminating error + if (($ApplianceConnection | ? ConnectionID -eq $_appliance.ConnectionId).ApplianceType -eq "VMA" -and [VMADisallowedNetworkTypesEnum].GetEnumNames() -Contains $Type) + { + + $ExceptionMessage = "The -Type parameter value '{0}' is not supported with the HPE OneView virtual machine appliance. Only Fibre Channel networks can be created." -f $Type + $ErrorRecord = New-ErrorRecord HPEOneView.NetworkResourceException InvalidNetworkTypeOperation InvalidOperation 'Type' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + if ($PSBoundParameters['Scope']) + { + + ForEach ($_Scope in $Scope) + { + + "[{0}] Adding resource to Scope: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_Scope.Name | Write-Verbose + + [void]$network.initialScopeUris.Add($_Scope.Uri) + + } + + } + + foreach($net in $network) + { + + if ($net.type.StartsWith('ethernet-networks') -and $net.type -ne 'ethernet-networkV4') + { + + $net.type = 'ethernet-networkV4' + + } + + if ($net.defaultTypicalBandwidth) + { + + $typicalBandwidth = $net.defaultTypicalBandwidth + $net = $net | Select-Object * -ExcludeProperty defaultTypicalBandwidth + + } + + if ($net.defaultMaximumBandwidth) + { + + $maximumBandwidth = $net.defaultMaximumBandwidth + $net = $net | Select-Object * -ExcludeProperty defaultMaximumBandwidth + + } + + if ($net.typicalBandwidth) { $typicalBandwidth = $net.typicalBandwidth } + if ($net.maximumBandwidth) { $maximumBandwidth = $net.maximumBandwidth } + if ($PSBoundParameters['ImportFile'] -and $net.fabricUri) { $net.fabricUri = $null } + if ($PSBoundParameters['ImportFile'] -and $net.subnetUri) { $net.subnetUri = $null } + if ($PSBoundParameters['ImportFile'] -and [Array]$net.scopeUris -gt 0) { [Array]$net.scopeUris = @() } + if ($PSBoundParameters['ImportFile'] -and $net.connectionTemplateUri) { [Array]$net.connectionTemplateUri = $null } + + switch ($net.type) + { + + {[RegEx]::Match($_, "bulk-ethernet-network", $RegExInsensitiveFlag).Success} + { + + "[{0}] Creating bulk '{1}' + '{2}' Ethernet Networks" -f $MyInvocation.InvocationName.ToString().ToUpper(), $name, $vlanRange | Write-Verbose + + $netUri = $EthernetNetworksUri + "/bulk" + + break + + } + + {[RegEx]::Match($_, "ethernet-network", $RegExInsensitiveFlag).Success} + { + + "[{0}] Creating {1} Ethernet Network" -f $MyInvocation.InvocationName.ToString().ToUpper(), $net.name | Write-Verbose + + $netUri = $EthernetNetworksUri + + $net = $net | Select-Object * -ExcludeProperty uri + + } + + {[RegEx]::Match($_, "fc-network", $RegExInsensitiveFlag).Success} + { + + "[{0}] Creating {1} FC Network" -f $MyInvocation.InvocationName.ToString().ToUpper(), $net.name | Write-Verbose + + $netUri = $FcNetworksUri + + $net = $net | Select-Object * -ExcludeProperty uri + + } + + {[RegEx]::Match($_, "fcoe-network", $RegExInsensitiveFlag).Success} + { + + "[{0}] Creating {1} FCoE Network" -f $MyInvocation.InvocationName.ToString().ToUpper(), $net.name | Write-Verbose + + $netUri = $FCoENetworksUri + + $net = $net | Select-Object * -ExcludeProperty uri + + } + + {[RegEx]::Match($_, "roce-network", $RegExInsensitiveFlag).Success} + { + + "[{0}] Creating {1} RoCE Network" -f $MyInvocation.InvocationName.ToString().ToUpper(), $net.name | Write-Verbose + + $netUri = $RoCENetworksUri + + $net = $net | Select-Object * -ExcludeProperty uri + + } + + # Should never get here. If so, this is an internal error we need to fix. + default + { + + $ErrorRecord = New-ErrorRecord System.ArgumentException InvalidNetworkType InvalidType 'type' -Message "(INTERNAL ERROR) The Network Resource Type $($net.type) is invalid for '$($net.name)' network." + + # Generate Terminating Error + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + # Remove object attributes from the object as they are not supported with VMA + if (($ApplianceConnection | ? ConnectionID -eq $_appliance.ConnectionId).ApplianceType -eq "VMA") + { + + $net = $net | Select-Object * -ExcludeProperty typicalBandwidth, maximumBandwidth, subnetUri, connectionTemplateUri, smartLink, privateNetwork, purpose + + } + + $objStatus = [pscustomobject]@{ + + Name = $net.Name; + Status = $Null; + Details = $Null; + Exception = $Null; + + } + + $task = $null + + # Check if Network Type is Direct Attach and if ManagedFabric Parameter is being called at the same time. + if (($fabricType -eq "DirectAttach" -or $fabricType -eq "DA") -and $managedfabric) + { + + $objStatus.Details = "You specified a DirectAttach Fabric Type and passed the ManagedSan Parameter. The ManagedSan Parameter is to be used for FabricAttach networks only." + + } + + else + { + + Try + { + + "[{0}] Sending request to create '$($net.name)' network." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $task = Send-OVRequest -Uri $netUri -Method POST -Body $net -Hostname $_appliance + + } + + Catch + { + + "[{0}] Exception caught when trying to create '$($net.name)' network." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + "[{0}] Exception: $($_.Exception.Message.ToString())" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $objStatus.Status = "Failed" + $objStatus.Details = $_.exception.message + $objStatus.Exception = $_ + + } + + } + + if (-not $task.Uri) + { + + "[{0}] Create Network Object '$($net.name)' request was rejected." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $objStatus.Status = "Failed" + + # Do not want to overwrite the details value from the Fabric Type check above. + if ($task) { $objStatus.Details = $task } + + } + + else + { + + "[{0}] Create Network Object '$($net.name)' creating. Monitor task." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + # Wait for the network to be created + Try + { + + $task = Wait-OVTaskComplete $task #-Appliance $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $objStatus.Status = $task.taskState + $objStatus.Details = $task + + } + + [void] $colStatus.add($objStatus) #| Out-Null + + # Update Bandwidth allocation if set to different than default values, bypassing bulk network create and VM appliance + if (($typicalBandwidth -or $maximumBandwidth) -and + (-not($objStatus.Status -eq "Failed")) -and + $net.type -ne $EthernetNetworkBulkType -and + ($ApplianceConnection | ? ConnectionID -eq $_appliance.ConnectionId).ApplianceType -ne "VMA") + { + + "[{0}] Setting bandwidth to network object" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + "[{0}] Getting Network object to retrieve ConnectionTemplate URI" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + # Get network resource URI + Try + { + + $net = Send-OVRequest $task.associatedResource.resourceUri -Hostname $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + "[{0}] ConnectionTemplate URI '$($net.connectionTemplateUri)'" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if ($net -and $net.connectionTemplateUri) + { + + $ctUri = $net.connectionTemplateUri + + Try + { + + $ct = Send-OVRequest -Uri $ctUri -Hostname $_appliance + + if ($typicalBandwidth) { $ct.bandwidth.typicalBandwidth = $typicalBandwidth } + + if ($maximumBandwidth) { $ct.bandwidth.maximumBandwidth = $maximumBandwidth } + + $void = Send-OVRequest -Uri $ct.uri -Method PUT -Body $ct -Hostname $ct.ApplianceConnection.Name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + if ($PSBoundParameters['NetworkSet'] -and -not $PSBoundParameters['VlanRange']) + { + + ForEach ($_netset in $NetworkSet) + { + + "[{0}] NetworkSet {1} was provided, validating." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_netset.name | Write-Verbose + + # Genrate Error + if (-not($_netset -is [PSCustomObject])) + { + + $Message = 'The NetworkSet Parameter value is not an Object. Please provide a valid Object by using the Get-OVNetworkSet Cmdlet.' + $ErrorRecord = New-ErrorRecord HPEOneView.NetworkResourceException InvalidHPOVNetworkSetValue InvalidArgument 'NetworkSet' -TargetType $_subnet.Gettype().Name -Message $Message + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + # Genrate Error, invalid object type + if ($ResourceCategoryEnum.NetworkSet -ne $_netset.category) + { + + $Message = "The NetworkSet Parameter value is not a valid IP Subnet object. The object category provided was {0}. Please provide a valid Object by using the Get-OVNetworkSet Cmdlet." -f $Subnet.category + $ErrorRecord = New-ErrorRecord HPEOneView.NetworkResourceException InvalidHPOVNetworkSetObject InvalidArgument 'NetworkSet' -TargetType 'PSObject' -Message $Message + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + # Invalid object for the appliance connection + if ($_netset.ApplianceConnection.Name -ne $_appliance.Name) + { + + $Message = "The NetworkSet Parameter value is missing the 'ApplianceConnection' property. Please provide a valid Object by using the Get-OVNetworkSet Cmdlet." + $ErrorRecord = New-ErrorRecord HPEOneView.NetworkResourceException InvalidNetworkTypeOperation InvalidOperation 'NetworkSet' -TargetType 'PSObject' -Message $Message + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Set-OVNetworkSet -InputObject $_netset -AddNetwork $net -ApplianceConnection $_appliance | Wait-OVTaskComplete | Out-Null + + } + + } + + } + + } + + } + + End + { + + if ($colStatus | Where-Object { $_.Status -ne "Completed" }) + { + + write-error "One or more networks failed the creation attempt!" + + } + + Return $colStatus + + } + +} + +function VerifyManagedSan +{ + + [CmdletBinding ()] + Param + ( + + [Parameter (Mandatory = $false)] + [ValidateNotNullorEmpty()] + [Object]$managedSan, + + [Parameter (Mandatory)] + [ValidateNotNullorEmpty()] + [object]$Appliance + + ) + + Process + { + + if ($managedSan -eq "" -or $Null -eq $ManagedSan) + { + + $managedSanUri = $Null + + } + + elseif ($managedSan -is [PSCustomObject] -and $managedSan.category -eq $ResourceCategoryEnum.ManagedSAN) + { + + $managedSanUri = $managedSan.uri + + } + + elseif ($managedSan -is [PSCustomObject] -and -not ($managedSan.category -eq $ResourceCategoryEnum.ManagedSAN)) + { + + $ErrorRecord = New-ErrorRecord HPEOneView.NetworkResourceException InvalidManagedSanUri InvalidArgument 'managedSan' -Message "The Managed SAN object category provided '$($managedSan.category)' is not the the expected value of 'fc-sans'. Please verify the Parameter value and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($managedSan -is [String] -and $managedSan.StartsWith('/rest/')) + { + + $ErrorRecord = New-ErrorRecord HPEOneView.NetworkResourceException InvalidManagedSanUri InvalidArgument 'managedSan' -Message "The Managed SAN Uri provided '$managedSan' is incorrect. Managed SAN URI must Begin with '/rest/fc-sans/managed-sans'." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($managedSan -is [String] -and (-not($managedSan.StartsWith($script:fcManagedSansUri)))) + { + + # Get ManagedSan object + Try { $managedSanUri = (Get-OVManagedSan $managedSan -appliance $Appliance).uri } + + # If specified ManagedSan object does not exist, generate trappable error + catch + { + + $ErrorRecord = New-ErrorRecord HPEOneView.NetworkResourceException InvalidManagedSanName InvalidArgument 'managedSan' -Message "The Managed SAN Name provided '$managedSan' was not found." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + else + { + + $managedSanUri = $managedSan + + } + + Return $managedSanUri + + } + +} + +function Get-OVNetwork +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = 'Default')] + Param + ( + + [Parameter (ParameterSetName = 'Default', ValueFromPipeline, Mandatory = $false)] + [ValidateNotNullOrEmpty ()] + [SupportsWildcards ()] + [String]$Name, + + [Parameter (ParameterSetName = 'Default', Mandatory = $false)] + [ValidateSet ("Ethernet", "FC", "FibreChannel", "FCOE", "ROCE")] + [String]$Type, + + [Parameter (ParameterSetName = 'Default', Mandatory = $false)] + [ValidateSet ("General", "Management", "VMMigration", "FaultTolerance", "ISCSI")] + [String]$Purpose, + + [Parameter (ParameterSetName = 'Default', Mandatory = $false)] + [ValidateNotNullOrEmpty ()] + [Object]$Scope = "AllResourcesInScope", + + [Parameter (ParameterSetName = 'Default', Mandatory = $false)] + [ValidateNotNullOrEmpty ()] + [String]$Label, + + [Parameter (ParameterSetName = 'Default', Mandatory = $false)] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default), + + [Parameter (ParameterSetName = 'Default', Mandatory = $false)] + [Alias ("x", "export")] + [ValidateScript ({split-path $_ | Test-Path})] + [String]$exportFile + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not($PSBoundParameters['type'])) + { + + "[{0}] -Type Parameter wasn't provided. Specifying all Network Resource Types." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + [Array]$Type = "Ethernet","FibreChannel","FCOE","ROCE" + + } + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $NetworkCollection = [System.Collections.ArrayList]::new() + + } + + Process + { + + ForEach ($_appliance in $ApplianceConnection) + { + + if ($PSBoundParameters['Purpose']) + { + + $Type = 'Ethernet' + + } + + $Found = [System.Collections.ArrayList]::new() + + "[{0}] Processing '{1}' Appliance (of {2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name, $ApplianceConnection.Count | Write-Verbose + + # Build the category to search for + $_Category = [System.Text.StringBuilder]::new() + + switch ($Type) + { + + "Ethernet" + { + + [void]$_Category.Append('category=ethernet-networks&') + + } + + {"FibreChannel", "FC" -contains $_} + { + + [void]$_Category.Append('category=fc-networks&') + + } + + "FCOE" + { + + [void]$_Category.Append('category=fcoe-networks&') + + } + + "ROCE" + { + + [void]$_Category.Append('category=roce-networks&') + + } + + } + + $_Query = [System.Collections.ArrayList]::new() + + # Handle default cause of AllResourcesInScope + if ($Scope -eq 'AllResourcesInScope') + { + + "[{0}] Processing AllResourcesInScope." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_Scopes = $ApplianceConnection.ActivePermissions | Where-Object Active + + # If one scope contains 'AllResources' ScopeName "tag", then all resources should be returned regardless. + if ($_Scopes | Where-Object ScopeName -eq 'AllResources') + { + + $_ScopeNames = [String]::Join(', ', ($_Scopes | Where-Object ScopeName -eq 'AllResources').ScopeName) + + "[{0}] Scope(s) {1} is set to 'AllResources'. Will not add scope to URI query parameter." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_ScopeNames | Write-Verbose + + } + + # Process ApplianceConnection ActivePermissions collection + else + { + + Try + { + + $_ScopeQuery = Join-Scope $_Scopes + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + [Void]$_Query.Add(("({0})" -f $_ScopeQuery)) + + } + + } + + elseif ($Scope | Where-Object ScopeName -eq 'AllResources') + { + + $_ScopeNames = [String]::Join(', ', ($_Scopes | Where-Object ScopeName -eq 'AllResources').ScopeName) + + "[{0}] Scope(s) {1} is set to 'AllResources'. Will not add scope to URI query parameter." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_ScopeNames | Write-Verbose + + } + + elseif ($Scope -eq 'AllResources') + { + + "[{0}] Requesting scope 'AllResources'. Will not add scope to URI query parameter." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_ScopeNames | Write-Verbose + + } + + else + { + + Try + { + + $_ScopeQuery = Join-Scope $Scope + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + [Void]$_Query.Add(("({0})" -f $_ScopeQuery)) + + } + + if ($Name) + { + + if ($Name.Contains('*')) + { + + [Void]$_Query.Add(("name%3A{0}" -f $Name.Replace(" ","?").Replace("*", "%2A"))) + + } + + else + { + + [Void]$_Query.Add(("name:'{0}'" -f $Name)) + + } + + } + + if ($Label) + { + + [Void]$_Query.Add(("labels:'{0}'" -f $Label)) + + } + + if ($Purpose) + { + + [Void]$_Query.Add(("purpose:'{0}'" -f $Purpose)) + + } + + # Build the final URI + $_uri = '{0}?{1}sort=name:asc&query={2}' -f $IndexUri, $_Category.ToString(), [String]::Join(' AND ', $_Query.ToArray()) + + Try + { + + $_NetworksFromIndexCol = Get-AllIndexResources -Uri $_uri -ApplianceConnection $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + ForEach ($_member in $_NetworksFromIndexCol) + { + + switch ($_member.category) + { + + 'ethernet-networks' + { + + $_member.psobject.typenames.Insert(0,"HPEOneView.Networking.EthernetNetwork") + + } + + 'fc-networks' + { + + $_member.psobject.typenames.Insert(0,"HPEOneView.Networking.FibreChannelNetwork") + + } + + 'fcoe-networks' + { + + $_member.psobject.typenames.Insert(0,"HPEOneView.Networking.FCoENetwork") + + } + + 'roce-networks' + { + + $_member.psobject.typenames.Insert(0,"HPEOneView.Networking.RoCENetwork") + + } + + } + + "[{0}] Adding '{1}' to found collection" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_member.Name | Write-Verbose + + [void]$Found.Add($_member) + + } + + # If network not found, report error + if ($Found.Count -eq 0 -and $Name) + { + + "[{0}] Network Resource Name was provided, yet no results were found. Generate Error." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $ExceptionMessage = "The specified '{0}' Network resource was not found on '{1}' appliance connection. Please check the name and try again." -f $Name, $_appliance.Name + $ErrorRecord = New-ErrorRecord HPEOneView.NetworkResourceException NetworkResourceNotFound ObjectNotFound "Name" -Message $ExceptionMessage + $PSCmdlet.WriteError($ErrorRecord) + + } + + else + { + + ForEach ($_item in $Found) + { + + "[{0}] Adding '{1}' to final collection" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_item.Name | Write-Verbose + + [void]$NetworkCollection.Add($_item) + + } + + } + + } + + } + + End + { + + if ($NetworkCollection) + { + + "[{0}] Results returned " -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + "[{0}] Networks Found: {1} " -f $MyInvocation.InvocationName.ToString().ToUpper(), $NetworkCollection.Count | Write-Verbose + + "[{0}] Getting Network resource Connection Template Object to add bandwidth values to network objects." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + ForEach ($NetObject in $NetworkCollection) + { + + "[{0}] Processing '$($NetObject.Name)' Network resource." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if ($NetObject.connectionTemplateUri) + { + + Try + { + + $ct = Send-OVRequest -uri $NetObject.connectionTemplateUri -Hostname $NetObject.ApplianceConnection.Name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + Add-Member -InputObject $NetObject -NotePropertyName defaultMaximumBandwidth -NotePropertyValue $ct.bandwidth.maximumBandwidth -Force + Add-Member -InputObject $NetObject -NotePropertyName defaultTypicalBandwidth -NotePropertyValue $ct.bandwidth.typicalBandwidth -Force + + } + + } + + "[{0}] Done. {1} network resource(s) found." -f $MyInvocation.InvocationName.ToString().ToUpper(), $NetworkCollection.Count | Write-Verbose + + if ($exportFile) + { + + "[{0}] Exporting JSON to $($exportFile)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $NetworkCollection | Sort-Object type,name | convertto-json > $exportFile + + } + + else + { + + $NetworkCollection | Sort-Object type,name + + } + + } + + # No networks found + else + { + + "[{0}] No Network resources found." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + } + +} + +function Set-OVNetwork +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "Ethernet")] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = "Ethernet")] + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = "FibreChannel")] + [ValidateNotNullOrEmpty()] + [Alias ('net','Network')] + [Object]$InputObject, + + [Parameter (Mandatory = $false, ParameterSetName = "Ethernet")] + [Parameter (Mandatory = $false, ParameterSetName = "FibreChannel")] + [ValidateNotNullOrEmpty()] + [String]$Name, + + [Parameter (Mandatory = $false, ParameterSetName = "Ethernet")] + [Parameter (Mandatory = $false, ParameterSetName = "FibreChannel")] + [ValidateNotNullOrEmpty()] + [String]$Prefix, + + [Parameter (Mandatory = $false, ParameterSetName = "Ethernet")] + [Parameter (Mandatory = $false, ParameterSetName = "FibreChannel")] + [ValidateNotNullOrEmpty()] + [String]$Suffix, + + [Parameter (Mandatory = $false, ParameterSetName = "Ethernet")] + [ValidateNotNullOrEmpty()] + [ValidateSet ("General", "Management", "VMMigration", "FaultTolerance", "ISCSI")] + [String]$Purpose, + + [Parameter (Mandatory = $false, ParameterSetName = "Ethernet")] + [Bool]$Smartlink, + + [Parameter (Mandatory = $false, ParameterSetName = "Ethernet")] + [Bool]$PrivateNetwork, + + [Parameter (Mandatory = $false, ParameterSetName = "Ethernet")] + [Parameter (Mandatory = $false, ParameterSetName = "FibreChannel")] + [ValidateRange(2,50000)] + [int32]$TypicalBandwidth = 2500, + + [Parameter (Mandatory = $false, ParameterSetName = "Ethernet")] + [Parameter (Mandatory = $false, ParameterSetName = "FibreChannel")] + [validaterange(100,50000)] + [int32]$MaximumBandwidth, + + [Parameter (Mandatory = $false, ParameterSetName = "FibreChannel")] + [ValidateRange(1,1800)] + [Alias ('lst')] + [int32]$LinkStabilityTime, + + [Parameter (Mandatory = $false, ParameterSetName = "FibreChannel")] + [Alias ('ald')] + [Bool]$AutoLoginRedistribution, + + [Parameter (Mandatory = $false, ParameterSetName = "FibreChannel")] + [ValidateNotNullOrEmpty()] + [Object]$ManagedSan, + + [Parameter (Mandatory = $false, ParameterSetName = "Ethernet")] + [Object]$IPv4Subnet, + + [Parameter (Mandatory = $false, ParameterSetName = "Ethernet")] + [Object]$IPv6Subnet, + + [Parameter (ValueFromPipelineByPropertyName, Mandatory = $false, ParameterSetName = "Ethernet")] + [Parameter (ValueFromPipelineByPropertyName, Mandatory = $false, ParameterSetName = "FibreChannel")] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not($PSBoundParameters['InputObject'])) + { + + "[{0}] Network resource passed via pipeline." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $PipelineInput = $True + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + $_NetworksToUpdate = [System.Collections.ArrayList]::new() + $NetCollection = [System.Collections.ArrayList]::new() + + } + + Process + { + + #build collection of networks to modify + foreach ($net in $InputObject) + { + + if ($PSBoundParameters['LinkStabilityTime'] -and $net.category -eq $ResourceCategoryEnum.FCoENetwork) + { + + $ErrorRecord = New-ErrorRecord HPEOneView.NetworkResourceException InvalidArgumentValue InvalidArgument 'LinkStabilityTime' -TargetType 'Int' -Message "The -LinkStabilityTime Parameter is not supported with FCoE Network resources, only FibreChannel network resources. Please check your call and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + if ($PSBoundParameters['AutoLoginRedistribution'] -and $net.category -eq $ResourceCategoryEnum.FCoENetwork) + { + + $ErrorRecord = New-ErrorRecord HPEOneView.NetworkResourceException InvalidArgumentValue InvalidArgument 'AutoLoginRedistribution' -TargetType 'Boolean' -Message "The -AutoLoginRedistribution Parameter is not supported with FCoE Network resources, only FibreChannel network resources. Please check your call and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + # Check the name Parameter value if the caller inadvertantly provided an object for name Parameter + if ($name -and ([RegEx]::Match($name, "category=ethernet-networks", $RegExInsensitiveFlag).Success -or [RegEx]::Match($name, "category=fc-networks", $RegExInsensitiveFlag).Success -or [RegEx]::Match($name, "category=fcoe-networks", $RegExInsensitiveFlag).Success)) + { + + $ErrorRecord = New-ErrorRecord HPEOneView.NetworkResourceException InvalidArgumentValue InvalidArgument 'Name' -Message "The -name Parameter value appears to have been passed the network resource object, which is converted to type [String] and is an invalid operation. Please verify that you provided the Network Name attribute in the -name Parameter value and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($name -and $name.length -gt 255) + { + + $ErrorRecord = New-ErrorRecord HPEOneView.NetworkResourceException InvalidArgumentValue InvalidArgument 'Name' -Message "The -name Parameter value is greater than 255 characters. Please check the -name Parameter value and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + switch ($net.Gettype().Name) + { + + "PSCustomObject" + { + + if ($net -is [PSCustomObject] -and ($net.category -eq $ResourceCategoryEnum.EthernetNetwork -or $net.category -eq $ResourceCategoryEnum.FibreChannelNetwork -or $net.category -eq $ResourceCategoryEnum.FCoENetwork)) + { + + "[{0}] Collecting $($net.type) $($net.name) resource." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + else + { + + $ErrorRecord = New-ErrorRecord HPEOneView.NetworkResourceException InvalidArgumentValue InvalidArgument 'InputObject' -TargetType 'PSObject' -Message "[$($net.gettype().name)] is an unspported data type. Only [System.String] or [PSCustomObject] or an [Array] of [System.String] or [PSCustomObject] network resources are allowed. Please check the -network Parameter value and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + "String" + { + + # User provided Network 'name' and 1 or more Appliance Connections + if ($net -is [String] -and (-not ($net.StartsWith('/rest/')))) + { + + ForEach ($_appliance in $ApplianceConnection) + { + + "[{0}] Getting '$($net)' resource from appliance." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $net = Get-OVNetwork -Name $net -type $PSCmdlet.ParameterSetName -ApplianceConnection $_appliance -ErrorAction Stop + + } + + Catch [HPEOneView.NetworkResourceException] + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if ($net.count -gt 1) + { + + $ErrorRecord = New-ErrorRecord HPEOneView.NetworkResourceException NonUniqueNetworkName InvalidResult 'InputObject' -Message "Multiple '$_tempNet' Network resource found with the same name. Please check the value and try again, or provide the Network Resource Object instead of the name." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + } + + elseif ($net -is [String] -and ($net.StartsWith($EthernetNetworksUri) -or $net.StartsWith($FCNetworksUri))) + { + + "[{0}] Getting '$($net)' resource from appliance." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $net = Send-OVRequest -URi $net -Appliance $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + } + + # Perform the work + # Set Specific Network Type settings + switch ($net.category) + { + + "ethernet-networks" + { + + "[{0}] Updating $($net.name) Ethernet Network." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + switch ($PSBoundParameters.keys) + { + + "purpose" + { + + "[{0}] Setting network Purpose to: $purpose" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $net.purpose = $EthernetNetworkPurposeEnum[$Purpose] + + } + + "smartlink" + { + + "[{0}] Setting smartlink Enabled to: $([Bool]$smartlink)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $net.smartlink = [Bool]$Smartlink + + } + + "privateNetwork" + { + + "[{0}] Setting privateNetwork Enabled to: $([Bool]$privateNetwork)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $net.privateNetwork = [Bool]$PrivateNetwork + + } + + 'IPv4Subnet' + { + + if ($null -eq $PSBoundParameters['IPv4Subnet']) + { + + "[{0}] Setting subnetUri to null" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $net.subnetUri = $null + + } + + else + { + + if ($IPv4Subnet.category -ne $ResourceCategoryEnum.IPv4Subnet) + { + + "[{0}] Invalid IPv4 Address Pool resource object." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $ExceptionMessage = "An invalid IPv4 Address Pool resource object was provided. Please verify the Parameter value and try again." + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AddressPoolResourceException InvalidIPv4AddressPoolResource InvalidArgument 'IPv4Subnet' -TargetType 'PSObject' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + $net.subnetUri = $IPv4Subnet.uri + + } + + } + + 'IPv6Subnet' + { + + if ($null -eq $PSBoundParameters['IPv6Subnet']) + { + + "[{0}] Setting subnetIPv6Uri to null" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $net.ipv6SubnetUri = $null + + } + + else + { + + if ($IPv6Subnet.category -ne $ResourceCategoryEnum.IPv6Subnet) + { + + "[{0}] Invalid IPv6 Address Pool resource object." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $ExceptionMessage = "An invalid IPv6 Address Pool resource object was provided. Please verify the Parameter value and try again." + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AddressPoolResourceException InvalidIPv4AddressPoolResource InvalidArgument 'IPv6Subnet' -TargetType 'PSObject' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + $net.ipv6SubnetUri = $IPv6Subnet.uri + + } + + } + + } + + } + + "fc-networks" + { + + switch ($PSBoundParameters.keys) + { + + "LinkStabilityTime" + { + + "[{0}] Setting LinkStabilityTime to '$LinkStabilityTime' seconds" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if ($net.fabricType -eq 'DirectAttach') + { + + $ExceptionMessage = "Cannot set LinkStabilityTime value to a DirectAttach FibreChannel resource, {0}." -f $net.name + $ErrorRecord = New-ErrorRecord HPEOneView.NetworkResourceException InvalidFabricOperation InvalidOperation 'LinkStabilityTime' -TargetType $LinkStabilityTime.Gettype().Name -Message $ExeptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + $net.linkStabilityTime = [Int]$linkStabilityTime + + } + + "AutoLoginRedistribution" + { + + "[{0}] Setting AutoLoginRedistribution Enabled to: $([Bool]$AutoLoginRedistribution)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if ($net.fabricType -eq 'DirectAttach') + { + + $ExceptionMessage = "Cannot set AutoLoginRedistribution value to a DirectAttach FibreChannel resource, {0}" -f $net.name + $ErrorRecord = New-ErrorRecord HPEOneView.NetworkResourceException InvalidFabricOperation InvalidOperation 'AutoLoginRedistribution' -TargetType $AutoLoginRedistribution.Gettype().Name -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + $net.autoLoginRedistribution = [Bool]$autoLoginRedistribution + + if ($net.linkStabilityTime -eq 0 -and (-not($LinkStabilityTime)) -and [Bool]$AutoLoginRedistribution) + { + + $ExceptionMessage = "The '{0}' FC Network resource is a Direct Attach fabric. The Managed SAN resource cannot be modified." -f $_net.name + $ErrorRecord = New-ErrorRecord HPEOneView.NetworkResourceException InvalidLinkStabilityTimeValue InvalidOperation 'AutoLoginRedistribution' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + "ManagedSan" + { + + if ($null -eq $PSBoundParameters['ManagedSan']) + { + + "[{0}] Setting managedSanUri to null" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $net.managedSanUri = $null + + } + + else + { + + if ($net.fabricType -eq 'DirectAttach') + { + + $ErrorRecord = New-ErrorRecord HPEOneView.NetworkResourceException InvalidFabricOperation InvalidResult 'Network' -Message ("The '{0}' FC Network resource is a Direct Attach fabric. The Managed SAN resource cannot be modified." -f $net.name) + $PSCmdlet.WriteError($ErrorRecord) + + } + + else + { + + "[{0}] Processing ManagedSAN for FC Network." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $net.managedSanUri = (VerifyManagedSan $managedSan $net.ApplianceConnection.Name) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + } + + } + + } + + "fcoe-networks" + { + + switch ($PSBoundParameters.keys) + { + + "managedSan" + { + + "[{0}] Processing ManagedSAN for FC Network." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $net.managedSanUri = (VerifyManagedSan $managedSan $net.ApplianceConnection.Name) + + } + + } + + } + + } + + # Shared Parameters for each Network Type + if ($PSBoundParameters["name"]) + { + + "[{0}] Updating Network name to '$name'." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + # Validate name Parameter is [String] + $net.name = $name + + } + + if ($PSBoundParameters["prefix"]) + { + + "[{0}] Updating Network name to include '$prefix' prefix to Network Name." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + "[{0}] Updated Network Name: $($prefix + $net.name)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + # Validate name Parameter is [String] + $net.name = $prefix + $net.name + + } + + if ($PSBoundParameters["suffix"]) + { + + "[{0}] Updating Network name to include '$suffix' suffix to Network Name." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + "[{0}] Updated Network Name: $($net.name + $suffix)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + # Validate name Parameter is [String] + $net.name += $suffix + + } + + if ($PSBoundParameters["typicalBandwidth"] -or $PSBoundParameters["maximumBandwidth"]) + { + + "[{0}] Updating Network bandwidth assignment." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + "[{0}] Getting Connection Template resource." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $ct = Send-OVRequest $net.connectionTemplateUri -Appliance $net.ApplianceConnection.Name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if ($PSBoundParameters["maximumBandwidth"]) + { + + "[{0}] Original Maximum bandwidth assignment: $($ct.bandwidth.maximumBandwidth)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + "[{0}] New Maximum bandwidth assignment: $maximumBandwidth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $ct.bandwidth.maximumBandwidth = $maximumBandwidth + + } + + if($PSBoundParameters["typicalBandwidth"]) + { + + "[{0}] Original Typical bandwidth assignment: $($ct.bandwidth.typicalBandwidth)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + "[{0}] New Typical bandwidth assignment: $typicalBandwidth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $ct.bandwidth.typicalBandwidth = $typicalBandwidth + + } + + Try + { + + $ct = Send-OVRequest -Uri $ct.uri -Method PUT -Body $ct -Appliance $ct.ApplianceConnection.Name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + + } + + $net = $net | Select-Object * -ExcludeProperty defaultTypicalBandwidth, defaultMaximumBandwidth, created, modified + + Try + { + + $resp = Send-OVRequest -Uri $net.uri -Method PUT -Body $net -Appliance $net.ApplianceConnection.Name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $resp + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Remove-OVNetwork +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "Default", SupportsShouldProcess, ConfirmImpact = 'High')] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = "Default")] + [ValidateNotNullOrEmpty()] + [Alias ('uri', 'name', 'network', 'Resource')] + [System.Object]$InputObject, + + [Parameter (Mandatory = $False, ValueFromPipelineByPropertyName, ParameterSetName = "Default")] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default), + + [Parameter (Mandatory = $False, ParameterSetName = "Default")] + [Switch]$Force + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not($PSBoundParameters['Resource'])) + { + + $PipelineInput = $True + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + $_TaskCollection = [System.Collections.ArrayList]::new() + $_NetworkCollection = [System.Collections.ArrayList]::new() + + } + + Process + { + + if ($PipelineInput) + { + + "[{0}] Processing Pipeline input" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + "[{0}] Network Object provided." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + "[{0}] object name: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject.name | Write-Verbose + "[{0}] object uri: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject.uri | Write-Verbose + "[{0}] object appliance connection: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject.ApplianceConnection.Name | Write-Verbose + "[{0}] object category: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject.category | Write-Verbose + + If ($ResourceCategoryEnum.EthernetNetwork, $ResourceCategoryEnum.FibreChannelNetwork, $ResourceCategoryEnum.FCoENetwork, $ResourceCategoryEnum.RoCENetwork -contains $InputObject.category) + { + + If (-not($InputObject.ApplianceConnection)) + { + + $ErrorRecord = New-ErrorRecord InvalidOperationException InvalidArgumentValue InvalidArgument "Network:$($InputObject.Name)" -TargetType PSObject -Message "The Network resource provided is missing the source ApplianceConnection property. Please check the object provided and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + [void]$_NetworkCollection.Add($InputObject) + + } + + else + { + + $ErrorRecord = New-ErrorRecord InvalidOperationException InvalidArgumentValue InvalidArgument "Network:$($InputObject.Name)" -TargetType PSObject -Message "The Network resource is not an expected category type [$($InputObject.category)]. Allowed resource category types are 'ethernet-networks', 'fc-networks', or 'fcoe-networks'. Please check the object provided and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + else + { + + foreach ($net in $InputObject) + { + + # Network passed is a URI + if (($net -is [String]) -and [System.Uri]::IsWellFormedUriString($net,'Relative')) + { + + "[{0}] Received URI: $($net)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + "[{0}] Getting Network Name" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $net = Send-OVRequest -Uri $net -ApplianceConnection $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + # Network passed is the Name + elseif (($net -is [String]) -and (!$net.startsWith("/rest"))) + { + + "[{0}] Received Network Name $($net)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + "[{0}] Getting Network object from Get-OVNetwork" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + # // NEED APPLIANCE NAME HERE with If Condition + $net = Get-OVNetwork -Name $net -ApplianceConnection $ApplianceConnection + + if ($network.count -gt 1 ) + { + + $ErrorRecord = New-ErrorRecord InvalidOperationException NetworkResourceNameNotUnique InvalidResult 'Remove-OVNetwork' -Message "Invalid Network Parameter: $net" + $PSCmdlet.WriteError($ErrorRecord) + + } + + } + + # Network passed is the object + elseif ($net -is [PSCustomObject] -and ('ethernet-networks', 'fc-networks', 'fcoe-networks' -match $net.category)) + { + + "[{0}] Network Object provided.)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + "[{0}] object name: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $net.name | Write-Verbose + "[{0}] object uri: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $net.uri | Write-Verbose + "[{0}] object appliance connection: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $net.ApplianceConnection.Name | Write-Verbose + "[{0}] object category: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $net.category | Write-Verbose + + } + + else + { + + $ErrorRecord = New-ErrorRecord InvalidOperationException InvalidArgumentValue InvalidArgument 'Network' -TargetType 'PSObject' -Message "Invalid Network Parameter: $($net )" + $PSCmdlet.WriteError($ErrorRecord) + + } + + [void]$_NetworkCollection.Add($InputObject) + + } + + } + + } + + End + { + + "[{0}] Processing $($_NetworkCollection.count) Network resources to remove." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + # Process Network Resources + ForEach ($_network in $_NetworkCollection) + { + + if ($PSCmdlet.ShouldProcess($_network.name,"Remove Network from appliance '$($_network.ApplianceConnection.Name)'")) + { + + "[{0}] Removing Network '$($_network.name)' from appliance '$($_network.ApplianceConnection.Name)'." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + if ($PSBoundParameters['Force']) + { + + $_network.uri += "?force=true" + + } + + $_resp = Send-OVRequest -Uri $_network.Uri -Method DELETE -AddHeader @{'If-Match' = $_network.eTag } -Hostname $_network.ApplianceConnection.Name + + [void]$_TaskCollection.Add($_resp) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + elseif ($PSBoundParameters['WhatIf']) + { + + "[{0}] WhatIf Parameter was passed." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + } + + Return $_TaskCollection + + } + +} + +function New-OVNetworkSet +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding ()] + Param + ( + + [Parameter (Mandatory)] + [ValidateNotNullorEmpty()] + [String]$Name, + + [Parameter (Mandatory = $false)] + [Alias ('networkUris')] + [ValidateNotNullorEmpty()] + [Object]$Networks, + + [Parameter (Mandatory = $False)] + [Alias ('untagged','native','untaggedNetworkUri')] + [Object]$UntaggedNetwork, + + [Parameter (Mandatory = $False)] + [Switch]$Large, + + [Parameter (Mandatory = $False)] + [ValidateRange(2,50000)] + [int32]$TypicalBandwidth = 2500, + + [Parameter (Mandatory = $False)] + [ValidateRange(2,50000)] + [int32]$MaximumBandwidth = 10000, + + [Parameter (Mandatory = $False)] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $_NetSetStatusCol = [System.Collections.ArrayList]::new() + + } + + Process + { + + + "[{0}] Processing '{1}' Appliance Connection" -f $MyInvocation.InvocationName.ToString().ToUpper(), $ApplianceConnection.Name | Write-Verbose + + "[{0}] Building NetworkSet '{1}' object." -f $MyInvocation.InvocationName.ToString().ToUpper(), $Name | Write-Verbose + + $_NewNetSet = Newobject -NetworkSet + + $_NewNetSet.name = $Name + + # Validate Networks if they are objects, and ApplianceConnection prop matches $_connection.Name value + ForEach ($_net in $Networks) + { + + switch ($_net.GetType().Name) + { + + 'String' + { + + # URI provided + if ($_net.StartsWith($EthernetNetworksUri)) + { + + "[{0}] Network resource is [String] and URI. Getting resource object." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + try + { + + $_net = Send-OVRequest -Uri $_net -Hostname $ApplianceConnection.Name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + # Name provided + else + { + + "[{0}] Network resource is [String] and Name. Getting resource object." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + try + { + + $_originalnet = $_net.Clone() + + $_net = Get-OVNetwork -Name $_net -ApplianceConnection $ApplianceConnection.Name -ErrorAction Stop + + if ($_net.count -gt 1) + { + + $ErrorRecord = New-ErrorRecord HPEOneView.NetworkResourceException MultipleNetworkResourcesFound LimitsExceeded 'Networks' -Message "Network '$_originalnet' is not a unique resource name, as multiple Network resources were found. Please correct the Parameter value and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + 'PSCustomObject' + { + + "[{0}] Processing Object." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + "[{0}] object name: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_net.name | Write-Verbose + "[{0}] object uri: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_net.uri | Write-Verbose + "[{0}] object appliance connection: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_net.ApplianceConnection.Name | Write-Verbose + "[{0}] object category: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_net.category | Write-Verbose + + # Object must have the ApplianceConnection NoteProperty + if (-not($_net.ApplianceConnection)) + { + + $ErrorRecord = New-ErrorRecord HPEOneView.NetworkResourceException MissingApplianceConnectionNoteProperty InvalidArgument 'Networks' -TargetType 'PSObject' -Message "Network '$($_net.name)' does not contain the required 'ApplianceConnection' NoteProperty. Network objects must be retrieved from the appliance either using their unique URI or with Get-OVNetwork. Please correct the Parameter value and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($_net.ApplianceConnection.Name -ne $ApplianceConnection.Name) + { + + $ErrorRecord = New-ErrorRecord HPEOneView.NetworkResourceException ApplianceConnetionDoesNotMatchObject InvalidArgument 'Networks' -TargetType 'PSObject' -Message "Network '$($_net.name)' 'ApplianceConnection' NoteProperty {$($_net.ApplianceConnection.Name)}does not match the Appliance Connection currently Processing {$($ApplianceConnection.Name)}. Network objects must be retrieved from the appliance either using their unique URI or with Get-OVNetwork. Please correct the Parameter value and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + if ($_net.category -ne 'ethernet-networks') + { + + $ErrorRecord = New-ErrorRecord HPEOneView.NetworkResourceException UnsupportedResourceCategory InvalidArgument 'Networks' -TargetType 'PSObject' -Message "Network '$($_net.name)' category {$($_net.category)} is not the supported type, 'ethernet-networks'. Network objects must be retrieved from the appliance either using their unique URI or with Get-OVNetwork using the -Type Ethernet Parameter. Please correct the Parameter value and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + default + { + + $ErrorRecord = New-ErrorRecord HPEOneView.NetworkResourceException UnsupportedParameterValueType InvalidType 'Networks' -TargetType $_Net.GetType().Name -Message "The provided Networks Parameter value type '$($_Net.GetType().Name)' is not supported. Only String (Name or URI) or PSCustomObject types are allowed and supported. Please correct the Parameter value and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + [void]$_NewNetSet.networkUris.Add($_net.uri) + + } + + if ($Large) + { + + "[{0}] Setting NetworkSetType to 'Large'." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_NewNetSet.networkSetType = 'Large' + + } + + else + { + + "[{0}] Setting NetworkSetType to 'Regular'." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_NewNetSet.networkSetType = 'Regular' + + } + + if ($PSboundParameters['UntaggedNetwork']) + { + + # Validate UntaggedNetwork if it is an object, and ApplianceConnection prop matches $_connection.Name value + switch ($UntaggedNetwork.GetType().Name) + { + + 'String' + { + + # URI provided + if ($UntaggedNetwork.StartsWith($EthernetNetworksUri)) + { + + "[{0}] UntaggedNetwork resource is [String] and URI. Getting resource object." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + try + { + + $UntaggedNetwork = Send-OVRequest -Uri $UntaggedNetwork -Hostname $ApplianceConnection.Name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + # Name provided + else + { + + "[{0}] UntaggedNetwork resource is [String] and Name. Getting resource object." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + try + { + + $UntaggedNetwork = Get-OVNetwork -Name $UntaggedNetwork -ApplianceConnection $ApplianceConnection.Name -ErrorAction Stop + + if ($UntaggedNetwork.count -gt 1) + { + + $ErrorRecord = New-ErrorRecord HPEOneView.NetworkResourceException MultipleNetworkResourcesFound LimitsExceeded 'UntaggedNetwork' -Message "Network '$_originalnet' is not a unique resource name, as multiple Network resources were found. Please correct theParameter value and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + 'PSCustomObject' + { + + "[{0}] Processing Untagged object." -f $MyInvocation.InvocationName.ToString().ToUpper(), $UntaggedNetwork.name | Write-Verbose + "[{0}] object name: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $UntaggedNetwork.name | Write-Verbose + "[{0}] object uri: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $UntaggedNetwork.uri | Write-Verbose + "[{0}] object appliance connection: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $UntaggedNetwork.ApplianceConnection.Name | Write-Verbose + "[{0}] object category: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $UntaggedNetwork.category | Write-Verbose + + # Object must have the ApplianceConnection NoteProperty + if (-not($UntaggedNetwork.ApplianceConnection)) + { + + $ErrorRecord = New-ErrorRecord HPEOneView.NetworkResourceException MissingApplianceConnectionNoteProperty InvalidArgument 'UntaggedNetwork' -TargetType 'PSObject' -Message "Network '$($UntaggedNetwork.name)' does not contain the required 'ApplianceConnection' NoteProperty. Networkobjects must be retrieved from the appliance either using their unique URI or with Get-OVNetwork. Please correct the Parameter value and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($UntaggedNetwork.ApplianceConnection.Name -ne $ApplianceConnection.Name) + { + + $ErrorRecord = New-ErrorRecord HPEOneView.NetworkResourceException ApplianceConnetionDoesNotMatchObject InvalidArgument 'UntaggedNetwork' -TargetType 'PSObject' -Message "Network '$($UntaggedNetwork.name)' 'ApplianceConnection' NoteProperty {$($UntaggedNetwork.ApplianceConnection.Name)}does notmatch the Appliance Connection currently Processing {$($ApplianceConnection.Name)}. Network objects must be retrieved from the appliance either using their unique URI or with Get-OVNetwork. Please correct the Parameter value and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + if ($UntaggedNetwork.category -ne 'ethernet-networks') + { + + $ErrorRecord = New-ErrorRecord HPEOneView.NetworkResourceException UnsupportedResourceCategory InvalidArgument 'UntaggedNetwork' -TargetType'PSObject' -Message "Network '$($UntaggedNetwork.name)' category {$($UntaggedNetwork.category)} is not the supported type, 'ethernet-networks'. Network objects must be retrieved from the appliance either using their unique URI or with Get-OVNetwork using the -Type Ethernet Parameter.Please correct the Parameter value and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + default + { + + $ErrorRecord = New-ErrorRecord HPEOneView.NetworkResourceException UnsupportedParameterValueType InvalidType 'UntaggedNetwork' -TargetType $UntaggedNetwork.GetType().Name -Message "The provided UntaggedNetwork Parameter value type '$($UntaggedNetwork.GetType().Name)' is not supported. Only String (Name or URI) or PSCustomObject types are allowed and supported. Please correct the Parameter value and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + $_NewNetSet.nativeNetworkUri = $UntaggedNetwork.uri + + } + + # Caller is requesting different bandwidth settings. Need to handle async task to create network set. + if ($PSBoundParameters['TypicalBandwidth'] -or $PSBoundParameters['MaximumBandwidth']) + { + + try + { + + $_task = Send-OVRequest -Uri $NetworkSetsUri -Method POST -Body $_NewNetSet -Hostname $ApplianceConnection.Name | Wait-OVTaskComplete + + if ($_task.taskStatus -eq "Created") + { + + "[{0}] Network Set was successfully created" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + "[{0}] Updating Network Set bandwidth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + "[{0}] Requested Typical bandwidth: $($typicalBandwidth)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + "[{0}] Requested Maximum bandwidth: $($maximumBandwidth)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + # Get Network Set Object + Try + { + + $_NetSetObj = Send-OVRequest -Uri $_task.associatedResource.resourceUri -Hostname $ApplianceConnection.Name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + # Update the associated connection template with max & typical bandwidth settings + Try + { + + $_ct = Send-OVRequest -Uri $_NetSetObj.connectionTemplateUri -Hostname $ApplianceConnection.Name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + + if ($PSBoundParameters['typicalBandwidth']) { $_ct.bandwidth.typicalBandwidth = $typicalBandwidth } + + if ($PSBoundParameters['maximumBandwidth']) { $_ct.bandwidth.maximumBandwidth = $maximumBandwidth } + + # Update Connection Template Object + Try + { + + $_ct = Send-OVRequest -Uri $_ct.uri -Method PUT -Body $_ct -Hostname $ApplianceConnection.Name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + # Get Network Set Object after CT has been updated + Try + { + + $_NetSetObj = Send-OVRequest -Uri $_NetSetObj.uri -Hostname $ApplianceConnection.Name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + [void]$_NetSetStatusCol.Add($_NetSetObj) + + } + + else + { + + "[{0}] Sending request with default bandwidth." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $_task = Send-OVRequest -Uri $NetworkSetsUri -Method POST -Body $_NewNetSet -Hostname $ApplianceConnection.Name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + [void]$_NetSetStatusCol.Add($_task) + + } + + } + + End + { + + # Return Network Set collection status/objects + Return $_NetSetStatusCol + + } + +} + +function Get-OVNetworkSet +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "Default")] + Param + ( + + [Parameter (ParameterSetName = "Default", Mandatory = $false)] + [Parameter (ParameterSetName = "Export", Mandatory = $false)] + [ValidateNotNullorEmpty()] + [String]$Name, + + [Parameter (ParameterSetName = "Default", Mandatory = $false)] + [Parameter (ParameterSetName = "Export", Mandatory = $false)] + [ValidateNotNullOrEmpty()] + [Object]$Scope = "AllResourcesInScope", + + [Parameter (ParameterSetName = "Default", Mandatory = $false)] + [Parameter (ParameterSetName = "Export", Mandatory = $false)] + [ValidateNotNullOrEmpty()] + [String]$Label, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Parameter (Mandatory = $false, ParameterSetName = "Export")] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default), + + [Parameter (ParameterSetName = "Export", Mandatory = $false)] + [Alias ("x", "export")] + [ValidateScript({split-path $_ | Test-Path})] + [String]$ExportFile + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $_NetworkSetCollection = [System.Collections.ArrayList]::new() + + } + + Process + { + + ForEach ($_appliance in $ApplianceConnection) + { + + "[{0}] Processing appliance {1} (of {2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name, $ApplianceConnection.Count | Write-Verbose + + $_Query = [System.Collections.ArrayList]::new() + + # Handle default cause of AllResourcesInScope + if ($Scope -eq 'AllResourcesInScope') + { + + "[{0}] Processing AllResourcesInScope." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_Scopes = $ApplianceConnection.ActivePermissions | Where-Object Active + + # If one scope contains 'AllResources' ScopeName "tag", then all resources should be returned regardless. + if ($_Scopes | Where-Object ScopeName -eq 'AllResources') + { + + $_ScopeNames = [String]::Join(', ', ($_Scopes | Where-Object ScopeName -eq 'AllResources').ScopeName) + + "[{0}] Scope(s) {1} is set to 'AllResources'. Will not add scope to URI query parameter." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_ScopeNames | Write-Verbose + + } + + # Process ApplianceConnection ActivePermissions collection + else + { + + Try + { + + $_ScopeQuery = Join-Scope $_Scopes + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + [Void]$_Query.Add(("({0})" -f $_ScopeQuery)) + + } + + } + + elseif ($Scope | Where-Object ScopeName -eq 'AllResources') + { + + $_ScopeNames = [String]::Join(', ', ($_Scopes | Where-Object ScopeName -eq 'AllResources').ScopeName) + + "[{0}] Scope(s) {1} is set to 'AllResources'. Will not add scope to URI query parameter." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_ScopeNames | Write-Verbose + + } + + elseif ($Scope -eq 'AllResources') + { + + "[{0}] Requesting scope 'AllResources'. Will not add scope to URI query parameter." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_ScopeNames | Write-Verbose + + } + + else + { + + Try + { + + $_ScopeQuery = Join-Scope $Scope + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + [Void]$_Query.Add(("({0})" -f $_ScopeQuery)) + + } + + if ($Name) + { + + if ($Name.Contains('*')) + { + + [Void]$_Query.Add(("name%3A{0}" -f $Name.Replace("*", "%2A").Replace(',','%2C').Replace(" ", "?"))) + + } + + else + { + + [Void]$_Query.Add(("name:'{0}'" -f $Name)) + + } + + } + + if ($Label) + { + + [Void]$_Query.Add(("labels:'{0}'" -f $Label)) + + } + + $_Category = 'category=network-sets' + + # Build the final URI + $_uri = '{0}?{1}&sort=name:asc&query={2}' -f $IndexUri, [String]::Join('&', $_Category), [String]::Join(' AND ', $_Query.ToArray()) + + Try + { + + [Array]$_ResourcesFromIndexCol = Get-AllIndexResources -Uri $_uri -ApplianceConnection $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + # If network not found, report error + if ($_ResourcesFromIndexCol.Count -eq 0 -and $Name) + { + + "[{0}] Network Set Resource Name '{1}' was not found on appliance {2}. Generate Error." -f $MyInvocation.InvocationName.ToString().ToUpper(), $Name, $_appliance.Name | Write-Verbose + + $ExceptionMessage = "The specified '{0}' Network Set resource was not found on appliance {1}. Please check the name and try again." -f $Name, $_appliance.Name + $ErrorRecord = New-ErrorRecord HPEOneView.NetworkSetResourceException NetworkSetResourceNotFound ObjectNotFound "Name" -Message $ExceptionMessage + $PSCmdlet.WriteError($ErrorRecord) + + } + + else + { + + ForEach ($_member in $_ResourcesFromIndexCol) + { + + if ($_member.connectionTemplateUri) + { + + "[{0}] Getting Network Set resource Connection Template Object to add bandwidth values to network objects." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $ct = Send-OVRequest -uri $_member.connectionTemplateUri -Hostname $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + Add-Member -InputObject $_member -NotePropertyName maximumBandwidth -NotePropertyValue $ct.bandwidth.maximumBandwidth -Force + Add-Member -InputObject $_member -NotePropertyName typicalBandwidth -NotePropertyValue $ct.bandwidth.typicalBandwidth -Force + + } + + $_member.PSObject.TypeNames.Insert(0,"HPEOneView.Networking.NetworkSet") + + [void]$_NetworkSetCollection.Add($_member) + + } + + } + + } + + } + + End + { + + "[{0}] Done. {1} network set resource(s) found." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_NetworkSetCollection.Count | Write-Verbose + + if ($ExportFile) + { + + "{0}] Exporting JSON to {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $ExportFile | Write-Verbose + + $_NetworkSetCollection | convertto-json > $exportFile + + } + + else + { + + Return $_NetworkSetCollection + + } + + } + +} + +function Set-OVNetworkSet +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding ()] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline)] + [ValidateNotNullorEmpty()] + [Alias ('NetSet', 'NetworkSet')] + [Object]$InputObject, + + [Parameter (Mandatory = $false)] + [ValidateNotNullorEmpty()] + [String]$Name, + + [Parameter (Mandatory = $false)] + [ValidateNotNullorEmpty()] + [Object]$Networks, + + [Parameter (Mandatory = $false)] + [Switch]$Large, + + [Parameter (Mandatory = $false)] + [ValidateNotNullorEmpty()] + [Object[]]$AddNetwork, + + [Parameter (Mandatory = $false)] + [ValidateNotNullorEmpty()] + [Object[]]$RemoveNetwork, + + [Parameter (Mandatory = $False)] + [Alias ('untagged','native','untaggedNetworkUri')] + [ValidateNotNullorEmpty()] + [Object]$UntaggedNetwork, + + [Parameter (Mandatory = $false)] + [validaterange(2,20000)] + [int32]$TypicalBandwidth, + + [Parameter (Mandatory = $false)] + [validaterange(100,20000)] + [int32]$MaximumBandwidth, + + [Parameter (Mandatory = $false, ValueFromPipelinebyPropertyName)] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not($PSBoundParameters['InputObject'])) + { + + $PipelineInput = $True + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + # Check for URI Parameters with multiple appliance connections + if($ApplianceConnection.Count -gt 1) + { + + if ($InputObject -is [String] -and ($InputObject.StartsWith($NetworkSetsUri))) + { + + $ErrorRecord = New-ErrorRecord HPEOneView.NetworkResourceException InvalidArgumentValue InvalidArgument 'InputObject' -Message "The InputObject Parameter as URI is unsupported with multiple appliance connections. Please check the -NetworkSet Parameter value and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + if (($Networks -is [String] -and $Networks.startswith($EthernetNetworksUri)) -or ($Networks -is [Array] -and ($Networks | ForEach-Object { $_.startswith($EthernetNetworksUri) }))) + { + + $ErrorRecord = New-ErrorRecord HPEOneView.NetworkResourceException InvalidArgumentValue InvalidArgument 'Networks' -TargetType $Networks.GetType().Name -Message "Networks Parameter contains 1 or more URIs that are unsupported with multiple appliance connections. Please check the -networks Parameter value and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + if ($UntaggedNetwork -is [String] -and $UntaggedNetwork.startswith($EthernetNetworksUri)) + { + + $ErrorRecord = New-ErrorRecord HPEOneView.NetworkResourceException InvalidArgumentValue InvalidArgument 'Untaggednetwork' -Message "Untaggednetwork Parameter as URI is unsupported with multiple appliance connections. Please check the -untaggednetwork Parameter value and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + $_TaskCollection = [System.Collections.ArrayList]::new() + + } + + Process + { + + # Process Network Set input object is the correct resource and data type. + switch ($InputObject.Gettype().Name) + { + + {"PSCustomObject", "Object", "Object[]" -contains $_} + { + + if ($InputObject.category -eq $ResourceCategoryEnum.NetworkSet) + { + + "[{0}] Processing $($InputObject.type) $($InputObject.name) resource." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + else + { + + $ExceptionMessage = "The provided InputObject resource contains an unsupported category type, '{0}'. Only 'network-sets' resources are allowed. Please check the -NetworkSet Parameter value and try again." -f $InputObject.category + $ErrorRecord = New-ErrorRecord HPEOneView.NetworkSetResourceException InvalidArgumentValue InvalidArgument 'InputObject' -TargetType 'PSObject' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + "String" + { + + if (-not ($InputObject.StartsWith($NetworkSetsUri))) + { + + "[{0}] Getting '$($InputObject)' resource from appliance." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $InputObject = Get-OVNetworkSet -Name $InputObject -ErrorAction Stop -appliance $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + + } + + elseif ($InputObject.StartsWith($NetworkSetsUri)) + { + + "[{0}] Getting '$($InputObject)' resource from appliance." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $InputObject = Send-OVRequest -Uri $InputObject -appliance $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + default + { + + $ExceptionMessage = "[{0}] is an unsupported data type. Only [System.String] or [PSCustomObject] Network Set resources are allowed. Please check the -InputObject Parameter value and try again." -f $InputObject.gettype().name + $ErrorRecord = New-ErrorRecord HPEOneView.NetworkSetResourceException InvalidArgumentValue InvalidArgument 'InputObject' -TargetType $InputObject.GetType().Name -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + $_UpdatedNetSet = $InputObject.PSObject.Copy() + + $_UpdatedNetSet.networkUris = [System.Collections.ArrayList]::new() + + # Rebuild the list of URIs + ForEach ($_OriginalNetUri in $InputObject.networkUris) + { + + [void]$_UpdatedNetSet.networkUris.Add($_OriginalNetUri) + + } + + # Process Network Set Name change + if ($PSBoundParameters["Name"]) + { + + "[{0}] Updating Network Set name to '$name'." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_UpdatedNetSet.name = $name + + } + + if ($PSBoundParameters["Networks"]) + { + + "[{0}] Processing $($Networks.count) network resources" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $i = 1 + + "[{0}] Clearing out existing networkUris." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_UpdatedNetSet.networkUris = [System.Collections.ArrayList]::new() + + foreach ($_net in $Networks) + { + + switch ($_net.GetType().Name) + { + + 'String' + { + + if ($_net.startswith($EthernetNetworksUri)) + { + + "[{0}] Network [$i] is a URI: $_net" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + [void]$_UpdatedNetSet.networkUris.Add($_net) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + elseif ($_net -is [String]) + { + + "[{0}] Network [$i] is a Name: $_net" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $_networkObject = Get-OVNetwork $_net -type Ethernet -appliance $ApplianceConnection + + [void]$_UpdatedNetSet.networkUris.Add($_networkObject.uri) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + 'PSCustomObject' + { + + if ($_net.category -eq $ResourceCategoryEnum.EthernetNetwork) + { + + "[{0}] Network [$i] is a type [PsCustomObject]" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + "[{0}] Network [$i] Name: $($_net.name)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + "[{0}] Network [$i] uri: $($_net.uri)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + else + { + + $ErrorRecord = New-ErrorRecord HPEOneView.NetworkResourceException InvalidArgumentValue InvalidArgument 'Networks' -TargetType $_Net.GetType().Name -Message "Network '$($_net.name)' is not a supported type '$($_net.gettype().fullname)'. Network resource must be either [System.String] or [PsCustomObject]. Please correct the Parameter value and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + [void]$_UpdatedNetSet.networkUris.Add($_net.uri) + + } + + default + { + + $ErrorRecord = New-ErrorRecord HPEOneView.NetworkResourceException InvalidArgumentValue InvalidArgument 'Networks' -TargetType $_Net.GetType().Name -Message "The provided Network is not a supported type '$($_net.gettype().fullname)'. Network resource must be either [System.String] or [PsCustomObject]. Please correct the Parameter value and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + $i++ + + } + + } + + # Need to validate that the -Large switch parameter was passed. + if ($PSBoundParameters.Keys.GetEnumerator() | ? { $_ -eq 'Large' }) + { + + if ($Large.IsPresent) + { + + "[{0}] Setting NetworkSetType to 'Large'." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_UpdatedNetSet.networkSetType = 'Large' + + } + + else + { + + "[{0}] Setting NetworkSetType to 'Regular'." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_UpdatedNetSet.networkSetType = 'Regular' + + } + + } + + if ($PSBoundParameters['AddNetwork']) + { + + $a = 1 + + ForEach ($_NetToAdd in $AddNetwork) + { + + switch ($_NetToAdd.GetType().Name) + { + + 'String' + { + + if ($_NetToAdd.startswith($EthernetNetworksUri)) + { + + "[{0}] Network [$a] is a URI: $_NetToAdd" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $_NetToAdd = Send-OVRequest -Uri $_NetToAdd -Appliance $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + elseif ($_NetToAdd -is [String]) + { + + "[{0}] Network [$a] is a Name: $_NetToAdd" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $_NetToAdd = Get-OVNetwork -Name $_NetToAdd -type Ethernet -appliance $ApplianceConnection -ErrorAction Stop + + # [void]$_UpdatedNetSet.networkUris.Add($_networkObject.uri) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + 'PSCustomObject' + { + + if ($_NetToAdd.category -eq $ResourceCategoryEnum.EthernetNetwork) + { + + "[{0}] Network [$a] is a type [PsCustomObject]" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + "[{0}] Network [$a] Name: $($_NetToAdd.name)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + "[{0}] Network [$a] uri: $($_NetToAdd.uri)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + else + { + + $ExceptionMessage = "Network '{0}' is not a supported type '{1}'. Network resource must be either [System.String] or [PsCustomObject]. Please correct the Parameter value and try again." -f $_NetToAdd.name, $_NetToAdd.gettype().fullname + $ErrorRecord = New-ErrorRecord HPEOneView.NetworkResourceException InvalidArgumentValue InvalidArgument 'AddNetwork' -TargetType $_NetToAdd.GetType().Name -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + default + { + + $ExceptionMessage = "The provided Network is not a supported type '$($_NetToAdd.gettype().fullname)'. Network resource must be either [System.String] or [PsCustomObject]. Please correct the Parameter value and try again." + $ErrorRecord = New-ErrorRecord HPEOneView.NetworkResourceException InvalidArgumentValue InvalidArgument 'AddNetwork' -TargetType $_NetToAdd.GetType().Name -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + "[{0}] Adding network '{1}' to Network Set" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_NetToAdd.name | Write-Verbose + + [void]$_UpdatedNetSet.networkUris.Add($_NetToAdd.uri) + + $a++ + + } + + } + + if ($PSBoundParameters['RemoveNetwork']) + { + + $r = 1 + + ForEach ($_NetToREmove in $RemoveNetwork) + { + + switch ($_NetToRemove.GetType().Name) + { + + 'String' + { + + if ($_NetToRemove.startswith($EthernetNetworksUri)) + { + + "[{0}] Network [$r] is a URI: $_NetToRemove" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $_NetToRemove = Send-OVRequest -Uri $_NetToAdd -Appliance $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + elseif ($_NetToRemove -is [String]) + { + + "[{0}] Network [$r] is a Name: $_NetToRemove" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $_NetToRemove = Get-OVNetwork -Name $_NetToRemove -type Ethernet -appliance $ApplianceConnection -ErrorAction Stop + + # [void]$_UpdatedNetSet.networkUris.Add($_networkObject.uri) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + 'PSCustomObject' + { + + if ($_NetToRemove.category -eq $ResourceCategoryEnum.EthernetNetwork) + { + + "[{0}] Network [$r] is a type [PsCustomObject]" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + "[{0}] Network [$r] Name: $($_NetToRemove.name)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + "[{0}] Network [$r] uri: $($_NetToRemove.uri)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + else + { + + $ExceptionMessage = "Network '{0}' is not a supported type '{1}'. Network resource must be either [System.String] or [PsCustomObject]. Please correct the Parameter value and try again." -f $_NetToRemove.name, $_NetToRemove.gettype().fullname + $ErrorRecord = New-ErrorRecord HPEOneView.NetworkResourceException InvalidArgumentValue InvalidArgument 'RemoveNetwork' -TargetType $_NetToRemove.GetType().Name -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + default + { + + $ExceptionMessage = "The provided Network is not a supported type '$($_NetToRemove.gettype().fullname)'. Network resource must be either [System.String] or [PsCustomObject]. Please correct the Parameter value and try again." + $ErrorRecord = New-ErrorRecord HPEOneView.NetworkResourceException InvalidArgumentValue InvalidArgument 'RemoveNetwork' -TargetType $_NetToRemove.GetType().Name -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + "[{0}] REmoving network '{1}' from Network Set" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_NetToRemove.name | Write-Verbose + + [void]$_UpdatedNetSet.networkUris.Remove($_NetToRemove.uri) + + $r++ + } + + } + + if ($PSBoundParameters["UntaggedNetwork"]) + { + + switch ($UntaggedNetwork.GetType().Name) + { + + 'String' + { + + if ($UntaggedNetwork.startswith($EthernetNetworksUri)) + { + + "[{0}] Untagged Network is a URI: $UntaggedNetwork" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $_UpdatedNetSet.nativeNetworkUri = (Send-OVRequest $UntaggedNetwork -Hostname $ApplianceConnection).uri + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + elseif ($UntaggedNetwork -is [String]) + { + + "[{0}] Untagged Network is a Name: $UntaggedNetwork" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $_networkObject = Get-OVNetwork -Name $UntaggedNetwork -type Ethernet -appliance $ApplianceConnection -ErrorAction Stop + + $_UpdatedNetSet.nativeNetworkUri = $_networkObject.uri + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + 'PSCustomObject' + { + + if ($UntaggedNetwork.category -eq $ResourceCategoryEnum.EthernetNetwork) + { + + "[{0}] Native Network is a type [PsCustomObject]" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + "[{0}] Native Network Name: $($UntaggedNetwork.name)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + "[{0}] Native Network uri: $($UntaggedNetwork.uri)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + else + { + + $ErrorRecord = New-ErrorRecord HPEOneView.NetworkResourceException InvalidArgumentValue InvalidArgument 'UntaggedNetwork' -TargetType $UntaggedNetwork.GetType().Name -Message "The UntaggedNetwork '$($UntaggedNetwork.name)' is not a supported type '$($UntaggedNetwork.gettype().fullname)'. Network resource must be either [System.String] or [PsCustomObject]. Please correct the Parameter value and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + $_UpdatedNetSet.nativeNetworkUri = $UntaggedNetwork.uri + + } + + default + { + + $ErrorRecord = New-ErrorRecord HPEOneView.NetworkResourceException InvalidArgumentValue InvalidArgument 'UntaggedNetwork' -TargetType $UntaggedNetwork.GetType().Name -Message "The provided UntaggedNetwork is not a supported type '$($UntaggedNetwork.gettype().fullname)'. Network resource must be either [System.String] or [PsCustomObject]. Please correct the Parameter value and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + } + + # Process Network Set Bandwidth assignment change + if ($PSBoundParameters["TypicalBandwidth"] -or $PSBoundParameters["MaximumBandwidth"]) + { + + "[{0}] Updating Network bandwidth assignment." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + "[{0}] Getting Network Set Connection Template." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $_ct = Send-OVRequest -Uri $_UpdatedNetSet.connectionTemplateUri -appliance $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if ($PSBoundParameters["MaximumBandwidth"]) + { + + "[{0}] Original Maximum bandwidth assignment: $($_ct.bandwidth.maximumBandwidth)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + "[{0}] New Maximum bandwidth assignment: $MaximumBandwidth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_ct.bandwidth.maximumBandwidth = $MaximumBandwidth + + } + + if($PSBoundParameters["TypicalBandwidth"]) + { + + "[{0}] Original Typical bandwidth assignment: $($_ct.bandwidth.typicalBandwidth)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + "[{0}] New Typical bandwidth assignment: $TypicalBandwidth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_ct.bandwidth.typicalBandwidth = $TypicalBandwidth + + } + + Try + { + + $_ct = Send-OVRequest -Uri $_UpdatedNetSet.connectionTemplateUri -Method PUT -Body $_ct -appliance $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $_UpdatedNetSet = $_UpdatedNetSet | Select-Object * -ExcludeProperty typicalBandwidth, maximumBandwidth, created, modified, state, status + + Try + { + + $_results = Send-OVRequest -Uri $_UpdatedNetSet.Uri -Method PUT -Body $_UpdatedNetSet -appliance $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + [void]$_TaskCollection.Add($_results) + + } + + End + { + + Return $_TaskCollection + + } + +} + +function Remove-OVNetworkSet +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdLetBinding (DefaultParameterSetName = "default" ,SupportsShouldProcess, ConfirmImpact = 'High')] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = "default")] + [ValidateNotNullOrEmpty()] + [Alias ("uri","name")] + [Object]$NetworkSet, + + [Parameter (Mandatory = $false, ValueFromPipelinebyPropertyName)] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not($PSBoundParameters['NetworkSet'])) + { + + $PipelineInput = $True + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + # Check for URI Parameters with multiple appliance connections + if($ApplianceConnection.Count -gt 1) + { + + if (($NetworkSet -is [String] -and ($NetworkSet.StartsWith($NetworkSetsUri))) -or ($NetworkSet -is [Array] -and ($NetworkSet | ForEach-Object { $_.startswith($NetworkSetsUri) }))) + { + + $ErrorRecord = New-ErrorRecord HPEOneView.NetworkResourceException InvalidArgumentValue InvalidArgument 'NetworkSet' -Message "The NetworkSet Parameter as URI is unsupported with multiple appliance connections. Please check the -NetworkSet Parameter value and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + $_NetSetsToRemoveCol = [System.Collections.ArrayList]::new() + + $_TaskCollection = [System.Collections.ArrayList]::new() + + } + + Process + { + + if ($PipelineInput) + { + + "[{0}] Processing NetworkSet object." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + "[{0}] object name: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $NetworkSet.name | Write-Verbose + "[{0}] object uri: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $NetworkSet.uri | Write-Verbose + "[{0}] object appliance connection: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $NetworkSet.ApplianceConnection.Name | Write-Verbose + "[{0}] object category: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $NetworkSet.category | Write-Verbose + + if ($NetworkSet.category -ne 'network-sets') + { + + $ErrorRecord = New-ErrorRecord HPEOneView.NetworkSetResourceException InvalidArgumentValue InvalidArgument 'NetworkSet' -TargetType 'PSObject' -Message "The provided Network Set {$($NetworkSet.Name)} is an unsupported object category, '$($NetworkSet.category)'. Only 'network-sets' category objects are supported. please chceck the Parameter value and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + [void]$_NetSetsToRemoveCol.Add($NetworkSet) + + } + + Else + { + + ForEach ($_appliance in $ApplianceConnection) + { + + "[{0}] Processing $($_appliance.Name) appliance connection (of $($ApplianceConnection.Count))." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + "[{0}] Getting Network Set object from Get-OVNetworkSet." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $NetworkSet = Get-OVNetworkSet $NetworkSet -ApplianceConnection $_appliance + + [void]$_NetSetsToRemoveCol.Add($NetworkSet) + + } + + Catch + { + + + $PSCmdlet.ThrowTerminatingError($_) + } + + } + + } + + } + + End + { + + "[{0}] Begin resource removal process." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + foreach ($_NetSet in $_NetSetsToRemoveCol) + { + + if ($PSCmdlet.ShouldProcess($_NetSet.name,"Remove Network Set from appliance '$($_NetSet.ApplianceConnection.Name)'")) + { + + + Try + { + + $_task = Send-OVRequest -Uri $_NetSet.uri -Method DELETE -AddHeader @{'If-Match' = $_NetSet.eTag } -Hostname $_NetSet.ApplianceConnection.Name + + [void]$_TaskCollection.Add($_task) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + elseif ($PSBoundParameters['WhatIf']) + { + + "[{0}] Caller passed -WhatIf Parameter." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + else + { + + "[{0}] Caller selected NO to confirmation prompt." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + } + + Return $_TaskCollection + + } + +} + +function Get-OVAddressPool +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "Default")] + Param + ( + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [ValidateSet ('VMAC', 'VWWN', 'VSN', 'IPv4', 'IPv6', 'All')] + [String[]]$Type = "All", + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + "[{0}] Requested Address Pool type: $($Type) " -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if ($Type -ieq "all") { $Type = @("VMAC", "VWWN", "VSN", "IPv4", "IPv6") } + + $_AddressPoolCollection = [System.Collections.ArrayList]::new() + + } + + Process + { + + ForEach ($_appliance in $ApplianceConnection) + { + + "[{0}] Processing '{1}' Appliance (of {2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name, $ApplianceConnection.Count | Write-Verbose + + switch ($Type) + { + + 'IPv4' + { + + "[{0}] Retrieve IPv4 Address Pool details." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + # Get the VMAC Pool object + Try + { + + $_IPv4Pool = Send-OVRequest -Uri $ApplianceIPv4PoolsUri -Hostname $_appliance.Name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $_IPv4Pool | ForEach-Object { + + $_.PSObject.TypeNames.Insert(0,"HPEOneview.Appliance.AddressPool") + + [void]$_AddressPoolCollection.Add($_) + + } + + } + + 'IPv6' + { + + "[{0}] Retrieve IPv6 Address Pool details." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + # Get the VMAC Pool object + Try + { + + $_IPv6Pool = Send-OVRequest -Uri $ApplianceIPv6PoolsUri -Hostname $_appliance.Name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $_IPv6Pool | ForEach-Object { + + $_.PSObject.TypeNames.Insert(0,"HPEOneview.Appliance.AddressPool") + + [void]$_AddressPoolCollection.Add($_) + + } + + } + + "vmac" + { + + "[{0}] Retrieve VMAC Address Pool details." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + # Get the VMAC Pool object + Try + { + + $_VMACPool = Send-OVRequest $ApplianceVmacPoolsUri -Hostname $_appliance.Name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $_VMACPool | ForEach-Object { + + $_.PSObject.TypeNames.Insert(0,"HPEOneview.Appliance.AddressPool") + + [void]$_AddressPoolCollection.Add($_) + + } + + } + + "vwwn" + { + + "[{0}] Retrieve VWWN Address Pool details." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + # Get the VWWN Pool object + Try + { + + $_VWWNPool = Send-OVRequest $ApplianceVwwnPoolsUri -Hostname $_appliance.Name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $_VWWNPool | ForEach-Object { + + $_.PSObject.TypeNames.Insert(0,"HPEOneview.Appliance.AddressPool") + + [void]$_AddressPoolCollection.Add($_) + + } + + } + + "vsn" + { + + "[{0}] Retrieve VSN Address Pool details." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + # Get the VSN Pool object + Try + { + + $_VWWNPool = Send-OVRequest -Uri $ApplianceVsnPoolsUri -Hostname $_appliance.Name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $_VWWNPool | ForEach-Object { + + $_.PSObject.TypeNames.Insert(0,"HPEOneview.Appliance.AddressPool") + + [void]$_AddressPoolCollection.Add($_) + + } + + } + + } + + } + + } + + End + { + + return $_AddressPoolCollection + + } + +} + +function Get-OVAddressPoolRange +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "Default")] + Param + ( + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [ValidateNotNullorEmpty()] + [ValidateSet ('IPv4', 'IPv6', 'vmac', 'vwwn', 'vsn', 'all')] + [Alias('Pool')] + [String[]]$Type = 'all', + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [ValidateNotNullorEmpty()] + [String]$Name, + + [Parameter (Mandatory = $false, ValueFromPipeline, ParameterSetName = "Pipeline")] + [ValidateNotNullorEmpty()] + [Object]$InputObject, + + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = "Default")] + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = "Pipeline")] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if ($PSCmdlet.ParameterSetName -eq 'Pipeline') + { + + $PipelineInput = $true + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + $_RangeList = [System.Collections.ArrayList]::new() + + } + + Process + { + + if ($PipelineInput -or $PSBoundParameters['InputObject']) + { + + if (([RegEx]::Match($InputObject.category, "id-pool-", $RegExInsensitiveFlag).Success -or $ResourceCategoryEnum.IPv4Subnet, $ResourceCategoryEnum.IPv6Subnet -contains $InputObject.category) -and $InputObject.ApplianceConnection) + { + + foreach ($_RangeUri in $InputObject.rangeUris) + { + + Try + { + + $_rangeObject = Send-OVRequest -Uri $_RangeUri -Hostname $InputObject.ApplianceConnection.Name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $_rangeObject | ForEach-Object { $_.PSObject.TypeNames.Insert(0,"HPEOneview.Appliance.AddressPoolRange") } + + $_rangeObject + + } + + } + + elseif ([RegEx]::Match($InputObject.category, "id-pool-", $RegExInsensitiveFlag).Success -and -not($InputObject.ApplianceConnection)) + { + + $ErrorRecord = New-ErrorRecord InvalidOperationException MissingApplianceConnectionProperty InvalidArgument 'InputObject' 'PSObject' -Message "The InputObject Parameter value does not contain an ApplianceConnection property. Did this object come from Get-OVAddressPool or Send-OVRequest? Please correct the Parameter value and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + else + { + + $ExceptionMessage = "The InputObject Parameter value is not a valid pool ID object. Object Category '{0}', expected 'id-pool-vmac', 'id-pool-vwwn', or 'id-pool-vsn'. Please correct the Parameter value and try again." -f $InputObject.category + $ErrorRecord = New-ErrorRecord InvalidOperationException InvalidArgumentValue InvalidArgument 'InputObject' -TargetType 'PSObject' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + else + { + + ForEach ($_appliance in $ApplianceConnection) + { + + Try + { + + $_AddressPoolCol = Get-OVAddressPool -Type $Type -ApplianceConnection $_appliance.Name -ErrorAction Stop + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + foreach ($_AddressPool in $_AddressPoolCol) + { + + ForEach ($_RangUri in $_AddressPool.rangeUris) + { + + Try + { + + $_rangeObject = Send-OVRequest $_RangUri -Hostname $_AddressPool.ApplianceConnection.Name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if ($PSBoundParameters['Name']) + { + + $_rangeObject = $_rangeObject | ? name -eq $Name + + } + + ForEach ($_range in $_rangeObject) + { + + $_range.PSObject.TypeNames.Insert(0, "HPEOneview.Appliance.AddressPoolRange") + + $_range + + } + + } + + } + + } + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Get-OVAddressPoolSubnet +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = 'Default')] + Param + ( + + [Parameter (Mandatory = $False, ParameterSetName = "Default")] + [ValidateNotNullorEmpty()] + [String]$NetworkId, + + [Parameter (Mandatory = $False, ParameterSetName = "Default")] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $_SubnetCollection = [System.Collections.ArrayList]::new() + + } + + Process + { + + + $_Query = [System.Collections.ArrayList]::new() + + if ($PSBoundParameters['NetworkID']) + { + + "[{0}] Filtering for NetworkID: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $NetworkID | Write-Verbose + + [Void]$_Query.Add(("name:'{0}'" -f $NetworkID)) + + } + + $_Category = 'category={0}&category={1}' -f $ResourceCategoryEnum.IPv4Subnet, $ResourceCategoryEnum.IPv6Subnet + + # Build the final URI + $_uri = '{0}?{1}&sort=name:asc&query={2}' -f $IndexUri, [String]::Join('&', $_Category), [String]::Join(' AND ', $_Query.ToArray()) + + + + $uri = $ApplianceIPv4SubnetsUri + + ForEach ($_appliance in $ApplianceConnection) + { + + Try + { + + [Array]$_ResourcesFromIndexCol = Get-AllIndexResources -Uri $_uri -ApplianceConnection $_appliance + + ForEach ($_resource in $_ResourcesFromIndexCol) + { + + $_resource.PSObject.TypeNames.Insert(0,"HPEOneview.Appliance.IPAddressSubnet") + + $_resource + + } + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if ($NetworkId -and $_ResourcesFromIndexCol.Count -eq 0) + { + + $ExceptionMessage = "The NetworkID {0} was not found on appliance {1}." -f $NetworkId, $_appliance.Name + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AddressPoolResourceException ResourceNotFound ObjectNotFound 'NetworkId' -Message $ExceptionMessage + $PSCmdlet.WriteError($ErrorRecord) + + } + + } + + } + + End + { + + Return $_SubnetCollection + + } + +} + +function New-OVAddressPoolSubnet +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = 'Default')] + Param + ( + + [Parameter (Mandatory, ParameterSetName = "Default")] + [ValidateNotNullorEmpty()] + [Net.IPAddress]$NetworkId, + + [Parameter (Mandatory, ParameterSetName = "Default")] + [Alias ("PrefixLength")] + [ValidateNotNullorEmpty()] + [String]$SubnetMask, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [ValidateNotNullorEmpty()] + [Net.IPAddress]$Gateway, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [ValidateNotNullorEmpty()] + [String]$Domain, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [ValidateNotNullorEmpty()] + [Net.IPAddress[]]$DNSServers, + + [Parameter (Mandatory = $False, ParameterSetName = "Default")] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + # Validate Parameters before auth + if (($SubnetMask -lt 1 -or $SubnetMask -gt 32) -and ($SubnetMask -notmatch $IPSubnetAddressPattern)) + { + + $Exceptionmessage = "The provided SubnetID {0} does not appear to be a valid Subnet Mask." -f $SubnetMask + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AddressPoolResourceException InvalidIPv4SubnetMask InvalidArgument 'SubnetMask' -TargetType 'String' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $_SubnetCollection = [System.Collections.ArrayList]::new() + + } + + Process + { + + # Validate what the NetworkID AddressFamily is + + [IPAddress]$Address = $null; + + if ([IPAddress]::TryParse($NetworkId, [ref]$Address)) + { + + switch ($Address.AddressFamily) + { + + # IPv4 AddressFamily + 'InterNetwork' + { + + Write-Verbose 'IPv4Address' + + $_Uri = $ApplianceIPv4SubnetsUri + + # $IPSubnetType = 'IPv4AddressSubnet' + + # Calculate the CIDR bit value to the SubnetMask Address + if ($PSBoundParameters['SubnetMask'].Length -le 2) + { + + Try + { + + "[{0}] Converting Subnet CIDR Bit value to Subnet Mask Address." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + [Int64]$_Int64Value = ([convert]::ToInt64(('1' * $SubnetMask + '0' * (32 - $SubnetMask)), 2)) + + $SubnetMask = '{0}.{1}.{2}.{3}' -f ([math]::Truncate($_Int64Value / 16777216)).ToString(), + ([math]::Truncate(($_Int64Value % 16777216) / 65536)).ToString(), + ([math]::Truncate(($_Int64Value % 65536)/256)).ToString(), + ([math]::Truncate($_Int64Value % 256)).ToString() + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $_ExcludedIPSubnetIDBin = (([Net.IPAddress]$ExcludedIPSubnetID).IPAddressToString -split '\.' | ForEach-Object {[System.Convert]::ToString($_,2).PadLeft(8,'0')}) -join "" + $_ExcludedIPSubnetEndBin = (([Net.IPAddress]$ExcludedIPSubnetEnd).IPAddressToString -split '\.' | ForEach-Object {[System.Convert]::ToString($_,2).PadLeft(8,'0')}) -join "" + $_NetworIdDecBin = (([Net.IPAddress]$NetworkId.IPAddressToString).IPAddressToString -split '\.' | ForEach-Object {[System.Convert]::ToString($_,2).PadLeft(8,'0')}) -join "" + + "[{0}] NetworkID overlaps with Reserved Address: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), (($_NetworIdDecBin -eq $_ExcludedIPSubnetIDBin) -or (($_NetworIdDecBin -ge $_ExcludedIPSubnetIDBin) -and ($_NetworIdDecBin -le $_ExcludedIPSubnetEndBin))) | Write-Verbose + "[{0}] {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), ($_NetworIdDecBin -eq $_ExcludedIPSubnetIDBin) | Write-Verbose + "[{0}] {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), (($_NetworIdDecBin -ge $_ExcludedIPSubnetIDBin) -and ($_NetworIdDecBin -le $_ExcludedIPSubnetEndBin)) | Write-Verbose + + "[{0}] {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_NetworIdDecBin | Write-Verbose + "[{0}] {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_ExcludedIPSubnetIDBin | Write-Verbose + "[{0}] {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_ExcludedIPSubnetEndBin | Write-Verbose + + if (($_NetworIdDecBin -eq $_ExcludedIPSubnetIDBin) -or (($_NetworIdDecBin -ge $_ExcludedIPSubnetIDBin) -and ($_NetworIdDecBin -le $_ExcludedIPSubnetEndBin))) + { + + "[{0}] The calculated SubnetID overlaps with the reserved IP Address range, 172.30.254.0/24." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AddressPoolResourceException InvalidIPv4AddressPoolResource InvalidArgument 'NetworkId' -TargetType 'System.Net.IPAddress' -Message ("The provided SubnetID {0} overlaps with the reserved {1} subnet. Please choose a different IPv4 SubnetID." -f $NetworkId, $ExcludedIPSubnetID.IPAddressToString) + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + $_NewSubnet = NewObject -IPv4Subnet + + $_NewSubnet.networkId = $NetworkId.IPAddressToString + $_NewSubnet.subnetmask = $SubnetMask + + } + + # IPv6 AddressFamily + 'InterNetworkV6' + { + + Write-Verbose 'IPv6Address' + + $_Uri = $ApplianceIPv6SubnetsUri + + # $IPSubnetType = 'IPv6AddressSubnet' + + $_NewSubnet = NewObject -IPv6Subnet + $_NewSubnet.networkId = $NetworkId.IPAddressToString + $_NewSubnet.prefixLength = $SubnetMask + + } + + + default + { + + $ExceptionMessage = "The provided NetworkID '{0}' did not parse as a valid IPv4 or IPv6 address." -f $NetworkdID + + "[{0}] {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $ExceptionMessage | Write-Verbose + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AddressPoolResourceException InvalidIPv4AddressPoolResource InvalidArgument 'NetworkId' -TargetType 'System.Net.IPAddress' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + if ($PSBoundParameters['Gateway']) + { + + $_NewSubnet.gateway = $Gateway.IPAddressToString + + } + + if ($PSBoundParameters['Domain']) + { + + $_NewSubnet.domain = $Domain + + } + + if ($PSBoundParameters['DnsServers']) + { + + ForEach ($_dnsServer in $DnsServers) + { + + [void]$_NewSubnet.dnsServers.Add($_dnsServer.IPAddressToString) + + } + + } + + ForEach ($_appliance in $ApplianceConnection) + { + + "[{0}] Sending request" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $_resp = Send-OVRequest -Uri $_Uri -Method POST -Body $_NewSubnet -Hostname $_appliance + + $_resp.PSObject.TypeNames.Insert(0,"HPEOneview.Appliance.IPAddressSubnet") + + [void]$_SubnetCollection.Add($_resp) + + $_resp + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Set-OVAddressPoolSubnet +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = 'IPv4')] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = "IPv4")] + [Alias ('Subnet','IPv4Subnet')] + [ValidateNotNullorEmpty()] + [Object]$InputObject, + + [Parameter (Mandatory = $false, ParameterSetName = "IPv4")] + [ValidateScript({ [String]::IsNullOrEmpty($_) -or + $_ -match [Net.IPAddress]$_})] + [Net.IPAddress]$SubnetMask, + + [Parameter (Mandatory = $false, ParameterSetName = "IPv4")] + [ValidateScript({ [String]::IsNullOrEmpty($_) -or + $_ -match [Net.IPAddress]$_})] + [Net.IPAddress]$Gateway, + + [Parameter (Mandatory = $false, ParameterSetName = "IPv4")] + [ValidateNotNullorEmpty()] + [String]$Domain, + + [Parameter (Mandatory = $false, ParameterSetName = "IPv4")] + [ValidateNotNullorEmpty()] + [String[]]$DNSServers, + + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName , ParameterSetName = "IPv4")] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not($PSBoundParameters['InputObject'])) + { + + $PipelineInput = $True + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + $_SubnetCollection = [System.Collections.ArrayList]::new() + + } + + Process + { + + # Validate IPv4Subnet object + if ($InputObject.category -ne $ResourceCategoryEnum.IPv4Subnet) + { + + "[{0}] Invalid IPv4 Address Pool resource object." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AddressPoolResourceException InvalidIPv4AddressPoolResource InvalidArgument 'InputObject' -TargetType 'PSObject' -Message "An invalid IPv4 Address Pool resource object was provided. Please verify the Parameter value and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + switch ($PSBoundParameters.keys) + { + + 'SubnetMask' + { + + $InputObject.subnetMask = $SubnetMask.IPAddressToString + + } + + 'Gateway' + { + + $InputObject.gateway = $Gateway.IPAddressToString + + } + + 'Domain' + { + + $InputObject.domain = $Domain + + } + + 'DNSServers' + { + + $InputObject.DNSServers = [System.Collections.ArrayList]::new() + + $DNSServers | ForEach-Object { [void]$InputObject.DNSServers.Add($_) } + + } + + } + + # "[{0}] Defining new IPv4 Subnet object: {0}" -f ($InputObject ) | Write-Verbose + + "[{0}] Sending request" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $_resp = Send-OVRequest $InputObject.uri PUT $InputObject -Hostname $ApplianceConnection.Name + + $_resp.PSObject.TypeNames.Insert(0,"HPEOneview.Appliance.IPv4AddressSubnet") + + [void]$_SubnetCollection.Add($_resp) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + End + { + + Return $_SubnetCollection + + } + +} + +function Remove-OVAddressPoolSubnet +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "IPv4",SupportsShouldProcess,ConfirmImpact = 'High')] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = "IPv4")] + [Alias ('Subnet', 'IPv4Subnet')] + [ValidateNotNullorEmpty()] + [Object]$InputObject, + + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName , ParameterSetName = "IPv4")] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not($PSBoundParameters['InputObject'])) + { + + $PipelineInput = $True + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + $_InputObjectPoolsToRemoveCol = [System.Collections.ArrayList]::new() + + $_TaskCollection = [System.Collections.ArrayList]::new() + + } + + Process + { + + if ($PipelineInput) + { + + "[{0}] Processing pipeline input objects." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + if ($ResourceCategoryEnum.IPv4Subnet, $ResourceCategoryEnum.IPv6Subnet -notcontains $InputObject.category) + { + + $ExceptionMessage = "The provided InputObject '{0}' is an unsupported object category, '{1}'. Only IPv4 or IPv6 address pool subnet objects are supported. Please chceck the Parameter value and try again." -f $InputObject.Name, $InputObject.category + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AddressSubnetException InvalidArgumentValue InvalidArgument 'InputObject' -TargetType 'PSObject' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + "[{0}] Begin resource removal Process." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + foreach ($_Subnet in $InputObject) + { + + if ($PSCmdlet.ShouldProcess($_Subnet.ApplianceConnection.Name,("Remove IP NetworkID '{0}'" -f $_Subnet.networkId))) + { + + Try + { + + Send-OVRequest -uri $_Subnet.uri -Method DELETE -AddHeader @{'If-Match' = $_Subnet.eTag } -Hostname $_Subnet.ApplianceConnection.Name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + elseif ($PSBoundParameters['WhatIf']) + { + + "[{0}] Caller passed -WhatIf Parameter." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + else + { + + "[{0}] Caller selected NO to confirmation prompt." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +# Need to enhance with IPv6subnet and pool +function New-OVAddressPoolRange +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = 'Default')] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = "IPPool")] + [Alias ('Subnet', 'IPv4Subnet', 'IPv6Subnet')] + [ValidateNotNullorEmpty()] + [Object]$IPSubnet, + + [Parameter (Mandatory, ParameterSetName = "Default")] + [Parameter (Mandatory, ParameterSetName = "Custom")] + [ValidateSet ('vmac', 'vwwn', 'vsn')] + [String]$PoolType, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Parameter (Mandatory, ParameterSetName = "Custom")] + [ValidateSet ("Generated", "Custom")] + [String]$RangeType = "Generated", + + [Parameter (Mandatory, ParameterSetName = "IPPool")] + [ValidateNotNullorEmpty()] + [String]$Name, + + [Parameter (Mandatory, ParameterSetName = "Custom")] + [Parameter (Mandatory, ParameterSetName = "IPPool")] + [ValidateNotNullorEmpty()] + [String]$Start, + + [Parameter (Mandatory, ParameterSetName = "Custom")] + [Parameter (Mandatory, ParameterSetName = "IPPool")] + [ValidateNotNullorEmpty()] + [String]$End, + + [Parameter (Mandatory = $False, ParameterSetName = "Default")] + [Parameter (Mandatory = $False, ParameterSetName = "Custom")] + [Parameter (Mandatory = $False, ValueFromPipelineByPropertyName, ParameterSetName = "IPPool")] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if ($PSCmdlet.ParameterSetName -eq 'IPv4' -and (-not($PSBoundParameters['IPSubnet']))) + { + + $PipelineInput = $True + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + $_Collection = [System.Collections.ArrayList]::new() + + # Validate Parameter options here + if ($PSCmdlet.ParameterSetName -eq 'Custom' -and $RangeType -ne 'Custom') + { + + $ErrorRecord = New-ErrorRecord InvalidOperationException LogicalInterconnectUriNoApplianceConnection InvalidArgument 'RangeType' -Message "Custom Address Range was provided, but the RangeType Parameter value was not set to 'Custom'. Please check to make sure your call is correct, and try again.." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + # Generate error when defining custom range and not a specific appliance + if ($PSCmdlet.ParameterSetName -eq 'Custom' -and $ApplianceConnection.count -gt 1) + { + + $ErrorRecord = New-ErrorRecord InvalidOperationException LogicalInterconnectUriNoApplianceConnection InvalidArgument 'ApplianceConnection' -Message "A Custom Address Range was provided with no Appliance Connection specified. Custom Address Pool Ranges should be unique per appliance connection. Please specify an Appliance Connection and try your call again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + Process + { + + if ($PSCmdlet.ParameterSetName -eq 'IPPool') + { + + $_newRange = NewObject -IPIDPoolRange + + if ($IPSubnet.category -eq $ResourceCategoryEnum.IPv4Subnet) + { + + $_subnetMask = $IPSubnet.subnetMask + + $_uri = $ApplianceIPv4PoolRangesUri + + } + + else + { + + $_subnetMask = $IPSubnet.prefixLength + + $_uri = $ApplianceIPv6PoolRangesUri + + $_newRange.type = 'RangeIPv6' + + } + + # Validate IPSubnet value + if ($ResourceCategoryEnum.IPv4Subnet, $ResourceCategoryEnum.IPv6Subnet -notcontains $IPSubnet.category) + { + + "[{0}] Invalid IP Address Pool resource object." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $ExceptionMessage = "An invalid IP Address Pool resource object was provided. Please verify the Parameter value and try again." + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AddressPoolResourceException InvalidIPv4AddressPoolResource InvalidArgument 'IPSubnet' -TargetType 'PSObject' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + if (-not [HPEOneView.Appliance.AddressPool]::IsInSameSubnet($IPSubnet.networkId + '/' + $_subnetMask, $Start)) + { + + "[{0}] The Start address value {1} is not within the Subnet Network ID {2}." -f $MyInvocation.InvocationName.ToString().ToUpper(), $Start, $IPSubnet.networkId | Write-Verbose + + $ExceptionMessage = "The Start address value {0} is not within the Subnet Network ID {1}\{2}." -f $Start, $IPSubnet.networkId, $_subnetMask + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AddressPoolResourceException InvalidIPAddressPoolResource InvalidArgument 'Start' -TargetType 'PSObject' -Message $Exceptionmessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + if (-not [HPEOneView.Appliance.AddressPool]::IsInSameSubnet($IPSubnet.networkId + '/' + $_subnetMask, $End)) + { + + "[{0}] The End address value {1} is not within the Subnet Network ID {2}." -f $MyInvocation.InvocationName.ToString().ToUpper(), $End, $IPSubnet.networkId | Write-Verbose + + $Exceptionmessage = "The End address value {0} is not within the Subnet Network ID {1}\{2}." -f $End, $IPSubnet.networkId, $_subnetMask + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AddressPoolResourceException InvalidIPAddressPoolResource InvalidArgument 'End' -TargetType 'PSObject' -Message $Exceptionmessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + # Create Pool Range, then assign to Subnet + + $_newRange.name = $Name + $_newRange.subnetUri = $IPSubnet.uri + + $_startStopFragments = NewObject -IDPoolStartStopFragment + $_startStopFragments.startAddress = $Start + $_startStopFragments.endAddress = $End + + [void]$_newRange.startStopFragments.Add($_startStopFragments) + + "[{0}] Sending request" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $_resp = Send-OVRequest -Uri $_uri -Method POST -Body $_newRange -Hostname $ApplianceConnection.Name + + $_resp.PSObject.TypeNames.Insert(0,'HPEOneview.Appliance.AddressPoolRange') + + $_resp + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + else + { + + ForEach ($_appliance in $ApplianceConnection) + { + + "[{0}] Processing '{1}' Appliance (of {2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name, $ApplianceConnection.Count | Write-Verbose + + # Get the correct URI to request a new Generated Address Range + "[{0}] Creating new $($PoolType) type address range" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + switch ($PoolType) + { + + "vmac" + { + + $_newGenRangeUri = $ApplianceVmacGenerateUri + $_newPoolRangeUri = $ApplianceVmacPoolRangesUri + + } + + "vwwn" + { + + $_newGenRangeUri = $ApplianceVwwnGenerateUri + $_newPoolRangeUri = $ApplianceVwwnPoolRangesUri + + } + + "vsn" + { + + $_newGenRangeUri = $ApplianceVsnPoolGenerateUri + $_newPoolRangeUri = $ApplianceVsnPoolRangesUri + + } + + } + + switch ($RangeType) + { + + "Generated" + { + + "[{0}] Generating new address range" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + # Send the request, and remove the fragmentType property as it's not a valid JSON pfield for the request. + Try + { + + $_newRange = Send-OVRequest $_newGenRangeUri -Hostname $_appliance.Name | Select-Object -Property * -excludeproperty fragmentType + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $_newRange | Add-Member -NotePropertyName type -NotePropertyValue "Range" + $_newRange | Add-Member -NotePropertyName rangeCategory -NotePropertyValue "GENERATED" + + } + + "Custom" + { + + "[{0}] Creating custom new address range" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + "[{0}] Starting Address: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Start | Write-Verbose + "[{0}] End Address: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $End | Write-Verbose + + switch ($PoolType) + { + + "vmac" + { + + if (-not $MacAddressPattern.Match($Start).Success) + { + + $ExceptionMessage = "The provided Start address {0} does not conform to a valid MAC Address value." -f $Start + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AddressPoolRangeException InvalidMacStartAddress InvalidArgument 'Start' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + if (-not $MacAddressPattern.Match($End).Success) + { + + $ExceptionMessage = "The provided End address {0} does not conform to a valid MAC Address value." -f $End + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AddressPoolRangeException InvalidMacendAddress InvalidArgument 'End' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + "vwwn" + { + + if (-not $WwnAddressPattern.Match($Start).Success) + { + + $ExceptionMessage = "The provided Start address {0} does not conform to a valid WWN Address value." -f $Start + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AddressPoolRangeException InvalidWwnStartAddress InvalidArgument 'Start' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + if (-not $WwnAddressPattern.Match($End).Success) + { + + $ExceptionMessage = "The provided End address {0} does not conform to a valid WWN Address value." -f $End + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AddressPoolRangeException InvalidWwnendAddress InvalidArgument 'End' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + "vsn" + { + + if (-not $Start.StartsWith('VCU')) + { + + $ExceptionMessage = "The provided Start address {0} does not conform to a valid Serial Number value." -f $Start + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AddressPoolRangeException InvalidSerialNumberStartAddress InvalidArgument 'Start' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + if (-not $End.StartsWith('VCU')) + { + + $ExceptionMessage = "The provided End address {0} does not conform to a valid Serial Number value." -f $End + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AddressPoolRangeException InvalidSerialNumberendAddress InvalidArgument 'End' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + } + + $_newRange = NewObject -IDPoolRange + + $_newRange.startAddress = $Start + $_newRange.endAddress = $End + + } + + } + + "[{0}] Sending request" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $_resp = Send-OVRequest -Uri $_newPoolRangeUri -Method POST -Body $_newRange -Hostname $_appliance.Name + + $_resp.PSObject.TypeNames.Insert(0,'HPEOneview.Appliance.AddressPoolRange') + + $_resp + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Remove-OVAddressPoolRange +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "Default", SupportsShouldProcess, ConfirmImpact = 'High')] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = "Default")] + [Alias ('AddressPool')] + [ValidateNotNullorEmpty()] + [Object]$InputObject, + + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName , ParameterSetName = "Default")] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not($PSBoundParameters['InputObject'])) + { + + $PipelineInput = $True + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + $_AddressPoolsToRemoveCol = [System.Collections.ArrayList]::new() + + $_TaskCollection = [System.Collections.ArrayList]::new() + + } + + Process + { + + if ($PipelineInput) + { + + "[{0}] Processing pipeline input objects." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + "[{0}] Processing object." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + "[{0}] object name: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject.name | Write-Verbose + "[{0}] object uri: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject.uri | Write-Verbose + "[{0}] object appliance connection: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject.ApplianceConnection.Name | Write-Verbose + "[{0}] object category: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject.category | Write-Verbose + + if ($InputObject.category -notmatch 'id-range-') + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AddressSubnetException InvalidArgumentValue InvalidArgument 'InputObject' -TargetType 'PSObject' -Message "The provided InputObject {$($InputObject.Name)} is an unsupported object category, '$($InputObject.category)'. Only 'id-range-VMAC', 'id-range-VWWN', 'id-range-VSN' or 'id-range-IPv4-subnet' category objects are supported." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + [void]$_AddressPoolsToRemoveCol.Add($InputObject) + + } + + End + { + + "[{0}] Begin resource removal process." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + foreach ($_Pool in $_AddressPoolsToRemoveCol) + { + + if ($PSCmdlet.ShouldProcess($_Pool.ApplianceConnection.Name,("Remove address pool range '{0}-{1}'" -f $_Pool.startStopFragments.startAddress, $_Pool.startStopFragments.endAddress))) + { + + Try + { + + Send-OVRequest -Uri $_Pool.uri -Method DELETE -AddHeader @{'If-Match' = $_Pool.eTag } -Hostname $_Pool.ApplianceConnection.Name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + elseif ($PSBoundParameters['WhatIf']) + { + + "[{0}] Caller passed -WhatIf Parameter." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + else + { + + "[{0}] Caller selected NO to confirmation prompt." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + } + + # Return $_TaskCollection + + } + +} + +function Get-OVReservedVlanRange +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = 'Default')] + param + ( + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = ($ConnectedSessions | Where-Object Default) + + ) + + Begin + { + + "[{0}] Bound PS Parameters: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(),($PSBoundParameters | out-string) | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not($ConnectedSessions)) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command agian." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -gt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $_FabricManagerCol = [System.Collections.ArrayList]::new() + + } + + Process + { + + ForEach ($_appliance in $ApplianceConnection) + { + + "[{0}] Processing appliance {1} (of {2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name, $ApplianceConnection.Count | Write-Verbose + + if ($_appliance.ApplianceType -ne 'Composer') + { + + $ExceptionMessage = 'The ApplianceConnection {0} is an HPE OneView Virtual Machine Appliance, which does not support reserved VLAN configuration.' -f $_appliance.Name + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.ComposerNodeException InvalidOperation InvalidOperation 'ApplianceConnection' -Message $ExceptionMessage + $PSCmdlet.WriteError($ErrorRecord) + + } + + else + { + + # Get reserved vlan range from fabric + try + { + + $_applianceFabrics = Send-OVRequest -Uri $DomainFabrics -Hostname $_appliance + + } + + catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + ForEach ($_fabric in $_applianceFabrics.members) + { + + [HPEOneView.Networking.ReservedVlanRange]::new($_fabric.reservedVlanRange.start, + $_fabric.reservedVlanRange.length, + $_fabric.reservedVlanRange.created, + $_fabric.reservedVlanRange.modified, + $_fabric.reservedVlanRange.etag, + $_fabric.reservedVlanRange.uri, + $_fabric.ApplianceConnection) + + + } + + } + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Set-OVReservedVlanRange +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = 'Default')] + param + ( + + [Parameter (Mandatory, ParameterSetName = 'Default')] + [ValidateRange(2, 4095)] + [Int]$Start, + + [Parameter (Mandatory, ParameterSetName = 'Default')] + [ValidateRange(60, 128)] + [Int]$Length, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = ($ConnectedSessions | Where-Object Default) + + ) + + Begin + { + + "[{0}] Bound PS Parameters: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(),($PSBoundParameters | out-string) | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not($ConnectedSessions)) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command agian." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -gt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $_FabricManagerCol = [System.Collections.ArrayList]::new() + + } + + Process + { + + ForEach ($_appliance in $ApplianceConnection) + { + + "[{0}] Processing appliance {1} (of {2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name, $ApplianceConnection.Count | Write-Verbose + + if ($_appliance.ApplianceType -ne 'Composer') + { + + $ExceptionMessage = 'The ApplianceConnection {0} is an HPE OneView Virtual Machine Appliance, which does not support VLAN reservation configuration.' -f $_appliance.Name + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.ComposerNodeException InvalidOperation InvalidOperation 'ApplianceConnection' -Message $ExceptionMessage + $PSCmdlet.WriteError($ErrorRecord) + + } + + else + { + + # Generate error that start and length is larger than allowed 4095 + if (($Start + $Length) -gt 4095) + { + + $ExceptionMessage = 'The provided Length value {0} will exceed the allowed range value beyond 4095. Specify a lower Start, or shorter Length value.' -f $Length + $ErrorRecord = New-ErrorRecord HPEOneView.Networking.ReservedVlanRangeException InvalidOperation InvalidOperation 'ApplianceConnection' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + $_UpdatedVlanRange = NewObject -ReservedVlanRange + + $_UpdatedVlanRange.start = $Start + $_UpdatedVlanRange.length = $Length + + # Get reserved vlan range URI from appliance + try + { + + $_applianceFabrics = Send-OVRequest -Uri $DomainFabrics -Hostname $_appliance + + } + + catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + ForEach ($_fabric in $_applianceFabrics.members) + { + + $_uri = '{0}/reserved-vlan-range' -f $_fabric.uri + + Send-OVRequest -Uri $_uri -Method PUT -Body $_UpdatedVlanRange -Hostname $_appliance | Wait-OVTaskComplete + + } + + } + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Get-OVFabricManager +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = 'Default')] + param + ( + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [String]$Name, + + [Parameter (ParameterSetName = 'Default', Mandatory = $false)] + [ValidateNotNullOrEmpty()] + [String]$Label, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = ($ConnectedSessions | Where-Object Default) + + ) + + Begin + { + + "[{0}] Bound PS Parameters: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(),($PSBoundParameters | out-string) | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not($ConnectedSessions)) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command agian." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -gt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $_FabricManagerCol = [System.Collections.ArrayList]::new() + + } + + Process + { + + ForEach ($_appliance in $ApplianceConnection) + { + + "[{0}] Processing appliance {1} (of {2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name, $ApplianceConnection.Count | Write-Verbose + + $_Query = [System.Collections.ArrayList]::new() + + if ($Name) + { + + "[{0}] Filtering for Name: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Name | Write-Verbose + + if ($Name.Contains('*')) + { + + "[{0}] Filtering for Name: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Name | Write-Verbose + + [Void]$_Query.Add(("name%3A{0}" -f $Name.Replace("*", "%2A").Replace(',','%2C').Replace(" ", "?"))) + + } + + else + { + + [Void]$_Query.Add(("name:'{0}'" -f $Name)) + + } + + } + + if ($Label) + { + + [Void]$_Query.Add(("labels:'{0}'" -f $Label)) + + } + + $_Category = 'category={0}' -f $ResourceCategoryEnum.FabricManager + + # Build the final URI + $_uri = '{0}?{1}&sort=name:asc&query={2}' -f $IndexUri, [String]::Join('&', $_Category), [String]::Join(' AND ', $_Query.ToArray()) + + Try + { + + [Array]$_ResourcesFromIndexCol = Get-AllIndexResources -Uri $_uri -ApplianceConnection $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if ($_ResourcesFromIndexCol.Count -eq 0 -and $Name) + { + + "[{0}] FabricManager Resource Name '{1}' was not found on appliance {2}. Generate Error." -f $MyInvocation.InvocationName.ToString().ToUpper(), $Name, $_appliance.Name | Write-Verbose + + $ExceptionMessage = "The specified FabricManager '{0}' was not found on '{1}' appliance connection. Please check the name again, and try again." -f $Name, $_appliance.Name + $ErrorRecord = New-ErrorRecord HPEOneView.Networking.FabricManagerResourceException FabricManagerResourceNotFound ObjectNotFound "Name" -Message $ExceptionMessage + + $PSCmdlet.WriteError($ErrorRecord) + + } + + else + { + + ForEach ($_member in $_ResourcesFromIndexCol) + { + + $_FabricManagerClusterNodes = [System.Collections.Generic.List[HPEOneView.Networking.FabricManager+ClusterNodeInfo]]::new() + $_Tenants = [System.Collections.Generic.List[HPEOneView.Networking.FabricManager+Tenant]]::new() + + # Loop through fabricManagerClusterNodeInfo + ForEach ($_ClusterNode in $_member.fabricManagerClusterNodeInfo) + { + + $_ClusterNodeInfo = [HPEOneView.Networking.FabricManager+ClusterNodeInfo]::new($_ClusterNode.id, + $_ClusterNode.oobMgmtAddr, + $_ClusterNode.nodeDN, + $_ClusterNode.connected) + + $_FabricManagerClusterNodes.Add($_ClusterNodeInfo) + + } + + # Loop through tenants + ForEach ($_tenant in $_member.tenants) + { + + $_TenantInfo = [HPEOneView.Networking.FabricManager+Tenant]::new($_tenant.name, + $_tenant.description, + $_tenant.dn, + $_tenant.uri, + $_tenant.complianceStatus, + $_tenant.state, + $_tenant.status, + $_tenant.preconfigured, + $_tenant.monitored) + + $_Tenants.Add($_TenantInfo) + + } + + [HPEOneView.Networking.FabricManager]::new($_member.name, + $_member.uri, + $_member.eTag, + $_member.version, + $_FabricManagerClusterNodes, + $_Tenants, + $_member.state, + $_member.status, + $_member.created, + $_member.modified, + $_member.applianceConnection) + + } + + } + + } + + } + + end + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Add-OVFabricManager +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = 'Default')] + param + ( + + [Parameter (Mandatory, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [String]$ManagementAddress, + + [Parameter (Mandatory, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [String]$Name, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [String]$SecondaryManagementAddress, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [String]$TertiearyManagementAddress, + + [Parameter (ParameterSetName = 'Default', Mandatory)] + [ValidateNotNullOrEmpty()] + [PSCredential]$Credential, + + [Parameter (ParameterSetName = 'Default', Mandatory = $false)] + [ValidateNotNullOrEmpty()] + [Switch]$TrustLeafCertificate, + + [Parameter (ParameterSetName = 'Default', Mandatory = $false)] + [ValidateNotNullOrEmpty()] + [Switch]$EnableAutomaticRemediation, + + [Parameter (ParameterSetName = 'Default', Mandatory = $false)] + [Switch]$Async, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = ($ConnectedSessions | Where-Object Default) + + ) + + Begin + { + + "[{0}] Bound PS Parameters: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(),($PSBoundParameters | out-string) | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not($ConnectedSessions)) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command agian." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -gt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + Process + { + + ForEach ($_appliance in $ApplianceConnection) + { + + if ($PSBoundParameters['TrustLeafCertificate']) + { + + "[{0}] Caller provide the -TrustLeafCertificate switch. Adding SSL certificate to appliance trust store." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + "[{0}] Getting SSL certificate." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + # This is not an async task operation + Try + { + + $_uri = '{0}/{1}' -f $RetrieveHttpsCertRemoteUri, $ManagementAddress + + $_DeviceCertificate = Send-OVRequest -Uri $_uri -Hostname $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $_DeviceCertificateToImport = NewObject -CertificateToImport + $_DeviceCertificateToImport.certificateDetails[0].base64Data = $_DeviceCertificate.certificateDetails.base64Data + $_DeviceCertificateToImport.certificateDetails[0].aliasName = $_DeviceCertificate.certificateDetails.commonName + + Try + { + + "[{0}] Adding SSL certificate to appliance trust store." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_uri = '{0}' -f $ApplianceTrustedSslHostStoreUri + + $_TaskResults = Send-OVRequest -Uri $_uri -Method POST -Body $_DeviceCertificateToImport -Hostname $_appliance | Wait-OVTaskComplete + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if ($_TaskResults.taskErrors) + { + + "[{0}] Task errors adding SSL certificate." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if ($_TaskResults.taskErrors.errorCode -eq '409' -and [RegEx]::Match($_TaskResults.taskErrors.message, 'The certificate already exists for the alias', $RegExInsensitiveFlag).Success) + { + + "[{0}] Certificate already exists." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + else + { + + $ErrorRecord = New-ErrorRecord InvalidOperationException $_TaskResults.taskErrors.errorCode InvalidResult 'Hostname' -Message $_TaskResults.taskErrors.message + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + } + + # Build the import object + "[{0}] - Starting" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_import = NewObject -AddFabricManager + + $_import.name = $Name; + $_import.userName = $Credential.Username + $_import.password = [Runtime.InteropServices.Marshal]::PtrToStringBSTR([Runtime.InteropServices.Marshal]::SecureStringToBSTR($Credential.Password)) + + if ($PSBoundParameters.Keys -contains "EnableAutomaticRemediation") + { + + $_import.automaticRemediation = [Bool]$EnableAutomaticRemediation + + } + + $_FabricManagerClusterNode1 = NewObject -FabricManagerClusterNodeInfo + + $_FabricManagerClusterNode1.oobMgmtAddr = $ManagementAddress + + $_import.fabricManagerClusterNodeInfo.Add($_FabricManagerClusterNode1) + + if ($PSBoundParameters['SecondaryManagementAddress']) + { + + "[{0}] Adding secondary management address." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_FabricManagerClusterNode2 = NewObject -FabricManagerClusterNodeInfo + + $_FabricManagerClusterNode2.oobMgmtAddr = $SecondaryManagementAddress + + $_import.fabricManagerClusterNodeInfo.Add($_FabricManagerClusterNode2) + + } + + if ($PSBoundParameters['TertiearyManagementAddress']) + { + + "[{0}] Adding tertieary management address." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_FabricManagerClusterNode3 = NewObject -FabricManagerClusterNodeInfo + + $_FabricManagerClusterNode3.oobMgmtAddr = $TertiearyManagementAddress + + $_import.fabricManagerClusterNodeInfo.Add($_FabricManagerClusterNode3) + + } + + Try + { + + $_resp = Send-OVRequest -Uri $FabricManagersUri -Method POST -Body $_import -Hostname $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if ($_resp.taskState -ne "Running" -and $_resp.taskState -eq "Error" -and $_resp.stateReason -eq "ValidationError") + { + + "[{0}] Task error found {1} {2} " -f $MyInvocation.InvocationName.ToString().ToUpper(), $resp.taskState, $resp.stateReason | Write-Verbose + + if ($_resp.taskErrors | Where-Object { $_.errorCode -eq "FABRIC_MANAGER_SECURE_CONNECTION_FAILED" }) + { + + $ExceptionMessage = 'The leaf certificate for {0} is untrusted by the appliance. Either provide the -TrustLeafCertificate parameter or manually add the certificate using the Add-OVApplianceTrustedCertificate Cmdlet.' -f $Hostname + $ErrorRecord = New-ErrorRecord InvalidOperationException UntrustedLeafCertificate InvalidResult 'Hostname' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + } + + elseif ($_resp.taskErrors) + { + + $_errorMessage = $_resp.taskErrors + + $ErrorRecord = New-ErrorRecord InvalidOperationException $_errorMessage.errorCode InvalidResult 'Hostname' -Message ($_errorMessage.details + " " + $_errorMessage.message) + + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + if ($Async) + { + + $_resp + + } + + else + { + + $_resp | Wait-OVTaskComplete + + } + + } + + } + + end + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +# // TODO: DEVELOP DOCUMENT TEST +function Update-OVFabricManager +{ + + +} + +function Remove-OVFabricManager +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "Default", SupportsShouldProcess, ConfirmImpact = 'High')] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [HPEOneView.Networking.FabricManager[]]$InputObject, + + [Parameter (Mandatory = $False, ParameterSetName = 'Default')] + [Switch]$Force, + + [Parameter (Mandatory = $False, ValueFromPipelineByPropertyName, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not($PSBoundParameters['InputObject'])) + { + + $Pipelineinput = $True + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ExceptionMessage = "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command agian." + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + } + + Process + { + + Write-Warning "Removing the fabric manager will disassociate it's tenant from all logical interconnects, networks and networks sets. Inconsistencies with the APIC tenant configuration will no longer be monitored or remediated by OneView." + + $RemoveMessage = "remove '{0}' {1}" -f $InputObject.name, $ResourceCategoryEnum.FabricManager + + if ($PSCmdlet.ShouldProcess($InputObject.ApplianceConnection, $RemoveMessage)) + { + + "[{0}] Removing resource: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), ($InputObject | Out-String) | Write-Verbose + "[{0}] URI: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject.uri | Write-Verbose + + $_Uri = '{0}' -f $InputObject.uri + + if ($Force) + { + + $_Uri += '?force=true' + + } + + try + { + + Send-OVRequest -Uri $_Uri -Method DELETE -AddHeader @{'If-Match' = $InputObject.eTag } -Hostname $InputObject.ApplianceConnection + + } + + catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + elseif ($PSBoundParameters['whatif']) + { + + "[{0}] -WhatIf was passed" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +####################################################### +# Interconnects and Uplinks +# + + +function Get-OVInterconnectNTPConfiguration +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "Default")] + Param + ( + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + "[{0}] Bound PS Parameters: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), ($PSBoundParameters | out-string) | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -TargetType $InputObject.ApplianceConnection.GetType().Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + Process + { + + # Display obselete message if the connection is a VM, not Synergy + [ObsoleteMessage]::Write($ApplianceConnection) + + $_uri = $ApplianceGlobalSettingsUri + '/appliance/global/InterconnectManagerNtpSource' + + # BY DEFAULT THE URI WILL NOT EXIST, RESULTING IN DEFAULT APPLIANCE SOURCE + # NEED TO HANDLE HTTP404 error for this + Try + { + + $_config = Send-OVRequest -Uri $_uri -Hostname $ApplianceConnection + + $_TimeConfigPolicy = [HPEOneView.Appliance.GlobalSetting]::new($_config.name, + $_config.value, + $_config.eTag, + $_config.created, + $_config.modified, + $_config.group, + $_config.settingCategory, + $_config.uri, + $_config.ApplianceConnection) + + if ($_TimeConfigPolicy.Value -eq $NTPSourceEnum.External) + { + + # Get timelocale to get appliance configured NTP servers + Try + { + + $_applianceDateTimeLocaleConfig = Send-OVRequest -Uri $ApplianceDateTimeUri -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $_TimeConfigPolicy | Add-Member -NotePropertyName NTPServers -NotePropertyValue $_applianceDateTimeLocaleConfig.ntpServers + + } + + $_TimeConfigPolicy + + } + + # Default + Catch [HPEOneView.ResourceNotFoundException] + { + + "[{0}] Global-setting URI not found. Likely default, so returning default value." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + # Global-setting does not exist, must be set to default + [HPEOneView.Appliance.GlobalSetting]::new('InterconnectManagerNtpSource', + $NTPSourceEnum.ICMDefault, + [DateTime]::now, + [DateTime]::now, + [DateTime]::now, + 'global', + 'global-settings', + $_uri, + ([HPEOneView.Library.ApplianceConnection]::new($ApplianceConnection.Name, $ApplianceConnnection.ConnectionId))) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Set-OVInterconnectNTPConfiguration +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "Default")] + Param + ( + + [Parameter (Mandatory, ParameterSetName = "Default")] + [Switch]$SyncWithAppliance, + + [Parameter (Mandatory, ParameterSetName = "SyncWithNTP")] + [Switch]$SyncWithNTP, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Parameter (Mandatory = $false, ParameterSetName = "SyncWithNTP")] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + "[{0}] Bound PS Parameters: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), ($PSBoundParameters | out-string) | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -TargetType $InputObject.ApplianceConnection.GetType().Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + Process + { + + # Display obselete message if the connection is a VM, not Synergy + [ObsoleteMessage]::Write($ApplianceConnection) + + $_uri = $ApplianceGlobalSettingsUri + '/appliance/global/InterconnectManagementNtpSource' + $_method = "PUT" + + Try + { + + $_serverTimePolicyConfig = Send-OVRequest -Uri $_uri -Hostname $ApplianceConnection + + } + + # Default + Catch [HPEOneView.ResourceNotFoundException] + { + + "[{0}] Global-setting URI not found. Likely default, so returning default value." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_InterconnectTimePolicyConfig = NewObject -GlobalSetting + + $_InterconnectTimePolicyConfig.name = 'InterconnectManagementNtpSource' + + $_uri = $ApplianceGlobalSettingsUri + $_method = "POST" + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + switch ($PSBoundParameters.Keys) + { + + 'SyncWithAppliance' + { + + "[{0}] Will sync with appliance." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + $_InterconnectTimePolicyConfig.value = $NTPSourceEnum.Appliance + + } + + 'SyncWithNTP' + { + + "[{0}] Will sync with external NTP servers." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + $_InterconnectTimePolicyConfig.value = $NTPSourceEnum.External + + } + + } + + Try + { + + $_resp = Send-OVRequest -Uri $_uri -Method $_method -Body $_InterconnectTimePolicyConfig -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $_UpdatedTimeConfigPolicy = [HPEOneView.Appliance.GlobalSetting]::new($_resp.name, + $_resp.value, + $_resp.eTag, + $_resp.created, + $_resp.modified, + $_resp.group, + $_resp.settingCategory, + $_resp.uri, + $_resp.ApplianceConnection) + + if ($_UpdatedTimeConfigPolicy.Value -eq $NTPSourceEnum.External) + { + + # Get timelocale to get appliance configured NTP servers + Try + { + + $_applianceDateTimeLocaleConfig = Send-OVRequest -Uri $ApplianceDateTimeUri -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $_UpdatedTimeConfigPolicy | Add-Member -NotePropertyName NTPServers -NotePropertyValue $_applianceDateTimeLocaleConfig.ntpServers + + } + + $_UpdatedTimeConfigPolicy + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Get-OVInterconnectType +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = 'Name')] + Param + ( + + [Parameter (Mandatory = $false, ParameterSetName = 'Name')] + [ValidateNotNullorEmpty()] + [String]$Name, + + [Parameter (Mandatory, ParameterSetName = 'PartNumber')] + [ValidateNotNullorEmpty()] + [String]$PartNumber, + + [Parameter (Mandatory = $false, ParameterSetName = 'Name')] + [Parameter (Mandatory = $false, ParameterSetName = 'PartNumber')] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $Collection = [System.Collections.ArrayList]::new() + $NotFound = [System.Collections.ArrayList]::new() + + } + + Process + { + + ForEach ($_appliance in $ApplianceConnection) + { + + # Display obselete message if the connection is a VM, not Synergy + [ObsoleteMessage]::Write($_appliance) + + $uri = $interconnectTypesUri + "?sort=name:descEnding" + + if ($PSboundParameters['Name']) + { + + $uri += "&filter=name='$name'" + + } + + elseif ($PSboundParameters['PartNumber']) + { + + $uri += "&filter=partNumber='$partNumber'" + + } + + "[{0}] Sending request" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $resp = Send-OVRequest $uri -Appliance $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if ($resp.count -gt 0) + { + + $resp.members | Sort-Object name | ForEach-Object { + + $_interconnectType = $_ + + $_interconnectType | ForEach-Object { $_.PSObject.TypeNames.Insert(0,'HPEOneView.Networking.InterconnectType')} + + [void]$Collection.Add($_interconnectType) + + } + + } + + else + { + + [Void]$NotFound.Add($_appliance.Name) + + } + + } + + } + + End + { + + if (((-not $Collection) -or ($NotFound.count -gt 1)) -and $Name) + { + + $Collection + + $ExceptionMessage = "No Interconnect Types with '{0}' name were found on appliance {1}." -f $Name, ($NotFound -join ", ") + $ErrorRecord = New-ErrorRecord HPEOneView.InterconnectResourceException InterconnectTypeNameResourceNotFound ObjectNotFound 'Name' -Message $ExceptionMessage + $PSCmdlet.WriteError($ErrorRecord) + + } + + elseif (((-not $Collection) -or ($NotFound.count -gt 0)) -and $PartNumber) + { + + $Collection + + $ExceptionMessage = "No Interconnect Types with '{0}' partnumber were found on appliance {1}." -f $PartNumber, ($NotFound -join ", ") + $ErrorRecord = New-ErrorRecord HPEOneView.InterconnectTypeResourceException InterconnectTypePartnumberResourceNotFound ObjectNotFound 'PartNumber' -Message $ExceptionMessage + $PSCmdlet.WriteError($ErrorRecord) + + } + + else + { + + return $Collection + + } + + } + +} + +function Get-OVSasInterconnectType +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = 'Name')] + Param + ( + + [Parameter (Mandatory = $false, ParameterSetName = 'Name')] + [ValidateNotNullorEmpty()] + [String]$Name, + + [Parameter (Mandatory, ParameterSetName = 'PartNumber')] + [ValidateNotNullorEmpty()] + [String]$PartNumber, + + [Parameter (Mandatory = $false, ParameterSetName = 'Name')] + [Parameter (Mandatory = $false, ParameterSetName = 'PartNumber')] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $Collection = [System.Collections.ArrayList]::new() + $NotFound = [System.Collections.ArrayList]::new() + + } + + Process + { + + ForEach ($_appliance in $ApplianceConnection) + { + + if ($_appliance.ApplianceType -ne 'Composer') + { + + $ExceptionMessage = 'The ApplianceConnection {0} is an HPE OneView Virtual Machine Appliance, which does not support VLAN reservation configuration.' -f $_appliance.Name + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.ComposerNodeException InvalidOperation InvalidOperation 'ApplianceConnection' -Message $ExceptionMessage + $PSCmdlet.WriteError($ErrorRecord) + + } + + else + { + + $uri = $SasInterconnectTypeUri + "?sort=name:descEnding" + + if ($PSboundParameters['Name']) + { + + $uri += "&filter=name='$name'" + + } + + elseif ($PSboundParameters['PartNumber']) + { + + $uri += "&filter=partNumber='$partNumber'" + + } + + "[{0}] Sending request" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $resp = Send-OVRequest $uri -Appliance $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if ($resp.count -gt 0) + { + + $resp.members | Sort-Object name | ForEach-Object { + + $_interconnectType = $_ + + $_interconnectType | ForEach-Object { $_.PSObject.TypeNames.Insert(0,'HPEOneView.Networking.SasInterconnectType')} + + [void]$Collection.Add($_interconnectType) + + } + + } + + elseif ($resp.count -eq 0 -and $Name) + { + + $ErrorRecord = New-ErrorRecord HPEOneView.InterconnectResourceException SasInterconnectTypeNameResourceNotFound ObjectNotFound 'Name' -Message "No SAS Interconnect Types with '{0}' name were found on appliance '{1}'." -f $Name, $_appliance.Name + $PSCmdlet.WriteError($ErrorRecord) + + } + + elseif ($resp.count -eq 0 -and $PartNumber) + { + + $ErrorRecord = New-ErrorRecord HPEOneView.InterconnectResourceException InterconnectTypePartnumberResourceNotFound ObjectNotFound 'Name' -Message "No SAS Interconnect Types with '{0}' PartNumber were found on appliance '{1}'." -f $PartNumber, $_appliance.Name + $PSCmdlet.WriteError($ErrorRecord) + + } + + } + + } + + } + + End + { + + return $Collection + + } + +} + +function Get-OVInterconnect +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding ()] + Param + ( + + [Parameter (Mandatory = $false)] + [ValidateNotNullorEmpty()] + [String]$Name, + + [Parameter (Mandatory = $false)] + [ValidateNotNullOrEmpty()] + [Object]$Scope = "AllResourcesInScope", + + [Parameter (Mandatory = $false)] + [ValidateNotNullOrEmpty()] + [String]$Label, + + [Parameter (Mandatory = $false)] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default), + + [Parameter (Mandatory = $false)] + [Alias ("x", "exportFile")] + [ValidateScript({split-path $_ | Test-Path})] + [String]$Export + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $InterconnectCollection = [System.Collections.ArrayList]::new() + $ApplianceInterconnectCol = [System.Collections.ArrayList]::new() + $NotFound = [System.Collections.ArrayList]::new() + + $InterconnecUris = $SasInterconnectsUri, $InterconnectsUri + + } + + Process + { + + ForEach ($_appliance in $ApplianceConnection) + { + + # Display obselete message if the connection is a VM, not Synergy + [ObsoleteMessage]::Write($_appliance) + + "[{0}] Processing appliance {1} (of {2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name, $ApplianceConnection.Count | Write-Verbose + + $_Query = [System.Collections.ArrayList]::new() + + # Handle default cause of AllResourcesInScope + if ($Scope -eq 'AllResourcesInScope') + { + + "[{0}] Processing AllResourcesInScope." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_Scopes = $ApplianceConnection.ActivePermissions | Where-Object Active + + # If one scope contains 'AllResources' ScopeName "tag", then all resources should be returned regardless. + if ($_Scopes | Where-Object ScopeName -eq 'AllResources') + { + + $_ScopeNames = [String]::Join(', ', ($_Scopes | Where-Object ScopeName -eq 'AllResources').ScopeName) + + "[{0}] Scope(s) {1} is set to 'AllResources'. Will not add scope to URI query parameter." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_ScopeNames | Write-Verbose + + } + + # Process ApplianceConnection ActivePermissions collection + else + { + + Try + { + + $_ScopeQuery = Join-Scope $_Scopes + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + [Void]$_Query.Add(("({0})" -f $_ScopeQuery)) + + } + + } + + elseif ($Scope | Where-Object ScopeName -eq 'AllResources') + { + + $_ScopeNames = [String]::Join(', ', ($_Scopes | Where-Object ScopeName -eq 'AllResources').ScopeName) + + "[{0}] Scope(s) {1} is set to 'AllResources'. Will not add scope to URI query parameter." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_ScopeNames | Write-Verbose + + } + + elseif ($Scope -eq 'AllResources') + { + + "[{0}] Requesting scope 'AllResources'. Will not add scope to URI query parameter." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_ScopeNames | Write-Verbose + + } + + else + { + + Try + { + + $_ScopeQuery = Join-Scope $Scope + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + [Void]$_Query.Add(("({0})" -f $_ScopeQuery)) + + } + + if ($Name) + { + + if ($Name.Contains('*')) + { + + [Void]$_Query.Add(("name%3A{0}" -f $Name.Replace("*", "%2A").Replace(',','%2C').Replace(" ", "?"))) + + } + + else + { + + [Void]$_Query.Add(("name:'{0}'" -f $Name)) + + } + + } + + if ($Label) + { + + [Void]$_Query.Add(("labels:'{0}'" -f $Label)) + + } + + # Build the final URI + $_uri = '{0}?category=interconnects&category=sas-interconnects&sort=name:asc&query={1}' -f $IndexUri, [String]::Join(' AND ', $_Query.ToArray()) + + Try + { + + [Array]$_ResourcesFromIndexCol = Get-AllIndexResources -Uri $_uri -ApplianceConnection $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + ForEach ($_member in $_ResourcesFromIndexCol) + { + + "[{0}] Processing resource {1} (of {2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_member.name, $_ResourcesFromIndexCol.Count | Write-Verbose + + switch ($_member.category) + { + + 'sas-interconnects' + { + + # Add the Custom TypeName + $_member.PSObject.TypeNames.Insert(0,"HPEOneView.Networking.SasInterconnect") + + } + + 'interconnects' + { + + # Add the Custom TypeName + $_member.PSObject.TypeNames.Insert(0,"HPEOneView.Networking.Interconnect") + + # Add the Custom Uplink/Stacking Link TypeName + $_member.ports | Where-Object { $_.portType -eq "Uplink" -or $_.portType -eq "Stacking" } | ForEach-Object { + + $_.PSObject.TypeNames.Insert(0,"HPEOneView.Networking.Interconnect.UplinkPort") + + $_ | Add-Member -NotePropertyName ApplianceConnection -NotePropertyValue ([HPEOneView.Library.ApplianceConnection]::new($_appliance.Name, $_appliance.ConnectionID)) + + } + + # Add the Custom Downlink Link TypeName + $_member.ports | Where-Object { $_.portType -eq "Downlink" } | ForEach-Object { + + $_.PSObject.TypeNames.Insert(0,"HPEOneView.Networking.Interconnect.DownlinkPort") + + $_ | Add-Member -NotePropertyName ApplianceConnection -NotePropertyValue ([HPEOneView.Library.ApplianceConnection]::new($_appliance.Name, $_appliance.ConnectionID)) + + } + + } + + } + + [void]$InterconnectCollection.Add($_member) + + } + + # Generate final error if name wasn't found on appliance(s) + if ($NotFound.count -gt 0 -and $Name -and $ApplianceInterconnectCol.count -eq 0) + { + + $ErrorRecord = New-ErrorRecord HPEOneView.InterconnectResourceException InterconnectNameResourceNotFound ObjectNotFound 'Name' -Message "No Interconnect resources with '$Name' name were found on appliance $($NotFound -join ", ")." + $PSCmdlet.WriteError($ErrorRecord) + + } + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if ($Export) + { + + "[{0}] Exporting to: $($Export)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $InterconnectCollection | convertto-json -Depth 99 | Set-Content -Path $Export -force -encoding UTF8 + + } + + else + { + + Return $InterconnectCollection | Sort-Object type, name + + } + + } + +} + +function Set-OVInterconnectName +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding(DefaultParameterSetName = "default", SupportsShouldProcess, ConfirmImpact = 'High')] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = "default")] + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = "ResetToDefault")] + [ValidateNotNullorEmpty()] + [Object]$InputObject, + + [Parameter (Mandatory, ParameterSetName = "default")] + [ValidateNotNullOrEmpty()] + [String]$Name, + + [Parameter (Mandatory, ParameterSetName = "ResetToDefault")] + [Switch]$ResetNameToFactoryDefault, + + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = "default")] + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = "ResetToDefault")] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not $PSBoundParameters['InputObject']) + { + + $PipelineInput = $true + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + } + + Process + { + + # Validate the ICM is VC FlexFabric only + if ("794502-B23", "867796-B21", "779227-B21", "876259-B21" -NotContains $InputObject.partNumber) + { + + $ExceptionMessage = 'The provided resource "{0} ({1})" is unsupported with this Cmdlet. Please provide an HPE Synergy Virtual Connect SE module resource.' -f $InputObject.name, $InputObject.partNumber + $ErrorRecord = New-ErrorRecord InvalidOperationException InvalidInputObjectParameterValue InvalidArgument 'InputObject' -TargetType $InputObject.GetType().Name -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + $_uri = $InputObject.Uri.ToString() + + $_patchOperation = NewObject -PatchOperation + $_patchOperation.op = "replace" + $_patchOperation.path = "/hostname" + + if ($PSBoundParameters['ResetNameToFactoryDefault']) + { + + $_patchOperation.value = "$null" + + $_ShouldProcessMessage = "reset hostname back to factory default" + + } + + else + { + + $_patchOperation.value = $Name + + $_ShouldProcessMessage = "update hostname from '{0}' to '{1}'" -f $InputObject.hostName, $Name + + } + + if ($PSCmdlet.ShouldProcess($InputObject.name, $_ShouldProcessMessage)) + { + + Try + { + + "[{0}] Sending request to change ICM hostname." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Send-OVRequest -Uri $uri -Method PATCH -Body $_patchOperation -AddHeader @{"If-Match" = $InputObject.eTag} -Hostname $InputObject.ApplianceConnection | Wait-OVTaskComplete + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + elseif ($PSBoundParameters['WhatIf']) + { + + "[{0}] User included -WhatIf." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + else + { + + "[{0}] User cancelled." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Get-OVLogicalInterconnect +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "default")] + Param + ( + + [Parameter (Mandatory = $false, ParameterSetName = "default")] + [ValidateNotNullorEmpty()] + [String]$Name, + + [Parameter (ParameterSetName = 'default', Mandatory = $false)] + [ValidateNotNullOrEmpty()] + [Switch]$NonCompliant, + + [Parameter (Mandatory = $false, ParameterSetName = "default")] + [ValidateNotNullOrEmpty()] + [Object]$Scope = "AllResourcesInScope", + + [Parameter (Mandatory = $false, ParameterSetName = "default")] + [ValidateNotNullOrEmpty()] + [String]$Label, + + [Parameter (Mandatory = $false, ParameterSetName = "default")] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default), + + [Parameter (Mandatory = $false, ParameterSetName = "default")] + [Alias ("x", "ExportFile")] + [ValidateScript({split-path $_ | Test-Path})] + [String]$Export + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $LiCollection = [System.Collections.ArrayList]::new() + + } + + Process + { + + ForEach ($_appliance in $ApplianceConnection) + { + + # Display obselete message if the connection is a VM, not Synergy + [ObsoleteMessage]::Write($_appliance) + + "[{0}] Processing appliance {1} (of {2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name, $ApplianceConnection.Count | Write-Verbose + + $_Query = [System.Collections.ArrayList]::new() + + # Handle default cause of AllResourcesInScope + if ($Scope -eq 'AllResourcesInScope') + { + + "[{0}] Processing AllResourcesInScope." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_Scopes = $ApplianceConnection.ActivePermissions | Where-Object Active + + # If one scope contains 'AllResources' ScopeName "tag", then all resources should be returned regardless. + if ($_Scopes | Where-Object ScopeName -eq 'AllResources') + { + + $_ScopeNames = [String]::Join(', ', ($_Scopes | Where-Object ScopeName -eq 'AllResources').ScopeName) + + "[{0}] Scope(s) {1} is set to 'AllResources'. Will not add scope to URI query parameter." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_ScopeNames | Write-Verbose + + } + + # Process ApplianceConnection ActivePermissions collection + else + { + + Try + { + + $_ScopeQuery = Join-Scope $_Scopes + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + [Void]$_Query.Add(("({0})" -f $_ScopeQuery)) + + } + + } + + elseif ($Scope | Where-Object ScopeName -eq 'AllResources') + { + + $_ScopeNames = [String]::Join(', ', ($_Scopes | Where-Object ScopeName -eq 'AllResources').ScopeName) + + "[{0}] Scope(s) {1} is set to 'AllResources'. Will not add scope to URI query parameter." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_ScopeNames | Write-Verbose + + } + + elseif ($Scope -eq 'AllResources') + { + + "[{0}] Requesting scope 'AllResources'. Will not add scope to URI query parameter." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_ScopeNames | Write-Verbose + + } + + else + { + + Try + { + + $_ScopeQuery = Join-Scope $Scope + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + [Void]$_Query.Add(("({0})" -f $_ScopeQuery)) + + } + + if ($Name) + { + + if ($Name.Contains('*')) + { + + [Void]$_Query.Add(("name%3A{0}" -f $Name.Replace("*", "%2A").Replace(',','%2C').Replace(" ", "?"))) + + } + + else + { + + [Void]$_Query.Add(("name:'{0}'" -f $Name)) + + } + + } + + if ($PSBoundParameters['NonCompliant']) + { + + "[{0}] Filtering for non-compliant logical interconnects." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + [Void]$_Query.Add("state:'Inconsistent'") + + } + + if ($Label) + { + + [Void]$_Query.Add(("labels:'{0}'" -f $Label)) + + } + + $_Category = 'category=logical-interconnects' + + # Build the final URI + $_uri = '{0}?{1}&sort=name:asc&query={2}' -f $IndexUri, [String]::Join('&', $_Category), [String]::Join(' AND ', $_Query.ToArray()) + + Try + { + + [Array]$_ResourcesFromIndexCol = Get-AllIndexResources -Uri $_uri -ApplianceConnection $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if ($_ResourcesFromIndexCol.count -eq 0 -and $Name) + { + + "[{0}] Logical Interconnect '{1}' resource not found on '{2}'. Adding to notfound collection." -f $MyInvocation.InvocationName.ToString().ToUpper(), $Name, $_appliance.Name | Write-Verbose + + $ExceptionMessage = "Specified Logical Interconnect '{0}' was not found on '{1}' appliance. Please check the name and try again." -f $Name, $_appliance.Name + $ErrorRecord = New-ErrorRecord InvalidOperationException LogicalInterconnectGroupNotFound ObjectNotFound 'Name' -Message $ExceptionMessage + $PSCmdlet.WriteError($ErrorRecord) + + } + + elseif ($_ResourcesFromIndexCol.count -eq 0) + { + + "[{0}] No Logical Interconnect resources found on '{1}'." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.name | Write-Verbose + + } + + else + { + + "[{0}] Found {1} Logical Interconnect resource(s)." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_ResourcesFromIndexCol.Count | Write-Verbose + + ForEach ($_LiObject in $_ResourcesFromIndexCol) + { + + $_LiObject.PSobject.TypeNames.Insert(0,"HPEOneView.Networking.LogicalInterconnect") # FORMAT DONE + $_LiObject.snmpConfiguration | ForEach-Object { $_.PSObject.TypeNames.Insert(0,'HPEOneView.Networking.LogicalInterconnect.SnmpConfiguration') } # FORMAT DONE + $_LiObject.snmpConfiguration.trapDestinations | ForEach-Object { $_.PSObject.TypeNames.Insert(0,'HPEOneView.Networking.LogicalInterconnect.SnmpConfiguration.Destinations') } # FORMAT DONE + $_LiObject.ethernetSettings | ForEach-Object { $_.PSObject.TypeNames.Insert(0,'HPEOneView.Networking.LogicalInterconnect.InterconnectSettings') } + $_LiObject.telemetryConfiguration | ForEach-Object { $_.PSObject.TypeNames.Insert(0,'HPEOneView.Networking.LogicalInterconnect.UtilizationSampleSettings') } + $_LiObject.portMonitor | ForEach-Object { $_.PSObject.TypeNames.Insert(0,'HPEOneView.Networking.LogicalInterconnect.PortMonitorSettings') } + + [void]$LiCollection.Add($_LiObject) + + } + + } + + } + + } + + End + { + + "[{0}] Done. {1} logical interconnect group(s) found." -f $MyInvocation.InvocationName.ToString().ToUpper(), $LiCollection.count | Write-Verbose + + if ($Export) + { + + $LiCollection | convertto-json -Depth 99 | Set-Content -Path $Export -force -encoding UTF8 + + } + + else + { + + $LiCollection + + } + + } + +} + +function Get-OVLogicalInterconnectPortMonitoring +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "default")] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = "default")] + [ValidateNotNullorEmpty()] + [Alias ('uri', 'li','name','Resource')] + [object]$InputObject, + + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = "default")] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + if (-not $InputObject) + { + + $Pipeline = $true + + } + + else + { + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + } + + Process + { + + # Validate input object is $ResourceCategoryEnum.LogicalInterconnect + if ($InputObject.category -ne $ResourceCategoryEnum.LogicalInterconnect) + { + + # Throw exception + $ExceptionMessage = 'The provided object "{0}" is not supported. Only Logical Interconnect resources are supported.' -f $InputObject.name + $ErrorRecord = New-ErrorRecord HPEOneView.InputObjectResourceException InvalidInputObjectResource InvalidArgument "InputObject" -TargetType 'PSObject' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + # Display obselete message if the connection is a VM, not Synergy + [ObsoleteMessage]::Write($InputObject.ApplianceConnection) + + Try + { + + $Uri = '{0}/port-monitor' -f $InputObject.uri + $_LIPortMonitorConfigState = Send-OVRequest -Uri $Uri -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + switch ($_LIPortMonitorConfigState.portMonitorType) + { + + {[HPEOneView.Networking.PortMonitorTypeEnum]::Local -match $_} + { + + "[{0}] Port monitor configuration type: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), [HPEOneView.Networking.PortMonitorTypeEnum]::Local | Write-Verbose + + if ($null -ne $_LIPortMonitorConfigState.analyzerPort) + { + + $AnalyzerPort = [HPEOneView.Networking.AnalyzerPort]::new($_LIPortMonitorConfigState.analyzerPort.portName, + $_LIPortMonitorConfigState.analyzerPort.portStatus, + $_LIPortMonitorConfigState.analyzerPort.portHealthStatus, + $_LIPortMonitorConfigState.analyzerPort.interconnectName, + $_LIPortMonitorConfigState.analyzerPort.bayNumber, + $_LIPortMonitorConfigState.analyzerPort.interconnectUri, + $_LIPortMonitorConfigState.analyzerPort.portUri, + $_LIPortMonitorConfigState.ApplianceConnection) + } + + $_MonitoredPorts = [System.Collections.Generic.List[HPEOneView.Networking.MonitoredPort]]::new() + + ForEach ($_monitoredport in $_LIPortMonitorConfigState.monitoredPorts) + { + + # Get associated deployed connection + $Uri = '{0}?name=CONNECTION_TO_INTERCONNECT&childUri={1}' -f $IndexAssociatedResourcesUri, $_monitoredport.interconnectUri + + Try + { + + $_IndexResults = Send-OVRequest -Uri $Uri -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $_AssociatedConnection = $null + + # Get Connection object(s), and then filter for the associated connection we need + ForEach ($_IndexEntry in $_IndexResults.members) + { + + "[{0}] Get full object: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_IndexEntry.name | Write-Verbose + + Try + { + + $_FullIndexEntry = Send-OVRequest -Uri $_IndexEntry.parentResource.uri -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if ($_FullIndexEntry.interconnectPort -eq $_monitoredport.portName.Replace('d', $null)) + { + + $_AssociatedConnection = $_FullIndexEntry.PSObject.Copy() + break; + + } + + } + + $_Vlans = [System.Collections.Generic.List[Int]]::new() + + if ($null -ne $_AssociatedConnection) + { + + # Get list of VLANs + switch ($_AssociatedConnection.networkResourceUri) + { + + {$_.StartsWith($EthernetNetworksUri)} + { + + $_Uri = '{0}' -f $_AssociatedConnection.networkResourceUri + + } + + {$_.StartsWith($NetworkSetsUri)} + { + + $_Uri = '{0}/networkSetData' -f $_AssociatedConnection.networkResourceUri + + } + + } + + Try + { + + $_AssociatedNetwork = Send-OVRequest -Uri $_Uri -hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + ForEach ($_Network in $_AssociatedNetwork) + { + + $_Vlans.Add($_Network.vlanId) + + } + + # Finally, get Server Profile object so we can get Connection ID + $_ServerProfileUri = '{0}/{1}' -f $ServerProfilesUri, $_AssociatedConnection.containerId + + Try + { + + $_ServerProfile = Send-OVRequest -Uri $_ServerProfileUri -hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $deletgate = [Func[object,bool]]{ param ($c) return $c.mac -eq $_AssociatedConnection.macAddress } + $_AssociatedServerProfileConnection = [System.Linq.Enumerable]::Where($_ServerProfile.connectionSettings.connections,$deletgate) + + $_PortDetails = [HPEOneView.Networking.MonitoredPort+PortDetails]::new($_AssociatedServerProfileConnection.connectionId, + $_AssociatedNetwork.name, + $_AssociatedConnection.macAddress, + $_Vlans) + } + + $_MonitoredPortConfig = [HPEOneView.Networking.MonitoredPort]::new($_monitoredport.portName, + $_monitoredport.portMonitorConfigInfo, + $_monitoredport.portStatus, + $_monitoredport.portHealthStatus, + $_monitoredport.interconnectName, + $_monitoredport.bayNumber, + $_monitoredport.interconnectUri, + $_monitoredport.portUri, + $_PortDetails, + $_LIPortMonitorConfigState.ApplianceConnection) + + $_MonitoredPorts.Add($_MonitoredPortConfig) + + } + + [HPEOneView.Networking.LogicalInterconnect+PortMonitoringConfig]::new($_LIPortMonitorConfigState.enablePortMonitor, + $_LIPortMonitorConfigState.portMonitorType, + $AnalyzerPort, + $_MonitoredPorts, + $_LIPortMonitorConfigState.eTag, + $_LIPortMonitorConfigState.ApplianceConnection) + + } + + {[HPEOneView.Networking.PortMonitorTypeEnum]::Remote -match $_} + { + + "[{0}] Port monitor configuration type: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), [HPEOneView.Networking.PortMonitorTypeEnum]::Remote | Write-Verbose + + # Create analyzer port object + $_AnalyzerPort = [HPEOneView.Networking.AnalyzerPort]::new($_LIPortMonitorConfigState.remotePortMonitor[0].mirrorToPort.portName, + $_LIPortMonitorConfigState.remotePortMonitor[0].mirrorToPort.portStatus, + $_LIPortMonitorConfigState.remotePortMonitor[0].mirrorToPort.portHealthStatus, + $_LIPortMonitorConfigState.remotePortMonitor[0].mirrorToPort.interconnectName, + $_LIPortMonitorConfigState.remotePortMonitor[0].mirrorToPort.bayNumber, + $_LIPortMonitorConfigState.remotePortMonitor[0].mirrorToPort.interconnectUri, + $_LIPortMonitorConfigState.remotePortMonitor[0].mirrorToPort.portUri, + $_LIPortMonitorConfigState.ApplianceConnection) + + # Get network details + Try + { + + $_EthernetNetwork = Send-OVRequest -Uri $_LIPortMonitorConfigState.remotePortMonitor[0].networkUri -Hostname $InputObject.ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + # This contains the analyzer and monitored ports configuration, along with monitored port details + $_RemotePortMonitor = [HPEOneView.Networking.RemotePortMonitor]::new($_EthernetNetwork.uri, $_EthernetNetwork.name, $_AnalyzerPort) + + ForEach ($_monitoredport in $_LIPortMonitorConfigState.remotePortMonitor[0].monitoredPorts) + { + + # Get associated deployed connection + $Uri = '{0}?name=CONNECTION_TO_INTERCONNECT&childUri={1}' -f $IndexAssociatedResourcesUri, $_monitoredport.interconnectUri + + Try + { + + $_IndexResults = Send-OVRequest -Uri $Uri -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $_AssociatedConnection = $null + + # Get Connection object(s), and then filter for the associated connection we need + ForEach ($_IndexEntry in $_IndexResults.members) + { + + "[{0}] Get full object: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_IndexEntry.name | Write-Verbose + + Try + { + + $_FullIndexEntry = Send-OVRequest -Uri $_IndexEntry.parentResource.uri -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if ($_FullIndexEntry.interconnectPort -eq $_monitoredport.portName.Replace('d', $null)) + { + + $_AssociatedConnection = $_FullIndexEntry.PSObject.Copy() + break; + + } + + } + + $_Vlans = [System.Collections.Generic.List[Int]]::new() + + if ($null -ne $_AssociatedConnection) + { + + # Get list of VLANs + switch ($_AssociatedConnection.networkResourceUri) + { + + {$_.StartsWith($EthernetNetworksUri)} + { + + $_Uri = '{0}' -f $_AssociatedConnection.networkResourceUri + + } + + {$_.StartsWith($NetworkSetsUri)} + { + + $_Uri = '{0}/networkSetData' -f $_AssociatedConnection.networkResourceUri + + } + + } + + Try + { + + $_AssociatedNetwork = Send-OVRequest -Uri $_Uri -hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + ForEach ($_Network in $_AssociatedNetwork) + { + + $_Vlans.Add($_Network.vlanId) + + } + + # Finally, get Server Profile object so we can get Connection ID + $_ServerProfileUri = '{0}/{1}' -f $ServerProfilesUri, $_AssociatedConnection.containerId + + Try + { + + $_ServerProfile = Send-OVRequest -Uri $_ServerProfileUri -hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $deletgate = [Func[object,bool]]{ param ($c) return $c.mac -eq $_AssociatedConnection.macAddress } + $_AssociatedServerProfileConnection = [System.Linq.Enumerable]::Where($_ServerProfile.connectionSettings.connections,$deletgate) + + $_PortDetails = [HPEOneView.Networking.MonitoredPort+PortDetails]::new($_AssociatedServerProfileConnection.connectionId, + $_AssociatedNetwork.name, + $_AssociatedConnection.macAddress, + $_Vlans) + } + + $_MonitoredPortConfig = [HPEOneView.Networking.MonitoredPort]::new($_monitoredport.portName, + $_monitoredport.portMonitorConfigInfo, + $_monitoredport.portStatus, + $_monitoredport.portHealthStatus, + $_monitoredport.interconnectName, + $_monitoredport.bayNumber, + $_monitoredport.interconnectUri, + $_monitoredport.portUri, + $_PortDetails, + $_LIPortMonitorConfigState.ApplianceConnection) + + [void]$_RemotePortMonitor.MonitoredPorts.Add($_MonitoredPortConfig) + + } + + [HPEOneView.Networking.LogicalInterconnect+PortMonitoringConfig]::new($_LIPortMonitorConfigState.enablePortMonitor, + $_LIPortMonitorConfigState.portMonitorType, + $_RemotePortMonitor, + $_LIPortMonitorConfigState.eTag, + $_LIPortMonitorConfigState.ApplianceConnection) + + } + + } + + + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Enable-OVLogicalInterconnectPortMonitoring +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "default")] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = "default")] + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = "RemoteSession")] + [ValidateNotNullorEmpty()] + [Alias ('uri', 'li','name','Resource')] + [object]$InputObject, + + [Parameter (Mandatory, ParameterSetName = "default")] + [ValidateNotNullorEmpty()] + [Object]$AnalyzerPort, + + [Parameter (Mandatory, ParameterSetName = "default")] + [Parameter (Mandatory, ParameterSetName = "RemoteSession")] + [ValidateNotNullorEmpty()] + [Object]$MonitoredPorts, + + [Parameter (Mandatory, ParameterSetName = "RemoteSession")] + [ValidateNotNullorEmpty()] + [String]$UplinkSetName, + + [Parameter (ValueFromPipelineByPropertyName, ParameterSetName = "default", Mandatory = $false)] + [Parameter (ValueFromPipelineByPropertyName, ParameterSetName = "RemoteSession", Mandatory = $false)] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + if (-not $InputObject) + { + + $Pipeline = $true + + } + + else + { + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + } + + Process + { + + # Check if the appliance connection is a VM or not. + [ObsoleteMessage]::Write($ApplianceConnection) + + if ($InputObject.category -ne $ResourceCategoryEnum.LogicalInterconnect) + { + + # Throw exception + $ExceptionMessage = 'The provided object "{0}" is not supported. Only Logical Interconnect resources are supported.' -f $InputObject.name + $ErrorRecord = New-ErrorRecord HPEOneView.InputObjectResourceException InvalidInputObjectResource InvalidArgument "InputObject" -TargetType 'PSObject' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + if ([Array]$MonitorPorts.Count -gt 60) + { + + # Throw exception + $ExceptionMessage = 'The provided number of monitored ports exceeds the allowed limited of 60. Please remove {0} or more from the MonitoredPorts parameter.' -f ([Array]$MonitorPorts.Count - 16) + $ErrorRecord = New-ErrorRecord HPEOneView.PortMonitorException MonitoredPortsCountExceeded LimitsExceeded "MonitorPorts" -TargetType 'Object' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + $_Uri = "{0}/port-monitor" -f $InputObject.uri + + if ($PSCmdlet.ParameterSetName -eq 'RemoteSession') + { + + "[{0}] Setup REMOTE port monitor session." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + # Create port monitor cfg object first + $_LogicalInterconnectPortMonitorConfig = [HPEOneView.Networking.RemotePortMonitorCfg]::new() + + # Process uplink set name to get the "remote session" configuration + $_UplinkSetUri = '{0}?filter=name="{1}' -f $UplinkSetsUri, $UplinkSetName + + Try + { + + "[{0}] Getting list of uplink set resources." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_UplinkSets = Send-OVRequest -Uri $_UplinkSetUri -ApplianceConnection $InputObject.ApplianceConnection + + # There could be another LI with the same uplink set name, so need to filter for the provided LI + if ($_UplinkSets.Count -gt 1) + { + + "[{0}] More than 1 uplink set with the '{1}' name was found." -f $MyInvocation.InvocationName.ToString().ToUpper(), $UplinkSetName | Write-Verbose + + } + + $_UplinkSet = $_UplinkSets.members | ? logicalInterconnectUri -eq $InputObject.uri + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + # Throw error uplink set name wasn't found. + if ($null -eq $_UplinkSet) + { + + $ExceptionMessage = 'The provided uplink set name "{0}" was not found or was not found to be associated with the provided "{1}" logical interconnect resource.' -f $UplinkSetName, $InputObject.name + $ErrorRecord = New-ErrorRecord HPEOneView.Library.ParameterValidationException InvalidActivateOrderParameter InvalidOperation "UplinkSetName" -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + # Generate error that the uplink set has more than 1 uplink port assigned + if ($_UplinkSet.portConfigInfos.Count -gt 1) + { + + $ExceptionMessage = 'The provided uplink set name "{0}" has more than 1 uplink port assigned. Only uplink sets with a single uplink port is supported.' -f $UplinkSetName + $ErrorRecord = New-ErrorRecord HPEOneView.Library.ParameterValidationException InvalidActivateOrderParameter InvalidOperation "UplinkSetName" -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + # Generate error that the uplink set has more than 1 Ethernet network assigned + if ($_UplinkSet.networkUris.Count -gt 1) + { + + $ExceptionMessage = 'The provided uplink set name "{0}" has more than 1 Ethernet network assigned. Only uplink sets with a single tagged Ethernet is supported.' -f $UplinkSetName + $ErrorRecord = New-ErrorRecord HPEOneView.Library.ParameterValidationException InvalidActivateOrderParameter InvalidOperation "UplinkSetName" -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + # Check the associated LIG if the uplink set is provisioned + Try + { + + $_ParentLogicalInterconnectGroup = Send-OVRequest -Uri $InputObject.logicalInterconnectGroupUri -Hostname $InputObject.ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if (-not ($_ParentLogicalInterconnectGroup.uplinkSets | ? Name -eq $UplinkSetName)) + { + + $ExceptionMessage = 'The provided uplink set name "{0}" is not provisioned to the associated "{1}" logical interconnect group resource, which is required.' -f $UplinkSetName, $_ParentLogicalInterconnectGroup.name + $ErrorRecord = New-ErrorRecord HPEOneView.Library.ParameterValidationException InvalidActivateOrderParameter InvalidOperation "UplinkSetName" -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + $AnalyzerPort = [HPEOneView.Networking.AnalyzerPortCfg]::new($_UplinkSet.portConfigInfos[0].portUri) + $RemotePortMonitor = [HPEOneView.Networking.RemotePortMonitorPortCfg]::new($_UplinkSet.networkUris, $AnalyzerPort) + + # Process MonitoredPorts parameter + foreach ($_p in $MonitoredPorts) + { + + Try + { + + $_MonitoredPortUri = BuildAnalyzerPortUri -LogicalInterconnect $InputObject -Port $_p.Port + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $_MonitoredPort = [HPEOneView.Networking.MonitoredPortCfg]::new($_MonitoredPortUri, $_p.Direction) + + "[{0}] Adding monitored port {1} to config" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_MonitoredPort | Write-Verbose + + [void]$RemotePortMonitor.monitoredPorts.Add($_MonitoredPort) + + } + + "[{0}] Building final remote port monitor foniguration object." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + [void]$_LogicalInterconnectPortMonitorConfig.remotePortMonitor.Add($RemotePortMonitor) + + } + + elseif ($PSCmdlet.ParameterSetName -eq 'default') + { + + "[{0}] Setup LOCAL port monitor session." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + # Process AnalyzerPort parameter + Try + { + + $_AnalyzerPortUri = BuildAnalyzerPortUri -LogicalInterconnect $InputObject -Port $AnalyzerPort + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $_AnalyzerPortCfg = [HPEOneView.Networking.AnalyzerPortCfg]::new($_AnalyzerPortUri) + + "[{0}] Adding monitored port {1} to config" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_AnalyzerPortCfg | Write-Verbose + + $_LogicalInterconnectPortMonitorConfig = [HPEOneView.Networking.PortMonitorCfg]::new($_AnalyzerPortCfg) + + # Process MonitoredPorts parameter + foreach ($_p in $MonitoredPorts) + { + + Try + { + + $_MonitoredPortUri = BuildAnalyzerPortUri -LogicalInterconnect $InputObject -Port $_p.Port + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $_MonitoredPort = [HPEOneView.Networking.MonitoredPortCfg]::new($_MonitoredPortUri, $_p.Direction) + + "[{0}] Adding monitored port {1} to config" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_MonitoredPort | Write-Verbose + + $_LogicalInterconnectPortMonitorConfig.MonitoredPorts.Add($_MonitoredPort) + + } + + } + + Try + { + + Send-OVRequest -Uri $_Uri -Method PUT -Body $_LogicalInterconnectPortMonitorConfig -Hostname $ApplianceConnection | Wait-OVTaskComplete + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +# Private function to build port URI for permitted ICM +function BuildAnalyzerPortUri +{ + + [CmdletBinding (DefaultParameterSetName = "Default")] + [OutputType([String])] + Param + ( + + [Parameter (Mandatory, ParameterSetName = "default")] + [ValidateNotNullorEmpty()] + [Object]$LogicalInterconnect, + + [Parameter (Mandatory, ParameterSetName = "default")] + [ValidateNotNullorEmpty()] + [String]$Port + + ) + + '[{0}] Parsing: "{1}"' -f $MyInvocation.InvocationName.ToString().ToUpper(), $Port | Write-Verbose + + # Split string to get bay and port + # EXAMPLE1: Enclosure1:Bay3:Q2.2 + # EXMAPLE2: Frame2:BAY3:Q4:1 <-- Will split into 4 array entries, and will be recombined into the correct format below + $_port = $Port.Split(':') + + $_EnclosureID = [RegEx]::Replace($_port[0].ToLower(), 'enclosure|frame', '') + + # Remove bay so we just have the ID + $_Bay = [RegEx]::Replace($_port[1].ToLower(), 'bay', '') + + # Get faceplate or downlink portName (Need to make sure Synergy Uplink Port format which uses : instead of . for subport delimiter is replaced correctly) + # Do not use the \ to escape the . character, otherwise it will not work + $_PortName = $_port[2].Replace('.',':') + + # Port is a downlink port and D should be lowercase + if ($_PortName.ToLower().StartsWith("d")) + { + + $_PortName = $_PortName.ToLower() + + } + + # If caller provided Q#:# as the port name, the Split() operation above would have created an array of 4 items. Rejoin the last two into the correct format of "Q#.#". + if ($_port.Count -eq 4) + { + + $_PortName = '{0}.{1}' -f $_PortName, $_port[3] + + } + + '[{0}] Processing Frame "{1}", Bay "{2}", Port "{3}"' -f $MyInvocation.InvocationName.ToString().ToUpper(), $_EnclosureID, $_Bay, $_PortName | Write-Verbose + + # Can I simplify this next 4 lines into a single search call for either LI type (BL and SY)? + $_EnclosureDeletgate = [Func[object,bool]]{ param ($e) return $e.enclosureIndex -eq $_EnclosureID } + $_Enclosure = [Linq.Enumerable]::ToArray([System.Linq.Enumerable]::Where($LogicalInterconnect.interconnectMap.interconnectMapEntries, $_EnclosureDeletgate)) + + $_InterconnectDelegate = [Func[object,bool]]{ param ($i) return $i.location.locationEntries.type -eq 'Bay' -and $i.location.locationEntries.value -eq $_Bay } + $_PermittedIc = [Linq.Enumerable]::ToArray([System.Linq.Enumerable]::Where($_Enclosure, $_InterconnectDelegate)) + + # Generate error that Interconnect could not be found from the LI + # $_PermittedIc is an Array, so comparing it to $null won't work. + if ($_PermittedIc.Count -eq 0) + { + + "[{0}] Unable to find permitted Interconnect URI from provided logical interconnect and specific port. Generate terminating error." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_PermittedIc.interconnectUri, $_Bay | Write-Verbose + + $ExceptionMessage = 'The Interconnect Bay ID {0} as part of the "{1}" requested port could not be identified within the provided Logical Interconnect resource object.' -f $_Bay, $_p.Port + $ErrorRecord = New-ErrorRecord HPEOneView.UplinkSetResourceException UnsupportedLogicalInterconnectResource InvalidArgument 'InputObject' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + "[{0}] Found permitted Interconnect URI {1} for Bay {2}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_PermittedIc.interconnectUri, $_Bay | Write-Verbose + + Return '{0}/ports/{1}:{2}' -f $_PermittedIc.interconnectUri, [regex]::Match($_PermittedIc.interconnectUri, '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}').value, $_PortName + +} + +function Disable-OVLogicalInterconnectPortMonitoring +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "default")] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = "default")] + [ValidateNotNullorEmpty()] + [Alias ('uri', 'li','name','Resource')] + [object]$InputObject, + + [Parameter (ValueFromPipelineByPropertyName, ParameterSetName = "default", Mandatory = $false)] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + if (-not $InputObject) + { + + $Pipeline = $true + + } + + else + { + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + } + + Process + { + + # Check if the appliance connection is a VM or not. + [ObsoleteMessage]::Write($ApplianceConnection) + + if ($InputObject.category -ne $ResourceCategoryEnum.LogicalInterconnect) + { + + # Throw exception + $ExceptionMessage = 'The provided object "{0}" is not supported. Only Logical Interconnect resources are supported.' -f $InputObject.name + $ErrorRecord = New-ErrorRecord HPEOneView.InputObjectResourceException InvalidInputObjectResource InvalidArgument "InputObject" -TargetType 'PSObject' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + # Display obselete message if the connection is a VM, not Synergy + [ObsoleteMessage]::Write($InputObject.ApplianceConnection) + + $_DisablePortMonitorConfig = [HPEOneView.Networking.PortMonitorCfg]::new() + $_DisablePortMonitorConfig.DisableConfig() + + $_Uri = "{0}/port-monitor" -f $InputObject.uri + + Try + { + + Send-OVRequest -Uri $_Uri -Method PUT -Body $_DisablePortMonitorConfig -Hostname $ApplianceConnection | Wait-OVTaskComplete + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Get-OVSasLogicalInterconnect +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "default")] + Param + ( + + [Parameter (Mandatory = $false, ParameterSetName = "default")] + [ValidateNotNullorEmpty()] + [String]$Name, + + [Parameter (Mandatory = $false, ParameterSetName = "default")] + [ValidateNotNullOrEmpty()] + [String]$Label, + + [Parameter (Mandatory = $false, ParameterSetName = "default")] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default), + + [Parameter (Mandatory = $false, ParameterSetName = "default")] + [Alias ("x", "ExportFile")] + [ValidateScript({split-path $_ | Test-Path})] + [String]$Export + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $LiCollection = [System.Collections.ArrayList]::new() + $NotFound = [System.Collections.ArrayList]::new() + + if (-not $PSBoundParameters['Type']) + { + + $Type = 'Ethernet', 'FibreChannel', 'SAS' + + } + + } + + Process + { + + ForEach ($_appliance in $ApplianceConnection) + { + + if ($_appliance.ApplianceType -ne 'Composer') + { + + $ExceptionMessage = 'The ApplianceConnection {0} is an HPE OneView Virtual Machine Appliance, which does not support SAS Logical Interconnect Group resources.' -f $_appliance.Name + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.ComposerNodeException InvalidOperation InvalidOperation 'ApplianceConnection' -Message $ExceptionMessage + $PSCmdlet.WriteError($ErrorRecord) + + } + + else + { + + $_IndexLookup = $false + + $uri = $SasLogicalInterconnectsUri + + "[{0}] Processing '{1}' Appliance (of {2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name, $ApplianceConnection.Count | Write-Verbose + + if ($PSBoundParameters['Name']) + { + + $Method = 'eq' + + if ($Name.Contains('*')) + { + + $Name = $Name.Replace('*', '%25') + $Method = 'matches' + + } + + "[{0}] Logical Interconnect name provided: '{1}'" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Name | Write-Verbose + + $uri = "{0}?filter=name {1} '{2}'" -f $uri, $Method, $Name + + } + + if ($PSBoundParameters['Label']) + { + + $uri = "{0}?category:logical-interconnects&sort=name:asc&query=labels:{1}" -f $IndexUri, $Label + + if ($PSBoundParameters['Name']) + { + + $uri += '&query=name:{0}' -f $Name + + } + + $_IndexLookup = $true + + } + + Try + { + + $resp = Send-OVRequest -Uri $uri -Hostname $_appliance.Name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if ($resp.count -eq 0 -and $Name) + { + + "[{0}] Logical Interconnect '{1}' resource not found on '{2}'." -f $MyInvocation.InvocationName.ToString().ToUpper(), $Name, $_appliance.Name | Write-Verbose + + $ExceptionMessage = "Specified Logical Interconnect '{0}' was not found on '{1}' appliance. Please check the name and try again." -f $Name, $_appliance.Name + $ErrorRecord = New-ErrorRecord InvalidOperationException SASLogicalInterconnectGroupNotFound ObjectNotFound 'Name' -Message $ExceptionMessage + $PSCmdlet.WriteError($ErrorRecord) + + } + + elseif ($resp.count -eq 0) + { + + "[{0}] No Logical Interconnect resources found on '{1}'." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name | Write-Verbose + + } + + else + { + + "[{0})] Found {1} Logical Interconnect resource(s)." -f $MyInvocation.InvocationName.ToString().ToUpper(), $resp.count | Write-Verbose + + ForEach ($_LiObject in $resp.members) + { + + Try + { + + if ($_IndexLookup) + { + + "[{0}] Getting LI resource object for {1} (Indexed)." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_LiObject.name | Write-Verbose + + Try + { + + $_LiObject = Send-OVRequest -Uri $_LiObject.uri -Hostname $_appliance.Name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $_LiObject.PSobject.TypeNames.Insert(0,"HPEOneView.Storage.SasLogicalInterconnect") + + [void]$LiCollection.Add($_LiObject) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + } + + } + + } + + End + { + + "[{0}] Done. {1} logical interconnect(s) found." -f $MyInvocation.InvocationName.ToString().ToUpper(), $LiCollection.count | Write-Verbose + + if ($Export) + { + + $LiCollection | convertto-json -Depth 99 | Set-Content -Path $ExportFile -force -encoding UTF8 + + } + + else + { + + $LiCollection + + } + + } + +} + +function Update-OVLogicalInterconnect +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "default", SupportsShouldProcess, ConfirmImpact = 'High')] + Param + ( + + [Parameter (Mandatory = $false, ValueFromPipeline, ParameterSetName = "default")] + [Parameter (Mandatory = $false, ValueFromPipeline, ParameterSetName = "Reapply")] + [Parameter (Mandatory = $false, ValueFromPipeline, ParameterSetName = "FactoryReset")] + [ValidateNotNullorEmpty()] + [Alias ('uri', 'li','name','Resource')] + [object]$InputObject, + + [Parameter (ValueFromPipelineByPropertyName, ParameterSetName = "default", Mandatory = $false)] + [Parameter (ValueFromPipelineByPropertyName, ParameterSetName = "Reapply", Mandatory = $false)] + [Parameter (ValueFromPipelineByPropertyName, ParameterSetName = "FactoryReset", Mandatory = $false)] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default), + + [Parameter (Mandatory, ParameterSetName = "Reapply")] + [Switch]$Reapply, + + [Parameter (Mandatory, ParameterSetName = "FactoryReset")] + [Switch]$FactoryReset + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $_returntasks = [System.Collections.ArrayList]::new() + $_liobjects = [System.Collections.ArrayList]::new() + + } + + Process + { + + "[{0}] Processing $($InputObject.count) LI objects." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + foreach ($_li in $InputObject) + { + + # Name provided + if (($_li -is [String]) -and (-not($_li.StartsWith($LogicalInterconnectsUri)))) + { + + "[{0}] LI Name was provided '$($_li)'" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + # Loop through appliance connections to add LI objects to collection + ForEach ($_appliance in $ApplianceConnection) + { + + Try + { + + Get-OVLogicalInterconnect -Name $_li -ApplianceConnection $_appliance.Name | ForEach-Object { [void]$_liobjects.Add($_) } + + } + + Catch + { + + "[{0}] $_.FullyQualifiedErrorId Error Caught: $($_.Exception.Message)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + "[{0}] Retrieved $($_liobjects.count) LI Objects" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + elseif (($_li -is [String]) -and ($_li.StartsWith($LogicalInterconnectsUri))) + { + + # User didn't provide an appliance connection during call + if (-not($PSBoundParameters['ApplianceConnection']) -and $ApplianceConnection.Count -gt 1) + { + + $ErrorRecord = New-ErrorRecord InvalidOperationException LogicalInterconnectUriNoApplianceConnection InvalidArgument 'ApplianceConnection' -Message "A Logical Interconnect URI was provided in the -Resource Parameter, but no Appliance Connection specified. URI's are unique per appliance connection. Please specify an Appliance Connection and try your call again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + # User provided more than 1 appliance connection, and LI URI, generate error + elseif ($ApplianceConnection.Count -gt 1) + { + + $ErrorRecord = New-ErrorRecord InvalidOperationException LogicalInterconnectUriMultipleApplianceConnections InvalidArgument 'ApplianceConnection' -Message "A Logical Interconnect URI was provided in the -Resource Parameter, with multiple Appliance Connections specified. URI's are unique per appliance connection. Please specify an Appliance Connection and try your call again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + "[{0}] LI URI was provided $($_li)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + Send-OVRequest $_li -HostName $ApplianceConnection.Name | ForEach-Object { [void]$_liobjects.Add($_) } + + } + + Catch + { + + "[{0}] $_.FullyQualifiedErrorId Error Caught: $($_.Exception.Message)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + elseif (($_li -is [PSCustomObject]) -and ($_li.category -ieq 'logical-interconnects')) + { + + "[{0}] LI Object was provided: {1} ({2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_li.name, $_li.uri | Write-Verbose + + [void]$_liobjects.Add($_li) + + } + + else + { + + $ErrorRecord = New-ErrorRecord InvalidOperationException InvalidArgumentValue InvalidArgument 'Resource' -TargetType $_li.GetType().Name -Message "An invalid Resource object was provided. $($_li.GetType()) $($_li.category) was provided. Only type String or PSCustomObject, and 'logical-interconnects' object category are permitted." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + } + + End + { + + # Loop through liobject collection to perform action + ForEach ($_liobject in $_liobjects) + { + + # Display obselete message if the connection is a VM, not Synergy + [ObsoleteMessage]::Write($_liobject.ApplianceConnection) + + "[{0}] Processing Logical Interconnect: $($_liobject.name)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if ($PSboundParameters['Reapply']) + { + + "[{0}] Reapply LI configuration requested." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if ($PSCmdlet.ShouldProcess($_liobject.name,"Reapply Logical Interconnect configuration. WARNING: Depending on this action, there might be a brief outage.")) + { + + Try + { + + "[{0}] Sending request to reapply configuration" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $uri = $_liobject.uri + "/configuration" + + $task = Send-OVRequest $uri PUT -Hostname $_liobject.ApplianceConnection.Name + + [void]$_returntasks.Add($task) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + elseif ($PSBoundParameters['WhatIf']) + { + + "[{0}] User included -WhatIf." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + else + { + + "[{0}] User cancelled." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + } + + elseif ($PSboundParameters['FactoryReset']) + { + + "[{0}] FactoryReset LI configuration requested." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if ($PSCmdlet.ShouldProcess($_liobject.name,"Factory reset Logical Interconnect configuration. WARNING: This will cause a complete outage and should only be performed during maintenance window.")) + { + + Try + { + + "[{0}] Sending request to FactoryReset configuration" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $uri = $_liobject.uri # + "/factoryResetState" + + $_PatchRequest = NewObject -PatchOperation + + $_PatchRequest.op = 'replace' + $_PatchRequest.path = '/factoryResetState' + $_PatchRequest.value = 'ReapplyConfiguration' + + $task = Send-OVRequest -Uri $uri -Method PATCH -Body $_PatchRequest -Hostname $_liobject.ApplianceConnection.Name + + [void]$_returntasks.Add($task) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + elseif ($PSBoundParameters['WhatIf']) + { + + "[{0}] User included -WhatIf." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + else + { + + "[{0}] User cancelled." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + } + + else + { + + # Do not Process LI if consistencyStatus is good. + if ($_liobject.consistencyStatus -eq 'CONSISTENT') + { + + Write-Warning 'Logical Interconnect is Consistent with Policy. Nothing to do.' + + } + + else + { + + "[{0}] Update '$($liDisplayName)' Logical Interconnect from parent $($parentLig.name)." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $_ligname = (Send-OVRequest $_liobject.logicalInterconnectGroupUri -HostName $_liobject.ApplianceConnection.Name).Name + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if ($PSCmdlet.ShouldProcess($_liobject.name,"Update Logical Interconnect from Group '$_ligname'. WARNING: Depending on the Update, there might be a brief outage.")) + { + + Try + { + + "[{0}] Sending request" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $uri = $_liobject.uri + "/compliance" + + $task = Send-OVRequest -Uri $uri -Method PUT -Hostname $_liobject.ApplianceConnection + + [void]$_returntasks.Add($task) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + elseif ($PSBoundParameters['WhatIf']) + { + + "[{0}] User included -WhatIf." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + Compare-LogicalInterconnect -InputObject $_liobject + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + else + { + + "[{0}] User cancelled." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + } + + } + + } + + return $_returntasks + + } + +} + +# // TODO: Need to make sure HPEOneView.Library.CompareObject is Format-Table, and not Format-List? +Function Compare-LogicalInterconnect +{ + + [CmdletBinding ()] + Param + ( + + [Parameter (Mandatory, HelpMessage = "Please provide the Encloure or Logical Interconnect object.")] + [ValidateNotNullorEmpty()] + [Object]$InputObject + + ) + + Begin + { + + $ApplianceConnection = $InputObject.ApplianceConnection + + Try + { + + 'Getting all configured Uplink Set objects.' -f $_LigUplinkSet.name | Write-Verbose #-Verbose + $UplinkSets = Get-OVUplinkSet -ApplianceConnection $ApplianceConnection.Name + + 'Getting all Interconnect Types objects.' -f $_LigUplinkSet.name | Write-Verbose #-Verbose + $InterconnectTypes = Get-OVInterconnectType -ApplianceConnection $ApplianceConnection.Name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + Process + { + + + $CompareObject = [System.Collections.ArrayList]::new() + $_LogicalInterconnects = [System.Collections.ArrayList]::new() # Logical Interconnect Uris; not sure what this is used for yet. + $InterconnectMap = [System.Collections.ArrayList]::new() # Collection of Interconnects? + $InterconnectMapTemplate = [System.Collections.ArrayList]::new() + $SideIndicator = @{ Parent = '<='; Child = '=>'; NotEqual = '<=>'} + + function CompareInterconnects ($_LogicalInterconnect, $_LogicalInterconnectGroup) + { + + "Processing Logical Interconnect '{0}' and LIG '{1}'" -f $_LogicalInterconnect.name, $_LogicalInterconnectGroup.name | Write-Verbose #-Verbose + + #Build array of expected Interconnects within LIG + foreach ($InterconnectMapEntryGroup in $_LogicalInterconnectGroup.interconnectMapTemplate.interconnectMapEntryTemplates) + { + + if ($InterconnectMapEntryGroup.permittedInterconnectTypeUri) + { + + [void]$InterconnectMapTemplate.Add([PSCustomObject]@{ + bayNumber = ($InterconnectMapEntryGroup.logicalLocation.locationEntries | Where-Object type -eq "BAY").relativeValue; + InterconnectTypeUri = $InterconnectMapEntryGroup.permittedInterconnectTypeUri + }) + + } + + } + + + #$InterconnectMap = [System.Collections.ArrayList]::new() + #Build array of actual Interconnects in LI + foreach ($_InterconnectMapEntry in $_LogicalInterconnect.InterconnectMap.interconnectMapEntries) + { + + if ($_InterconnectMapEntry.permittedInterconnectTypeUri) + { + + [void]$InterconnectMap.Add([PSCustomObject]@{ + bayNumber = ($_InterconnectMapEntry.location.locationEntries | Where-Object type -eq "Bay").value; + InterconnectTypeUri = $_InterconnectMapEntry.permittedInterconnectTypeUri + }) + + } + + } + + $diff = Compare-Object -ReferenceObject $InterconnectMapTemplate -DifferenceObject $InterconnectMap -Property bayNumber, InterconnectTypeUri -IncludeEqual + + foreach ($d in $diff) + { + + 'Processing LI with LIG DIFF' | Write-Verbose #-Verbose + + $InterconnectType = $InterconnectTypes | Where-Object { $_.uri -eq $d.InterconnectTypeUri } + + if ($d.SideIndicator -eq "==") + { + + 'Expected Interconnect in "{0}" matches Group for Interconnect bay "{1}" type "{2}"' -f $_LogicalInterconnect.name, $d.bayNumber, $InterconnectType.name | Write-Verbose #-Verbose + + } + + else + { + + if ($d.SideIndicator -eq $SideIndicator.Parent) + { + + $_diff = [HPEOneView.Library.CompareObject]::new($d.bayNumber, + $SideIndicator.Child, + $InterconnectType.name, + $null, + $_LogicalInterconnectGroup.name, + $_LogicalInterconnect.name, + 'MISSING_MODULE') + + [void]$CompareObject.Add($_diff) + + '"{0}" Logical Interconnect is currently missing expected module "{1}" within Interconnect bay "{2}" ' -f $_LogicalInterconnect.name, $InterconnectType.name, $d.bayNumber | Write-Verbose + + } + + elseif ($d.SideIndicator -eq $SideIndicator.Child) + { + + $_diff = [HPEOneView.Library.CompareObject]::new($d.bayNumber, + $SideIndicator.Parent, + $InterconnectType.name, + $null, + $_LogicalInterconnectGroup.name, + $_LogicalInterconnect.name, + 'EXTRA_MODULE') + + [void]$CompareObject.Add($_diff) + + '"{0}" Logical Interconnect contains an extra module "{1}" within Interconnect bay "{2}" ' -f $_LogicalInterconnect.name, $InterconnectType.name, $d.bayNumber | Write-Verbose + + } + + } + + } + + # Process Ethernet Settings + $EthernetSettingsProperties = "enableIgmpSnooping", "igmpIdleTimeoutInterval", "enableFastMacCacheFailover", "macRefreshInterval", "enableNetworkLoopProtection", "enablePauseFloodProtection", "enableRichTLV", "enableTaggedLldp" + $EthernetSettingsDiff = [System.Collections.ArrayList]::new() + + if ($_LogicalInterconnectGroup.category -ne 'sas-logical-interconnect-groups') + { + + ForEach ($Property in $EthernetSettingsProperties) + { + + if ($_LogicalInterconnectGroup.ethernetSettings.$Property -ne $_LogicalInterconnect.ethernetSettings.$Property) + { + + $_diff = [HPEOneView.Library.CompareObject]::new($Property, + $SideIndicator.NotEqual, + $_LogicalInterconnectGroup.ethernetSettings.$Property, + $_LogicalInterconnect.ethernetSettings.$Property, + $_LogicalInterconnectGroup.name, + $_LogicalInterconnect.name, + 'SETTING_MISMATCH') + + [void]$EthernetSettingsDiff.Add($_diff) + [void]$CompareObject.Add($_diff) + + } + + } + + ForEach ($diff in $EthernetSettingsDiff) + { + + 'Logical Interconnect "{0}" Ethernet Setting "{1}" does not match the parent "{2}" setting.' -f $diff.InputObject, $diff.ChildSetting, $diff.ParentSetting | Write-Verbose + + } + + # } + + # if ($_LogicalInterconnectGroup.category -ne 'sas-logical-interconnect-groups') + # { + + # Process QoS + $_diff = Compare-Object -ReferenceObject $_LogicalInterconnectGroup.qosConfiguration.activeQosConfig.configType -DifferenceObject $_LogicalInterconnect.qosConfiguration.activeQosConfig.configType -PassThru + + if ($_diff.SideIndicator -eq $SideIndicator.Parent) + { + + $_diff = [HPEOneView.Library.CompareObject]::new('ActiveQosConfig', + $SideIndicator.Parent, + $_LogicalInterconnectGroup.qosConfiguration.activeQosConfig.configType, + $_LogicalInterconnect.qosConfiguration.activeQosConfig.configType, + $_LogicalInterconnectGroup.name, + $_LogicalInterconnect.name, + 'SETTING_MISMATCH') + + [void]$CompareObject.Add($_diff) + + } + + elseif ($_diff.SideIndicator -eq $SideIndicator.Child) + { + + $_diff = [HPEOneView.Library.CompareObject]::new('ActiveQosConfig', + $SideIndicator.Child, + $_LogicalInterconnectGroup.qosConfiguration.activeQosConfig.configType, + $_LogicalInterconnect.qosConfiguration.activeQosConfig.configType, + $_LogicalInterconnectGroup.name, + $_LogicalInterconnect.name, + 'SETTING_MISMATCH') + + [void]$CompareObject.Add($_diff) + + } + + } + + } + + function GetUplinkSets ($_LI, $_LIG) + { + + 'Processing Uplink Set objects' | Write-Verbose #-Verbose + 'LI: {0} [{1}]' -f $_LI.name,$_LI.uri | Write-Verbose #-Verbose + 'LIG: {0}' -f $_LIG.name | Write-Verbose #-Verbose + 'Number of LIG Uplink Sets: {0}' -f $_LIG.uplinkSets.count | Write-Verbose #-Verbose + 'Number of matched Uplink Sets to LI: {0}' -f ($UplinkSets | Where-Object logicalInterconnectUri -eq $_LI.uri).Count | Write-Verbose #-Verbose + + if (($UplinkSets | Where-Object logicalInterconnectUri -eq $_LI.uri).Count -gt $_LIG.uplinkSets.Count) + { + + 'Number of Unmatched Uplink Sets to LI: {0}' -f (($UplinkSets | Where-Object logicalInterconnectUri -eq $_LI.uri).Count - $_LIG.uplinkSets.Count) | Write-Verbose #-Verbose + + } + + else + { + + 'Number of Unmatched Uplink Sets to LIG: {0}' -f ($_LIG.uplinkSets.Count - ($UplinkSets | Where-Object logicalInterconnectUri -eq $_LI.uri).Count) | Write-Verbose #-Verbose + + } + + $myLUs = [System.Collections.ArrayList]::new() + + 'Processing LIG policy for undefined Uplink Sets within LI.' -f $_LigUplinkSet.name | Write-Verbose #-Verbose + + ForEach ($_LigUplinkSet in $_LIG.uplinkSets) + { + + 'Looking for unprovisioned LIG Uplink Set: {0}' -f $_LigUplinkSet.name | Write-Verbose #-Verbose + + if (($UplinkSets | Where-Object logicalInterconnectUri -eq $_LI.uri).name -notcontains $_LigUplinkSet.name) + { + + '{0} is not provisioned within LI.' -f $_LigUplinkSet.name | Write-Verbose #-Verbose + + $MissingUplinkSet = NewObject -liUplinkSetObject + $MissingUplinkSet.name = "Missing" + Add-Member -InputObject $MissingUplinkSet -NotePropertyName UplinkSetGroup -NotePropertyValue $null -Force + Add-Member -InputObject $MissingUplinkSet -NotePropertyName LogicalInterconnectName -NotePropertyValue $_LI.name + Add-Member -InputObject $MissingUplinkSet.UplinkSetGroup -NotePropertyName LogicalInterconnectGroupName -NotePropertyValue $_LIG.name + [void]$myLUs.Add($MissingUplinkSet) + + } + + } + + # Inject LIG Uplink Set object into LI for further matching later + foreach ($lu in ($UplinkSets | Where-Object logicalInterconnectUri -eq $_LI.uri)) + { + + "Match on: {0}" -f $lu.logicalInterconnectUri | Write-Verbose #-Verbose + + Add-Member -InputObject $lu -NotePropertyName UplinkSetGroup -NotePropertyValue $null -Force + Add-Member -InputObject $lu -NotePropertyName LogicalInterconnectName -NotePropertyValue $_LI.name + $lu.UplinkSetGroup = $_LIG.uplinkSets | Where-Object name -eq $lu.name + + # If LIG Uplink Set doesn't exist, add placebo + if ($null -eq $lu.UplinkSetGroup) + { + + 'Uplink Set "{0}" is not defined in the LIG.' -f $_LigUplinkSet.name | Write-Verbose #-Verbose + + $MissingLIGUplinkSet = MissingUplinkSetFromLIG + $MissingLIGUplinkSet.UplinkSetGroup = $_LigUplinkSet + $MissingLIGUplinkSet.LogicalInterconnectUri = $_LI.uri + $MissingLIGUplinkSet.LogicalInterconnectName = $_LI.name + $MissingLIGUplinkSet.LogicalInterconnectGroupName = $_Lig.name + + } + + else + { + + 'Uplink Set "{0}" exists in both LI and LIG.' -f $_LigUplinkSet.name | Write-Verbose #-Verbose + + Add-Member -InputObject $lu.UplinkSetGroup -NotePropertyName LogicalInterconnectGroupName -NotePropertyValue $_LIG.name + + } + + [void]$myLUs.Add($lu) + + } + + # Need to add a check here for when the LIG Uplink Set(s) differe from LI, not what matches from LI to global Uplink Sets + return $myLUs + + } + + function GetPortName ($bay, $portNumber) + { + + 'Getting name for port Bay: {0}; Port Number: {1}' -f $Bay, $PortNumber | Write-Verbose #-Verbose + + + # This function uses the Interconnect map Group set up in CompareInterconnects + $InterconnectMapEntry = $InterconnectMapTemplate | Where-Object bayNumber -eq $bay + "InterconnectType: {0}" -f $InterconnectMapEntry | Write-Verbose #-Verbose + + $InterconnectModuleType = $InterconnectTypes | Where-Object uri -eq $InterconnectMapEntry.InterconnectTypeUri + "Interconnect Module Type: {0}" -f $InterconnectModuleType | Write-Verbose #-Verbose + + "Uplink Port Name: {0}" -f ($InterconnectModuleType.portInfos | Where-Object portNumber -eq $PortNumber).portName | Write-Verbose #-Verbose + Return ($InterconnectModuleType.portInfos | Where-Object portNumber -eq $PortNumber).portName + + } + + function CompareNetworks ($lu, $lut) + { + + 'Examining Networks associated with Uplink Set "{0}"' -f $lu.name | Write-Verbose #-Verbose + + switch ($lu.networkType) + { + + 'FibreChannel' + { + + 'Processing Fibre Channel Uplink Set' | Write-Verbose #-Verbose + + if ($lu.fcNetworkUris.Count -ne $lut.networkUris.Count) + { + + '{0} currently has {1} FC networks, Group has {2}' -f $lu.name, $lu.fcNetworkUris.Count, $lut.networkUris.Count | Write-Verbose + + } + + if ($null -eq $lut.fcNetworkUris) + { + + $diff = [PSCustomObject]@{InputObject = $lu.fcNetworkUris; SideIndicator = "=>"} + + } + + elseif ($null -eq $lu.fcNetworkUris) + { + + $diff = [PSCustomObject]@{InputObject = $lut.fcNetworkUris; SideIndicator = "<="} + + } + + else + { + + $diff = Compare-Object -ReferenceObject $lu.fcNetworkUris -DifferenceObject $lut.networkUris + + } + + } + + 'Ethernet' + { + + 'Processing Ethernet Uplink Set' | Write-Verbose #-Verbose + + if ($lu.networkUris.Count -ne $lut.networkUris.Count) + { + + '{0} currently has {1} Ethernet networks, Group has {2}' -f $lu.name, $lu.networkUris.Count, $lut.networkUris.Count | Write-Verbose + + } + + if ($null -eq $lut.networkUris) + { + + $diff = [PSCustomObject]@{InputObject = $lu.networkUris; SideIndicator = "=>"} + + } + + elseif ($null -eq $lu.networkUris) + { + + $diff = [PSCustomObject]@{InputObject = $lut.networkUris; SideIndicator = "<="} + + } + + else + { + + $diff = Compare-Object -ReferenceObject $lu.networkUris -DifferenceObject $lut.networkUris + + } + + } + + } + + foreach ($d in $diff) + { + + ForEach ($_uri in $d.InputObject) + { + + Try + { + + $net = Send-OVRequest -Uri $_uri -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if ($d.SideIndicator -eq $SideIndicator.Child) + { + + $_diff = [HPEOneView.Library.CompareObject]::new($lu.name, + $SideIndicator.Parent, + $net.name, + $null, + $lut.LogicalInterconnectGroupName, + $lu.LogicalInterconnectName, + 'MISSING_NETWORK') + + [void]$CompareObject.Add($_diff) + + '{0} is currently missing network {1} VLAN {2}' -f $lu.name, $net.name, $net.vlanId | Write-Verbose + + } + + else + { + + $_diff = [HPEOneView.Library.CompareObject]::new($lu.name, + $SideIndicator.Child, + $null, + $net.name, + $lut.LogicalInterconnectGroupName, + $lu.LogicalInterconnectName, + 'EXTRA_NETWORK') + [void]$CompareObject.Add($_diff) + + '{0} currently has extra network {1} VLAN {2}' -f $lu.name, $net.name, $net.vlanId | Write-Verbose + + } + + } + + } + + } + + function CompareLocalNetworks ($li, $lig) + { + + 'Examining Internal Networks' | Write-Verbose #-Verbose + + if ($li.internalNetworkUris.Count -ne $lig.internalNetworkUris.Count) + { + + '{0} currently has {1} Internal Ethernet networks, Group has {2}' -f $li.name, $li.internalNetworkUris.Count, $lig.internalNetworkUris.Count | Write-Verbose + + } + + $diff = Compare-Object -ReferenceObject $lig.internalNetworkUris -DifferenceObject $li.internalNetworkUris + + + foreach ($d in $diff) + { + + Try + { + + $net = Send-OVRequest $d.InputObject + + } + + Catch + { + + PSCmdlet.ThrowTerminatingError($_) + + } + + if ($d.SideIndicator -eq $SideIndicator.Parent) + { + + $_diff = [HPEOneView.Library.CompareObject]::new('InternalNetworks', + $SideIndicator.Child, + $net.name, + $null, + $lig.name, + $li.name, + 'MISSING_NETWORK') + + [void]$CompareObject.Add($_diff) + + '{0} is currently missing internal network {1} VLAN {2}' -f $li.name, $net.name, $net.vlanId | Write-Verbose + + } + + else + { + + $_diff = [HPEOneView.Library.CompareObject]::new('InternalNetworks', + $SideIndicator.Parent, + $null, + $net.name, + $lig.name, + $li.name, + 'EXTRA_NETWORK') + [void]$CompareObject.Add($_diff) + + '{0} currently has extra network {1} VLAN {2}' -f $li.name, $net.name, $net.vlanId | Write-Verbose + + } + + } + + } + + function ComparePorts ($lu, $lut) + { + + "Comparing ports" | Write-Verbose #-Verbose + + "Uplink Set Port count: {0}" -f $lu.portConfigInfos.Count | Write-Verbose #-Verbose + "LIG Uplink Set Port count: {0}" -f $lut.logicalPortConfigInfos.Count | Write-Verbose #-Verbose + + if ($lu.portConfigInfos.Count -ne $lut.logicalPortConfigInfos.Count) + { + + '{0} currently has {1} ports, Group has {2}' -f $lu.name, $lu.portConfigInfos.Count, $lut.logicalPortConfigInfos.Count | Write-Verbose + + } + + #Build array of LU ports + $luPorts = [System.Collections.ArrayList]::new() + $lutPorts = [System.Collections.ArrayList]::new() + + # Process LIG Uplink Set Uplink Ports + foreach ($upPorts in $lut.logicalPortConfigInfos) + { + + $Port = [PSCustomObject]@{ type = 'lut.portConfigInfos';bayNumber = $null; portNumber = $null; portName = $null; Speed = $null } + + foreach ($loc in $upPorts.logicalLocation.locationEntries) + { + + $Port.Speed = $upPorts.desiredSpeed + + if ($loc.type -eq "BAY") { $Port.bayNumber = $loc.relativeValue } + + if ($loc.type -eq "PORT") { $Port.portNumber = $loc.relativeValue } + + } + + $Port.portName = GetPortName $Port.bayNumber $Port.portNumber + + [void]$lutPorts.Add($Port) + + } + + # // TODO: Logic here is incorrect and broken. Not identifying the corect ports. + # Process LI Uplink Set Uplink Ports + foreach ($upPorts in $lu.portConfigInfos) + { + + $Port = [PSCustomObject]@{ type = 'lu.portConfigInfos';bayNumber = $null; portNumber = $null; portName = $null; Speed = $null } + + foreach ($loc in $upPorts.Location.locationEntries) + { + + $Port.Speed = $upPorts.desiredSpeed + + if ($loc.type -eq "BAY") { $Port.bayNumber = $loc.Value } + + if ($loc.type -eq "PORT") { $Port.portName = $loc.Value } + + } + + [void]$luPorts.Add($Port) + + } + + $PortLocationDiff = Compare-Object -ReferenceObject $lutPorts -DifferenceObject $luPorts -Property bayNumber, portName + + 'PortLocationDiff Object: {0}' -f ($PortLocationDiff | Out-String) | Write-Verbose #-Verbose + + foreach ($d in $PortLocationDiff) + { + + $Property = 'Bay{0}:{1}' -f $d.bayNumber, $d.portName + + if ($d.SideIndicator -eq $SideIndicator.Parent) + { + + $_diff = [HPEOneView.Library.CompareObject]::new($lu.name, + $SideIndicator.Child, + $Property, + $null, + $lut.LogicalInterconnectGroupName, + $lu.LogicalInterconnectName, + 'MISSING_UPLINKPORT') + + [void]$CompareObject.Add($_diff) + + '{0} is currently missing port bay {1} port ' -f $lu.name, $d.bayNumber, $d.portName | Write-Verbose + + } + + elseif ($d.SideIndicator -eq $SideIndicator.Child) + { + + $_diff = [HPEOneView.Library.CompareObject]::new($lu.name, + $SideIndicator.Parent, + $null, + $Property, + $lut.LogicalInterconnectGroupName, + $lu.LogicalInterconnectName, + 'ADDITIONAL_UPLINKPORT') + + [void]$CompareObject.Add($_diff) + + '{0} currently has extra port on bay {1} port {2}' -f $lu.name, $d.bayNumber, $d.portName | Write-Verbose + + } + + } + + $PortSpeedDiff = Compare-Object -ReferenceObject $lutPorts -DifferenceObject $luPorts -Property Speed -PassThru + + 'PortSpeedDiff Object: {0}' -f ($PortSpeedDiff | Out-String) | Write-Verbose #-Verbose + + foreach ($d in $PortSpeedDiff) + { + + if ($luPorts | Where-Object { $_.bayNumber -eq $d.bayNumber -and $_.portName -eq $d.portName} ) + { + + $Property = '{0}:Bay{1}:{2}' -f $lut.name,$d.bayNumber, $d.portName + + 'luPort Object: {0}' -f (($luPorts | Where-Object { $_.bayNumber -eq $d.bayNumber -and $_.portName -eq $d.portName}) | Out-String) | Write-Verbose #-Verbose + + if ($d.SideIndicator -eq '=>') + { + + $ParentValue = $null + + if ($lutPorts | Where-Object { $_.bayNumber -eq $d.bayNumber -and $_.portName -eq $d.portName}) + { + + $ParentValue = '{0}' -f $GetUplinkSetPortSpeeds[($lutPorts | Where-Object { $_.bayNumber -eq $d.bayNumber -and $_.portName -eq $d.portName}).Speed] + + } + + $ChildValue = '{0}' -f $GetUplinkSetPortSpeeds[$d.Speed] + + } + + elseif ($d.SideIndicator -eq '<=') + { + + $ChildValue = $null + + if ($luPorts | Where-Object { $_.bayNumber -eq $d.bayNumber -and $_.portName -eq $d.portName}) + { + + $ChildValue = '{0}' -f $GetUplinkSetPortSpeeds[($luPorts | Where-Object { $_.bayNumber -eq $d.bayNumber -and $_.portName -eq $d.portName}).Speed] + + } + + $ParentValue = '{0}' -f $GetUplinkSetPortSpeeds[$d.Speed] + + } + + $_diff = [HPEOneView.Library.CompareObject]::new($Property, + $SideIndicator.NotEqual, + $ParentValue, + $ChildValue, + $lut.LogicalInterconnectGroupName, + $lu.LogicalInterconnectName, + 'LINKSPEED_MISMATCH') + + [void]$CompareObject.Add($_diff) + + '{0} Uplink Port {1}:{2} has different link speed {3} than Group {4}' -f $lut.name, $d.bayNumber, $d.portName, $ParentValue, $ChildValue | Write-Verbose + + } + + } + + } + + function CompareUplinksWithGroup ($lu) + { + + $lut = $lu.UplinkSetGroup + + if (! $lut) + { + + '"{0}" Uplink Set has no matching LIG Uplink Set. Skipping.' -f $lu.name | Write-Verbose + + } + + if ($lu.name -eq 'missing') + { + + '"{0}" Uplink Set within Logical Interconnect Group "{1}" is not provisioned or missing from Logical Interconnect "{2}"' -f $lut.name, $lu.LogicalInterconnectGroupName, $lu.LogicalInterconnectName | Write-Verbose + + $_diff = [HPEOneView.Library.CompareObject]::new('UplinkSets', + $SideIndicator.Child, + $lut.name, + $null, + $lu.LogicalInterconnectGroupName, + $lu.LogicalInterconnectName, + 'MISSING_UPLINKSET') + + [void]$CompareObject.Add($_diff) + + } + + else + { + + 'Comparing {0} Uplink Set with Group' -f $lu.name | Write-Verbose #-Verbose + + 'LU: {0}' -f $lu | Write-Verbose #-Verbose + 'LUT: {0}' -f $lut | Write-Verbose #-Verbose + + if ($lu.networkType -ne $lut.networkType) + { + + $_diff = [HPEOneView.Library.CompareObject]::new(($lu.name + ':networkType'), + $SideIndicator.Parent, + $lut.networkType, + $lu.networkType, + $lut.LogicalInterconnectGroupName, + $lu.LogicalInterconnectName, + 'NETWORKTYPE_MISMATCH') + + [void]$CompareObject.Add($_diff) + + '"{0}" current Type "{1}" differs from Group Type "{2}"' -f $lu.name, $lu.networkType, $lut.networkType | Write-Verbose + + } + + if ($lu.connectionMode -ne $lut.mode) + { + + $LutPort = $null + $LuPort = $null + + if ($lut.LogicalInterconnectGroupName) + { + + $LutPort = $lut.LogicalInterconnectGroupName + ":" + $lut.name + + } + + if ($lu.LogicalInterconnectName) + { + + $LuPort = $lu.LogicalInterconnectName + ":" + $lu.name + + } + + $_diff = [HPEOneView.Library.CompareObject]::new('connectionMode', + $SideIndicator.Parent, + $lut.mode, + $lu.connectionMode, + $LutPort, + $LuPort, + 'CONNECTIONMODE_MISMATCH') + + [void]$CompareObject.Add($_diff) + + '"{0}" current Connection Mode "{1}" differs from Group Connection Mode "{2}"' -f $lu.name, $lu.connectionMode, $lut.mode | Write-Verbose + + } + + if ( $lut.mode -ne 'Auto' -or $lu.connectionMode -ne 'Auto') + { + + $LutPrimaryPort = [PSCustomObject]@{ bayNumber = $null; portNumber = $null; portName = $null; Speed = $null } + $LutPrimaryPort.bayNumber = ($lut.primaryPort.locationEntries | Where-Object { $_.type -eq 'Bay' } ).relativeValue + $LutPrimaryPort.portNumber = ($lut.primaryPort.locationEntries | Where-Object { $_.type -eq 'Port' } ).relativeValue + $LutPrimaryPort.portName = GetPortName $LutPrimaryPort.bayNumber $LutPrimaryPort.portNumber + + $LuPrimaryPort = [PSCustomObject]@{ bayNumber = $null; portNumber = $null; portName = $null; Speed = $null } + $LuPrimaryPort.bayNumber = ($lu.primaryPortLocation.locationEntries | Where-Object type -eq 'Bay').value + $LuPrimaryPort.portName = ($lu.primaryPortLocation.locationEntries | Where-Object type -eq 'Port').value + + $PrimaryPortDiff = Compare-Object -ReferenceObject $LutPrimaryPort -DifferenceObject $LuPrimaryPort -Property portName -PassThru + + 'PrimaryPortDiff Object: {0}' -f ($PrimaryPortDiff | Out-String) | Write-Verbose #-Verbose + + if ($PrimaryPortDiff) + { + + $_SideIndicator = '<=>' + + $_ParentPrimaryPort = ('BAY{0}:{1}' -f $LutPrimaryPort.bayNumber, $LutPrimaryPort.portName) + $_ChildPrimaryPort = ('BAY{0}:{1}' -f $LuPrimaryPort.bayNumber, $LuPrimaryPort.portName) + + if (! $LuPrimaryPort.portName) + { + + $_SideIndicator = '<=' + $_ChildPrimaryPort = $null + + } + + elseif (! $LutPrimaryPort.portName) + { + + $_SideIndicator = '=>' + $_ParentPrimaryPort = $null + + } + + $_diff = [HPEOneView.Library.CompareObject]::new('PrimaryPort', + $_SideIndicator, + $_ParentPrimaryPort, + $_ChildPrimaryPort, + ($lut.LogicalInterconnectGroupName + ":" + $lut.name), + ($lu.LogicalInterconnectName + ":" + $lu.name), + 'PRIMARYPORT_MISMATCH') + + [void]$CompareObject.Add($_diff) + + '"{0}" current Primary Port "{1}" differs from Group "{2}"' -f $lu.name, $_ChildPrimaryPort, $_ParentPrimaryPort | Write-Verbose + + } + + } + + + if ($lu.nativeNetworkUri -ne $lut.nativeNetworkUri) + { + + 'LU NativeNetworkUri: {0}' -f $lu.nativeNetworkUri | Write-Verbose #-Verbose + 'LUT NativeNetworkUri: {0}' -f $lut.nativeNetworkUri | Write-Verbose #-Verbose + + $_SideIndicator = $SideIndicator.NotEqual + + if ($lu.nativeNetworkUri) + { + + $luNativeNetwork = (Send-OVRequest $lu.nativeNetworkUri).name + + } + + else + { + + $luNativeNetwork = "None" + $_SideIndicator = $SideIndicator.Parent + + } + + if ($lut.nativeNetworkUri) + { + + $lutNativeNetwork = (Send-OVRequest $lut.nativeNetworkUri).name + + } + + else + { + + $lutNativeNetwork = "None" + $_SideIndicator = $SideIndicator.Child + + } + + $_diff = [HPEOneView.Library.CompareObject]::new(($lu.name + ':nativeNetworkUri'), + $_SideIndicator, + $lutNativeNetwork, + $luNativeNetwork, + $lut.LogicalInterconnectGroupName, + $lu.LogicalInterconnectName, + 'NATIVENETWORK_MISMATCH') + + [void]$CompareObject.Add($_diff) + + '"{0}" current Native Network "{1}" differs from Group Native Network "{2}"' -f $lu.name, $luNativeNetwork, $lutNativeNetwork | Write-Verbose + + } + + CompareNetworks $lu $lut + + ComparePorts $lu $lut + + } + + } + + Function MissingUplinkSetFromLIG + { + + Return [PSCustomObject] @{ + + Name = "missing"; + UplinkSetGroup = $null; + LogicalInterconnectUri = $null; + LogicalInterconnectName = $null; + LogicalInterconnectGroupName = $null + + } + + } + + ################################################################## + # If InputObject is not a PSCustomObject, assume it is an Enclosure Name + if ($InputObject -IsNot [System.Management.Automation.PSCustomObject]) + { + + Try + { + + $InputObject = Get-OVEnclosure -Name $InputObject -ApplianceConnection $ApplianceConnection + + } + + Catch + { + + PSCmdlet.ThrowTerminatingError($_) + + } + + } + + "InputObject resource: {0} [{1}]" -f $InputObject.name, $InputObject.category | Write-Verbose + + # Loop through all ICM bays of the Enclosure object + if ($InputObject.category -eq $ResourceCategoryEnum.Enclosure) + { + + '{0} has {1} interconnect bays which are configured as {2} logical Interconnects' -f $InputObject.name, ($InputObject.interconnectBays | Where-Object interconnectUri).Count, $_LogicalInterconnectUris.Count | Write-Verbose + + $UniqueLIUris = $InputObject.interconnectBays | Select-Object -Property logicalInterconnectUri -Unique | Where-Object { $_.logicalInterconnectUri } + + ForEach ($_uri in $UniqueLIUris.logicalInterconnectUri) + { + + 'Processing LI URI: {0}' -f $_uri | Write-Verbose + + Try + { + + $_LIObject = Send-OVRequest -Uri $_uri -Hostname $ApplianceConnection + $_LigObject = Send-OVRequest -Uri $_LIObject.logicalInterconnectGroupUri -Hostname $ApplianceConnection + + $_LIObject | Add-Member -NotePropertyName LogicalInterconnectGroup -NotePropertyValue $_LigObject -Force + [void]$_LogicalInterconnects.Add($_LIObject) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + elseif ($InputObject.category -eq $ResourceCategoryEnum.LogicalEnclosure) + { + + # Is this even right? There is a logicalInterconnectUris property. Should that be used, even for C-Class and Synergy? + ForEach ($_LogicalInterconnectUri in ($InputObject.logicalInterconnectUris | Where-Object { -not $_.StartsWith($SasLogicalInterconnectsUri) })) + { + + Try + { + + $_LogicalInterconnect = Send-OVRequest -Uri $_LogicalInterconnectUri -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + '{0} has {1} interconnect bays which are configured within the Logical Interconnect' -f $InputObject.name, $InputObject.interconnects.Count | Write-Verbose + + Try + { + + $_LigObject = Send-OVRequest -Uri $_LogicalInterconnect.logicalInterconnectGroupUri -Hostname $ApplianceConnection + + $_LogicalInterconnect | Add-Member -NotePropertyName LogicalInterconnectGroup -NotePropertyValue $_LigObject -Force + + [void]$_LogicalInterconnects.Add($_LogicalInterconnect) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + elseif ($InputObject.category -eq $ResourceCategoryEnum.LogicalInterconnect) + { + + '{0} has {1} interconnect bays which are configured within the Logical Interconnect' -f $InputObject.name, $InputObject.interconnects.Count | Write-Verbose + + Try + { + + $_LIObject = $InputObject.PSObject.Copy() + $_LigObject = Send-OVRequest -Uri $_LIObject.logicalInterconnectGroupUri -Hostname $ApplianceConnection + + $_LIObject | Add-Member -NotePropertyName LogicalInterconnectGroup -NotePropertyValue $_LigObject -Force + [void]$_LogicalInterconnects.Add($_LIObject) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + else + { + + Throw "Unsupported InputObject. Only Enclosure or Logical Interconnect resources are permitted." + + } + + # Start the compare process + foreach ($_LI in $_LogicalInterconnects) + { + + "Logical Interconnect '{0}' has '{1}' Interconnects and is based on Group '{2}'" -f $_LI.name, $_LogicalInterconnect.Interconnects.Count, $_LI.LogicalInterconnectGroup.name | Write-Verbose + + # Compare Expected and Actual interconnect map + CompareInterconnects $_LI $_LI.LogicalInterconnectGroup + + # Collect Uplink Sets from both LIG and LI + $lus = GetUplinkSets $_LI $_LI.LogicalInterconnectGroup + + foreach ($lu in $lus) + { + + # Compare Uplink Sets between LI and LIG, with LIG Uplink Set within LI Uplink Set (LU) + CompareUplinksWithGroup $lu + + } + + # Compare Local Networks + CompareLocalNetworks $_LI $_LI.LogicalInterconnectGroup + + } + + # Display final object + $CompareObject + + } + + End + { + + 'Done.' | Write-Verbose + + } + +} + +# // TODO: Compare Enclosure with EG +function Compare-Enclosure +{ + + +} + +function Show-OVLogicalInterconnectMacTable +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "default")] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = "default")] + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = "MACAddress")] + [ValidateNotNullorEmpty()] + [Alias ("name","li","LogicalInterconnect")] + [object]$InputObject, + + [Parameter (Mandatory = $false, ParameterSetName = "default")] + [ValidateNotNullorEmpty()] + [String]$network, + + [Parameter (Mandatory = $false, ParameterSetName = "MACAddress")] + [validatescript({$MacAddressPattern.Match($_).Success})] # { throw "The input value '$_' does not match 'aa:bb:cc:dd:ee:ff'. Please correct the value and try again."}})] + [Alias ("mac")] + [String]$MacAddress, + + [Parameter (Mandatory = $false, ParameterSetName = "default")] + [Parameter (Mandatory = $false, ParameterSetName = "MACAddress")] + [Alias ("x", "ExportFile")] + [ValidateScript({split-path $_ | Test-Path})] + [String]$Export, + + [Parameter (Mandatory = $false, ParameterSetName = "default", ValueFromPipelineByPropertyName)] + [Parameter (Mandatory = $false, ParameterSetName = "MACAddress", ValueFromPipelineByPropertyName)] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not $PSBoundParameters['InputObject']) + { + + $PipelineInpute = $true + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + $MacTables = [System.Collections.ArrayList]::new() + + } + + Process + { + + "[{0}] Logical Interconnect via PipeLine: $PipelineInput" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($InputObject)) + { + + "[{0}] No Logical Interconnects provided via Parameter. Getting all LI resources." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $InputObject = Get-OVLogicalInterconnect + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + ForEach ($li in $InputObject) + { + + # Display obselete message if the connection is a VM, not Synergy + [ObsoleteMessage]::Write($li.ApplianceConnection) + + if ($li -is [PSCustomObject] -and $li.category -eq $ResourceCategoryEnum.LogicalInterconnect) + { + + "[{0}] Logical Interconnect object provided: $($li.name)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + "[{0}] Logical Interconnect object URI: $($li.uri)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $uri = $li.uri +"/forwarding-information-base" + + } + + else + { + + # Unsupported type + $ErrorRecord = New-ErrorRecord InvalidOperationException InvalidArgumentValue InvalidArgument 'LogicalInterconnect' -TargetType $li.GetType().Name -Message "The Parameter -LogicalInterconnect contains an invalid Parameter value type, '$($li.gettype().fullname)' is not supported. Only [PSCustomObject] type is allowed." + $PSCmdlet.WriteError($ErrorRecord) + + } + + # Filter the request for a specific Network + if ($Network) + { + + "[{0}] Filtering for '$Network' Network Resource" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_Network = Get-OVNetwork $network -ApplianceConnection $li.ApplianceConnection.Name + + $_internalVlanId = $_Nework.internalVlanId + + $uri += "?filter=internalVlan=$_internalVlanId" + + "[{0}] Processing $uri" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $resp = (Send-OVRequest $uri -Hostname $li.ApplianceConnection.Name).members + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + + } + + elseif ($MacAddress) + { + + "[{0}] Filtering for MAC Address '$MacAddress'" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $uri += "?filter=macAddress='$MacAddress'" + + "[{0}] Processing $uri" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $resp = (Send-OVRequest $uri -Hostname $li.ApplianceConnection.Name).members + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + else + { + + "[{0}] Generating '{1}' mactable file." -f $MyInvocation.InvocationName.ToString().ToUpper(), $uri | Write-Verbose + + Try + { + + $MacTableFile = Send-OVRequest -Uri $uri -Method POST -Hostname $li.ApplianceConnection.Name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + + if ("Success","Completed" -match $MacTableFile.state -and $MacTableFile.fileSize -gt 0 -and -not([System.String]::IsNullOrWhiteSpace($MacTableFile))) + { + + "[{0}] Processing '{1}' mactable file." -f $MyInvocation.InvocationName.ToString().ToUpper(), $MacTableFile.uri | Write-Verbose + + Try + { + + $resp = Download-MacTable $MacTableFile + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + elseif ([System.String]::IsNullOrWhiteSpace($MacTableFile)) + { + + $Message = 'The results returned are null. This Cmdlet is not supported with the HPE OneView DCS appliance.' + $ErrorRecord = New-ErrorRecord HPEOneView.NetworkResourceException InvalidInterconnectFibDataInfo InvalidOperation 'InputObject' -Message $Message + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + else + { + + "[{0}] Results are likely null. Will not generate an error and return null value." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + } + + if ($null -ne $resp) + { + + ForEach ($_entry in $resp) + { + + $_entry | Out-Host + + "[{0}] Adding '{1}' to collection" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_entry.address | Write-Verbose + + $Entry = NewObject -MacTableAddressEntry + + if ($Network -or $MacAddress) + { + + $Entry.Enclosure = $_entry.interconnectName.Split(",", [System.StringSplitOptions]::TrimEntries -bxor [System.StringSplitOptions]::RemoveEmptyEntries)[0] + $Entry.Interconnect = $_entry.interconnectName.Split(",", [System.StringSplitOptions]::TrimEntries -bxor [System.StringSplitOptions]::RemoveEmptyEntries)[1] + $Entry.Interface = $_entry.networkInterface + $Entry.Address = $_entry.macAddress + $Entry.Type = $_entry.entryType + $Entry.Network = $_entry.networkName + $Entry.VLAN = $_entry.externalVlan + + } + + else + { + + $Entry.Enclosure = $_entry.Enclosure + $Entry.Interconnect = $_entry.Interconnect + $Entry.Interface = $_entry.Interface + $Entry.Address = $_entry.address + $Entry.Type = $_entry.type + $Entry.Network = $_entry.network + $Entry.VLAN = $_entry.extVlan + $Entry | Add-Member -NotePropertyName LAGPorts -NotePropertyValue $_entry.LAGPorts + + } + + [void]$MacTables.Add($Entry) + + } + + } + + } + + } + + End + { + + if ($list) + { + + "[{0}] Displaying formatted table." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $MacTables | Sort-Object Enclosure, Interconnect, macAddress + + } + + elseif ($PSBoundParameters['Export']) + { + + "[{0}] Exporting to CSV file: $Export" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $MacTables | Sort-Object Enclosure, Interconnect, macAddress | Export-CSV $Export -NoTypeInformation + + } + + else + { + + "[{0}] Displaying results." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $MacTables | Sort-Object Enclosure, Interconnect, macAddress + + } + + "[{0}] Done. {1} mac table entry(ies) found." -f $MyInvocation.InvocationName.ToString().ToUpper(), $MacTables.Count | Write-Verbose + + } + +} + +function Download-MacTable +{ + + <# + .SYNOPSIS + Download Logical Interconnect MAC Table CSV. + + .DESCRIPTION + This internal helper function will download the MAC Table CSV from a provided Logical Interconnect, parse it and return an array of MAC Table entries. + + .Parameter Uri + [System.String] URI of Logical Interconnect. + + .Parameter Hostname + [System.String] Hostname of Appliance + + .INPUTS + None. + + .OUTPUTS + System.Array + Array of MAC Table entries. + + .LINK + Get-OVLogicalInterconnect + + .EXAMPLE + PS C:\> $encl1li = Get-OVLogicalInterconnect Encl1-LI + PS C:\> Download-MACTable $encl1li + + Get the Logical Interconnect 'Encl1-LI' and + + #> + + [CmdletBinding ()] + Param + ( + + [Parameter (Mandatory)] + [ValidateNotNullOrEmpty()] + [ValidateScript( { if ($_.type -eq 'interconnect-fib-data-info') + { + $true + } + else + { + throw "-URI must being with a '/rest/logical-interconnects/' in its value. Please correct the value and try again." + } })] + [Object]$InputObject + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + $enc = [System.Text.Encoding]::UTF8 + + } + + Process + { + + "[{0}] Download URI: $($InputObject.uri)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + [System.Net.httpWebRequest]$fileDownload = RestClient GET $InputObject.uri $InputObject.ApplianceConnection.Name + + $fileDownload.accept = "application/zip,application/octet-stream,*/*" + $fileDownload.Headers.Item("auth") = ($ConnectedSessions | Where-Object Name -eq $InputObject.ApplianceConnection.Name).SessionID + + $i = 0 + foreach ($h in $fileDownload.Headers) + { + + "[{0}] Request Header $($i): $($h) = $($fileDownload.Headers[$i])" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $i++ + + } + + Try + { + + "[{0}] Request: GET {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $fileDownload.RequestUri.AbsolutePath | Write-Verbose + + # Get response + "[{0}] Getting response" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + [Net.httpWebResponse]$rs = $fileDownload.GetResponse() + + # Display the response status if verbose output is requested + "[{0}] Response Status: $([Int]$rs.StatusCode) $($rs.StatusDescription)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $i = 0 + foreach ($h in $rs.Headers) + { + + "[{0}] Response Header $($i): $($h) = $($rs.Headers[$i])" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $i++ + + } + + # Request is a redirect to download file contained in the response headers + $fileName = ($rs.headers["Content-Disposition"].SubString(21)) -replace '"', $null + + "[{0}] Filename: $($fileName)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + "[{0}] Filesize: $($rs.ContentLength)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $responseStream = $rs.GetResponseStream() + + # Define buffer and buffer size + [Int] $bufferSize = ($rs.ContentLength*1024) + [byte[]]$Buffer = [byte[]]::new($rs.ContentLength*1024) + [Int] $bytesRead = 0 + + # This is used to keep track of the file upload progress. + $totalBytesToRead = $rs.ContentLength + $numBytesRead = 0 + $numBytesWrote = 0 + + # Read from stream + "[{0}] Reading and decompressing HttpWebRequest file stream." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $gzipstream = [IO.Compression.GZipStream]::new($responseStream, [IO.Compression.CompressionMode]::Decompress) + + $memoryStream = [System.IO.MemoryStream]::new() + + $buffer = [byte[]]::new(1024) + + $count = 0 + + do + { + + $count = $gzipstream.Read($buffer, 0, 1024) + + if ($count -gt 0) + { + + $memoryStream.Write($buffer, 0, $count) + + } + + } While ($count -gt 0) + + $array = $memoryStream.ToArray() + $GZipStream.Close() + $memoryStream.Close() + $responseStream.Close() + $sb = [System.Text.Encoding]::UTF8.GetString($array).Split("`n") + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + Finally + { + + # Clean up our work + if ($responseStream) + { + $responseStream.Close() + } + if ($rs) + { + $rs.Close() + } + if ($sr) + { + $sr.Close(); $sr.Dispose() + } + + } + + } + + End + { + + "[{0}] Building string array in CSV format" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + # $macTableArray = $sb.ToString() -split "`n" + $header = "enclosure", "interconnect", "interface", "address", "type", "network", "extVLAN", "intVLAN", "serverProfile", "uplinkSet", "LAGPort1", "LAGPort2", "LAGPort3", "LAGPort4", "LAG Port5", "LAG Port6", "LAG Port7", "LAG Port8" + $sb = $sb[1..($sb.count)] + + $e = @{Expression = { + + $lagport = $_ + 1..8 | ForEach-Object { if ($lagport."LAGPort$($_)") + { + $lagport."LAGPort$($_)" + } } + + }; name = "LAGPorts" + } + + $macTable = $sb | ConvertFrom-Csv -Header $header | Select-Object "enclosure", "interconnect", "interface", "address", "type", "network", "extVLAN", "intVLAN", "serverProfile", "uplinkSet", $e + + "[{0}] Returning results." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Return $macTable + + } + +} + +function Install-OVLogicalInterconnectFirmware +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "default", SupportsShouldProcess, ConfirmImpact = 'High')] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = "default")] + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = "SasModule")] + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = "Manual")] + [Alias ('LogicalInterconnect', 'name','uri', 'li')] + [ValidateNotNullorEmpty()] + [object]$InputObject, + + [Parameter (Mandatory = $false, ParameterSetName = "default")] + [Parameter (Mandatory = $false, ParameterSetName = "SasModule")] + [Parameter (Mandatory = $false, ParameterSetName = "Manual")] + [ValidateSet ('Update', 'Activate', 'Stage')] + [String]$Method = "Update", + + [Parameter (Mandatory = $false, ParameterSetName = "SasModule")] + [ValidateSet ('Orchestrated', 'Parallel')] + [String]$SasActivationMethod = 'Orchestrated', + + [Parameter (Mandatory = $false, ParameterSetName = "default")] + [Parameter (Mandatory = $false, ParameterSetName = "Manual")] + [ValidateSet ('Orchestrated', 'OddEven', 'Parallel', 'Serial', 'Manual')] + [Alias ('Order','ActivateOrder')] + [String]$EthernetActivateOrder = 'OddEven', + + [Parameter (Mandatory = $false, ParameterSetName = "default")] + [ValidateNotNullorEmpty()] + [Int]$EthernetActivateDelay = 5, + + [Parameter (Mandatory = $false, ParameterSetName = "default")] + [ValidateSet ('Orchestrated', 'OddEven', 'Parallel', 'Serial')] + [String]$FCActivateOrder = 'Serial', + + [Parameter (Mandatory = $false, ParameterSetName = "default")] + [ValidateNotNullorEmpty()] + [Int]$FCActivateDelay = 5, + + [Parameter (Mandatory, ParameterSetName = "Manual")] + [ValidateSet ('Bay3', 'Bay6', 'Bay1', 'Bay5', 'Bay2', 'Bay4')] + [String]$ManualOrder, + + [Parameter (Mandatory = $false, ParameterSetName = "default")] + [Parameter (Mandatory = $false, ParameterSetName = "SasModule")] + [Parameter (Mandatory = $false, ParameterSetName = "Manual")] + [Alias ('spp')] + [ValidateNotNullorEmpty()] + [object]$Baseline, + + [Parameter (Mandatory = $false, ParameterSetName = "default")] + [Parameter (Mandatory = $false, ParameterSetName = "Manual")] + [Switch]$NoPreview, + + [Parameter (Mandatory = $false, ParameterSetName = "default")] + [Parameter (Mandatory = $false, ParameterSetName = "SasModule")] + [Parameter (Mandatory = $false, ParameterSetName = "Manual")] + [Switch]$Async, + + [Parameter (Mandatory = $false, ParameterSetName = "default")] + [Parameter (Mandatory = $false, ParameterSetName = "SasModule")] + [Parameter (Mandatory = $false, ParameterSetName = "Manual")] + [Switch]$Force, + + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = "default")] + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = "SasModule")] + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = "Manual")] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not $PSBoundParameters['InputObject']) + { + + $PipelineInput = $True + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + if ($EthernetActivateOrder -eq 'Manual' -or $FCActivateOrder -eq 'Manual' -and -not $PSBoundParameters['ManualOrder']) + { + + $ParameterException = if ($PSBoundParameters['EthernetActivateOrder']) { 'EthernetActivateOrder' } elseif ($PSBoundParameters['FCActivateOrder']) { 'FCActivateOrder' } + + $ExceptionMessage = "When specifying a manual activation order, you must specify a bay value with the -ManualOrder parameter." + $ErrorRecord = New-ErrorRecord HPEOneView.Library.ParameterValidationException InvalidActivateOrderParameter InvalidOperation $ParameterException -Message $ExceptionMessage + + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + Process + { + + $Staging = $False + $Activating = $False + $IsSasLogicalInterconnect = $false + + if ($Method -ne "Activate" -and -not $PSBoundParameters['Baseline']) + { + + $ExceptionMessage = "The Baseline parameter is required when Method is set to Update or Stage." + $ErrorRecord = New-ErrorRecord HPEOneView.Library.ParameterValidationException NoBaselineParameter InvalidOperation 'Method' -Message $ExceptionMessage + + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + # Validate the InputObject value to ensure it is the correct and supports object type + if ($PipelineInput -or $InputObject -is [PSCustomObject]) + { + + # Validate Logical Interconnect Object Type + if (-not($InputObject -is [PSCustomObject]) -and ($ResourceCategoryEnum.LogicalInterconnect, $ResourceCategoryEnum.SasLogicalInterconnect -notcontains $InputObject.category)) + { + + "[{0}] invalid LogicalInterconnect passed: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject | Write-Verbose + + $ExceptionMessage = "The 'InputObject' Parameter value '{0}' is invalid object. Please check the Parameter value and try again." -f $InputObject.name + $ErrorRecord = New-ErrorRecord InvalidOperationException InvalidArgumentValue InvalidArgument 'InputObject' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + $_LogicalInterconnect = $InputObject.PSObject.Copy() + + } + + else + { + + if ($null -eq $ApplianceConnection) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message 'No Appliance Connection was provided. Please provide a valid ApplianceConnection Object.' + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + "[{0}] Looking for Logical Interconnect '{1}' from Get-OVLogicalInterconnect." -f $MyInvocation.InvocationName.ToString().ToUpper(), $LogicalInterconnect | Write-Verbose + + Try + { + + $_LogicalInterconnect = Get-OVLogicalInterconnect -Name $InputObject -ApplianceConnection $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + # Display obselete message if the connection is a VM, not Synergy + [ObsoleteMessage]::Write($_LogicalInterconnect.ApplianceConnection) + + "[{0}] Processing '{1}' Logical Interconnect." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_LogicalInterconnect.name | Write-Verbose + + $IsSynergy = ($ConnectedSessions | Where-Object Name -eq $_LogicalInterconnect.ApplianceConnection).ApplianceType -eq 'Composer' + + # Validate the LI type + Try + { + + $_LogicalInterconnectTypes = GetIcmType -InputObject $_LogicalInterconnect | Select -Unique + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + switch ($_LogicalInterconnectTypes) + { + + {[InterconnectModuleFamilyTypeEnum]::FibreChannel, [InterconnectModuleFamilyTypeEnum]::FlexFabric -contains $_} + { + + $_Request = NewObject -LogicalInterconnectBaseline + + if ('Activate', 'Update' -contains $Method) + { + + if ($IsSynergy) + { + + $_Request.validationType = $SynergyValidationTypeEnum.$Method + + if ('Orchestrated', 'Parallel', 'Manual' -notcontains $EthernetActivateOrder) + { + + $ExceptionMessage = "The allowed activation order for HPE Synergy fabric modules are 'Orchestrated', 'Parallel', or 'Manual'. Please specify one of these values." + $ErrorRecord = New-ErrorRecord HPEOneView.Library.ParameterValidationException InvalidEthernetActivateOrderParameter InvalidOperation 'EthernetActivateOrder' -Message $ExceptionMessage + + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + if ($FCActivateOrder -eq 'Manual') + { + + $ExceptionMessage = "The allowed activation order for HPE Synergy Fibre Channel fabric modules are 'Orchestrated' or 'Parallel'. Please specify one of these values." + $ErrorRecord = New-ErrorRecord HPEOneView.Library.ParameterValidationException InvalidEthernetActivateOrderParameter InvalidOperation 'FCActivateOrder' -Message $ExceptionMessage + + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + if (-not $PSBoundParameters['FCActivateOrder']) + { + + $FCActivateOrder = "Orchestrated" + + } + + if ($PSCmdlet.ParameterSetName -eq 'Manual') + { + + $_Request | Add-Member -NotePropertyName interconnects -NotePropertyValue @() + + ForEach ($_InterconnectToProcess in ($_LogicalInterconnect.interconnectMap.interconnectMapEntries | ? { $_.location.locationEntries.type -eq "Bay" -and $_.location.locationEntries.value -eq $ManualOrder.Substring(3,1) }) ) + { + + $_Request.interconnects += @{interconnectUri = $_InterconnectToProcess.interconnectUri} + + } + + } + + } + + else + { + + if ('OddEven', 'Parallel', 'Serial' -notcontains $EthernetActivateOrder) + { + + $ExceptionMessage = "The allowed activation order for HPE BladeSystem fabric modules are 'OddEven', 'Parallel', or 'Serial'. Please specify one of these values." + $ErrorRecord = New-ErrorRecord HPEOneView.Library.ParameterValidationException InvalidEthernetActivateOrderParameter InvalidOperation 'InputObject' -Message $ExceptionMessage + + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + $_Request.ethernetActivationType = $LogicalInterconnectActivationTypeEnum.$EthernetActivateOrder + $_Request.ethernetActivationDelay = [Int]$EthernetActivateDelay + $_Request.fcActivationType = $LogicalInterconnectActivationTypeEnum.$FCActivateOrder + $_Request.fcActivationDelay = [Int]$FCActivateDelay + + } + + # Staged process + else + { + + if ($IsSynergy) + { + + $_Request.validationType = $SynergyValidationTypeEnum.$Method + + $_Request.ethernetActivationType = $LogicalInterconnectActivationTypeEnum.Orchestrated + $_Request.fcActivationType = $LogicalInterconnectActivationTypeEnum.Orchestrated + + } + + else + { + + $_Request.ethernetActivationType = $LogicalInterconnectActivationTypeEnum.OddEven + $_Request.fcActivationType = $LogicalInterconnectActivationTypeEnum.OddEven + + } + + } + + break + + } + + {[InterconnectModuleFamilyTypeEnum]::SAS -contains $_} + { + + $IsSasLogicalInterconnect = $true + + $_Request = NewObject -SasLogicalInterconnectBaseline + + $_Request.validationType = $SynergyValidationTypeEnum.$Method + + if ($Method -ne 'Stage') + { + + $_Request.fwActivationMode = $SasActivationMethod + + } + + } + + } + + $_Request.command = $Method + $_Request.force = [Bool]$PSBoundParameters['Force'] + + if ($PSBoundParameters['Baseline']) + { + + "[{0}] Validating Baseline input value." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + switch ($Baseline.GetType().Name) + { + + 'String' + { + + Try + { + + "[{0}] Firmware Baseline name passed: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Baseline | Write-Verbose + + $FirmwareBaselineName = $Baseline.PSObject.Copy() + + $_BaseLinePolicy = Get-OVBaseline -Name $Baseline -ApplianceConnection $LogicalInterconnect.ApplianceConnection.Name -ErrorAction SilentlyContinue + + If (-not $_BaseLinePolicy) + { + + $ExceptionMessage = "The provided Baseline '{0}' was not found." -f $FirmwareBaselineName + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.BaselineResourceException BaselineResourceNotFound ObjectNotFound 'Baseline' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + {'Baseline', 'PSCustomObject' -contains $_} + { + + "[{0}] Firmware Baseline object passed." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + "[{0}] object name: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Baseline.name | Write-Verbose + "[{0}] object uri: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Baseline.uri | Write-Verbose + "[{0}] object appliance connection: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Baseline.ApplianceConnection | Write-Verbose + "[{0}] object category: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Baseline.category | Write-Verbose + + if ($Baseline.category -ne 'firmware-drivers') + { + + $ExceptionMessage = "The Baseline provided in an invalid object. Baseline category value '{0}', expected 'firmware-drivers'. Please check the Parameter value and try again." -f $Baseline.caetegory + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.BaselineResourceException InvalidBaselineObject InvalidArgument 'Baseline' -TargetType 'PSObject' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + $_BaseLinePolicy = $Baseline + + } + + } + + $_Request.sppUri = $_BaseLinePolicy.uri + + } + + # Generate preview of firmware installation from preview task + if (-not $PSBoundParameters['NoPreview'] -and $IsSynergy) + { + + $_PreviewRequest = $_Request.PSObject.Copy() + + $_PreviewRequest.command = "UPDATE" + $_PreviewRequest.validationType = $SynergyValidationTypeEnum.Preview + + if ([String]::IsNullOrEmpty($_PreviewRequest.sppUri)) + { + + Try + { + + $_FirmwareStatus = Send-OVRequest -Uri ($_LogicalInterconnect.uri + "/firmware") -Hostname $_LogicalInterconnect.ApplianceConnection + $_BaselinePolicy = Send-OVRequest -Uri $_FirmwareStatus.sppUri -Hostname $_LogicalInterconnect.ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $_PreviewRequest.sppUri = $_FirmwareStatus.sppUri + + } + + + Try + { + + $_uri = $_LogicalInterconnect.uri + '/firmware' + + $_PreviewResponce = Send-OVRequest -Uri $_uri -Method PUT -Body $_PreviewRequest | Wait-OVTaskComplete + + if ($_PreviewResponce.taskState -eq 'Completed') + { + + Write-Warning ($_PreviewResponce.taskStatus + ". The firmware update can be performed without any downtime or disruptions.") + + } + + elseif ($_PreviewResponce.taskState -eq 'Error') + { + + $ExceptionMessage = $_PreviewResponce.taskStatus + [String]::Join(" ", $_PreviewResponce.progressUpdates.statusUpdates) + $ErrorRecord = New-ErrorRecord HPEOneView.Library.ParameterValidationException FirmwareInstallationValidationError InvalidOperation 'InputObject' -Message $ExceptionMessage + + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + else + { + + Write-Warning ($_PreviewResponce.taskStatus + [String]::Join(" ", $_PreviewResponce.progressUpdates.statusUpdates)) + + } + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + switch ($Method) + { + + {'Update', 'Stage' -match $_} + { + + "[{0}] '{1}' Method called." -f $MyInvocation.InvocationName.ToString().ToUpper(), $Method | Write-Verbose + + $_Request.command = $Method + $Staging = $True + + } + + "Activate" + { + + $Activating = $true + + "[{0}] 'Activate' Method called." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + "[{0}] Verifying '{1}' LI is in a Staged state." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_LogicalInterconnect.name | Write-Verbose + + if ([String]::IsNullOrEmpty($_FirmwareStatus)) + { + + Try + { + + $_FirmwareStatus = Send-OVRequest -Uri ($_LogicalInterconnect.uri + "/firmware") -Hostname $_LogicalInterconnect.ApplianceConnection + $_BaselinePolicy = Send-OVRequest -Uri $_FirmwareStatus.sppUri -Hostname $_LogicalInterconnect.ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + # Validate interconnect firmware update state + switch ($_FirmwareStatus.state) + { + + 'STAGED' + { + + "[{0}] '{1}' LI is in the proper '{2}' state." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_LogicalInterconnect.name, $_FirmwareStatus.state | Write-Verbose + + #$baselineObj = [pscustomobject] @{ uri = $_FirmwareStatus.sppUri } + + $_Request.command = 'ACTIVATE' + $_Request.sppUri = $_FirmwareStatus.sppUri + + } + + 'STAGING' + { + + "[{0}] '{1}' is currently being staged with firmware. Please wait until the task completes." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_LogicalInterconnect.name | Write-Verbose + + # Locate and return running task. + $_task = Get-OVTask -State Running -resource $_LogicalInterconnect.name -ApplianceConnection $_LogicalInterconnect.ApplianceConnection + + $_task | Where-Object { $_.taskStatus.StartsWith('Staging') } | ForEach-Object { + + [void]$TaskCollection.Add($_) + + } + + # Flag to skip the command Processing IF block below + $Staging = $true + + } + + 'STAGING_FAILED' + { + + $ExceptionMessage = "The '{0}' Logical Interconnect is in an invalid state ({1}) in order to issue the Activate command." -f $_LogicalInterconnect.name, $_FirmwareStatus.state + $ErrorRecord = New-ErrorRecord InvalidOperationException InvalidLogicalInterconnectState InvalidResult 'InputObject' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + 'ACTIVATED' + { + + "[{0}] '{1}' is already activated." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_LogicalInterconnect.name | Write-Verbose + + Write-Warning ("'{0}' is already activated." -f $_LogicalInterconnect.name) + + Return + + } + + 'ACTIVATING' + { + + # Logical Interconnect is already Processing the Activate command. + "[{0}] '{1}' is already activating. Returning task resource." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_LogicalInterconnect.name | Write-Verbose + + # Flag to skip the command Processing IF block below + $activating = $True + + # Locate and return running task. + Try + { + + $_task = Get-OVTask -State Running -resource $_LogicalInterconnect.name -ApplianceConnection $_LogicalInterconnect.ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $_task | Where-Object { $_.taskStatus.StartsWith('Activating') } | ForEach-Object { + + [void]$TaskCollection.Add($_) + + } + + } + + 'ACTIVATION_FAILED' + { + + "[{0}] '{1}' failed a prior activation request. LI is in a valid state to attempt Activation command." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_LogicalInterconnect.name | Write-Verbose + + #$baselineObj = [pscustomobject] @{ uri = $_FirmwareStatus.sppUri } + + $_Request.command = 'ACTIVATE' + $_Request.sppUri = $_FirmwareStatus.sppUri + + } + + 'PARTIALLY_ACTIVATED' + { + + "[{0}] '{1}' is Partially Activated. LI is in a valid state to attempt Activation command." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_LogicalInterconnect.name | Write-Verbose + $baselineObj = [pscustomobject] @{ uri = $_FirmwareStatus.sppUri } + + } + + 'PARTIALLY_STAGED' + { + + $ExceptionMessage = "The '{0}' Logical Interconnect is in an invalid state ({1}) in order to issue the Activate command." -f $_LogicalInterconnect.name, $_FirmwareStatus.state + $ErrorRecord = New-ErrorRecord InvalidOperationException InvalidLogicalInterconnectState InvalidResult 'InputObject' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + 'UNINITIALIZED' + { + + <# Generate Error that firmware has not been staged #> + $ExceptionMssage = "No staged firmware found for '{0}' Logical Interconnect. Use Install-OVLogicalInterconnectFirmware -Method Stage to first stage the firmware before attempting to Activate." -f $_LogicalInterconnect.name + $ErrorRecord = New-ErrorRecord InvalidOperationException NoStagedFirmwareFound ObjectNotFound 'InputObject' -Message $ExceptionMssage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + } + + } + + # Not supported with SAS modules + if (-not $IsSasLogicalInterconnect -and $PSCmdlet.ParameterSetName -ne 'Manual') + { + + "[{0}] Getting firmware installation estimage from appliance." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_FirmwareInstallationEstimate = [System.Collections.ArrayList]::new() + + Try + { + + $_uri = $_LogicalInterconnect.uri + "/firmware-update-estimate" + + $_FirmwareInstallationEstimateResp = Send-OVRequest -Uri $_uri -Method POST -Body $_Request -Hostname $_LogicalInterconnect.ApplianceConnection + + ForEach ($_IcmUri in $_LogicalInterconnect.interconnects) + { + + $_Icm = Send-OVRequest -Uri $_IcmUri -Hostname $_LogicalInterconnect.ApplianceConnection + + switch ($_LogicalInterconnect.enclosureType) + { + + 'C7000' + { + + $_ComponentType = 'vceth' + + } + + default + { + + switch ($_Icm.model) + { + + 'Virtual Connect SE 100Gb F32 Module for Synergy' + { + + $_ComponentType = 'icmvc100gbf32' + + } + + 'Virtual Connect SE 40Gb F8 Module for Synergy' + { + + $_ComponentType = 'icmvc40gbf8' + + } + + 'Virtual Connect SE 16Gb FC Module for Synergy' + { + + $_ComponentType = 'icmvc16gbfc' + + } + + 'Virtual Connect SE 32Gb FC Module for Synergy' + { + + $_ComponentType = 'icmvc32gbfc' + + } + + 'Synergy 50Gb Interconnect Link Module' + { + + $_ComponentType = 'icmslm' + + } + + {'Synergy 10Gb Interconnect Link Module', 'Synergy 20Gb Interconnect Link Module' -contains $_} + { + + $_ComponentType = 'icmlm' + + } + + 'Synergy 10Gb Pass-Thru Module' + { + + $_ComponentType = 'icmpt' + + } + + 'Synergy 12Gb SAS Connection Module' + { + + $_ComponentType = '12G SAS Conn Mod' + + } + + default + { + + Throw ("{0} module not implemented." -f $_Icm.model) + + } + + } + + } + + } + + $_BaselineVersions = $_BaselinePolicy.fwComponents | Where-Object { $_.KeyNameList -contains $_ComponentType -or $_.swKeyNameList -contains $_ComponentType } + + $_BaselineVer = GetNewestVersion -Collection $_BaselineVersions + + $_FirmwareInstallationIcmEstimate = [PSCustomObject]@{ + ModuleName = $_Icm.name; + InstalledVersion = $_Icm.firmwareVersion; + UpdateVersion = $_BaselineVer; + EstimateTotalTime = (New-TimeSpan -Minutes $_FirmwareInstallationEstimateResp.totalestimatedtime) + } + + [void]$_FirmwareInstallationEstimate.Add($_FirmwareInstallationIcmEstimate) + + } + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $_FirmwareInstallationEstimate | Out-Host + + } + + # This variable is used for both the Activate and Stage operations below + $_uri = $_LogicalInterconnect.uri + "/firmware" + + # Need to prompt user to update or activate firmware, which could cause an outage. + if ('Update', 'Activate' -contains $Method -and -not $Staging) + { + + if ($EthernetActivateOrder -eq "Parallel" -or $FCActivateOrder -eq 'Parallel' -or $SasActivationMethod -eq 'Parallel') + { + + Write-Warning ('Module activation may cause a network or storage connectivity outage with the Activation Order "{0}".' -f $Method) + + } + + if ($PSCmdlet.ShouldProcess($_LogicalInterconnect.name, 'update logical interconnect firmware')) + { + + "[{0}] User was prompted warning and accepted. Sending request." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $_taskResults = Send-OVRequest -method PUT -uri $_uri -Body $_Request -Hostname $_LogicalInterconnect.ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + else + { + + "[{0}] User was prompted and selected No, will not update '{1}'" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_LogicalInterconnect.name | Write-Verbose + + } + + } + + # User is staging firmware, no need to prompt. + elseif ($Method -eq "Stage") + { + + "[{0}] Beginning to stage firmware to '{1}'." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_LogicalInterconnect.name | Write-Verbose + + Try + { + + $_taskResults = Send-OVRequest -method PUT -uri $_uri -Body $_Request -Hostname $_LogicalInterconnect.ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + if (-not($PSBoundParameters['Async']) -and $_taskResults) + { + + Try + { + + $_taskResults = Wait-OVTaskComplete $_taskResults -ApplianceConnection $_taskResults.ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $_taskResults + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Show-OVPortStatistics +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "InterconnectPort")] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = "Pipeline")] + [Parameter (Mandatory = $false, ParameterSetName = "InterconnectPort")] + [object]$Port, + + [Parameter (Mandatory, ParameterSetName = "InterconnectPort")] + [object]$Interconnect, + + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = "Pipeline")] + [Parameter (Mandatory = $false, ParameterSetName = "InterconnectPort")] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if ($PSCmdlet.ParameterSetName -eq 'Pipeline') + { + + "[{0}] Port object provided by pipeline." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $PipelineInput = $True + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + $_PortStatsCol = [System.Collections.ArrayList]::new() + + } + + Process + { + + Switch ($PSCmdlet.ParameterSetName) + { + + "Pipeline" + { + + switch ($Port.GetType().Name) + { + + # Do not support String Port values via pipeline, so generate error + "String" + { + + $ErrorRecord = New-ErrorRecord HPEOneView.InterconnectPortResourceException InvalidInterconnectPortParameter InvalidArgument 'Port' -Message "The -Port Parameter only supports Objects via the pipeline. Please refer to the CMDLET help for proper pipeline syntax." + + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + "PSCustomObject" + { + + "[{0}] Port Object provided: {1} ({2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Port.name, $Port.uri | Write-Verbose + + # Validate the Port Object is type Port + if ($Port.category -ne "ports") + { + + $ErrorRecord = New-ErrorRecord HPEOneView.InterconnectPortResourceException InvalidInterconnectPortObject InvalidArgument 'Port' -TargetType "PSObject" -Message ("The object for the -Port Parameter is the wrong type: {0}. Expected category 'ports'. Please check the object provided and try again." -f $Port.category ) + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Try + { + + "[{0}] Getting Interconnect resource from Port Object." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_InterconnectUri = $Port.uri.SubString(0,$Port.uri.IndexOf('/ports/' + $Port.portId)) + + $Interconnect = Send-OVRequest $_InterconnectUri -ApplianceConnection $Port.ApplianceConnection.Name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + } + + "InterconnectPort" + { + + switch ($Interconnect.GetType().Name) + { + + "String" + { + + + "[{0}] Getting Interconnect object '$Interconnect'" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $Interconnect = Get-OVInterconnect $Interconnect -ApplianceConnection $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + "PSCustomObject" + { + + "[{0}] Interconnect Object provided: {1} ({2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Interconnect.name, $Interconnect.uri | Write-Verbose + + # Validate the Port Object is type Port + if ($Interconnect.category -ne 'interconnects') + { + + $ErrorRecord = New-ErrorRecord HPEOneView.InterconnectPortResourceException InvalidInterconnectPortObject InvalidArgument 'Interconnect' -TargetType "PSObject" -Message ("The object for -Interconnect Parameter is the wrong resource category: {0}. Expected type 'interconnects'. Please check the object provided and try again." -f $Interconnect.category) + + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + } + + if ($PSBoundParameters['Port']) + { + + if ($Port -is [String]) + { + + "[$($MyInvocation.InvocationName.ToString().ToUpper())] Filtering for '{0}' within '{1}' Interconnect." -f $Port, $Interconnect.name | Write-Verbose + + $_originalport = $Port + + $Port = $Interconnect.ports | Where-Object portName -like $Port + + if (-not($Port)) + { + + $ErrorRecord = New-ErrorRecord HPEOneView.InterconnectPortResourceException InvalidInterconnectPort InvalidArgument 'Port' -Message ("The the port '{0}' was not found within '{1}'. Available ports within the interconnect are '{2}' Please check the port value and try again." -f $_originalport, $Interconnect.name, ($interconnect.ports.portName -join ",") ) + + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + elseif ($Port -is [PSCustomObject]) + { + + $_originalport = $Port.PSObject.Copy() + + "[$($MyInvocation.InvocationName.ToString().ToUpper())] Filtering for '{0}' within '{1}' Interconnect." -f $Port.name, $Interconnect.name | Write-Verbose + + $Port = $Interconnect.ports | Where-Object portName -like $Port.name + + if (-not($Port)) + { + + $ErrorRecord = New-ErrorRecord HPEOneView.InterconnectPortResourceException InvalidInterconnectPort InvalidArgument 'Port' -TargetType 'PSObject' -Message ("The the port '{0}' was not found within '{1}'. Available ports within the interconnect are '{2}' Please check the port value and try again." -f $_originalport.name, $Interconnect.name, ($interconnect.ports.portName -join ",") ) + + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + } + + } + + } + + # Display obselete message if the connection is a VM, not Synergy + [ObsoleteMessage]::Write($Interconnect.ApplianceConnection) + + Try + { + + $_InterconnectStats = Send-OVRequest ($Interconnect.uri + "/statistics") -ApplianceConnection $ApplianceConnection.Name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $_InterconnectStats | ForEach-Object { $_.PSObject.TypeNames.Insert(0,"HPEOneView.Networking.InterconnectStatistics") } + + if ($Port) + { + + $_InterconnectStats.portStatistics = $_InterconnectStats.portStatistics | Where-Object { $port.portName -contains $_.portName } + + } + + # Set the specific TypeNames value for Formats to handle + foreach ($_PortObj in $Interconnect.ports) + { + + switch ($_PortObj.configPortTypes) + { + + {@("EnetFcoe","Ethernet") -match $_ } + { + + $TypeName = "HPEOneView.Networking.PortStatistics.Ethernet" + $SubTypeName = "Ethernet" + Break + + } + + "FibreChannel" + { + + $TypeName = "HPEOneView.Networking.PortStatistics.FibreChannel" + $SubTypeName = "FibreChannel" + Break + + } + + } + + "[$($MyInvocation.InvocationName.ToString().ToUpper())] inserting '{0}' into '{1}' [{2}]" -f $TypeName, $_PortObj.name, ($_PortObj.configPortTypes -join ",") | Write-Verbose + + ($_InterconnectStats.portStatistics | Where-Object portName -eq $_PortObj.portName ).PSObject.TypeNames.Insert(0,$TypeName) + ($_InterconnectStats.portStatistics | Where-Object portName -eq $_PortObj.portName ) | Add-Member -NotePropertyName portConfigType -NotePropertyValue $SubTypeName -force + } + + # Insert sampleInterval from the Interconnect itself. Otherwise, portStatistics doesn't contain the interval. + $_InterconnectStats.portStatistics | ForEach-Object { Add-Member -InputObject $_ -NotePropertyName sampleInterval -NotePropertyValue $_InterconnectStats.moduleStatistics.portTelemetryPeriod -force } + + $_InterconnectStats.portStatistics | sort-Object portConfigType,portName | ForEach-Object { + + [void]$_PortStatsCol.Add($_) + + } + + } + + End + { + + Return $_PortStatsCol + + } + +} + +function Reset-OVInterconnectNetOpPassword +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = 'Default')] + Param + ( + + [Parameter (ValueFromPipeline, Mandatory, ParameterSetName = 'Default')] + [Alias('Interconnect')] + [ValidateNotNullorEmpty()] + [Object]$InputObject, + + [Parameter (Mandatory, ParameterSetName = 'Default')] + [ValidateNotNullorEmpty()] + [SecureString]$Password, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullorEmpty()] + [Switch]$Async, + + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = 'Default')] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if ($PSCmdlet.ParameterSetName -eq 'Pipeline') + { + + $PipelineInput = $True + + } + + Else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + } + + Process + { + + # Validate the resource is supported + if ($SynergyVCEthModulePartNumbers -NotContains $InputObject.partnumber) + { + + $Message = 'The provided interconnect resource is not a supported resource for this Cmdlet. Only HPE Synergy Ethernet Virtual Connect fabric modules are.' + $ErrorRecord = New-ErrorRecord HPEOneView.Networking.InterconnectResourceException UnsupportedResource InvalidOperation 'InputObject' -Message $Message + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + $_PatchOp = NewObject -PatchOperation + $_PatchOp.op = 'replace' + $_PatchOp.path = '/netOpPasswd' + $_PatchOp.value = [Runtime.InteropServices.Marshal]::PtrToStringBSTR([Runtime.InteropServices.Marshal]::SecureStringToBSTR($Password)) + + Try + { + + $_Resp = Send-OVRequest -Uri $InputObject.uri -Method PATCH -Body $_PatchOp -ApplianceConnection $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if (-not $PSBoundParameters['Async']) + { + + $_Resp = $_Resp | Wait-OVTaskComplete + + } + + $_Resp + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Get-OVLogicalInterconnectGroup +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = 'Default')] + Param + ( + + [Parameter (ValueFromPipeline, Mandatory, ParameterSetName = 'Pipeline')] + [Alias('Resource')] + [ValidateNotNullorEmpty()] + [Object]$InputObject, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullorEmpty()] + [String]$Name, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateSet ('SAS','VC')] + [String]$Type, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [ValidateNotNullOrEmpty()] + [Object]$Scope = "AllResourcesInScope", + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [ValidateNotNullOrEmpty()] + [String]$Label, + + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = 'Pipeline')] + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default), + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [Alias ("x", "export")] + [ValidateScript({split-path $_ | Test-Path})] + [String]$exportFile + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if ($PSCmdlet.ParameterSetName -eq 'Pipeline') + { + + $PipelineInput = $True + + } + + Else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + $LigCollection = [System.Collections.ArrayList]::new() + + } + + Process + { + + if ($PipelineInput -or $InputObject -is [PSCustomObject]) + { + + # Display obselete message if the connection is a VM, not Synergy + [ObsoleteMessage]::Write($InputObject.ApplianceConnection) + + # Task Resource Object + if ($InputObject.category -eq $ResourceCategoryEnum.Task) + { + + "[{0}] Task Resource input object." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if ($InputObject.taskState -eq 'Completed') + { + + Try + { + + $_LigObject = Send-OVRequest $InputObject.associatedResource.resourceUri -Hostname $InputObject.ApplianceConnection.Name + + $_LigObject | ForEach-Object { + + $_.PSObject.TypeNames.Insert(0,'HPEOneView.Networking.LogicalInterconnectGroup') + + [void]$LigCollection.Add($_) + + } + + } + + Catch + { + + "[{0}] API Error Caught: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_.Exception.Message | Write-Verbose + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + # Generate error + else + { + + $InputObject + + $ErrorRecord = New-ErrorRecord HPEOneView.LogicalInterconnectGroupResourceException TaskFailure InvalidOperation 'InputObject' -Message "The Task object provided by the pipeline did not complete successfully. Please validate the task object resource and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + elseif ($InputObject.category -eq $ResourceCategoryEnum.LogicalInterconnect) + { + + Try + { + + $_LigObject = Send-OVRequest $InputObject.logicalInterconnectGroupUri -Hostname $InputObject.ApplianceConnection + + $_LigObject | ForEach-Object { + + $_.PSObject.TypeNames.Insert(0,'HPEOneView.Networking.LogicalInterconnectGroup') + + [void]$LigCollection.Add($_) + + } + + } + + Catch + { + + "[{0}] API Error Caught: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_.Exception.Message | Write-Verbose + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + else + { + + $ExceptionMessage = "The Logical Interconnect Group associated with the pipeline input task object was not found on '{0}'. Please check the value and try again." -f $InputObject.ApplianceConnection + $ErrorRecord = New-ErrorRecord HPEOneView.LogicalInterconnectGroupResourceException LogicalInterconnectGroupNotFound ObjectNotFound 'InputObject' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + Else + { + + ForEach ($_appliance in $ApplianceConnection) + { + + # Display obselete message if the connection is a VM, not Synergy + [ObsoleteMessage]::Write($_appliance) + + "[{0}] Processing appliance {1} (of {2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name, $ApplianceConnection.Count | Write-Verbose + + $_Query = [System.Collections.ArrayList]::new() + + # Handle default cause of AllResourcesInScope + if ($Scope -eq 'AllResourcesInScope') + { + + "[{0}] Processing AllResourcesInScope." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_Scopes = $ApplianceConnection.ActivePermissions | Where-Object Active + + # If one scope contains 'AllResources' ScopeName "tag", then all resources should be returned regardless. + if ($_Scopes | Where-Object ScopeName -eq 'AllResources') + { + + $_ScopeNames = [String]::Join(', ', ($_Scopes | Where-Object ScopeName -eq 'AllResources').ScopeName) + + "[{0}] Scope(s) {1} is set to 'AllResources'. Will not add scope to URI query parameter." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_ScopeNames | Write-Verbose + + } + + # Process ApplianceConnection ActivePermissions collection + else + { + + Try + { + + $_ScopeQuery = Join-Scope $_Scopes + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + [Void]$_Query.Add(("({0})" -f $_ScopeQuery)) + + } + + } + + elseif ($Scope | Where-Object ScopeName -eq 'AllResources') + { + + $_ScopeNames = [String]::Join(', ', ($_Scopes | Where-Object ScopeName -eq 'AllResources').ScopeName) + + "[{0}] Scope(s) {1} is set to 'AllResources'. Will not add scope to URI query parameter." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_ScopeNames | Write-Verbose + + } + + elseif ($Scope -eq 'AllResources') + { + + "[{0}] Requesting scope 'AllResources'. Will not add scope to URI query parameter." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_ScopeNames | Write-Verbose + + } + + else + { + + Try + { + + $_ScopeQuery = Join-Scope $Scope + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + [Void]$_Query.Add(("({0})" -f $_ScopeQuery)) + + } + + if ($Name) + { + + if ($Name.Contains('*')) + { + + [Void]$_Query.Add(("name%3A{0}" -f $Name.Replace("*", "%2A").Replace(',','%2C').Replace(" ", "?"))) + + } + + else + { + + [Void]$_Query.Add(("name:'{0}'" -f $Name)) + + } + + } + + if ($Label) + { + + [Void]$_Query.Add(("labels:'{0}'" -f $Label)) + + } + + if (-not $PSBoundParameters['Type'] -and $_appliance.ApplianceType -ne 'Composer') + { + + $_Category = 'category=logical-interconnect-groups' + + } + + elseif (-not $PSBoundParameters['Type'] -and $_appliance.ApplianceType -eq 'Composer') + { + + $_Category = 'category=logical-interconnect-groups&category=sas-logical-interconnect-groups' + + } + + else + { + + $_Category = @() + + switch ($Type) + { + + 'VC' + { + + $_Category += 'category=logical-interconnect-groups' + + } + + 'SAS' + { + + $_Category += 'category=sas-logical-interconnect-groups' + + } + + } + + } + + # Build the final URI + $_uri = '{0}?{1}&sort=name:asc&query={2}' -f $IndexUri, [String]::Join('&', $_Category), [String]::Join(' AND ', $_Query.ToArray()) + + Try + { + + [Array]$_ResourcesFromIndexCol = Get-AllIndexResources -Uri $_uri -ApplianceConnection $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + # Generate non-terminating exception if the name wasn't found + if ($_ResourcesFromIndexCol.count -eq 0 -and $Name) + { + + "[{0}] Logical Interconnect Group '$name' resource not found. Generating error" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $ExceptionMessage = "Specified Logical Interconnect Group '{0}' was not found on '{1}' appliance connection. Please check the name and try again." -f $Name, $_appliance.Name + $ErrorRecord = New-ErrorRecord InvalidOperationException LogicalInterconnectGroupNotFound ObjectNotFound 'Name' -Message $ExceptionMessage + $PSCmdlet.WriteError($ErrorRecord) + + } + + ForEach ($_member in $_ResourcesFromIndexCol) + { + + "[{0}] Processing '{1}' resource (of {2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_member.Name, $_ResourcesFromIndexCol.Count | Write-Verbose + + switch ($_member.category) + { + + 'logical-interconnect-groups' + { + + $_member.PSObject.TypeNames.Insert(0,'HPEOneView.Networking.LogicalInterconnectGroup') + + [void]$LigCollection.Add($_member) + + } + + 'sas-logical-interconnect-groups' + { + + $_member.PSObject.TypeNames.Insert(0,'HPEOneView.Networking.SASLogicalInterconnectGroup') + + [void]$LigCollection.Add($_member) + + } + + } + + } + + } + + } + + } + + End + { + + "[{0}] Done. {1} logical interconnect group(s) found." -f $MyInvocation.InvocationName.ToString().ToUpper(), $LigCollection.count | Write-Verbose + + if ($exportFile) + { + + $LigCollection | convertto-json -Depth 99 | Set-Content -Path $exportFile -force -encoding UTF8 + + } + + else + { + + Return $LigCollection | Sort-Object category,name + + } + + } + +} + +function New-OVLogicalInterconnectGroup +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "C7000")] + Param + ( + + [Parameter (Mandatory, ParameterSetName = "C7000")] + [Parameter (Mandatory, ParameterSetName = "Synergy")] + [ValidateNotNullOrEmpty()] + [Alias ('ligname')] + [String]$Name, + + [Parameter (Mandatory, ParameterSetName = "Synergy")] + [ValidateRange(1,5)] + [Int]$FrameCount = 1, + + [Parameter (Mandatory, ParameterSetName = "Synergy")] + [ValidateRange(1,3)] + [Int]$InterconnectBaySet, + + [Parameter (Mandatory, ParameterSetName = "Synergy")] + [ValidateSet ('SEVC100F32', 'SEVC40F8', 'SEVC32FC', 'SEVC32GCFC', 'SEVCFC', 'SEVC16GbFC', 'SAS')] + [String]$FabricModuleType, + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = "C7000")] + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = "Synergy")] + [ValidateNotNullOrEmpty()] + [Hashtable]$Bays, + + [Parameter (Mandatory = $false, ParameterSetName = "C7000")] + [Parameter (Mandatory = $false, ParameterSetName = "Synergy")] + [ValidateSet('Exact', 'None')] + [String]$InterconnectConsistencyChecking, + + [Parameter (Mandatory = $False, ParameterSetName = "Synergy")] + [ValidateSet ('HighlyAvailable','Redundant','ASide','BSide')] + [String]$FabricRedundancy = 'Redundant', + + [Parameter (Mandatory = $False, ParameterSetName = "Synergy")] + [ValidateSet ('25', '50')] + [String]$DownlinkSpeedMode = "25", + + [Parameter (Mandatory = $False, ParameterSetName = "Synergy")] + [Bool]$EnableCutThroughSwitching = $false, + + [Parameter (Mandatory = $False, ParameterSetName = "Synergy")] + [Bool]$EnableStormControl = $false, + + [Parameter (Mandatory = $False, ParameterSetName = "Synergy")] + [ValidateRange(1, 262143)] + [Int]$StormControlPacketsPerSecondThreshold = 1, + + [Parameter (Mandatory = $False, ParameterSetName = "Synergy")] + [ValidateRange(5, 30)] + [Int]$StormControlPollingInterval = 10, + + [Parameter (Mandatory = $False, ParameterSetName = "Synergy")] + [Bool]$EnableDdns = $false, + + [Parameter (Mandatory = $False, ParameterSetName = "Synergy")] + [ValidateNotNullOrEmpty()] + [String]$DdnsDomainNameSuffix, + + [Parameter (Mandatory = $False, ParameterSetName = "C7000")] + [Parameter (Mandatory = $False, ParameterSetName = "Synergy")] + [Alias ("IGMPSnoop")] + [Bool]$EnableIgmpSnooping = $False, + + [Parameter (Mandatory = $False, ParameterSetName = "Synergy")] + [ValidateNotNullOrEmpty()] + [String]$IgmpVLANs = $null, + + [Parameter (Mandatory = $False, ParameterSetName = "C7000")] + [Parameter (Mandatory = $False, ParameterSetName = "Synergy")] + [ValidateRange(130,1225)] + [Alias ('IGMPIdle')] + [Int]$IgmpIdleTimeoutInterval = 260, + + [Parameter (Mandatory = $False, ParameterSetName = "Synergy")] + [Bool]$IgmpMulticastFloodPrevention, + + [Parameter (Mandatory = $False, ParameterSetName = "Synergy")] + [Bool]$IgmpProxyReporting, + + [Parameter (Mandatory = $false, ParameterSetName = "C7000")] + [Parameter (Mandatory = $false, ParameterSetName = "Synergy")] + [ValidateSet('Exact', 'Minimum', 'None')] + [String]$IgmpSnoopingConsistencyChecking, + + [Parameter (Mandatory = $False, ParameterSetName = "C7000")] + [Alias ('FastMAC')] + [Bool]$EnableFastMacCacheFailover = $True, + + [Parameter (Mandatory = $False, ParameterSetName = "C7000")] + [ValidateRange(1,30)] + [Alias ('FastMACRefresh')] + [Int]$MacRefreshInterval = 5, + + [Parameter (Mandatory = $False, ParameterSetName = "C7000")] + [Parameter (Mandatory = $False, ParameterSetName = "Synergy")] + [Alias ('LoopProtect')] + [Bool]$EnableNetworkLoopProtection = $True, + + [Parameter (Mandatory = $False, ParameterSetName = "C7000")] + [Parameter (Mandatory = $False, ParameterSetName = "Synergy")] + [Alias ('PauseProtect')] + [Bool]$EnablePauseFloodProtection = $true, + + [Parameter (Mandatory = $False, ParameterSetName = "C7000")] + [Parameter (Mandatory = $False, ParameterSetName = "Synergy")] + [Bool]$EnableLLDPTagging = $false, + + [Parameter (Mandatory = $False, ParameterSetName = "C7000")] + [Parameter (Mandatory = $False, ParameterSetName = "Synergy")] + [Bool]$EnableEnhancedLLDPTLV, + + [Parameter (Mandatory = $False, ParameterSetName = "C7000")] + [Parameter (Mandatory = $False, ParameterSetName = "Synergy")] + [ValidateSet ('IPv4','IPv6','IPv4AndIPv6')] + [String]$LldpAddressingMode, + + [Parameter (Mandatory = $False, ParameterSetName = "C7000")] + [Parameter (Mandatory = $False, ParameterSetName = "Synergy")] + [Object]$SNMP, + + [Parameter (Mandatory = $false, ParameterSetName = "C7000")] + [Parameter (Mandatory = $false, ParameterSetName = "Synergy")] + [ValidateSet('Exact', 'None')] + [String]$SNMPConsistencyChecking, + + [Parameter (Mandatory = $False, ParameterSetName = "C7000")] + [Parameter (Mandatory = $False, ParameterSetName = "Synergy")] + [Bool]$SnmpV1, + + [Parameter (Mandatory = $False, ParameterSetName = "C7000")] + [Parameter (Mandatory = $False, ParameterSetName = "Synergy")] + [Bool]$SnmpV3, + + [Parameter (Mandatory = $False, ParameterSetName = "C7000")] + [Parameter (Mandatory = $False, ParameterSetName = "Synergy")] + [ValidateNotNullOrEmpty()] + [Object]$SnmpV3User, + + [Parameter (Mandatory = $False, ParameterSetName = "C7000")] + [Parameter (Mandatory = $False, ParameterSetName = "Synergy")] + [ValidateNotNullOrEmpty()] + [Array]$InternalNetworks, + + [Parameter (Mandatory = $false, ParameterSetName = "C7000")] + [Parameter (Mandatory = $false, ParameterSetName = "Synergy")] + [ValidateSet('Exact', 'None')] + [String]$InternalNetworkConsistencyChecking, + + [Parameter (Mandatory = $False, ParameterSetName = "C7000")] + [Parameter (Mandatory = $False, ParameterSetName = "Synergy")] + [Alias ('qos','QosConfig')] + [Object]$QosConfiguration, + + [Parameter (Mandatory = $false, ParameterSetName = "C7000")] + [Parameter (Mandatory = $false, ParameterSetName = "Synergy")] + [ValidateSet('Exact', 'None')] + [String]$QoSConsistencyChecking, + + [Parameter (Mandatory = $False, ParameterSetName = "C7000")] + [Parameter (Mandatory = $False, ParameterSetName = "Synergy")] + [ValidateNotNullOrEmpty()] + [Hashtable[]]$UplinkSet, + + [Parameter (Mandatory = $False, ParameterSetName = "C7000")] + [Parameter (Mandatory = $False, ParameterSetName = "Synergy")] + [Parameter (Mandatory = $False, ParameterSetName = "Import")] + [ValidateNotNullOrEmpty()] + [HPEOneView.Appliance.ScopeCollection[]]$Scope, + + [Parameter (Mandatory = $False, ParameterSetName = "C7000")] + [Parameter (Mandatory = $False, ParameterSetName = "Synergy")] + [Parameter (Mandatory = $False, ParameterSetName = "Import")] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default), + + [Parameter (Mandatory = $False, ParameterSetName = "C7000")] + [Parameter (Mandatory = $False, ParameterSetName = "Synergy")] + [Switch]$Async, + + [Parameter (Mandatory, ParameterSetName = "Import")] + [ValidateScript({split-path $_ | Test-Path})] + [Alias ('i')] + [object]$Import + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $LigTasks = [System.Collections.ArrayList]::new() + + } + + Process + { + + ForEach ($_appliance in $ApplianceConnection) + { + + # Display obselete message if the connection is a VM, not Synergy + [ObsoleteMessage]::Write($_appliance) + + If ($Import) + { + + "[{0}] Reading input file" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + try + { + + # Open input file, join so we can validate if the JSON format is correct. + $lig = [String]::Join("", (Get-Content $import -ErrorAction Stop)) | convertfrom-json -ErrorAction Stop + + if ($PSBoundParameters['Scope']) + { + + $lig | Add-Member -NotePropertyName initialScopeUris -NotePropertyValue ([System.Collections.ArrayList]::new()) + + ForEach ($_Scope in $Scope) + { + + "[{0}] Adding resource to Scope: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_Scope.Name | Write-Verbose + + [void]$lig.initialScopeUris.Add($_Scope.Uri) + + } + + } + + "[{0}] LIG Object to Import: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), ($lig | ConvertTo-Json -depth 99 | Out-String) | Write-Verbose + + "[{0}] Sending request" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $task = Send-OVRequest $logicalInterconnectGroupsUri POST $lig -Appliance $_appliance + + [void]$LigStatus.Add($task) + + } + + # If there was a problem with the input file (format, not syntax) throw error + catch [System.ArgumentException] + { + + $ErrorRecord = New-ErrorRecord InvalidOperationException InvalidArgumentValue InvalidArgument 'Import' -TargetType "PSObject" -Message "JSON Input File is invalid. Please check the contents and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + Else + { + + switch ($PSCmdlet.ParameterSetName) + { + + 'C7000' + { + + $uri = $LogicalInterconnectGroupsUri + + # Create new LIgObject + $lig = NewObject -C7KLig + + $lig.ethernetSettings.enableFastMacCacheFailover = $EnableFastMacCacheFailover + $lig.ethernetSettings.macRefreshInterval = $MacRefreshInterval + $lig.ethernetSettings.enableNetworkLoopProtection = $EnableNetworkLoopProtection + $lig.ethernetSettings.enablePauseFloodProtection = $EnablePauseFloodProtection + $lig.ethernetSettings.enableTaggedLldp = $EnableLLDPTagging + $lig.ethernetSettings.enableRichTLV = $EnableEnhancedLLDPTLV + + if ($EnableIgmpSnooping) + { + + $lig.igmpSettings.enableIgmpSnooping = $EnableIgmpSnooping + $lig.igmpSettings.igmpIdleTimeoutInterval = $IgmpIdleTimeoutInterval + + if ($PSBoundParameters['IgmpVlans']) + { + + $lig.igmpSettings.igmpSnoopingVlanIds = $IgmpVLANs + + } + + } + + if ($PSBoundParameters['IgmpSnoopingConsistencyChecking']) + { + + $lig.igmpSettings.consistencyChecking = $IgmpSnoopingConsistencyChecking + + } + + # Fill in missing bay locations from the input value if needed. + $Secondary = @{ 1 = $null; 2 = $null; 3 = $null; 4 = $null; 5 = $null; 6 = $null; 7 = $null; 8 = $null } + + # Check for any duplicate keys + $duplicates = $Bays.keys | Where-Object { $Secondary.ContainsKey($_) } + + if ($duplicates) + { + + foreach ($item in $duplicates) + { + + $Secondary.Remove($item) + + } + + } + + #join the two hash tables + $NewBays = $Bays + $Secondary + + # Assign located Interconnect object URI to device bay mapping. + foreach ($_bay in ($NewBays.GetEnumerator() | Sort-Object Key)) + { + + $_interconnectObject = $null + + switch ($_bay.value) + { + + "FlexFabric" + { + + # Get VC FlexFabric interconnect-type URI + "[{0}] Found VC FF in bay: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_bay.name | Write-Verbose + + $_interconnectObject = Get-OVInterconnectType -partNumber "571956-B21" -Appliance $_appliance + + } + + "Flex10" + { + + # Get VC Flex-10 interconnect-type URI + "[{0}] Found VC F10 in bay: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_bay.name | Write-Verbose + + $_interconnectObject = Get-OVInterconnectType -partNumber "455880-B21" -Appliance $_appliance + + } + + "Flex1010D" + { + + # Get VC Flex-10/10D interconnect-type URI + "[{0}] Found VC F1010D in bay: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_bay.name | Write-Verbose + + $_interconnectObject = Get-OVInterconnectType -partNumber "638526-B21" -Appliance $_appliance + + } + + "Flex2040f8" + { + + # Get VC Flex-10/10D interconnect-type URI + "[{0}] Found VC Flex2040f8 in bay: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_bay.name | Write-Verbose + + $_interconnectObject = Get-OVInterconnectType -partNumber "691367-B21" -Appliance $_appliance + + } + + "VCFC20" + { + + # Get VC Flex-10/10D interconnect-type URI + "[{0}] Found VC FC 20-port in bay {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_bay.name | Write-Verbose + + $_interconnectObject = Get-OVInterconnectType -partNumber "572018-B21" -Appliance $_appliance + + } + + "VCFC24" + { + + # Get VC Flex-10/10D interconnect-type URI + "[{0}] Found VC FC 24-port in bay {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_bay.name | Write-Verbose + + $_interconnectObject = Get-OVInterconnectType -partNumber "466482-B21" -Appliance $_appliance + + } + + "VCFC16" + { + + # Get VC FC 16Gb 24-port interconnect-type URI + "[{0}] Found VC 16Gb FC 24-port in bay {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_bay.name | Write-Verbose + + $_interconnectObject = Get-OVInterconnectType -partNumber "751465-B21" -Appliance $_appliance + + } + + "FEX" + { + + # Get Cisco Fabric ExtEnder for HPE BladeSystem interconnect-type URI + "[{0}] Found Cisco Fabric ExtEnder for HPE BladeSystem in bay {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_bay.name | Write-Verbose + + $_interconnectObject = Get-OVInterconnectType -partNumber "641146-B21" -Appliance $_appliance + + } + + default + { + + $_interconnectObject = $null + + } + + } + + $_InterconnectMapEntryTemplate = NewObject -InterconnectMapEntryTemplate + + $_InterconnectMapEntryTemplate.permittedInterconnectTypeUri = $_interconnectObject.uri; + + $_LogicalLocationEntry = NewObject -LocationEntry + $_LogicalLocationEntry.relativeValue = 1 + $_LogicalLocationEntry.type = 'Enclosure' + + [void]$_InterconnectMapEntryTemplate.logicalLocation.locationEntries.Add($_LogicalLocationEntry) + + $_LogicalLocationEntry = NewObject -LocationEntry + $_LogicalLocationEntry.relativeValue = [String]$_bay.name.ToString().ToLower().Replace('bay',$null) + $_LogicalLocationEntry.type = 'Bay' + + [void]$_InterconnectMapEntryTemplate.logicalLocation.locationEntries.Add($_LogicalLocationEntry) + + [void]$lig.interconnectMapTemplate.interconnectMapEntryTemplates.Add($_InterconnectMapEntryTemplate) + + } + + } + + 'Synergy' + { + + if ((${Global:ConnectedSessions} | Where-Object Name -EQ $_appliance.Name).ApplianceType -ne 'Composer') + { + + $Message = 'The Appliance {0} is not a Synergy Composer, and this operation is not supported. Only Synergy managed resources are supported with this Cmdlet.' -f $_appliance.Name + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.ComposerNodeException UnsupportedMethod InvalidOperation 'ApplianceConnection' -TargetType 'HPEOneview.Appliance.Connection' -Message $Message + + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + switch ($FabricModuleType) + { + + {'SEVC40F8', 'SEVC100F32' -contains $_} + { + + # Used for the POST request below + $uri = $LogicalInterconnectGroupsUri + + # Create new LIgObject + $lig = NewObject -SELig + + $lig.name = $Name + $lig.redundancyType = $LogicalInterconnectGroupRedundancyEnum[$FabricRedundancy] + $lig.interconnectBaySet = $InterconnectBaySet + + # Check if 50Gb and + if ($NitroDownlinkSpeedEnum[50] -eq $NitroDownlinkSpeedEnum[$DownlinkSpeedMode] -and $FrameCount -gt 3) + { + + $Message = "The -DownlinkSpeedMode parameter value '{0}' is not allowed with more than 3 frames. Please change either the -FrameCount or -DownlinkSpeedMode" -f $DownlinkSpeedMode + $ErrorRecord = New-ErrorRecord HPEOneView.LogicalInterconnectGroupResourceException InvalidArgumentValue InvalidArgument 'DownlinkSpeedMode' -Message $Message + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($FabricModuleType -eq 'SEVC40F8' -and $PSBoundParameters['DownlinkSpeedMode']) + { + + $Message = "The -DownlinkSpeedMode parameter is only allowed for SEVC100F32 (Virtual Connect SE 100Gb F32 Module for Synergy) module types. Please remove this parameter before continuing." + $ErrorRecord = New-ErrorRecord HPEOneView.LogicalInterconnectGroupResourceException InvalidArgumentValue InvalidArgument 'DownlinkSpeedMode' -Message $Message + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + if ($EnablePauseFloodProtection -eq $true -and $EnableCutThroughSwitching -eq $true) + { + + $Message = '-EnablePauseFloodProtection and -EnableCutThroughSwitching are mutually exclusive parameters. Disable pause flood protection to enable cut-through switching or vice versa.' + $ErrorRecord = New-ErrorRecord HPEOneView.LogicalInterconnectGroupResourceException InvalidArgumentValue InvalidArgument 'DownlinkSpeedMode' -Message $Message + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + if ($FabricModuleType -eq 'SEVC40F8' -and $EnableCutThroughSwitching -eq $true) + { + + $Message = '-EnableCutThroughSwitching is only only allowed for SEVC100F32 (Virtual Connect SE 100Gb F32 Module for Synergy) module types. Please remove this parameter before continuing.' + $ErrorRecord = New-ErrorRecord HPEOneView.LogicalInterconnectGroupResourceException InvalidArgumentValue InvalidArgument 'EnableCutThroughSwitching' -Message $Message + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + $lig.downlinkSpeedMode = $NitroDownlinkSpeedEnum[$DownlinkSpeedMode] + $lig.ethernetSettings.enableFastMacCacheFailover = $EnableFastMacCacheFailover + $lig.ethernetSettings.macRefreshInterval = $MacRefreshInterval + $lig.ethernetSettings.enableNetworkLoopProtection = $EnableNetworkLoopProtection + $lig.ethernetSettings.enablePauseFloodProtection = $EnablePauseFloodProtection + $lig.ethernetSettings.enableTaggedLldp = $EnableLLDPTagging + $lig.ethernetSettings.enableRichTLV = $EnableEnhancedLLDPTLV + + if ($EnableIgmpSnooping) + { + + $lig.igmpSettings.enableIgmpSnooping = $EnableIgmpSnooping + $lig.igmpSettings.igmpIdleTimeoutInterval = $IgmpIdleTimeoutInterval + + if ($PSBoundParameters.Keys -Contains "IgmpMulticastFloodPrevention") + { + + $lig.igmpSettings.enablePreventFlooding = $IgmpMulticastFloodPrevention + + } + + if ($PSBoundParameters.Keys -Contains "IgmpProxyReporting") + { + + $lig.igmpSettings.enableProxyReporting = $IgmpProxyReporting + + } + + if ($PSBoundParameters['IgmpVlans']) + { + + "[{0}] Configuring IGMP per VLAN setting: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $IgmpVlans | Write-Verbose + + $lig.igmpSettings.igmpSnoopingVlanIds = $IgmpVLANs + + } + + } + + if ($PSBoundParameters['IgmpSnoopingConsistencyChecking']) + { + + $lig.igmpSettings.consistencyChecking = $IgmpSnoopingConsistencyChecking + + } + + if ($EnableStormControl) + { + + $lig.ethernetSettings.enableStormControl = $EnableStormControl + $lig.ethernetSettings.stormControlThreshold = $StormControlPacketsPerSecondThreshold + $lig.ethernetSettings.stormControlPollingInterval = $StormControlPollingInterval + + } + + if ($EnableDdns) + { + + $lig.ethernetSettings.enableDdns = $EnableDdns + $lig.ethernetSettings.domainName = $DdnsDomainNameSuffix + + } + + if ($EnableCutThroughSwitching) + { + + $lig.ethernetSettings.enableCutThrough = $EnableCutThroughSwitching + + } + + # This is here to make sure Frame# is present, and not just a hashtable of bays. + if ($FrameCount -ne $Bays.Count) + { + + $Message = "The -FrameCount parameter value '{0}' does not match the expected Frame and Fabric Bay configuration in the -Bays parameters, '{1}'." -f $FrameCount, $Bays.Count + $ErrorRecord = New-ErrorRecord HPEOneView.LogicalInterconnectGroupResourceException InvalidArgumentValue InvalidArgument 'InternalNetworks' -TargetType 'PSObject' -Message $Message + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + 1..$FrameCount | ForEach-Object { [void]$lig.enclosureIndexes.Add($_) } + + } + + {'SEVCFC', 'SEVC32FC' -contains $_} + { + + # Used for the POST request below + $uri = $LogicalInterconnectGroupsUri + + # Create new LIgObject + $lig = NewObject -SELig + $lig.name = $Name + $lig.redundancyType = $LogicalInterconnectGroupRedundancyEnum[$FabricRedundancy] + $lig.interconnectBaySet = $InterconnectBaySet + [void]$lig.enclosureIndexes.Add('-1') + $EnclosureIndex = '-1' + + # Validate BaySet + if ($InterconnectBaySet -eq 3) + { + + $Message = "The -InterconnectBaySet parameter value '{0}' is not supported. Please choose InterconnectBaySet 1 or 2." -f $InterconnectBaySet + $ErrorRecord = New-ErrorRecord HPEOneView.LogicalInterconnectGroupResourceException InvalidArgumentValue InvalidArgument 'InterconnectBaySet' -TargetType 'Int' -Message $Message + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + 'SAS' + { + + # Used for the POST request below + $uri = $SasLogicalInterconnectGroupsUri + + # Create new LIgObject + $lig = NewObject -SESASLIG + $lig.name = $Name + + } + + } + + ForEach ($_Entry in ($Bays.GetEnumerator() | Sort-Object Key)) + { + + if ([RegEx]::Match($_Entry.Name, 'frame', $RegExInsensitiveFlag).Success) + { + + if ($EnclosureIndex = '-1' -and ('SEVC32FC', 'SEVCFC' -contains $FabricModuleType)) + { + + [Int]$_FrameID = -1 + + } + + else + { + + [Int]$_FrameID = $_Entry.Name.ToLower().Replace("frame",$null) + + } + + + "[{0}] Processing Frame ID: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_FrameID | Write-Verbose + + ForEach ($_Bay in ($_Entry.Value).GetEnumerator()) + { + + [Int]$_BayID = $_Bay.Name.ToString().ToLower().Replace('bay',$null) + + "[{0}] Getting Fabric Module for Bay {1} to {2}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_BayID, $_Bay.Value | Write-Verbose + + $_InterconnectBayObject = $null + + Try + { + + $_InterconnectBayObject = Get-InterconnectBayObject $_Bay $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + "[{0}] Setting Fabric Module Bay {1} to {2}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_BayID, $_InterconnectBayObject.name | Write-Verbose + + $_InterconnectMapEntryTemplate = NewObject -InterconnectMapEntryTemplate + + $_InterconnectMapEntryTemplate.permittedInterconnectTypeUri = $_InterconnectBayObject.uri + $_InterconnectMapEntryTemplate.enclosureIndex = $_FrameID + + $_LogicalLocationEntry = NewObject -LocationEntry + $_LogicalLocationEntry.relativeValue = $_FrameID + $_LogicalLocationEntry.type = 'Enclosure' + + [void]$_InterconnectMapEntryTemplate.logicalLocation.locationEntries.Add($_LogicalLocationEntry) + + $_LogicalLocationEntry = NewObject -LocationEntry + $_LogicalLocationEntry.relativeValue = $_BayID + $_LogicalLocationEntry.type = 'Bay' + + [void]$_InterconnectMapEntryTemplate.logicalLocation.locationEntries.Add($_LogicalLocationEntry) + + [void]$lig.interconnectMapTemplate.interconnectMapEntryTemplates.Add($_InterconnectMapEntryTemplate) + + } + + } + + else + { + + [Int]$_BayID = $_Entry.Name.ToString().ToLower().Replace('bay',$null) + + if ($EnclosureIndex = '-1' -and $FabricModuleType -eq 'SEVCFC') + { + + [Int]$_FrameID = -1 + + } + + else + { + + $_FrameID = 1 + + } + + $_InterconnectBayObject = $null + + Try + { + + $_InterconnectBayObject = Get-InterconnectBayObject $_Entry $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if ($_BayID -ne 1 -and $_BayID -ne 4 -and [RegEx]::Match($_InterconnectBayObject.name, 'SAS', $RegExInsensitiveFlag).Success) + { + + $Message = 'The Fabric Module Bay {0} is invalid for the Synergy 12Gb SAS Connection Module. Please specify Fabric Module Bay 1 or 4.' -f $_BayID + $ErrorRecord = New-ErrorRecord HPEOneView.LogicalInterconnectGroupResourceException InvalidFabricBayIDforSasInterconnect InvalidArgument 'Bays' -TargetType $_Entry.GetType().Name -Message $Message + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + "[{0}] Setting Fabric Module Bay {1} to {2}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_BayID, $_Entry.Value | Write-Verbose + + $_InterconnectMapEntryTemplate = NewObject -InterconnectMapEntryTemplate + + $_InterconnectMapEntryTemplate.permittedInterconnectTypeUri = $_InterconnectBayObject.uri + $_InterconnectMapEntryTemplate.enclosureIndex = $_FrameID + + $_LogicalLocationEntry = NewObject -LocationEntry + $_LogicalLocationEntry.relativeValue = $_FrameID + $_LogicalLocationEntry.type = 'Enclosure' + + [void]$_InterconnectMapEntryTemplate.logicalLocation.locationEntries.Add($_LogicalLocationEntry) + + $_LogicalLocationEntry = NewObject -LocationEntry + $_LogicalLocationEntry.relativeValue = $_BayID + $_LogicalLocationEntry.type = 'Bay' + + [void]$_InterconnectMapEntryTemplate.logicalLocation.locationEntries.Add($_LogicalLocationEntry) + + [void]$lig.interconnectMapTemplate.interconnectMapEntryTemplates.Add($_InterconnectMapEntryTemplate) + + } + + } + + } + + } + + if ($lig.type -notmatch 'sas') + { + + # Process Uplink Sets here + if ($PSBoundParameters['UplinkSet']) + { + + ForEach ($_UplinkSet in $UplinkSet) + { + + "[{0}] Processing {1} uplink set to attach." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_UplinkSet.Name | Write-Verbose + + Try + { + + $_UplinkSetToAdd = BuildUplinkSet -InputObject $lig -Params $_UplinkSet -ApplianceConnection $ApplianceConnection + + [void]$lig.uplinkSets.Add($_UplinkSetToAdd) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + # Decide what type of QoS Configuration to add to activeQosConfig + $lig.qosConfiguration.activeQosConfig = if ($QosConfiguration) + { + + if(-not($QosConfiguration -is [PSCustomObject])) + { + + $Message = "The -QosConfiguration Parameter does not contain a valid QOS Configuration Object. Please check the value and try again." + $ErrorRecord = New-ErrorRecord HPEOneView.LogicalInterconnectGroupResourceException InvalidArgumentValue InvalidArgument 'QosConfiguration' -TargetType $QosConfiguration.Gettype().Name -Message $Message + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + if ($QosConfiguration.type -ne 'QosConfiguration') + { + + $Message = "The -QosConfiguration Parameter value does not contain a valid QOS Configuration Object. OBject type expected 'QosConfiguration', Received '$($QosConfiguration.type)'. Please check the value and try again." + $ErrorRecord = New-ErrorRecord HPEOneView.LogicalInterconnectGroupResourceException InvalidArgumentValue InvalidArgument 'QosConfiguration' -TargetType 'PSObject' -Message $Message + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + $QosConfiguration + + } + + Else + { + + NewObject -QosConfiguration + + } + + if ($PSBoundParameters['InternalNetworks']) + { + + ForEach ($_network in $InternalNetworks) + { + + "[{0}] Internal Network Type: $($_network.GetType().Name)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + switch ($_network.GetType().Name) + { + + 'String' + { + + "[{0}] Processing Internal Network: $_network" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if ($_network.StartsWith($EthernetNetworksUri)) + { + + Try + { + + # Validating object + $_network = Send-OVRequest -Uri $_network -Hostname $_appliance + + # Generate terminating error due to incorrect object from URI isn't the correct type + if ($_network.category -ne $ResourceCategoryEnum.EthernetNetwork) + { + + $ExceptionMessage = "The Internal Network '{0}' is not an Ethernet network. Please specify an Ethernet Network to assign to the Internal Networks property." -f $_network + $ErrorRecord = New-ErrorRecord HPEOneView.LogicalInterconnectGroupResourceException InvalidArgumentValue InvalidArgument 'InternalNetworks' -TargetType 'PSObject' -Message $Message + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + # Get network resource via Get-OVNetwork + else + { + + try + { + + $_network = Get-OVNetwork -Name $_network -ApplianceConnection $_appliance -ErroAction Stop + + } + + catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + 'PSCustomObject' + { + + "[{0}] Processing Internal PSObject Network: {1} ({2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_network.name, $_network.uri | Write-Verbose + + # Throw terminating error if the Internet Network object is not type Ethernet Network + if (-not($_network.category -eq $ResourceCategoryEnum.EthernetNetwork)) + { + + $Message = "The Internal Network category for ($_network.name) does not match the allowed value of 'ethernet-networks'." + $ErrorRecord = New-ErrorRecord InvalidOperationException InvalidArgumentValue InvalidArgument 'InternalNetworks' -TargetType 'PSObject' -Message $Message + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + # Error if Netowrk Object does not match the appliance connection we are currently Processing. + if ($_network.ApplianceConnection.Name -ne $_appliance.Name) + { + + $Message = "The Internal Network '($_network.name)' Appliance Connection ($($_network.ApplianceConnection.Name)) does not match the current Appliance Connection ($($_appliance.Name)) being Processed." + $ErrorRecord = New-ErrorRecord InvalidOperationException InvalidArgumentValue InvalidArgument 'InternalNetworks' -TargetType 'PSObject' -Message $Message + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + } + + # Add to URI's to collection + [void]$lig.internalNetworkUris.Add($_network.uri) + + } + + } + + if ($PSBoundParameters['Snmp']) + { + + $lig.snmpConfiguration = $Snmp.PSObject.Copy() + + } + + } + + $lig.name = $Name + + if ($PSBoundParameters['Scope']) + { + + "[{0}] Processing scopes parameter." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + ForEach ($_Scope in $Scope) + { + + "[{0}] Adding resource to Scope: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_Scope.Name | Write-Verbose + + [void]$lig.initialScopeUris.Add($_Scope.Uri) + + } + + } + + "[{0}] Sending request to create '{1}'..." -f $MyInvocation.InvocationName.ToString().ToUpper(), $lig.name | Write-Verbose + + Try + { + + $task = Send-OVRequest -Uri $uri -Method POST -Body $lig -Hostname $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if (-not $PSBoundParameters['Async']) + { + + $task = Wait-OVTaskComplete $task + + } + + $task + + } + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Get-InterconnectBayObject +{ + + [CmdletBinding ()] + Param + ( + + [Parameter (Mandatory)] + [ValidateNotNullOrEmpty()] + [System.Collections.DictionaryEntry]$InterconnectBay, + + [Parameter (Mandatory)] + [ValidateNotNullOrEmpty()] + [Object]$ApplianceConnection + + ) + + Process + { + + switch ($InterconnectBay.Value) + { + + 'SEVC100F32' + { + + $_PartNumber = '867796-B21' + + } + + 'SEVC40f8' + { + + $_PartNumber = '794502-B23' + + } + + {'SEVC16GbFC', 'SEVCFC' -contains $_} + { + + $_PartNumber = '779227-B21' + + } + + {'SEVC32GbFC', 'SEVC32FC' -contains $_} + { + + $_PartNumber = '876259-B21' + + } + + 'SE50ILM' + { + + $_PartNumber = '867793-B21' + + } + + 'SE20ILM' + { + + $_PartNumber = '779218-B21' + + } + + 'SE10ILM' + { + + $_PartNumber = '779215-B21' + + } + + 'SE12SAS' + { + + Try + { + + $_interconnectObject = Get-OVSasInterconnectType -partNumber "755985-B21" -Appliance $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + default + { + + $_interconnectObject = $null + + } + + } + + Try + { + + '[{0}] Looking for {1} (P/N: {2})' -f $MyInvocation.InvocationName.ToString().ToUpper(), $InterconnectBay.Value, $_Partnumber | Write-Verbose + + if ($Null -ne $_PartNumber) + { + + $_interconnectObject = Get-OVInterconnectType -partNumber $_PartNumber -Appliance $ApplianceConnection + + } + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + End + { + + Return $_interconnectObject + + } + +} + +function New-OVSnmpConfiguration +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "Default")] + Param + ( + + [Parameter (Mandatory, ParameterSetName = 'Default')] + [Parameter (Mandatory, ParameterSetName = 'Snmpv3')] + [ValidateNotNullOrEmpty()] + [String]$ReadCommunity, + + [Parameter (Mandatory = $False, ParameterSetName = 'Default')] + [Parameter (Mandatory = $False, ParameterSetName = 'Snmpv3')] + [ValidateNotNullOrEmpty()] + [Bool]$SnmpV1, + + [Parameter (Mandatory = $False, ParameterSetName = 'Default')] + [Parameter (Mandatory, ParameterSetName = 'Snmpv3')] + [ValidateNotNullOrEmpty()] + [Bool]$SnmpV3, + + [Parameter (Mandatory, ParameterSetName = 'Snmpv3')] + [HPEOneView.Networking.SnmpV3User[]]$SnmpV3Users, + + [Parameter (Mandatory = $False, ParameterSetName = "Default")] + [Parameter (Mandatory = $False, ParameterSetName = "Snmpv3")] + [ValidateNotNullOrEmpty()] + [String]$Contact, + + [Parameter (Mandatory = $False, ParameterSetName = "Default")] + [Parameter (Mandatory = $False, ParameterSetName = "Snmpv3")] + [ValidateNotNullOrEmpty()] + [Array]$AccessList, + + [Parameter (Mandatory = $False, ParameterSetName = "Default")] + [Parameter (Mandatory = $False, ParameterSetName = "Snmpv3")] + [ValidateNotNullOrEmpty()] + [Array]$TrapDestinations + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + $_SnmpConfigrationCol = [System.Collections.ArrayList]::new() + + } + + Process + { + + $_SnmpConfig = NewObject -SnmpConfig + + switch ($PSBoundParameters.keys) + { + + 'ReadCommunity' + { + + $_SnmpConfig.readCommunity = $ReadCommunity + + } + + 'Contact' + { + + $_SnmpConfig.systemContact = $Contact + + } + + 'Snmpv1' + { + + $_SnmpConfig.enabled = $Snmpv1 + + } + + 'Snmpv3' + { + + $_SnmpConfig.v3Enabled = $Snmpv3 + + } + + 'SnmpV3Users' + { + + ForEach ($_SnmpV3User in $SnmpV3Users) + { + + [void]$_SnmpConfig.snmpUsers.add($_SnmpV3User) + + } + + } + + 'AccessList' + { + + ForEach ($_entry in $AccessList) + { + + [void]$_SnmpConfig.snmpAccess.Add($_entry) + + } + + } + + 'TrapDestinations' + { + + + ForEach ($_entry in $TrapDestinations) + { + + [void]$_SnmpConfig.trapDestinations.Add($_entry) + + } + + } + + } + + + $_SnmpConfig.PSObject.TypeNames.Insert(0,'HPEOneView.Networking.SnmpConfiguration') + + [void]$_SnmpConfigrationCol.Add($_SnmpConfig) + + } + + End + { + + Return $_SnmpConfigrationCol + + } + +} + +function New-OVSnmpTrapDestination +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "Default")] + Param + ( + + [Parameter (Mandatory, ParameterSetName = 'Default')] + [Parameter (Mandatory, ParameterSetName = 'SnmpV3')] + [ValidateNotNullOrEmpty()] + [String]$Destination, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [ValidateNotNullOrEmpty()] + [String]$Community = 'public', + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Parameter (Mandatory = $false, ParameterSetName = "SnmpV3")] + [ValidateNotNullOrEmpty()] + [Int]$Port = '162', + + [Parameter (Mandatory = $False, ParameterSetName = "Default")] + [Parameter (Mandatory = $False, ParameterSetName = "SnmpV3")] + [ValidateNotNullOrEmpty()] + [ValidateSet ('SNMPv1', 'SNMPv2', 'SNMPv3', IgnoreCase = $False)] + [String]$SnmpFormat = 'SNMPv1', + + [Parameter (Mandatory, ParameterSetName = "SnmpV3")] + [ValidateNotNullOrEmpty()] + [HPEOneView.Networking.SnmpV3User]$SnmpV3User, + + [Parameter (Mandatory = $false, ParameterSetName = "SnmpV3")] + [ValidateSet ('Inform', 'Trap', IgnoreCase = $False)] + [String]$NotificationType = 'Trap', + + [Parameter (Mandatory = $false, ParameterSetName = "SnmpV3")] + [ValidateNotNullOrEmpty()] + [String]$EngineID, + + [Parameter (Mandatory = $False, ParameterSetName = "Default")] + [Parameter (Mandatory = $False, ParameterSetName = "SnmpV3")] + [ValidateNotNullOrEmpty()] + [String[]]$TrapSeverities, + + [Parameter (Mandatory = $False, ParameterSetName = "Default")] + [Parameter (Mandatory = $False, ParameterSetName = "SnmpV3")] + [ValidateNotNullOrEmpty()] + [String[]]$VCMTrapCategories, + + [Parameter (Mandatory = $False, ParameterSetName = "Default")] + [Parameter (Mandatory = $False, ParameterSetName = "SnmpV3")] + [ValidateNotNullOrEmpty()] + [String[]]$EnetTrapCategories, + + [Parameter (Mandatory = $False, ParameterSetName = "Default")] + [Parameter (Mandatory = $False, ParameterSetName = "SnmpV3")] + [ValidateNotNullOrEmpty()] + [String[]]$FCTrapCategories + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + $_TrapDestinationCol = [System.Collections.ArrayList]::new() + + } + + Process + { + + if ($SnmpFormat -eq 'SnmpV3' -and $NotificationType -eq 'Trap' -and -not $PSboundParameters['EngineID']) + { + + $ExceptionMessage = 'Setting NotificationType to "Trap" requires an SNMPv3 Engine ID. Please provide a value for the EngineID parameter.' + + Throw $ExceptionMessage + + } + + if ($PSCmdlet.ParameterSetName -eq "SnmpV3" -and $SnmpFormat -ne 'SnmpV3' -and $NotificationType -eq 'Trap' ) + { + + $ExceptionMessage = 'Setting NotificationType is only for SNMPv3 configurations. Please change the SnmpFormat to "SNMPv3" or omit the NotificationType parameter.' + + Throw $ExceptionMessage + + } + + if ($PSCmdlet.ParameterSetName -eq "SnmpV3" -and $SnmpFormat -eq 'SnmpV3' -and -not $PSboundParameters['SnmpV3User']) + { + + $ExceptionMessage = 'Configuring SNMPv3 trap destinations requires an SNMPv3 user account. Please use the New-OVSnmpV3User Cmdlet and provide the value to the SnmpV3User parameter.' + + Throw $ExceptionMessage + + } + + $_TrapDestination = NewObject -SnmpTrapDestination + + $_TrapDestination.trapDestination = $Destination + $_TrapDestination.trapFormat = $SnmpFormat + + if ($PSBoundParameters['Community'] -or (-not $PSBoundParameters['Community'] -and $SnmpFormat -ne "SnmpV3")) + { + + $_TrapDestination.communityString = $Community + + } + + switch ($PSBoundParameters.keys) + { + + 'TrapSeverities' + { + + ForEach ($_severity in $TrapSeverities) + { + + # Throw error + if ($SnmpTrapSeverityEnums -notcontains $_severity) + { + + $ErrorRecord = New-ErrorRecord HPEOneView.SnmpTrapDestination InvalidTrapSeverity InvalidArgument 'TrapSeverities' -Message ("The provided SNMP Trap Severity {0} is unsupported. Please check the value, making sure it is one of these values: {1}." -f $_severity, ([System.String]::Join(", ", $SnmpTrapSeverityEnums))) + + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + $_severity = $_severity.SubString(0,1).ToUpper() + $_severity.SubString(1).tolower() + + "[{0}] Processing {1} Trap Severity." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_severity | Write-Verbose + + [void]$_TrapDestination.trapSeverities.Add($_severity) + + } + + } + + 'VCMTrapCategories' + { + + ForEach ($_category in $VCMTrapCategories) + { + + # Throw error + if ($SnmpVcmTrapCategoryEnums -notcontains $_category) + { + + $ErrorRecord = New-ErrorRecord HPEOneView.SnmpTrapDestination InvalidVcmTrapCategory InvalidArgument 'VCMTrapCategories' -Message ("The provided VCM Trap Category {0} is unsupported. Please check the value, making sure it is one of these values: {1}." -f $_category, ([System.String]::Join(", ", $SnmpVcmTrapCategoryEnums))) + + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + $_category = $_category.SubString(0,1).ToUpper() + $_category.SubString(1).tolower() + + "[{0}] Processing {1} VCM Trap Category." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_category | Write-Verbose + + [void]$_TrapDestination.vcmTrapCategories.Add($_category) + + } + + } + + 'EnetTrapCategories' + { + + ForEach ($_category in $EnetTrapCategories) + { + + # Throw error + if ($SnmpEneTrapCategoryEnums -notcontains $_category) + { + + $ErrorRecord = New-ErrorRecord HPEOneView.SnmpTrapDestination InvalidEnetTrapCategory InvalidArgument 'EnetTrapCategories' -Message ("The provided Ethernet Trap Category {0} is unsupported. Please check the value, making sure it is one of these values: {1}." -f $_category, ([System.String]::Join(", ", $SnmpEneTrapCategoryEnums))) + + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + if ($_category.StartsWith('port')) + { + + $_category = $_category.SubString(0,1).ToUpper() + $_category.SubString(1,3).tolower() + $_category.SubString(4,1).ToUpper() + $_category.SubString(6).tolower() + + } + + "[{0}] Processing {1} Enet Trap Category." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_category | Write-Verbose + + [void]$_TrapDestination.enetTrapCategories.Add($_category) + + } + + } + + 'FCTrapCategories' + { + + ForEach ($_category in $FCTrapCategories) + { + + # Throw error + if ($SnmpFcTrapCategoryEnums -notcontains $_category) + { + + $ErrorRecord = New-ErrorRecord HPEOneView.SnmpTrapDestination InvalidFcTrapCategory InvalidArgument 'FCTrapCategories' -Message ("The provided FC Trap Category {0} is unsupported. Please check the value, making sure it is one of these values: {1}." -f $_category, ([System.String]::Join(", ", $SnmpFcTrapCategoryEnums))) + + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + "[{0}] Processing {1} FC Trap Category." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_category | Write-Verbose + + [void]$_TrapDestination.fcTrapCategories.Add($_category) + + } + + } + + } + + $_TrapDestination.PSObject.TypeNames.Insert(0,'HPEOneView.Networking.SnmpTrapDestination') + + [void]$_TrapDestinationCol.Add($_TrapDestination) + + if ($SnmpFormat -eq 'SnmpV3') + { + + $_TrapDestination.trapFormat = 'SNMPv3' + $_TrapDestination.userName = $SnmpV3User.snmpV3UserName + + if ($NotificationType -eq 'Trap') + { + + $_TrapDestination.inform = $false + + if ($PSBoundParameters['EngineID']) + { + + if (-not $SnmpV3EngineIdPattern.Match($EngineID).Success) + { + + # Generate terminating error EngineID is not in the correct format + $ExceptionMessage = "The EngineID parameter value '{0}' is not in the correct format. The EngineID must be prefixed with '10x' followed by an even muber of 10 to 64 hexadecimal digits." -f $EngineID + + Throw $ExceptionMessage + + } + + $_TrapDestination | Add-NoteProperty -NotePropertyName engineId -NotePropertyValue $EngineID + + } + + } + + } + + } + + End + { + + Return $_TrapDestinationCol + + } + +} + +function New-OVQosConfig +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "Passthrough")] + Param + ( + + [Parameter (Mandatory = $False, ParameterSetName = "Passthrough")] + [Parameter (Mandatory, ParameterSetName = "Custom")] + [ValidateSet ("Passthrough", "CustomNoFCoE", "CustomWithFCoE", IgnoreCase = $False)] + [String]$ConfigType = "Passthrough", + + [Parameter (Mandatory = $False, ParameterSetName = "Custom")] + [ValidateSet ("DSCP", "DOT1P", "DOT1P_AND_DSCP", IgnoreCase = $False)] + [String]$UplinkClassificationType = "DOT1P", + + [Parameter (Mandatory = $False, ParameterSetName = "Custom")] + [ValidateSet ("DSCP", "DOT1P", "DOT1P_AND_DSCP", IgnoreCase = $False)] + [String]$DownlinkClassificationType = "DOT1P_AND_DSCP", + + [Parameter (Mandatory = $False, ParameterSetName = "Custom")] + [System.Collections.ArrayList]$TrafficClassifiers = @() + + ) + + Begin + { + + # Helper CMDLET. Does not require appliance authentication. + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + # Validate the caller + if (($PSBoundParameters['UplinkClassificationType'] -or $PSBoundParameters['DownlinkClassificationType'] -or $PSBoundParameters['TrafficClassifiers']) -and $ConfigType -eq 'Passthrough') + { + + $ParameterNames = [System.Collections.ArrayList]::new() + + switch ($PSBoundParameters.Keys) + { + + 'UplinkClassificationType' { [void]$ParameterNames.Add('UplinkClassificationType') } + 'DownlinkClassificationType' { [void]$ParameterNames.Add('DownlinkClassificationType') } + 'TrafficClassifiers' { [void]$ParameterNames.Add('TrafficClassifiers') } + + } + + $Message = "ConfigType Parameter value was set to 'Passthrough' and $($ParameterNames -join ", ") Parameter (s) were provided. When choosing 'Passthrough' QOS Config Type, the other Parameters cannot be used." + $ErrorRecord = New-ErrorRecord InvalidOperationException InvalidArgumentValue InvalidArgument 'ConfigType' -Message $Message + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + Process + { + + $_QosConfigurationObject = NewObject -QosConfiguration + $_QosConfigurationObject.configType = $ConfigType + + switch ($ConfigType) + { + + 'CustomNoFCoE' + { + + "[{0}] Building 'CustomNoFCoE' QOS Configuration." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if ($PSBoundParameters['TrafficClassifiers']) + { + + "[{0}] Adding Custom Traffic Classifiers." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $TrafficClassifiers | ForEach-Object { [void]$_QosConfigurationObject.qosTrafficClassifiers.Add($_) } + + } + + else + { + + "[{0}] Adding Default NoFCoELossless Traffic Classifiers." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_QosConfigurationObject.qosTrafficClassifiers = NewObject -DefaultNoFCoELosslessQosTrafficClassifiers + + } + + $_QosConfigurationObject.uplinkClassificationType = $UplinkClassificationType + $_QosConfigurationObject.downlinkClassificationType = $DownlinkClassificationType + + } + + 'CustomWithFCoE' + { + + "[{0}] Building 'CustomWithFCoE' QOS Configuration." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if ($PSBoundParameters['TrafficClassifiers']) + { + + if ($TrafficClassifiers.Count -gt 6) + { + + $ErrorRecord = New-ErrorRecord InvalidOperationException InvalidArgumentValue InvalidArgument 'TrafficClassifiers' -TargetType 'System.Collections.ArrayList' -Message "The number of provided TrafficClassifiers is exceeded by $($TrafficClassifiers.Count - 2). When defining the QOS Configuration Type to 'CustomWithFCoE', only 6 Custom Traffic Classes are allowed." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($TrafficClassifiers.Count -le 6) + { + + 1..($TrafficClassifiers.Count - 6) | ForEach-Object { + + $_NewBaseTrafficClass = NewObject -BaseTrafficClass + + $_NewBaseTrafficClass.qosTrafficClass.className += $_ + + [void]$_QosConfigurationObject.qosTrafficClassifiers.Add($_NewBaseTrafficClass) + + } + + } + + "[{0}] Adding Custom Traffic Classifiers." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + # Check to make sure caller has not provided 'Best effort' or 'FCoE lossless' Classes + $TrafficClassifiers | ForEach-Object { + + # Generate Error + if ($_.name -eq 'FCoE lossless') + { + + $ErrorRecord = New-ErrorRecord InvalidOperationException InvalidArgumentValue InvalidArgument 'TrafficClassifiers' -TargetType 'System.Collections.ArrayList' -Message "The 'FCoE lossless' traffic class is reserved. Please remove it from the TrafficClassifiers Parameter and try again." + + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + # Add to collection + [void]$_QosConfigurationObject.qosTrafficClassifiers.Add($_) + + } + + # Add FCoE Class + [void]$_QosConfigurationObject.qosTrafficClassifiers.Add((NewObject -FCoELossLessTrafficClass)) + + } + + else + { + + "[{0}] Adding Default With FCoELossless Traffic Classifiers." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_QosConfigurationObject.qosTrafficClassifiers = NewObject -DefaultFCoELosslessQosTrafficClassifiers + + } + + $_QosConfigurationObject.uplinkClassificationType = $UplinkClassificationType + $_QosConfigurationObject.downlinkClassificationType = $DownlinkClassificationType + + } + + } + + } + + End + { + + $_QosConfigurationObject.qosTrafficClassifiers | ForEach-Object { + + if ($_.PSObject.TypeNames -notcontains 'HPEOneView.Networking.Qos.TrafficClassifier') + { + + $_.PSObject.TypeNames.Insert(0,'HPEOneView.Networking.Qos.TrafficClassifier') + + } + + } + + $_QosConfigurationObject.PSObject.TypeNames.Insert(0,'HPEOneView.Networking.Qos.Configuration') + + Return $_QosConfigurationObject + + } + +} + +function New-OVQosTrafficClass +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "default")] + Param + ( + + [Parameter (Mandatory = $False, ParameterSetName = "default")] + [Alias ('ClassName')] + [String]$Name, + + [Parameter (Mandatory = $False, ParameterSetName = "default")] + [ValidateRange(1,100)] + [Int]$MaxBandwidth, + + [Parameter (Mandatory = $False, ParameterSetName = "default")] + [String]$BandwidthShare, + + [Parameter (Mandatory = $False, ParameterSetName = "default")] + [Int]$EgressDot1pValue, + + [Parameter (Mandatory = $False, ParameterSetName = "default")] + [System.Collections.ArrayList]$IngressDot1pClassMapping, + + [Parameter (Mandatory = $False, ParameterSetName = "default")] + [System.Collections.ArrayList]$IngressDscpClassMapping, + + [Parameter (Mandatory = $False, ParameterSetName = "default")] + [Switch]$RealTime, + + [Parameter (Mandatory = $False, ParameterSetName = "default")] + [Switch]$Enabled + + ) + + Begin + { + + # CMDLET doesn't require auth + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + $NoMatch = [System.Collections.ArrayList]::new() + + # Validate the IngressDscpClassMapping values caller is providing + ForEach ($item in $IngressDscpClassMapping) + { + + if (-not($IngressDscpClassMappingEnum -contains $item)) + { + + [void]$NoMatch.Add($item) + + } + + } + + # Check to make sure caller isn't attempting to create an FCoE lossless Class + if ($Name -eq "FCoE lossless") + { + + $Message = "The 'FCoE lossless' Traffic Classifier cannot be modified or created. It is automatically created when using the 'New-OVQosConfig' CMDLET." + $ErrorRecord = New-ErrorRecord InvalidOperationException InvalidArgumentValue InvalidArgument 'Name' -Message $Message + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + if ($Name -eq "Best effort" -and $PSBoundParameters['MaxBandwidth'] -and $PSBoundParameters.Count -gt 2 -and (-not($PSBoundParameters['verbose']) -or -not($PSBoundParameters['debug']) -or -not($PSBoundParameters['Enabled']))) + { + + $Message = "The 'Best effort' Traffic Classifier can only be created with providing the 'Name' and 'MaxBandwidth' Parameters." + $ErrorRecord = New-ErrorRecord InvalidOperationException InvalidArgumentValue InvalidArgument 'Name' -Message $Message + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + if ($NoMatch) + { + + $Message = "Invalid IngressDscpClassMapping Parameter values found: $($NoMatch -join ', '). Please remove these values and try again." + $ErrorRecord = New-ErrorRecord InvalidOperationException InvalidArgumentValue InvalidArgument 'IngressDscpClassMapping' -TargetType 'Array' -Message $Message + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + Process + { + + $_BaseTrafficClass = NewObject -BaseTrafficClass + + switch ($PSBoundParameters.Keys) + { + + "Name" + { + + $_BaseTrafficClass.qosTrafficClass.className = $Name + + } + + "MaxBandwidth" + { + + $_BaseTrafficClass.qosTrafficClass.maxBandwidth = $MaxBandwidth + + } + + "BandwidthShare" + { + + $_BaseTrafficClass.qosTrafficClass.bandwidthShare = $BandwidthShare + + } + + + "EgressDot1pValue" + { + + $_BaseTrafficClass.qosTrafficClass.egressDot1pValue = $EgressDot1pValue + + } + + "RealTime" + { + + $_BaseTrafficClass.qosTrafficClass.realTime = $RealTime + + } + + "IngressDot1pClassMapping" + { + + $IngressDot1pClassMapping | ForEach-Object { [void]$_BaseTrafficClass.qosClassificationMapping.dot1pClassMapping.Add($_) } + + } + + "IngressDscpClassMapping" + { + + $IngressDscpClassMapping | ForEach-Object { [void]$_BaseTrafficClass.qosClassificationMapping.dscpClassMapping.Add($_) } + + } + + } + + } + + End + { + + $_BaseTrafficClass.PSObject.TypeNames.Insert(0,'HPEOneView.Networking.QosTrafficClassifier') + + Return $_BaseTrafficClass + + } + +} + +function Remove-OVLogicalInterconnectGroup +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdLetBinding (DefaultParameterSetName = "default", SupportsShouldProcess, ConfirmImpact = 'High')] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = "default")] + [ValidateNotNullOrEmpty()] + [Alias ("uri","name","Lig",'Resource')] + [Object]$InputObject, + + [Parameter (Mandatory = $False, ValueFromPipelineByPropertyName, ParameterSetName = "default")] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default), + + [Parameter (Mandatory = $false, ParameterSetName = "default")] + [Switch]$force + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not($PSBoundParameters['Resource'])) + { + + $PipelineInput = $True + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + $_taskcollection = [System.Collections.ArrayList]::new() + $_ligcollection = [System.Collections.ArrayList]::new() + + } + + Process + { + + if ($PipelineInput -or $InputObject -is [PSCustomObject]) + { + + "[{0}] Processing Pipeline input" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + "[{0}] LIG Object provided: {1} ({2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject.name, $InputObject.uri | Write-Verbose + + If ('sas-logical-interconnect-groups','logical-interconnect-groups' -contains $InputObject.category) + { + + If (-not($InputObject.ApplianceConnection)) + { + + $ErrorRecord = New-ErrorRecord InvalidOperationException InvalidArgumentValue InvalidArgument "LIG:$($InputObject.Name)" -TargetType PSObject -Message "The LIG resource provided is missing the source ApplianceConnection property. Please check the object provided and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + [void]$_ligcollection.Add($InputObject) + + } + + else + { + + $ErrorRecord = New-ErrorRecord InvalidOperationException InvalidArgumentValue InvalidArgument "LIG:$($InputObject.Name)" -TargetType PSObject -Message "The LIG resource is not an expected category type [$($InputObject.category)]. Allowed resource category type is 'logical-interconnect-groups'. Please check the object provided and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + else + { + + foreach ($_lig in $InputObject) + { + + # LIG passed is a URI + if (($_lig -is [String]) -and [System.Uri]::IsWellFormedUriString($_lig,'Relative')) + { + + "[{0}] Received URI: $($_lig)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + "[{0}] Getting Network Name" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if ($ApplianceConnection.count -gt 1) + { + + $ErrorRecord = New-ErrorRecord InvalidOperationException NetworkResourceNameNotUnique InvalidResult 'Resource' -Message "The provided Resource value is an URI, however a specific Appliance Connection was not provided. Please specify an Appliance Connection." + $PSCmdlet.WriteError($ErrorRecord) + + } + + else + { + + Try + { + + $_resp = Send-OVRequest $_lig -Appliance $ApplianceConnection.Name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + [void]$_ligcollection.Add($_resp) + + } + + } + + # LIG passed is the Name + elseif (($_lig -is [String]) -and (-not($_lig.startsWith("/rest/")))) + { + + "[{0}] Received LIG Name $($_lig)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + "[{0}] Getting LIG object from Get-OVLogicalInterconnectGroup" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $_lig = Get-OVLogicalInterconnectGroup $_lig -ApplianceConnection $ApplianceConnection.Name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + [void]$_ligcollection.Add($_lig) + + } + + # LIG passed is the object + elseif ($_lig -is [PSCustomObject] -and ('sas-logical-interconnect-groups','logical-interconnect-groups' -contains $_lig.category)) + { + + "[{0}] LIG Object provided: $($_lig )" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + [void]$_ligcollection.Add($_lig) + + } + + elseif ($_lig -is [PSCustomObject] -and ('sas-logical-interconnect-groups','logical-interconnect-groups' -notcontains $_lig.category)) + { + + $ErrorRecord = New-ErrorRecord InvalidOperationException InvalidArgumentValue InvalidArgument 'Resource' -TargetType 'PSObject' -Message "Invalid LIG Parameter: $($_lig )" + $PSCmdlet.WriteError($ErrorRecord) + + } + + } + + } + + } + + End + { + + "[{0}] Processing $($_ligcollection.count) LIG resources to remove." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + # Process LIG Resources + ForEach ($_lig in $_ligcollection) + { + + # Display obselete message if the connection is a VM, not Synergy + [ObsoleteMessage]::Write($_lig.ApplianceConnection) + + if ($PSCmdlet.ShouldProcess($_lig.name,"Remove Logical Interconnect Group from appliance '$($_lig.ApplianceConnection.Name)'")) + { + + "[{0}] Removing LIG '$($_lig.name)' from appliance '$($_lig.ApplianceConnection.Name)'." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + if ($force.IsPresent) + { + + $_lig.uri += "?force=true" + + } + + Send-OVRequest -Uri $_lig.Uri -Method DELETE -AddHeader @{'If-Match' = $_lig.eTag } -Hostname $_lig.ApplianceConnection.Name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + elseif ($PSBoundParameters['WhatIf']) + { + + "[{0}] WhatIf Parameter was passed." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + } + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Get-OVUplinkSet +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "Name")] + Param + ( + + [Parameter (Mandatory = $false, ParameterSetName = "Name")] + [ValidateNotNullorEmpty()] + [String]$Name, + + [Parameter (Mandatory = $false, ValueFromPipeline, ParameterSetName = "Name")] + [Parameter (Mandatory = $false, ValueFromPipeline, ParameterSetName = "Type")] + [ValidateNotNullorEmpty()] + [Alias ('liname')] + [object]$LogicalInterconnect, + + [Parameter (Mandatory = $false, ParameterSetName = "Type")] + [ValidateSet ('Ethernet','FibreChannel', IgnoreCase=$False)] + [String]$Type, + + [Parameter (Mandatory = $false, ParameterSetName = "Name")] + [Parameter (Mandatory = $false, ParameterSetName = "Type")] + [Switch]$Report, + + [Parameter (Mandatory = $false, ParameterSetName = "Name")] + [Parameter (Mandatory = $false, ParameterSetName = "Type")] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default), + + [Parameter (Mandatory = $false, ParameterSetName = "Name")] + [Parameter (Mandatory = $false, ParameterSetName = "Type")] + [Alias ("x", "export")] + [ValidateScript({split-path $_ | Test-Path})] + [String]$ExportFile + + ) + + Begin + { + + if ($PSBoundParameters['report']) + { + + Write-Warning "The Report Parameter has been deprecated. The CMDLET will now display object data in Format-List view." + + } + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command agian." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $_UplinkSetCollection = [System.Collections.ArrayList]::new() + + } + + Process + { + + if ($LogicalInterconnect -is [PSCustomObject]) + { + + $ApplianceConnection = $ApplianceConnection | Where-Object { $_.Name -eq $LogicalInterconnect.ApplianceConnection.Name } + + } + + ForEach ($_appliance in $ApplianceConnection) + { + + # Display obselete message if the connection is a VM, not Synergy + [ObsoleteMessage]::Write($_appliance) + + "[{0}] Processing '$($_appliance.Name)' Appliance" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + # Looking for UplinkSet Name without LI Object/Resource + if ($PSCmdlet.ParameterSetName -eq 'Name' -and (-not($PSBoundParameters['LogicalInterconnect']))) + { + + if ($PSboundParameters['Name']) + { + + "[{0}] Uplink Set name provided: '$name'" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $name = $name -replace ("[*]","%25") -replace ("[&]","%26") + + # We will crate a URI that uses filter at the resource URI + $uri = $uplinkSetsUri + "?filter=name matches '$name'" + + } + + else + { + + "[{0}] Looking for all Uplink Sets." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $uri = $uplinkSetsUri + + } + + Try + { + + $_uplinksets = Send-OVRequest -Uri $uri -Method GET -Hostname $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if ($_uplinksets.count -eq 0 -and $Name) + { + + # Generate Error if no name was found + $ExceptionMessage = "Specified Uplink Set '{0}' was not found on '{1}'. Please check the name and try again." -f $Name, $_appliance.Name + $ErrorRecord = New-ErrorRecord InvalidOperationException UplinkSetResourceNameNotFound ObjectNotFound 'Name' -Message $ExceptionMessage + $PSCmdlet.WriteError($ErrorRecord) + + } + + elseif ($_uplinksets.count -eq 0) + { + + "[{0}] No Uplink Sets found for {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name | Write-Verbose + + } + + else + { + + $_uplinksets = $_uplinksets.members + + } + + } + + # Looking for LI Object and associated Uplink Sets + elseif ($PSboundParameters['LogicalInterconnect']) # -and (-not($PSBoundParameters['Name']))) + { + + # Check the LogicalInterconnect Parameter value type + switch ($LogicalInterconnect.GetType().Name) + { + + 'PSCustomObject' + { + + "[{0}] Received PSCustomObject for LogicalInterconnect Parameter." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if ($LogicalInterconnect.category -eq $ResourceCategoryEnum.LogicalInterconnect) + { + + "[{0}] Logical Interconnect Object provided: $($LogicalInterconnect )." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + else + { + + "[{0}] Invalid Logical Interconnect Object provided: $($LogicalInterconnect | Out-String)." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $ErrorRecord = New-ErrorRecord InvalidOperationException LogicalInterconnectInvalidCategroy InvalidArgument 'LogicalInterconnect' -TargetType 'PSObject' -Message "The provided LogicalInterconnect resource category '$($LogicalInterconnect.category)' does not match the required 'logical-interconnects' value. Please check the Parameter value and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + 'String' + { + + # User provided Logical Interconnect Name, look for it on the appliance + if (-not($LogicalInterconnect.StartsWith('/rest/')) -or (-not($LogicalInterconnect.StartsWith($logicalInterconnectsUri)))) + { + + "[{0}] Logical Interconnect name provided: 'LogicalInterconnect'." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + "[{0}] Getting Logical Interconnect '$liName'" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $LogicalInterconnect = Get-OVLogicalInterconnect -Name $LogicalInterconnect -ApplianceConnection $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + # User didn't provide a Logical Interconnect Resource Name, generate error as URI's are not supported + else + { + + "[{0}] Invalid Logical Interconnect Parameter value provided: $($LogicalInterconnect | Out-String)." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $ErrorRecord = New-ErrorRecord InvalidOperationException InvalidLogicalInterconnectParameterValue InvalidArgument 'LogicalInterconnect' -TargetType 'PSObject' -Message "The provided LogicalInterconnect resource category '$($LogicalInterconnect.category)' does not match the required 'logical-interconnects' value. Please check the Parameter value and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + } + + # Use Index to find associations + try + { + + $_uplinksets = [System.Collections.ArrayList]::new() + + "[{0}] Looking for associated Uplink Sets to Logical Interconnects via Index." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $_uri = '{0}?parentUri={1}&name=LOGICAL_INTERCONNECT_TO_UPLINK_SET' -f $AssociationsUri, $LogicalInterconnect.uri + $_indexassociatedulinksets = Send-OVRequest -Uri $_uri -Hostname $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if ($_indexassociatedulinksets.count -gt 0) + { + + ForEach ($child in $_indexassociatedulinksets.members) + { + + $_uplinksetobject = Send-OVRequest $child.childUri -Hostname $_appliance + + if ($Name) + { + + "[{0}] Filtering Uplink Sets for '$Name'" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if ([RegEx]::Match($Name, "\*|\?", $RegExInsensitiveFlag).Success) + { + + if ($_uplinksetobject.name -match $Name) + { + + [void]$_uplinksets.Add($_uplinksetobject) + + } + + } + + else + { + + if ($_uplinksetobject.name -eq $Name) + { + + [void]$_uplinksets.Add($_uplinksetobject) + + } + + } + + } + + elseif ($type) + { + + "[{0}] Filtering Uplink Sets for '$type' type." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + if ($_uplinksetobject.networkType -eq $type) + { + + [void]$_uplinksets.Add($_uplinksetobject) + + } + + } + + } + + } + + + if ($Name -and $_uplinksets.count -eq 0) + { + + # Generate Error if no name was found + $ErrorRecord = New-ErrorRecord InvalidOperationException UplinkSetResourceNameNotFound ObjectNotFound 'Name' -Message "Specified Uplink Set '$name' was not found associated with '$($LogicalInterconnect.name)' on '$($_appliance.Name)'. Please check the name and try again." + $PSCmdlet.WriteError($ErrorRecord) + + } + + elseif ($type -and $_uplinksets.count -eq 0) + { + + $ErrorRecord = New-ErrorRecord InvalidOperationException UplinkSetResourceTypeNotFound ObjectNotFound 'Type' -Message "Specified Uplink Set Type '$type' was not found associated with '$($LogicalInterconnect.name)' on '$($_appliance.Name)'. Please check the name and try again." + $PSCmdlet.WriteError($ErrorRecord) + + } + + } + + catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + # Update TypeNames + if ($_uplinksets.count -gt 0) + { + + foreach ($_object in $_uplinksets) + { + + switch ($_object.networkType) + { + + 'Ethernet' + { + + $_object.PSObject.TypeNames.Insert(0,'HPEOneView.Networking.LogicalInterconnect.UplinkSet.Ethernet') + $_object.portConfigInfos | ForEach-Object { + + Add-Member -InputObject $_ -NotePropertyName ApplianceConnection -NotePropertyValue $_object.ApplianceConnection + + $_.PSObject.TypeNames.Insert(0,'HPEOneView.Networking.LogicalInterconnect.UplinkSet.Ethernet.UplinkPort') + + } + + } + + 'FibreChannel' + { + + $_object.PSObject.TypeNames.Insert(0,'HPEOneView.Networking.LogicalInterconnect.UplinkSet.FibreChannel') + $_object.portConfigInfos | ForEach-Object { + + Add-Member -InputObject $_ -NotePropertyName ApplianceConnection -NotePropertyValue $_object.ApplianceConnection + + $_.PSObject.TypeNames.Insert(0,'HPEOneView.Networking.LogicalInterconnect.UplinkSet.FibreChannel.UplinkPort') + + } + + } + + } + + "[{0}] Adding '$($_object.name)' to final collection." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + [void]$_UplinkSetCollection.Add($_object) + + } + + } + + } + + } + + End + { + + $_UplinkSetCollection | sort-object -Property networkType,name + + "[{0}] Done. $($_UplinkSetCollection.count) uplink set(s) found." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function BuildUplinkSet +{ + + [CmdletBinding (DefaultParameterSetName = "Default")] + Param + ( + + # This is the object the uplink set will be created for + [Parameter (Mandatory, ParameterSetName = "Default")] + [ValidateNotNullorEmpty()] + [Object]$InputObject, + + # This is the uplink set object needed to be attached + [Parameter (Mandatory, ParameterSetName = "Default")] + [ValidateNotNullorEmpty()] + [Hashtable]$Params, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [ValidateNotNullorEmpty()] + [String]$ApplianceConnection + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Params: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), ($Params | Out-String) | Write-Verbose + + if (-not $PSBoundParameters['ApplianceConnection']) + { + + $ApplianceConnection = $InputObject.ApplianceConnection + + } + + } + + Process + { + + $_InputObject = $InputObject.PSObject.Copy() + + # Do resource port specific operations here + switch ($_InputObject.category) + { + + # Uplink Sets are created differently for LI Resources + $ResourceCategoryEnum.LogicalInterconnect + { + + if ($Params.Type -eq 'Imagestreamer' -and $_InputObject.enclosureType -notmatch 'SY') + { + + $ExceptionMessage = "An non-Synergy enclosure resource was provided with the InputObject parameter. Only HPE Synergy enclosures are supported when uplink set Type is ImageStreamer." + $ErrorRecord = New-ErrorRecord ArgumentException InvalidParameter InvalidArgument 'Resource' -TargetType 'PSObject' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + if ($Params.ConsistencyChecking) + { + + $ExceptionMessage = "The -ConsistencyChecking parameter is only applicable with logical interconnect group resources." + $ErrorRecord = New-ErrorRecord ArgumentException InvalidParameter InvalidArgument 'ConsistencyChecking' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + "[{0}] Provided LI Resource Name: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_InputObject.name | Write-Verbose + "[{0}] Provided LI Resource Category: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_InputObject.category | Write-Verbose + "[{0}] Provided LI Resource URI: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_InputObject.uri | Write-Verbose + + # Init Uplink Set Objects + $_UplinkSetObject = NewObject -liUplinkSetObject + + # Add Logical Interconnect object URI to Uplink Set Object + $_UplinkSetObject.logicalInterconnectUri = $_InputObject.uri + + # Get list of interconnects within LI resource + $_liInterconnects = $_InputObject.interconnectMap.interconnectMapEntries + + "[{0}] Uplink Ports to Process: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), [System.String]::Join(', ', $UplinkPorts) | Write-Verbose + + # Loop through requested Uplink Ports + $port = [System.Collections.ArrayList]::new() + $uslogicalLocation = [System.Collections.ArrayList]::new() + + if ($Params.EthMode) + { + + "[{0}] Setting Uplink Set mode to '{1}'." -f $MyInvocation.InvocationName.ToString().ToUpper(), $Params.EthMode | Write-Verbose + + $_UplinkSetObject.connectionMode = $Params.EthMode + + } + + foreach ($_p in $Params.UplinkPorts) + { + + Try + { + + $_location = BuildPortConfigInfos -Port $_p -LogicalInterconnect $_InputObject + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + # Create Primary Port logical location object + if ($Params.PrimaryPort -match $_p -and $Params.EthMode -eq "Failover") + { + + "[{0}] Setting Primary Port to '{1}'" -f $MyInvocation.InvocationName.ToString().ToUpper(), $PrimaryPort | Write-Verbose + + Try + { + + $_PortLocation = BuildPortConfigInfos -Port $_p -LogicalInterconnect $_InputObject + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $_UplinkSetObject.primaryPortLocation = $_PortLocation.location + + } + + # Set FC Uplink Port Speed + if ($Params.Type -eq "FibreChannel") + { + + "[{0}] Setting FC port speed to '{1}'" -f $MyInvocation.InvocationName.ToString().ToUpper(), $global:SetUplinkSetPortSpeeds[$fcUplinkSpeed] | Write-Verbose + + $_location.desiredSpeed = $global:SetUplinkSetPortSpeeds[$fcUplinkSpeed] + + } + + elseif ($Params.PortSpeed) + { + + "[{0}] Setting Ethernet port speed to '{1}'" -f $MyInvocation.InvocationName.ToString().ToUpper(), $global:SetUplinkSetPortSpeeds[$Params.PortSpeed] | Write-Verbose + + $_location.desiredSpeed = $global:SetUplinkSetPortSpeeds[$Params.PortSpeed] + + } + + else + { + + "[{0}] Setting Ethernet port speed to auto" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_location.desiredSpeed = "Auto" + + } + + if ($Params.Keys -contains 'FecMode' -and $Params.FecMode -ne "None") + { + + "[{0}] Validating Ethernet forward error correct mode" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if ($_InputObject.enclosureType -notmatch 'SY') + { + + $ExceptionMessage = "The '{0}' logical interconnect is not an HPE Synergy fabric module type. Forward error correction is only supported with the 'Virtual Connect SE 100Gb F32 Module for Synergy'." -f $_InputObject.name + $ErrorRecord = New-ErrorRecord ArgumentException InvalidParameter InvalidArgument 'Resource' -TargetType 'PSObject' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + $_Port = [RegEx]::Match($_p.ToLower(), $UplinkPortParameterRegExPattern) + [Int]$_EnclosureID = $_Port.Groups['Enclosure'].Value.ToLower().TrimStart('enclosure') + [String]$_Bay = $_Port.Groups['Bay'].Value.ToLower().TrimStart('bay') + + # Get the list of ICM partnumbers from the interconnect map template entries + $_IcmTypeToProcess = $_InputObject.interconnectMap.interconnectMapEntries | ? { ($_.location.locationEntries.type -eq 'Bay' -and $_.location.locationEntries.relativeValue -eq $_Bay) -and ($_.location.locationEntries.type -eq 'Enclosure' -and $_.location.locationEntries.relativeValue -eq $_EnclosureID) } + + Try + { + + $_IcmType = Send-OVRequest -Uri $_IcmTypeToProcess.permittedInterconnectTypeUri -Hostname $_InputObject.ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if ($FecCapableICMPartnumberEnum -notcontains $_IcmType.partNumber) + { + + $ExceptionMessage = "The '{0}' interconnect module does not support forward error correction. The only module to support this feature is the 'Virtual Connect SE 100Gb F32 Module for Synergy'." -f $_IcmType.name + $ErrorRecord = New-ErrorRecord ArgumentException InvalidParameter InvalidArgument 'Resource' -TargetType 'PSObject' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + # Subport validated + if (-not [String]::IsNullOrEmpty($_Port.Groups['Subport'].Value)) + { + + "[{0}] Subport found, validate Ethernet forward error correct mode" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if ($UplinkSubPortAllowedFecModesEnum -notcontains $UplinkPortFecModeEnum[$Params.FecMode]) + { + + $ExceptionMessage = "The uplink set FEC mode for the port {0}.{1} is not valid. Only {2} are allowed." -f $_Port.Groups['FaceplatePort'].Value.ToUpper(), $_Port.Groups['Subport'].Value, [String]::Join("', '", $UplinkSubPortAllowedFecModesEnum) + $ErrorRecord = New-ErrorRecord ArgumentException InvalidParameter InvalidArgument 'Resource' -TargetType 'PSObject' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + else + { + + "[{0}] Parent port found, validate Ethernet forward error correct mode" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if ($UplinkPortAllowedFecModesEnum -notcontains $UplinkPortFecModeEnum[$Params.FecMode]) + { + + $ExceptionMessage = "The uplink set FEC mode for the port {0} is not valid. Only '{1}' are allowed." -f $_Port.Groups['FaceplatePort'].Value.ToUpper(), [String]::Join("', '", $UplinkPortAllowedFecModesEnum) + $ErrorRecord = New-ErrorRecord ArgumentException InvalidParameter InvalidArgument 'Resource' -TargetType 'PSObject' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + "[{0}] Setting Ethernet forward error correct mode to: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $UplinkPortFecModeEnum[$Params.FecMode] | Write-Verbose + + $_location.desiredFecMode = $Params.FecMode + + } + + "[{0}] Adding Uplink Set to LIG: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), ($_logicalLocation | out-string) | Write-Verbose + + [void]$_UplinkSetObject.portConfigInfos.Add($_location) + + } + + } + + $ResourceCategoryEnum.LogicalInterconnectGroup + { + + # Create new instance of the LIGUplinkSet Object + $_UplinkSetObject = NewObject -ligUplinkSetObject + + if ($Params.Type -eq 'Imagestreamer' -and $_InputObject.enclosureType -notmatch 'SY') + { + + $ExceptionMessage = "An non-Synergy enclosure resource was provided with the InputObject parameter. Only HPE Synergy enclosures are supported when uplink set Type is ImageStreamer." + $ErrorRecord = New-ErrorRecord ArgumentException InvalidParameter InvalidArgument 'InputObject' -TargetType 'PSObject' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + "[{0}] Provided LIG Resource Name: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_InputObject.name | Write-Verbose + "[{0}] Provided LIG Resource Category: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_InputObject.category | Write-Verbose + + if ([String]::IsNUllOrEmpty($_InputObject.uri)) + { + + "[{0}] LIG Resource has not been created yet." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + else + { + + "[{0}] Provided LIG Resource URI: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_InputObject.uri | Write-Verbose + + } + + # Get list of interconnects in LIG definition + $ligInterconnects = $_InputObject.interconnectMapTemplate.interconnectMapEntryTemplates + + if ($Params.UplinkPorts) + { + + "[{0}] Uplink Ports: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), [System.String]::Join(', ', $Params.UplinkPorts) | Write-Verbose + + } + + else + { + + "[{0}] No uplink ports request." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + # Loop through requested Uplink Ports + $port = [System.Collections.ArrayList]::new() + $uslogicalLocation = [System.Collections.ArrayList]::new() + + if ($Params.EthMode) + { + + "[{0}] Setting Uplink Set mode to '{1}'." -f $MyInvocation.InvocationName.ToString().ToUpper(), $Params.EthMode | Write-Verbose + + $_UplinkSetObject.mode = $Params.EthMode + + } + + foreach ($_p in $Params.UplinkPorts) + { + + Try + { + + $_logicalLocation = BuildLogicalPortConfigInfos -Port $_p -LogicalInterconnectGroup $_InputObject -ApplianceConnection $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + # Create Primary Port logical location object + if ($Params.PrimaryPort -match $_p -and $Params.EthMode -eq "Failover") + { + + "[{0}] Setting Primary Port to '{1}'" -f $MyInvocation.InvocationName.ToString().ToUpper(), $PrimaryPort | Write-Verbose + + Try + { + + $_PrimaryPortLogicalLocation = BuildLogicalPortConfigInfos -Port $_p -LogicalInterconnectGroup $_InputObject -ApplianceConnection $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $_UplinkSetObject.primaryPort = $_PrimaryPortLogicalLocation.logicalLocation + + } + + # Set FC Uplink Port Speed + if ($Params.Type -eq "FibreChannel") + { + + "[{0}] Setting FC port speed to '{1}'" -f $MyInvocation.InvocationName.ToString().ToUpper(), $global:SetUplinkSetPortSpeeds[$fcUplinkSpeed] | Write-Verbose + + $_logicalLocation.desiredSpeed = $global:SetUplinkSetPortSpeeds[$fcUplinkSpeed] + + } + + elseif ($Params.PortSpeed) + { + + "[{0}] Setting Ethernet port speed to '{1}'" -f $MyInvocation.InvocationName.ToString().ToUpper(), $global:SetUplinkSetPortSpeeds[$Params.PortSpeed] | Write-Verbose + + $_logicalLocation.desiredSpeed = $global:SetUplinkSetPortSpeeds[$Params.PortSpeed] + + } + + else + { + + "[{0}] Setting Ethernet port speed to auto" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_logicalLocation.desiredSpeed = "Auto" + + } + + if ($Params.Keys -contains 'FecMode' -and $Params.FecMode -ne "None") + { + + "[{0}] Validating Ethernet forward error correct mode" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if ($_InputObject.enclosureType -notmatch 'SY') + { + + $ExceptionMessage = "The '{0}' logical interconnect group is not an HPE Synergy fabric module type. Forward error correction is only supported with the 'Virtual Connect SE 100Gb F32 Module for Synergy'." -f $_InputObject.name + $ErrorRecord = New-ErrorRecord ArgumentException InvalidParameter InvalidArgument 'Resource' -TargetType 'PSObject' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + $_Port = [RegEx]::Match($_p.ToLower(), $UplinkPortParameterRegExPattern) + [Int]$_EnclosureID = $_Port.Groups['Enclosure'].Value.ToLower().TrimStart('enclosure') + [String]$_Bay = $_Port.Groups['Bay'].Value.ToLower().TrimStart('bay') + + # Get the list of ICM partnumbers from the interconnect map template entries + $_IcmTypeToProcess = $_InputObject.interconnectMapTemplate.interconnectMapEntryTemplates | ? { ($_.logicalLocation.locationEntries.type -eq 'Bay' -and $_.logicalLocation.locationEntries.relativeValue -eq $_Bay) -and ($_.logicalLocation.locationEntries.type -eq 'Enclosure' -and $_.logicalLocation.locationEntries.relativeValue -eq $_EnclosureID) } + + Try + { + + $_IcmType = Send-OVRequest -Uri $_IcmTypeToProcess.permittedInterconnectTypeUri -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if ($FecCapableICMPartnumberEnum -notcontains $_IcmType.partNumber) + { + + $ExceptionMessage = "The '{0}' interconnect module does not support forward error correction. The only module to support this feature is the 'Virtual Connect SE 100Gb F32 Module for Synergy'." -f $_IcmType.name + $ErrorRecord = New-ErrorRecord ArgumentException InvalidParameter InvalidArgument 'Resource' -TargetType 'PSObject' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + # Subport validated + if (-not [String]::IsNullOrEmpty($_Port.Groups['Subport'].Value)) + { + + "[{0}] Subport found, validate Ethernet forward error correct mode" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if ($UplinkSubPortAllowedFecModesEnum -notcontains $UplinkPortFecModeEnum[$Params.FecMode]) + { + + $ExceptionMessage = "The uplink set FEC mode for the port {0}.{1} is not valid. Only {2} are allowed." -f $_Port.Groups['FaceplatePort'].Value.ToUpper(), $_Port.Groups['Subport'].Value, [String]::Join("', '", $UplinkSubPortAllowedFecModesEnum) + $ErrorRecord = New-ErrorRecord ArgumentException InvalidParameter InvalidArgument 'Resource' -TargetType 'PSObject' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + else + { + + "[{0}] Parent port found, validate Ethernet forward error correct mode" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if ($UplinkPortAllowedFecModesEnum -notcontains $UplinkPortFecModeEnum[$Params.FecMode]) + { + + $ExceptionMessage = "The uplink set FEC mode for the port {0} is not valid. Only '{1}' are allowed." -f $_Port.Groups['FaceplatePort'].Value.ToUpper(), [String]::Join("', '", $UplinkPortAllowedFecModesEnum) + $ErrorRecord = New-ErrorRecord ArgumentException InvalidParameter InvalidArgument 'Resource' -TargetType 'PSObject' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + "[{0}] Setting Ethernet forward error correct mode to: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $UplinkPortFecModeEnum[$Params.FecMode] | Write-Verbose + + $_logicalLocation.desiredFecMode = $UplinkPortFecModeEnum[$Params.FecMode] + + } + + "[{0}] Adding Uplink Set to LIG: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), ($_logicalLocation | out-string) | Write-Verbose + + [void]$_UplinkSetObject.logicalPortConfigInfos.Add($_logicalLocation) + + } + + if ($Params.ConsistencyChecking) + { + + "[{0}] Setting uplink set consistentcy checking: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $LIGConsistencyCheckingEnum[$Params.ConsistencyChecking]| Write-Verbose + + $_UplinkSetObject.consistencyChecking = $LIGConsistencyCheckingEnum[$Params.ConsistencyChecking] + + } + + } + + # Unsupported resource category + default + { + + $ExceptionMessage = "The Resource Parameter value provided is not a Logical Interconnect Group or Logical Interconnect object. Please check the value and try again." + $ErrorRecord = New-ErrorRecord ArgumentException InvalidParameter InvalidArgument 'Resource' -TargetType 'PSObject' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + $_UplinkSetObject.name = $Params.Name + + if ($Params.Networks) + { + + "[{0}] Getting Network Uris" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $_NetworkUris = GetNetworkUris -Networks $Params.Networks -ApplianceConnection $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + ForEach ($_NetworkUri in $_NetworkUris) + { + + # LIGs have a different property here + if ($InputObject.Category -eq $ResourceCategoryEnum.LogicalInterconnectGroup) + { + + [void]$_UplinkSetObject.networkUris.Add($_NetworkUri) + + } + + else + { + + if ($_NetworkUri.StartsWith($EthernetNetworksUri)) + { + + [void]$_UplinkSetObject.networkUris.Add($_NetworkUri) + + } + + elseif ($_NetworkUri.StartsWith($ROCENetworksUri)) + { + + [void]$_UplinkSetObject.roceNetworkUris.Add($_NetworkUri) + + } + + elseif ($_NetworkUri.StartsWith($FcNetworksUri)) + { + + [void]$_UplinkSetObject.fcNetworkUris.Add($_NetworkUri) + + } + + elseif ($_NetworkUri.StartsWith($FCoENetworksUri)) + { + + [void]$_UplinkSetObject.fcoeNetworkUris.Add($_NetworkUri) + + } + + } + + } + + } + + Switch ($Params.Type) + { + + {"Ethernet", "Untagged", "Tunnel", 'ImageStreamer' -contains $_} + { + + $_UplinkSetObject.networkType = $UplinkSetNetworkTypeEnum[$Params.Type] + $_UplinkSetObject.ethernetNetworkType = $UplinkSetEthNetworkTypeEnum[$Params.Type] + + if ($Params.EthMode) + { + + if ($Params.EthMode -eq 'Failover' -and $Params.LacpTimer) + { + + $ExceptionMessage = "The -LacpTimer Parameter value is not supported when -EthMode is set to Failover." + $ErrorRecord = New-ErrorRecord ArgumentException InvalidParameter InvalidArgument 'LacpTimer' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + if ([RegEx]::Match($_InputObject.enclosureType, 'SY', $RegExInsensitiveFlag).Success -and $Params.EthMode -ne 'Auto') + { + + $ExceptionMessage = "The -EthMode Parameter is not supported with HPE Synergy Virtual Connect." + $ErrorRecord = New-ErrorRecord ArgumentException InvalidParameter InvalidArgument 'EthMode' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + if ($Params.LacpTimer) + { + + $_UplinkSetObject.lacpTimer = $Params.LacpTimer + + } + + if ($_InputObject.enclosureType -notmatch 'SY' -and $Params.LacpLoadbalancingMode) + { + + $ExceptionMessage = "The -LacpLoadbalancingMode Parameter is only supported with HPE Synergy Virtual Connect." + $ErrorRecord = New-ErrorRecord ArgumentException InvalidParameter InvalidArgument 'LacpLoadbalancingMode' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($Params.LacpLoadbalancingMode -and $Params.Type -ne 'ImageStreamer') + { + + "[{0}] Setting LACP load balance algorithm to: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Params.LacpLoadbalancingMode | Write-Verbose + + $_UplinkSetObject.loadBalancingMode = $Params.LacpLoadbalancingMode + + } + + # Ensure that ImaegStreamer uplink set load balancing mode is always set to NONE, as no other mode is supported + elseif ($Params.Type -eq 'ImageStreamer') + { + + "[{0}] ImageStreamer LACP load balance algorithm to 'NONE'." -f $MyInvocation.InvocationName.ToString().ToUpper(), $Params.LacpLoadbalancingMode | Write-Verbose + + $_UplinkSetObject.loadBalancingMode = "None" + + } + + if ($_InputObject.enclosureType -notmatch 'SY' -and $Params.LacpFailoverTrigger) + { + + $ExceptionMessage = "The -LacpFailoverTrigger Parameter is only supported with HPE Synergy Virtual Connect." + $ErrorRecord = New-ErrorRecord ArgumentException InvalidParameter InvalidArgument 'LacpFailoverTrigger' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($Params.LacpFailoverTrigger) + { + + "[{0}] Setting LACP failover trigger to: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Params.LacpFailoverTrigger | Write-Verbose + + $_UplinkSetObject | Add-Member -NotePropertyName failoverType -NotePropertyValue $Params.LacpFailoverTrigger + + if ($Params.LacpFailoverTrigger -eq 'FailoverBandwidthThreshold' -and -not $Params.LacpFailoverBandwidthThreshold) + { + + $ExceptionMessage = "The -LacpFailoverBandwidthThreshold Parameter is required when setting an LACP failover bandwidth policy." + $ErrorRecord = New-ErrorRecord ArgumentException InvalidParameter InvalidArgument 'LacpFailoverTrigger' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + if ($Params.LacpFailoverTrigger -eq 'FailoverActiveMemberThreshold' -and -not $Params.LacpFailoverActiveMemberThreshold) + { + + $ExceptionMessage = "The -LacpFailoverActiveMemberThreshold Parameter is required when setting an LACP failover bandwidth policy." + $ErrorRecord = New-ErrorRecord ArgumentException InvalidParameter InvalidArgument 'LacpFailoverTrigger' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + if ($Params.LacpFailoverTrigger -eq 'AllActiveUplinksOffline' -and ($Params.LacpFailoverBandwidthThreshold -or $Params.LacpFailoverActiveMemberThreshold)) + { + + $ExceptionMessage = "The -LacpFailoverTrigger Parameter value 'AllActiveUplinksOffline' does not support setting either -LacpFailoverBandwidthThreshold or -LacpFailoverActiveMemberThreshold policies. Please change -LacpFailoverTrigger to either 'FailoverActiveMemberThreshold' or 'FailoverBandwidthThreshold'." + $ErrorRecord = New-ErrorRecord ArgumentException InvalidParameter InvalidArgument 'LacpFailoverTrigger' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + if ($Params.LacpFailoverBandwidthThreshold) + { + + "[{0}] Setting LACP failover bandwidth threshold to: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Params.LacpFailoverBandwidthThreshold | Write-Verbose + + $_UplinkSetObject | Add-Member -NotePropertyName failoverBandwidthThreshold -NotePropertyValue $Params.LacpFailoverBandwidthThreshold + + } + + if ($Params.LacpFailoverActiveMemberThreshold) + { + + "[{0}] Setting LACP failover active member threshold to: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Params.LacpFailoverActiveMemberThreshold | Write-Verbose + + $_UplinkSetObject | Add-Member -NotePropertyName failoverActiveMemberThreshold -NotePropertyValue $Params.LacpFailoverActiveMemberThreshold + + } + + } + + # LacpDistributeUplinkPorts + if ($_InputObject.enclosureType -notmatch 'SY' -and $Params.LacpDistributeUplinkPorts) + { + + $ExceptionMessage = "The -LacpDistributeUplinkPorts Parameter is only supported with HPE Synergy Virtual Connect." + $ErrorRecord = New-ErrorRecord ArgumentException InvalidParameter InvalidArgument 'LacpDistributeUplinkPorts' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($Params.LacpDistributeUplinkPorts) + { + + "[{0}] Setting LACP load balance algorithm to: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Params.LacpDistributeUplinkPorts | Write-Verbose + + if ($Params.LacpDistributeUplinkPorts) + { + + $_UplinkSetObject | Add-Member -NotePropertyName lagPortBalance -NotePropertyValue "Enabled" + + } + + else + { + + $_UplinkSetObject | Add-Member -NotePropertyName lagPortBalance -NotePropertyValue "Disabled" + + } + + } + + if ($Params.NetworkSets) + { + + ForEach ($_netset in $Params.NetworkSets) + { + + if (-not $Params.CopyNetworksFromNetworkSet) + { + + if ($_netset.category -ne $ResourceCategoryEnum.NetworkSet) + { + + $ExceptionMessage = "The provided network set resource '{0}' is not an expected network set resource." -f $_netset.ToString() + $ErrorRecord = New-ErrorRecord HPEOneView.UplinkSetResourceException InvalidNetworkSetResource InvalidArgument 'NetworkSets' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + else + { + + "[{0}] Adding {1} ({2}) network set." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_netset.name, $_netset.uri | Write-Verbose + + [void]$_UplinkSetObject.networkSetUris.Add($_netset.uri) + + } + + } + + "[{0}] Copying network uris from network set." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_netset.Name | Write-Verbose + + ForEach ($_uri in $_netset.networkUris) + { + + # Check for duplicate entry + if (-not $_UplinkSetObject.networkUris.Contains($_uri)) + { + + "[{0}] Adding {1} to networkUris." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_uri | Write-Verbose + + [void]$_UplinkSetObject.networkUris.Add($_uri) + + } + + else + { + + "[{0}] {1} already exists in networkUris. Skipping." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_uri | Write-Verbose + + } + + } + + } + + } + + if ($Params.NativeEthNetwork) + { + + "[{0}] Getting Native Ethernet Network Uri" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $_UplinkSetObject.nativeNetworkUri = GetNetworkUris -Networks $Params.NativeEthNetwork -ApplianceConnection $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + 'FibreChannel' + { + + $_UplinkSetObject.networkType = $UplinkSetNetworkTypeEnum[$Params.Type] + + # Need to identify the module being used. This dictates the fcMode property + $_IcmType = GetIcmType -InputObject $_InputObject -Port @($Params.UplinkPorts[0]) + + if ($Params.EnableTrunking -and $_IcmType -eq [InterconnectModuleFamilyTypeEnum]::FibreChannel) + { + + $_UplinkSetObject.fcMode = 'TRUNK' + + } + + elseif ($_IcmType -eq [InterconnectModuleFamilyTypeEnum]::FibreChannel) + { + + $_UplinkSetObject.fcMode = 'NONE' + + } + + elseif ($_IcmType -eq [InterconnectModuleFamilyTypeEnum]::FlexFabric) + { + + $_UplinkSetObject.fcMode = 'NA' + + } + + $_UplinkSetObject.loadBalancingMode = "None" + + } + + } + + # Add DCBx override setting, only supported with Synergy + if ($_InputObject.enclosureType -match 'SY') + { + + $_UplinkSetObject | Add-Member -NotePropertyName dcbxOverride -NotePropertyValue (NewObject -DCBxOverride) + + if ($Params.DCBxOverride) + { + + "[{0}] Overriding DCBx settings" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_UplinkSetObject.dcbxOverride.enabled = $true + + ForEach ($DCBxVersion in $Params.RoCEVersion) + { + + "[{0}] DCBxVersion override: '{1}'" -f $MyInvocation.InvocationName.ToString().ToUpper(), $DCBxVersion | Write-Verbose + + $_UplinkSetObject.dcbxOverride.$DCBxVersion = $true + + } + + } + + } + + "[{0}] {1} Uplink Set object: {2}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_InputObject.name, ($_UplinkSetObject | convertto-json -depth 99) | Write-Verbose + + Return $_UplinkSetObject + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function GetIcmType +{ + + [OutputType([InterconnectModuleFamilyTypeEnum])] + [CmdletBinding (DefaultParameterSetName = "PipelineOrObjectEthernet")] + Param + ( + [Parameter (Mandatory)] + $InputObject, + + [Parameter (Mandatory = $false)] + $Port + + ) + + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + } + + Process + { + + if ($PSBoundParameters['Port']) + { + + $_Port = [RegEx]::Match($Port.ToLower(), $UplinkPortParameterRegExPattern) + + [Int]$_EnclosureID = $_Port.Groups['Enclosure'].Value.ToLower().TrimStart('enclosure') + [String]$_Bay = $_Port.Groups['Bay'].Value.ToLower().TrimStart('bay') + [String]$_UplinkPort = $_Port.Groups['FaceplatePort'].Value + + } + + Switch ($InputObject.Category) + { + + $ResourceCategoryEnum.LogicalInterconnectGroup + { + + $InterconnectMapParentProperty = 'interconnectMapTemplate' + $InterconnectMapEntryProperty = 'interconnectMapEntryTemplates' + $LocationProperty = "logicalLocation" + $ValueProperty = 'relativeValue' + + } + + $ResourceCategoryEnum.LogicalInterconnect + { + + $InterconnectMapParentProperty = 'interconnectMap' + $InterconnectMapEntryProperty = 'interconnectMapEntries' + $LocationProperty = 'location' + $ValueProperty = 'value' + + } + + $ResourceCategoryEnum.SasLogicalInterconnect + { + + $InterconnectMapParentProperty = 'interconnectMap' + $InterconnectMapEntryProperty = 'interconnectMapEntries' + $LocationProperty = 'location' + $ValueProperty = 'value' + + } + + } + + # For Synergy, need to filter based on EnclosureIndex + if ($_EnclosureId -gt 0) + { + + $InterconnectMapEntries = $InputObject.$InterconnectMapParentProperty.$InterconnectMapEntryProperty | ? EnclosureIndex -eq $_EnclosureID + + } + + else + { + + $InterconnectMapEntries = $InputObject.$InterconnectMapParentProperty.$InterconnectMapEntryProperty + + } + + ForEach ($Entry in $InterconnectMapEntries) + { + + $FoundLocation = $false + + if ($PSBoundParameters['Port']) + { + + ForEach ($LocationEntry in $Entry.$LocationProperty.locationEntries) + { + + if ($LocationEntry.type -eq 'Bay' -and $LocationEntry.$ValueProperty -eq $_Bay) + { + + $FoundLocation = $True + + break + + } + + } + + } + + if (-not $PSBoundParameters['Port'] -or $FoundLocation) + { + + '[{0}] Getting InterconnectTypeUri: {1}' -f $MyInvocation.InvocationName.ToString().ToUpper(), $Entry.permittedInterconnectTypeUri | Write-Verbose + + Try + { + + $IcmType = Send-OVRequest -Uri $Entry.permittedInterconnectTypeUri -Hostname $InputObject.ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + Switch ($IcmType.PartNumber) + { + + # HPE VC 16Gb 24-Port FC Module 751465-B21 + # Virtual Connect SE 16Gb FC Module for Synergy 779227-B21 + # Virtual Connect SE 32Gb FC Module for Synergy 876259-B21 + {'751465-B21', '779227-B21', '876259-B21', '572018-B21', '466482-B21' -Contains $_} + { + + [InterconnectModuleFamilyTypeEnum]::FibreChannel + + } + + '755985-B21' + { + + [InterconnectModuleFamilyTypeEnum]::SAS + + } + + {'794502-B23', '779215-B21', '779218-B21', '779224-B23', '867793-B21', '867796-B21', '455880-B21', '638526-B21', '571956-B21', '691367-B21' -Contains $_} + { + + [InterconnectModuleFamilyTypeEnum]::FlexFabric + + } + + # Everything else + default + { + + [InterconnectModuleFamilyTypeEnum]::Unsupported + + } + + } + + } + + if ($FoundLocation) + { + + Break + + } + + } + + } + + End + { + + '[{0}] Done.' -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function New-OVUplinkSet +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "PipelineOrObjectEthernet")] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = "PipelineOrObjectEthernet")] + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = "PipelineOrObjectFibreChannel")] + [Parameter (Mandatory = $false, ParameterSetName = "Passthru")] + [Alias ('li','lig','ligName','Resource')] + [Object]$InputObject, + + [Parameter (Mandatory, ParameterSetName = "PipelineOrObjectFibreChannel")] + [Parameter (Mandatory, ParameterSetName = "PipelineOrObjectEthernet")] + [Parameter (Mandatory, ParameterSetName = "Passthru")] + [Alias ('usName')] + [String]$Name, + + [Parameter (Mandatory, ParameterSetName = "PipelineOrObjectFibreChannel")] + [Parameter (Mandatory, ParameterSetName = "PipelineOrObjectEthernet")] + [Parameter (Mandatory, ParameterSetName = "Passthru")] + [Alias ('usType')] + [ValidateSet ("Ethernet", "FibreChannel", "Untagged", "Tunnel", 'ImageStreamer', IgnoreCase = $false)] + [String]$Type, + + [Parameter (Mandatory = $false, ParameterSetName = "PipelineOrObjectFibreChannel")] + [Parameter (Mandatory = $false, ParameterSetName = "PipelineOrObjectEthernet")] + [Parameter (Mandatory = $false, ParameterSetName = "Passthru")] + [Alias ('usNetworks')] + [ValidateNotNullorEmpty()] + [Array]$Networks, + + [Parameter (Mandatory = $false, ParameterSetName = "PipelineOrObjectEthernet")] + [Parameter (Mandatory = $false, ParameterSetName = "Passthru")] + [Alias ('usNativeEthNetwork','Native','PVID')] + [ValidateNotNullorEmpty()] + [Object]$NativeEthNetwork, + + [Parameter (Mandatory = $false, ParameterSetName = "PipelineOrObjectEthernet")] + [Parameter (Mandatory = $false, ParameterSetName = "Passthru")] + [ValidateNotNullorEmpty()] + [Array]$NetworkSets, + + [Parameter (Mandatory = $false, ParameterSetName = "PipelineOrObjectEthernet")] + [Parameter (Mandatory = $false, ParameterSetName = "Passthru")] + [Switch]$CopyNetworksFromNetworkSet, + + [Parameter (Mandatory = $false, ParameterSetName = "PipelineOrObjectFibreChannel")] + [Parameter (Mandatory = $false, ParameterSetName = "PipelineOrObjectEthernet")] + [Parameter (Mandatory = $false, ParameterSetName = "Passthru")] + [Alias ('usUplinkPorts')] + [ValidateScript({($_.Split(","))[0].contains(":")})] + [Array]$UplinkPorts, + + [Parameter (Mandatory = $false, ParameterSetName = "PipelineOrObjectEthernet")] + [Parameter (Mandatory = $false, ParameterSetName = "Passthru")] + [Alias ('usEthMode')] + [ValidateSet ("Auto", "Failover", IgnoreCase=$false)] + [String]$EthMode = "Auto", + + [Parameter (Mandatory = $false, ParameterSetName = "PipelineOrObjectEthernet")] + [Parameter (Mandatory = $false, ParameterSetName = "Passthru")] + [ValidateSet ("Short", "Long", IgnoreCase=$false)] + [String]$LacpTimer = "Short", + + [Parameter (Mandatory = $false, ParameterSetName = "PipelineOrObjectEthernet")] + [Parameter (Mandatory = $false, ParameterSetName = "Passthru")] + [ValidateSet ("None", "DestinationIp", "DestinationMac", "SourceAndDestinationIp", "SourceAndDestinationMac", "SourceIp", "SourceMac", IgnoreCase = $false)] + [String]$LacpLoadbalancingMode = "None", + + [Parameter (Mandatory = $false, ParameterSetName = "PipelineOrObjectEthernet")] + [Parameter (Mandatory = $false, ParameterSetName = "Passthru")] + [ValidateSet ("None", "AllActiveUplinksOffline", "FailoverActiveMemberThreshold", "FailoverBandwidthThreshold", IgnoreCase = $false)] + [String]$LacpFailoverTrigger, + + [Parameter (Mandatory = $false, ParameterSetName = "PipelineOrObjectEthernet")] + [Parameter (Mandatory = $false, ParameterSetName = "Passthru")] + [Bool]$LacpDistributeUplinkPorts, + + [Parameter (Mandatory = $false, ParameterSetName = "PipelineOrObjectEthernet")] + [Parameter (Mandatory = $false, ParameterSetName = "Passthru")] + [ValidateRange (1, 100)] + [Int]$LacpFailoverBandwidthThreshold, + + [Parameter (Mandatory = $false, ParameterSetName = "PipelineOrObjectEthernet")] + [Parameter (Mandatory = $false, ParameterSetName = "Passthru")] + [ValidateRange (1, 16)] + [Int]$LacpFailoverActiveMemberThreshold, + + [Parameter (Mandatory = $false, ParameterSetName = "PipelineOrObjectEthernet")] + [Parameter (Mandatory = $false, ParameterSetName = "Passthru")] + [ValidateScript({$_.contains(":")})] + [String]$PrimaryPort, + + [Parameter (Mandatory = $false, ParameterSetName = "PipelineOrObjectEthernet")] + [Parameter (Mandatory = $false, ParameterSetName = "Passthru")] + [ValidateNotNullorEmpty()] + [Bool]$DCBXOverride, + + [Parameter (Mandatory = $false, ParameterSetName = "PipelineOrObjectEthernet")] + [Parameter (Mandatory = $false, ParameterSetName = "Passthru")] + [ValidateSet ("RoCEV1", "RoCEV2")] + [String[]]$RoCEVersion, + + [Parameter (Mandatory = $false, ParameterSetName = "PipelineOrObjectFibreChannel")] + [Parameter (Mandatory = $false, ParameterSetName = "Passthru")] + [ValidateSet ("Auto", "100M", "1G", "10G", "40G", "100G", IgnoreCase = $false)] + [String]$PortSpeed = "Auto", + + [Parameter (Mandatory = $false, ParameterSetName = "PipelineOrObjectFibreChannel")] + [Parameter (Mandatory = $false, ParameterSetName = "Passthru")] + [ValidateSet ("Auto", "Cl108", "Cl74", "Cl91", "None", IgnoreCase = $false)] + [String]$FecMode, + + [Parameter (Mandatory = $false, ParameterSetName = "PipelineOrObjectFibreChannel")] + [Parameter (Mandatory = $false, ParameterSetName = "Passthru")] + [ValidateSet ("Auto", "2", "4", "8", "16", "32", IgnoreCase = $false)] + [String]$FcUplinkSpeed = "Auto", + + [Parameter (Mandatory = $false, ParameterSetName = "PipelineOrObjectFibreChannel")] + [Parameter (Mandatory = $false, ParameterSetName = "Passthru")] + [Bool]$EnableTrunking, + + [Parameter (Mandatory = $false, ValueFromPipelinebyPropertyName, ParameterSetName = "PipelineOrObjectEthernet")] + [Parameter (Mandatory = $false, ValueFromPipelinebyPropertyName, ParameterSetName = "PipelineOrObjectFibreChannel")] + [Parameter (Mandatory = $false, ValueFromPipelinebyPropertyName, ParameterSetName = "Passthru")] + [ValidateSet ('Exact', 'None')] + [String]$ConsistencyChecking, + + [Parameter (Mandatory, ParameterSetName = "Passthru")] + [Switch]$Passthru, + + [Parameter (Mandatory = $false, ValueFromPipelinebyPropertyName, ParameterSetName = "PipelineOrObjectEthernet")] + [Parameter (Mandatory = $false, ValueFromPipelinebyPropertyName, ParameterSetName = "PipelineOrObjectFibreChannel")] + [Switch]$Async, + + [Parameter (Mandatory = $false, ValueFromPipelinebyPropertyName, ParameterSetName = "PipelineOrObjectEthernet")] + [Parameter (Mandatory = $false, ValueFromPipelinebyPropertyName, ParameterSetName = "PipelineOrObjectFibreChannel")] + [Parameter (Mandatory = $false, ValueFromPipelinebyPropertyName, ParameterSetName = "Passthru")] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not($PSBoundParameters['InputObject']) -and $PSCmdlet.ParameterSetName -ne 'Passthru') + { + + $PipelineInput = $true + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + } + + Process + { + + # Display obselete message if the connection is a VM, not Synergy + [ObsoleteMessage]::Write($ApplianceConnection) + + $UplinkSetPassthru = [System.Collections.Hashtable]::new() + + Switch ($PSBoundParameters.keys) + { + + 'PortSpeed' + { + + $UplinkSetPassthru.Add("PortSpeed", $PortSpeed) + + } + + 'FecMode' + { + + $UplinkSetPassthru.Add("FecMode", $FecMode) + + } + + 'Name' + { + + $UplinkSetPassthru.Add("Name", $Name) + + } + + 'Type' + { + + $UplinkSetPassthru.Add("Type", $Type) + + } + + 'Networks' + { + + $UplinkSetPassthru.Add("Networks", $Networks) + + } + + 'NativeEthNetwork' + { + + $UplinkSetPassthru.Add("NativeEthNetwork", $NativeEthNetwork) + + } + + 'NetworkSets' + { + + $UplinkSetPassthru.Add("NetworkSets", $NetworkSets) + + if ($PSBoundParameters['CopyNetworksFromNetworkSet']) + { + + $UplinkSetPassthru.Add("CopyNetworksFromNetworkSet", $CopyNetworksFromNetworkSet) + + } + + } + + 'EthMode' + { + + $UplinkSetPassthru.Add("EthMode", $EthMode) + + } + + 'LacpTimer' + { + + $UplinkSetPassthru.Add("LacpTimer", $LacpTimer) + + } + + 'LacpLoadbalancingMode' + { + + $UplinkSetPassthru.Add("LacpLoadbalancingMode", $LacpLoadbalancingMode) + + } + + 'UplinkPorts' + { + + $UplinkSetPassthru.Add("UplinkPorts", $UplinkPorts) + + } + + 'PrimaryPort' + { + + $UplinkSetPassthru.Add("PrimaryPort", $PrimaryPort) + + } + + 'FcUplinkSpeed' + { + + $UplinkSetPassthru.Add("FcUplinkSpeed", $FcUplinkSpeed) + + } + + 'EnableTrunking' + { + + $UplinkSetPassthru.Add("EnableTrunking", $EnableTrunking) + + } + + 'ConsistencyChecking' + { + + $UplinkSetPassthru.Add("ConsistencyChecking", $ConsistencyChecking) + + } + + 'LacpFailoverActiveMemberThreshold' + { + + $UplinkSetPassthru.Add("LacpFailoverActiveMemberThreshold", $LacpFailoverActiveMemberThreshold) + + } + + 'LacpFailoverTrigger' + { + + $UplinkSetPassthru.Add("LacpFailoverTrigger", $LacpFailoverTrigger) + + } + + 'LacpDistributeUplinkPorts' + { + + $UplinkSetPassthru.Add("LacpDistributeUplinkPorts", $LacpDistributeUplinkPorts) + + } + + 'LacpFailoverBandwidthThreshold' + { + + $UplinkSetPassthru.Add("LacpFailoverBandwidthThreshold", $LacpFailoverBandwidthThreshold) + + } + + 'DCBxOverride' + { + + $UplinkSetPassthru.Add("DCBxOverride", $DCBXOverride) + $UplinkSetPassthru.Add("RoCEVersion", $RoCEVersion) + + } + + } + + if ($PSBoundParameters['Passthru']) + { + + $UplinkSetPassthru + + } + + else + { + + if ((${Global:ConnectedSessions} | Where-Object Name -eq $ApplianceConnection.Name).ApplianceType -ne 'Composer' -and $Type -eq 'ImageStreamer') + { + + $Exceptionmessage = 'The ApplianceConnection {0} is not a Synergy Composer. The "ImageStreamer" Type is only supported with HPE Synergy.' -f $ApplianceConnection.Name + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.ComposerNodeException InvalidOperation InvalidOperation 'ApplianceConnection' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ((${Global:ConnectedSessions} | Where-Object Name -eq $ApplianceConnection.Name).ApplianceType -ne 'Composer' -and $Type -eq 'Ethernet' -and $PSBoundParameters['LacpLoadbalancingMode']) + { + + $Exceptionmessage = 'The ApplianceConnection {0} is not a Synergy Composer. The "LacpLoadbalancingMode" parameter is only supported with HPE Synergy Virtual Connect.' -f $ApplianceConnection.Name + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.ComposerNodeException InvalidOperation InvalidOperation 'ApplianceConnection' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ((${Global:ConnectedSessions} | Where-Object Name -eq $ApplianceConnection.Name).ApplianceType -ne 'Composer' -and $PSBoundParameters['FecMode']) + { + + $Exceptionmessage = 'The ApplianceConnection {0} is not a Synergy Composer. The "FecMode" parameter is only supported with HPE Synergy Virtual Connect SE 100Gb modules.' -f $ApplianceConnection.Name + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.ComposerNodeException InvalidOperation InvalidOperation 'ApplianceConnection' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ((${Global:ConnectedSessions} | Where-Object Name -eq $ApplianceConnection.Name).ApplianceType -ne 'Composer' -and $PSBoundParameters['DCBxOverride']) + { + + $Exceptionmessage = 'The ApplianceConnection {0} is not a Synergy Composer. The "DCBxOverride" parameter is only supported with HPE Synergy Virtual Connect modules.' -f $ApplianceConnection.Name + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.ComposerNodeException InvalidOperation InvalidOperation 'ApplianceConnection' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + else + { + + # If pipeline object is String and not PSCustomObject, fail the call + if ($InputObject -is [String] -or (-not($InputObject -is [PSCustomObject]))) + { + + "[{0}] Input Object is an unsupported type: {1}. Generating error." -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject.GetType().FullName | Write-Verbose + + $ExceptionMessage = "The -InputObject Parameter value type ({0}) provided is not a Logical Interconnect Group object. Please check the value and try again." -f $InputObject.GetType().Fullname + + $ErrorRecord = New-ErrorRecord ArgumentException InvalidParameter InvalidArgument 'InputObject' -TargetType 'PSObject' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($InputObject -is [PSCustomObject]) + { + + $_InputObject = $InputObject.PSObject.Copy() + + } + + # Validate the resource contains the ApplianceConnection NoteProperty + if (-not($InputObject.ApplianceConnection)) + { + + "[{0}] Input Object does not contain the ApplianceConnection NoteProperty, generating error." -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject.GetType().FullName | Write-Verbose + + $ExceptionMessage = "Input Object does not contain the ApplianceConnection NoteProperty. Please validate the object was retrieved from Get-OVLogicalInterconnectGroup or a resource URI via Send-OVRequest." + $ErrorRecord = New-ErrorRecord ArgumentException InvalidParameter InvalidArgument 'Type' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + # Determine the resource type; LIG or LI + switch ($InputObject.category) + { + + # Uplink Sets are created differently for LI Resources + $ResourceCategoryEnum.LogicalInterconnect + { + + Try + { + + $_liUplinkSetObject = BuildUplinkSet -InputObject $InputObject -Params $UplinkSetPassthru + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + "[{0}] {1} Uplink Set object: {2}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject.name, ($_liUplinkSetObject | convertto-json -depth 99) | Write-Verbose + + "[{0}] Sending request..." | Write-Verbose + + Try + { + + $resp = Send-OVRequest -Uri $UplinkSetsUri -Method POST -Body $_liUplinkSetObject -Hostname $InputObject.ApplianceConnection + + if (-not $PSBoundParameters['Async']) + { + + $resp | Wait-OVTaskComplete + + } + + else + { + + $resp + + } + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $ResourceCategoryEnum.LogicalInterconnectGroup + { + + '[{0}] Create uplink set for logical interconnect group: ' -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject.name | Write-Verbose + + $_NewUplinkSetCol = [System.Collections.ArrayList]::new() + + Try + { + + $_NewUplinkSet = BuildUplinkSet -InputObject $InputObject -Params $UplinkSetPassthru + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + # Rebuld uplinkset collection + "[{0}] {1} Rebuilding UplinkSet template collection." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_InputObject.name | Write-Verbose + + '[{0}] UplinkSets to readd: {1}' -f $MyInvocation.InvocationName.ToString().ToUpper(), $_InputObject.uplinkSets.Count | Write-Verbose + + ForEach ($_uplinkSet in $InputObject.uplinkSets) + { + + "[{0}] Saving Uplink Set object to new collection: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_uplinkSet.name | Write-Verbose + + [void]$_NewUplinkSetCol.Add($_uplinkSet) + + } + + [void]$_NewUplinkSetCol.Add($_NewUplinkSet) + + [Array]$_InputObject.uplinkSets = $_NewUplinkSetCol + + '[{0}] UplinkSets after rebuild: {1}' -f $MyInvocation.InvocationName.ToString().ToUpper(), $_InputObject.uplinkSets.Count | Write-Verbose + + '[{0}] Updated Resource: {1}' -f $MyInvocation.InvocationName.ToString().ToUpper(), ($_InputObject | ConvertTo-Json -Depth 99 | Out-String) | Write-Verbose + + '[{0}] Sending request...' -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $resp = Send-OVRequest -uri $_InputObject.uri -method PUT -Body $_InputObject -Hostname $InputObject.ApplianceConnection.Name + + if ($PSBoundParameters['Async']) + { + + $resp + + } + + else + { + + $resp | Wait-OVTaskComplete + + } + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + # Unsupported resource category + default + { + + $ExceptionMessage = "The Resource Parameter value provided is not a Logical Interconnect Group or Logical Interconnect object. Please check the value and try again." + $ErrorRecord = New-ErrorRecord ArgumentException InvalidParameter InvalidArgument 'Resource' -TargetType 'PSObject' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + } + + } + + } + + End + { + + '[{0}] Done.' -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Set-OVUplinkSet +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = 'Ethernet')] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = 'Ethernet')] + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = 'FibreChannel')] + [ValidateNotNullorEmpty()] + [Object]$InputObject, + + [Parameter (Mandatory = $false, ParameterSetName = 'Ethernet')] + [Parameter (Mandatory = $false, ParameterSetName = 'FibreChannel')] + [ValidateNotNullorEmpty()] + [String]$UplinkSetName, + + [Parameter (Mandatory = $false, ParameterSetName = 'Ethernet')] + [Parameter (Mandatory = $false, ParameterSetName = 'FibreChannel')] + [ValidateNotNullorEmpty()] + [String]$Name, + + [Parameter (Mandatory = $false, ParameterSetName = 'Ethernet')] + [ValidateNotNullorEmpty()] + [Object[]]$AddNetwork, + + [Parameter (Mandatory = $false, ParameterSetName = 'Ethernet')] + [ValidateNotNullorEmpty()] + [Object[]]$RemoveNetwork, + + [Parameter (Mandatory = $false, ParameterSetName = 'Ethernet')] + [ValidateNotNullorEmpty()] + [Object[]]$AddNetworkSet, + + [Parameter (Mandatory = $false, ParameterSetName = 'Ethernet')] + [ValidateNotNullorEmpty()] + [Object[]]$RemoveNetworkSet, + + [Parameter (Mandatory = $false, ParameterSetName = 'Ethernet')] + [Parameter (Mandatory = $false, ParameterSetName = 'FibreChannel')] + [ValidateNotNullorEmpty()] + [Object[]]$AddPorts, + + [Parameter (Mandatory = $false, ParameterSetName = 'Ethernet')] + [Parameter (Mandatory = $false, ParameterSetName = 'FibreChannel')] + [ValidateNotNullorEmpty()] + [Object[]]$RemovePorts, + + [Parameter (Mandatory = $false, ParameterSetName = 'Ethernet')] + [ValidateNotNullorEmpty()] + [Object]$UntaggedNetwork, + + [Parameter (Mandatory = $false, ParameterSetName = 'Ethernet')] + [ValidateSet ('Short', 'Long')] + [String]$LacpTimer, + + [Parameter (Mandatory = $false, ParameterSetName = 'FibreChannel')] + [ValidateNotNullorEmpty()] + [Bool]$EnableTrunking, + + [Parameter (Mandatory = $false, ParameterSetName = "Ethernet")] + [ValidateSet ("Auto", "100M", "1G", "10G", "40G", "100G", IgnoreCase = $false)] + [String]$PortSpeed = "Auto", + + [Parameter (Mandatory = $false, ParameterSetName = "Ethernet")] + [ValidateSet ("Auto", "Cl108", "Cl74", "Cl91", "None", IgnoreCase = $false)] + [String]$FecMode, + + # Will need to add this for the Cmdlet to support LIG Uplink Sets + [Parameter (Mandatory = $false, ParameterSetName = 'Ethernet')] + [Parameter (Mandatory = $false, ParameterSetName = 'FibreChannel')] + [ValidateSet ('Exact', 'None')] + [String]$ConsistencyChecking, + + [Parameter (Mandatory = $false, ValueFromPipelinebyPropertyName, ParameterSetName = 'Ethernet')] + [Parameter (Mandatory = $false, ValueFromPipelinebyPropertyName, ParameterSetName = 'FibreChannel')] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not($PSBoundParameters['InputObject'])) + { + + $PipelineInput = $True + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneView.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + # Check for URI Parameters with multiple appliance connections + if($ApplianceConnection.Count -gt 1) + { + + if ($InputObject -is [String] -and ($InputObject.StartsWith($NetworkSetsUri))) + { + + $ErrorRecord = New-ErrorRecord HPEOneView.NetworkResourceException InvalidArgumentValue InvalidArgument 'InputObject' -Message "The InputObject Parameter as URI is unsupported with multiple appliance connections. Please check the -NetworkSet Parameter value and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + if (($Networks -is [String] -and $Networks.startswith($EthernetNetworksUri)) -or ($Networks -is [Array] -and ($Networks | ForEach-Object { $_.startswith($EthernetNetworksUri) }))) + { + + $ErrorRecord = New-ErrorRecord HPEOneView.NetworkResourceException InvalidArgumentValue InvalidArgument 'Networks' -TargetType $Networks.GetType().Name -Message "Networks Parameter contains 1 or more URIs that are unsupported with multiple appliance connections. Please check the -networks Parameter value and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + if ($UntaggedNetwork -is [String] -and $UntaggedNetwork.startswith($EthernetNetworksUri)) + { + + $ErrorRecord = New-ErrorRecord HPEOneView.NetworkResourceException InvalidArgumentValue InvalidArgument 'Untaggednetwork' -Message "Untaggednetwork Parameter as URI is unsupported with multiple appliance connections. Please check the -untaggednetwork Parameter value and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneView.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneView.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + $_TaskCollection = [System.Collections.ArrayList]::new() + + } + + Process + { + + # Display obselete message if the connection is a VM, not Synergy + [ObsoleteMessage]::Write($ApplianceConnection) + + $OriginalCategory = $null + + # Workaround for incorrect category type for uplink sets + if ($InputObject.type -eq 'uplink-setV7') + { + + $OriginalCategory = $InputObject.category.Clone() + $InputObject.category = 'uplink-sets' + + } + + # Process Network Set input object is the correct resource and data type. + switch ($InputObject.Gettype().Name) + { + + {"PSCustomObject", "Object", "Object[]" -contains $_} + { + + switch ($InputObject.category) + { + + $ResourceCategoryEnum.LogicalInterconnectGroup + { + + if (-not $PSBoundParameters['UplinkSetName']) + { + + $ExceptionMessage = "The -UplinkSetName parameter is required when trying to update/modify an uplink set associated with a logical interconnect group." + $ErrorRecord = New-ErrorRecord HPEOneView.UplinkSetResourceException InvalidArgumentValue InvalidArgument 'InputObject' -TargetType 'PSObject' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + "[{0}] Processing '{1}' ({2}) logical interconnect group resource, and its '{3}' uplink set." -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject.name, $InputObject.Uri, $UplinkSetName | Write-Verbose + + $_ObjectToUpdate = $InputObject.PSObject.Copy() + $_AssociatedLogicalResource = $InputObject.PSObject.Copy() + + $_UpdatedUplinkSet = $_ObjectToUpdate.uplinkSets | ? name -eq $UplinkSetName + + if ([String]::IsNullOrEmpty($_UpdatedUplinkSet)) + { + + $ExceptionMessage = "The uplink set name '{0}' was not found in the provided logical interconnect group." -f $UplinkSetName + $ErrorRecord = New-ErrorRecord HPEOneView.UplinkSetResourceException InvalidArgumentValue ObjectNotFound 'InputObject' -TargetType 'PSObject' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + $ResourceCategoryEnum.UplinkSet + { + + if ($InputObject.type -match 'uplink-set') + { + + "[{0}] Processing '{1}' ({2}) uplink set resource." -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject.name, $InputObject.Uri | Write-Verbose + + Try + { + + $_AssociatedLogicalResource = Send-OVRequest -Uri $InputObject.logicalInterconnectUri -Hostname $InputObject.ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError() + + } + + $_UpdatedUplinkSet = $InputObject.PSObject.Copy() + + } + + else + { + + $ExceptionMessage = "The provided InputObject resource contains an unsupported category type, '{0}'. Only '{1}' or '{2}' resources are allowed." -f $InputObject.category, $ResourceCategoryEnum.UplinkSet, $ResourceCategoryEnum.LogicalInterconnectGroup + $ErrorRecord = New-ErrorRecord HPEOneView.UplinkSetResourceException InvalidArgumentValue InvalidArgument 'InputObject' -TargetType 'PSObject' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + default + { + + $ExceptionMessage = "The provided InputObject resource contains an unsupported category type, '{0}'. Only '{1}' or '{2}' resources are allowed." -f $InputObject.category, $ResourceCategoryEnum.UplinkSet, $ResourceCategoryEnum.LogicalInterconnectGroup + $ErrorRecord = New-ErrorRecord HPEOneView.UplinkSetResourceException InvalidArgumentValue InvalidArgument 'InputObject' -TargetType 'PSObject' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + } + + default + { + + $ExceptionMessage = "[{0}] is an unsupported data type. Only [System.String] or [PSCustomObject] Network Set resources are allowed. Please check the -InputObject Parameter value and try again." -f $InputObject.gettype().name + $ErrorRecord = New-ErrorRecord HPEOneView.UplinkSetResourceException InvalidArgumentValue InvalidArgument 'InputObject' -TargetType $InputObject.GetType().Name -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + $_UpdatedNetworkUris = [System.Collections.ArrayList]::new() + $_UpdatedNetworkSetUris = [System.Collections.ArrayList]::new() + + # Rebuild the list of URIs + ForEach ($_OriginalNetUri in $_UpdatedUplinkSet.networkUris) + { + + [void]$_UpdatedNetworkUris.Add($_OriginalNetUri) + + } + + # Rebuild the list of URIs + ForEach ($_OriginalNetSetUri in $_UpdatedUplinkSet.networkSetUris) + { + + [void]$_UpdatedNetworkSetUris.Add($_OriginalNetSetUri) + + } + + switch ($PSBoundParameters.keys) + { + + 'PortSpeed' + { + + switch ($InputObject.category) + { + + $ResourceCategoryEnum.LogicalInterconnectGroup + { + + $PortConfigInfoPropertyName = 'logicalPortConfigInfos' + $LocationPropertyName = 'logicalLocation' + + } + + $ResourceCategoryEnum.UplinkSet + { + + $PortConfigInfoPropertyName = 'portConfigInfos' + $LocationPropertyName = 'location' + + } + + } + + "[{0}] Changing port speed to '{1}'." -f $MyInvocation.InvocationName.ToString().ToUpper(), $global:SetUplinkSetPortSpeeds[$PortSpeed] | Write-Verbose + + ForEach ($port in $_UpdatedUplinkSet.$PortConfigInfoPropertyName) + { + + $port.desiredSpeed = $global:SetUplinkSetPortSpeeds[$PortSpeed] + + } + + } + + 'FecMode' + { + + # Validate InputObject is a Synergy resource + if ($_AssociatedLogicalResource.enclosureType -notmatch "SY") + { + + $ExceptionMessage = "The '{0}' logical interconnect is not an HPE Synergy fabric module type. Forward error correction is only supported with the 'Virtual Connect SE 100Gb F32 Module for Synergy'." -f $_InputObject.name + $ErrorRecord = New-ErrorRecord ArgumentException InvalidParameter InvalidArgument 'Resource' -TargetType 'PSObject' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + else + { + + switch ($InputObject.category) + { + + $ResourceCategoryEnum.LogicalInterconnectGroup + { + + $PortConfigInfoPropertyName = 'logicalPortConfigInfos' + $LocationPropertyName = 'logicalLocation' + + } + + $ResourceCategoryEnum.UplinkSet + { + + $PortConfigInfoPropertyName = 'portConfigInfos' + $LocationPropertyName = 'location' + + } + + } + + "[{0}] Changing FEC mode to '{1}'." -f $MyInvocation.InvocationName.ToString().ToUpper(), $FecMode | Write-Verbose + + ForEach ($port in $_UpdatedUplinkSet.$PortConfigInfoPropertyName) + { + + $port.desiredFecMode = $UplinkPortFecModeEnum[$FecMode] + + } + + } + + } + + 'Name' + { + + "[{0}] Updating Network Set name to '$name'." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_UpdatedUplinkSet.name = $name + + } + + 'AddNetwork' + { + + $a = 1 + + ForEach ($_NetToAdd in $AddNetwork) + { + + switch ($_NetToAdd.GetType().Name) + { + + 'String' + { + + if ($_NetToAdd.startswith($EthernetNetworksUri)) + { + + "[{0}] Network [$a] is a URI: $_NetToAdd" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $_NetToAdd = Send-OVRequest -Uri $_NetToAdd -Appliance $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + elseif ($_NetToAdd -is [String]) + { + + "[{0}] Network [$a] is a Name: $_NetToAdd" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $_NetToAdd = Get-OVNetwork -Name $_NetToAdd -type Ethernet -appliance $ApplianceConnection -ErrorAction Stop + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + 'PSCustomObject' + { + + if ($_NetToAdd.category -eq $ResourceCategoryEnum.EthernetNetwork) + { + + "[{0}] Network [$a] is a type [PsCustomObject]" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + "[{0}] Network [$a] Name: $($_NetToAdd.name)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + "[{0}] Network [$a] uri: $($_NetToAdd.uri)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + else + { + + $ExceptionMessage = "Network '{0}' is not a supported type '{1}'. Network resource must be either [System.String] or [PsCustomObject]. Please correct the Parameter value and try again." -f $_NetToAdd.name, $_NetToAdd.gettype().fullname + $ErrorRecord = New-ErrorRecord HPEOneView.NetworkResourceException InvalidArgumentValue InvalidArgument 'AddNetwork' -TargetType $_NetToAdd.GetType().Name -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + default + { + + $ExceptionMessage = "The provided Network is not a supported type '$($_NetToAdd.gettype().fullname)'. Network resource must be either [System.String] or [PsCustomObject]. Please correct the Parameter value and try again." + $ErrorRecord = New-ErrorRecord HPEOneView.NetworkResourceException InvalidArgumentValue InvalidArgument 'AddNetwork' -TargetType $_NetToAdd.GetType().Name -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + "[{0}] Adding network '{1}' to Network Set" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_NetToAdd.name | Write-Verbose + + [void]$_UpdatedNetworkUris.Add($_NetToAdd.uri) + + $a++ + + } + + } + + 'AddNetworkSet' + { + + $a = 1 + + ForEach ($_NetSetToAdd in $AddNetworkSet) + { + + switch ($_NetSetToAdd.GetType().Name) + { + + 'String' + { + + if ($_NetSetToAdd.startswith($NetworkSetsUri)) + { + + "[{0}] Network Set [$a] is a URI: $_NetSetToAdd" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $_NetSetToAdd = Send-OVRequest -Uri $_NetSetToAdd -Appliance $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + elseif ($_NetSetToAdd -is [String]) + { + + "[{0}] Network Set [$a] is a Name: $_NetSetToAdd" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $_NetSetToAdd = Get-OVNetworkSet -Name $_NetSetToAdd -Appliance $ApplianceConnection -ErrorAction Stop + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + 'PSCustomObject' + { + + if ($_NetSetToAdd.category -eq $ResourceCategoryEnum.NetworkSet) + { + + "[{0}] Network [$a] is a type [PsCustomObject]" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + "[{0}] Network [$a] Name: $($_NetSetToAdd.name)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + "[{0}] Network [$a] uri: $($_NetSetToAdd.uri)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + else + { + + $ExceptionMessage = "Network Set '{0}' is not a supported type '{1}'. Network resource must be either [System.String] or [PsCustomObject]. Please correct the Parameter value and try again." -f $_NetSetToAdd.name, $_NetSetToAdd.gettype().fullname + $ErrorRecord = New-ErrorRecord HPEOneView.NetworkResourceException InvalidArgumentValue InvalidArgument 'AddNetworkSet' -TargetType $_NetSetToAdd.GetType().Name -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + default + { + + $ExceptionMessage = "The provided Network Set is not a supported type '{0}'. Network resource must be either [System.String] or [PsCustomObject]. Please correct the Parameter value and try again." -f $_NetSetToAdd.GetType().FullName + $ErrorRecord = New-ErrorRecord HPEOneView.NetworkResourceException InvalidArgumentValue InvalidArgument 'AddNetworkSet' -TargetType $_NetSetToAdd.GetType().Name -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + "[{0}] Adding network set '{1}' to Uplink Set" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_NetSetToAdd.name | Write-Verbose + + [void]$_UpdatedNetworkSetUris.Add($_NetSetToAdd.uri) + + ForEach ($_net in $_NetSetToAdd.networkUris) + { + + if (-not $_UpdatedNetworkUris.Contains($_net)) + { + + [void]$_UpdatedNetworkUris.Add($_net) + + } + + } + + $a++ + + } + + } + + 'RemoveNetwork' + { + + $r = 1 + + ForEach ($_NetToRemove in $RemoveNetwork) + { + + switch ($_NetToRemove.GetType().Name) + { + + 'String' + { + + if ($_NetToRemove.startswith($EthernetNetworksUri)) + { + + "[{0}] Network [$r] is a URI: $_NetToRemove" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $_NetToRemove = Send-OVRequest -Uri $_NetToRemove -Appliance $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + elseif ($_NetToRemove -is [String]) + { + + "[{0}] Network [$r] is a Name: $_NetToRemove" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $_NetToRemove = Get-OVNetwork -Name $_NetToRemove -Appliance $ApplianceConnection -ErrorAction Stop + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + 'PSCustomObject' + { + + if ($_NetToRemove.category -eq $ResourceCategoryEnum.EthernetNetwork) + { + + "[{0}] Network [$r] is a type [PsCustomObject]" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + "[{0}] Network [$r] Name: $($_NetToRemove.name)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + "[{0}] Network [$r] uri: $($_NetToRemove.uri)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + else + { + + $ExceptionMessage = "Network '{0}' is not a supported 'ethenet-network' resource type." -f $_NetToRemove.name, $_NetToRemove.name + $ErrorRecord = New-ErrorRecord HPEOneView.NetworkResourceException InvalidArgumentValue InvalidArgument 'RemoveNetwork' -TargetType $_NetToRemove.GetType().Name -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + default + { + + $ExceptionMessage = "The provided Network is not a supported type '{0}'. Network resource must be either [System.String] or [PSCustomObject]. Please correct the Parameter value and try again." -f $_NetToRemove.GetType().FullName + $ErrorRecord = New-ErrorRecord HPEOneView.NetworkResourceException InvalidArgumentValue InvalidArgument 'RemoveNetwork' -TargetType $_NetToRemove.GetType().Name -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + # TODO: Need to validate that the network to be removed here isn't a member of an assigned network set first. If os, throw terminating error + + "[{0}] Removing network '{1}' from Uplink Set" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_NetToRemove.name | Write-Verbose + + [void]$_UpdatedNetworkUris.Remove($_NetToRemove.uri) + + $r++ + + } + + } + + 'RemoveNetworkSet' + { + + $r = 1 + + ForEach ($_NetSetToRemove in $RemoveNetworkSet) + { + + switch ($_NetSetToRemove.GetType().Name) + { + + 'String' + { + + if ($_NetSetToRemove.startswith($NetworkSetsUri)) + { + + "[{0}] Network Set [$r] is a URI: $_NetSetToRemove" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $_NetSetToRemove = Send-OVRequest -Uri $_NetSetToRemove -Appliance $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + elseif ($_NetSetToRemove -is [String]) + { + + "[{0}] Network [$r] is a Name: $_NetSetToRemove" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $_NetSetToRemove = Get-OVNetworkSet -Name $_NetSetToRemove -Appliance $ApplianceConnection -ErrorAction Stop + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + 'PSCustomObject' + { + + if ($_NetSetToRemove.category -eq $ResourceCategoryEnum.NetworkSet) + { + + "[{0}] Network Set [$r] is a type [PsCustomObject]" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + "[{0}] Network Set [$r] Name: $($_NetSetToRemove.name)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + "[{0}] Network Set [$r] uri: $($_NetSetToRemove.uri)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + else + { + + $ExceptionMessage = "Network Set '{0}' is not a supported type '{1}'. Network resource must be either [System.String] or [PsCustomObject]. Please correct the Parameter value and try again." -f $_NetSetToRemove.name, $_NetSetToRemove.GetType().fullname + $ErrorRecord = New-ErrorRecord HPEOneView.NetworkResourceException InvalidArgumentValue InvalidArgument 'RemoveNetworkSet' -TargetType $_NetToRemove.GetType().Name -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + default + { + + $ExceptionMessage = "The provided Network is not a supported type '{0}'. Network resource must be either [System.String] or [PsCustomObject]. Please correct the Parameter value and try again." -f $_NetSetToRemove.GetType().FullName + $ErrorRecord = New-ErrorRecord HPEOneView.NetworkResourceException InvalidArgumentValue InvalidArgument 'RemoveNetworkSet' -TargetType $_NetSetToRemove.GetType().Name -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + "[{0}] Removing network set '{1}' from Uplink Set" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_NetSetToRemove.name | Write-Verbose + + [void]$_UpdatedNetworkSetUris.Remove($_NetSetToRemove.uri) + + "[{0}] Removing associated networks '{1}' from Uplink Set" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_NetSetToRemove.name | Write-Verbose + + ForEach ($_netUriToRemove in $_NetSetToRemove.networkUris) + { + + # Need to identify if the network to be removed is also a member of other network set(s) that also happen to be assigned to this uplink set. If it is, do not remove it. + "[{0}] Processing '{1}'" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_netUriToRemove | Write-Verbose + + # Lookup via index for net to netset association + Try + { + + $_Uri = '{0}?name=NETWORKSET_TO_NETWORK&childUri={1}' -f $AssociationsUri, $_netUriToRemove + + $_IndexResults = Send-OVRequest -Uri $_Uri + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $_found = $false + + ForEach ($_assignedNetworkSet in $_IndexResults.members) + { + + # If we find just one network set the network is assigned to that the network set is also assigned to this uplink set, we cannot remove the network from the uplink set. + if ($_ObjectToUpdate.networkSetUris -contains $_assignedNetworkSet.parentUri) + { + + $_found = $true + + } + + } + + if ($_found) + { + + "[{0}] Network is associated with {1} exsiting network set(s). Will not remove." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_IndexResults.count | Write-Verbose + + } + + else + { + + "[{0}] Removing network from uplink set." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + [void]$_UpdatedNetworkUris.Remove($_netUriToRemove) + + } + + } + + $r++ + + } + + } + + 'UntaggedNetwork' + { + + switch ($UntaggedNetwork.GetType().Name) + { + + 'String' + { + + if ($UntaggedNetwork.startswith($EthernetNetworksUri)) + { + + "[{0}] Untagged Network is a URI: $UntaggedNetwork" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $_UpdatedUplinkSet.nativeNetworkUri = (Send-OVRequest $UntaggedNetwork -Hostname $ApplianceConnection).uri + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + elseif ($UntaggedNetwork -is [String]) + { + + "[{0}] Untagged Network is a Name: $UntaggedNetwork" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $_networkObject = Get-OVNetwork -Name $UntaggedNetwork -type Ethernet -appliance $ApplianceConnection -ErrorAction Stop + + $_UpdatedUplinkSet.nativeNetworkUri = $_networkObject.uri + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + 'PSCustomObject' + { + + if ($UntaggedNetwork.category -eq $ResourceCategoryEnum.EthernetNetwork) + { + + "[{0}] Native Network is a type [PsCustomObject]" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + "[{0}] Native Network Name: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $UntaggedNetwork.name | Write-Verbose + "[{0}] Native Network uri: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $UntaggedNetwork.uri | Write-Verbose + + } + + else + { + + $"The UntaggedNetwork '{0}' is not a supported type '{1}'. Network resource must be either [System.String] or [PsCustomObject]. Please correct the Parameter value and try again." -f $UntaggedNetwork.name, $UntaggedNetwork.gettype().fullname + $ErrorRecord = New-ErrorRecord HPEOneView.NetworkResourceException InvalidArgumentValue InvalidArgument 'UntaggedNetwork' -TargetType $UntaggedNetwork.GetType().Name -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + $_UpdatedUplinkSet.nativeNetworkUri = $UntaggedNetwork.uri + + } + + default + { + + $ExceptionMessage = "The provided UntaggedNetwork is not a supported type '{0}'. Network resource must be either [System.String] or [PsCustomObject]. Please correct the Parameter value and try again." -f $UntaggedNetwork.gettype().fullname + $ErrorRecord = New-ErrorRecord HPEOneView.NetworkResourceException InvalidArgumentValue InvalidArgument 'UntaggedNetwork' -TargetType $UntaggedNetwork.GetType().Name -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + } + + 'AddPort' + { + + $a = 1 + + ForEach ($_PortToAdd in $AddPort) + { + + switch ($InputObject.category) + { + + $ResourceCategoryEnum.LogicalInterconnectGroup + { + + Try + { + + $_PortLocation = BuildLogicalPortConfigInfos -Port $_PortToAdd -LogicalInterconnectGroup $_AssociatedLogicalResource -ApplianceConnection $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $_UpdatedUplinkSet.logicalPortConfigInfos += $_PortLocation + + } + + $ResourceCategoryEnum.UplinkSet + { + + Try + { + + $_PortLocation = BuildLogicalPortConfigInfos -Port $_PortToAdd -LogicalInterconnectGroup $_AssociatedLogicalResource -ApplianceConnection $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $_Update.portConfigInfos += $_PortLocation + + } + + } + + } + + } + + 'RemovePort' + { + + switch ($InputObject.category) + { + + $ResourceCategoryEnum.LogicalInterconnectGroup + { + + $_Body = $_ObjectToUpdate + $_Uri = $_ObjectToUpdate.uri + + } + + $ResourceCategoryEnum.UplinkSet + { + + $_Body = $_UpdatedUplinkSet + $_Uri = $_UpdatedUplinkSet.uri + + } + + } + + $_PortParentConfigInfo + $_PortLocation + + } + + } + + $_UpdatedUplinkSet.networkUris = $_UpdatedNetworkUris + $_UpdatedUplinkSet.networkSetUris = $_UpdatedNetworkSetUris + + switch ($InputObject.category) + { + + $ResourceCategoryEnum.LogicalInterconnectGroup + { + + $_Body = $_ObjectToUpdate + $_Uri = $_ObjectToUpdate.uri + + } + + $ResourceCategoryEnum.UplinkSet + { + + $_Body = $_UpdatedUplinkSet + $_Uri = $_UpdatedUplinkSet.uri + + } + + } + + # Workaround for incorrect category type for uplink sets + if (-not [String]::IsNullOrEmpty($OriginalCategory)) + { + + $_Body.category = $OriginalCategory + + } + + Try + { + + $_results = Send-OVRequest -Uri $_Uri -Method PUT -Body $_Body -appliance $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + return $_results + + } + + End + { + + '[{0}] Done.' -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function GetNetworkUris +{ + + [CmdletBinding (DefaultParameterSetName = "Default")] + Param + ( + + [Parameter (Position = 0, Mandatory, ParameterSetName = "Default")] + [Array]$Networks, + + [Parameter (Position = 1, Mandatory, ParameterSetName = "Default")] + [Object]$ApplianceConnection + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + $_NetworkUris = [System.Collections.ArrayList]::new() + + } + + Process + { + + # Get Network URI's if values are of type String + ForEach ($_net in $Networks) + { + + "[{0}] _net Type is {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_net.GetType().FullName | Write-Verbose + + # Network is String and Name; call Get-OVNetwork + if ($_net -is [String] -and (-not($_net.StartsWith('/rest/')))) + { + + "[{0}] Network is type String, and Network Name" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + # Get Network Object + Try + { + + $_net = Get-OVNetwork -Name $_net -ApplianceConnection $ApplianceConnection -ErrorAction Stop + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + "[{0}] Found Network {1} ({2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_net.name, $_net.uri | Write-Verbose + + # Insert object into original arraylist + [void]$_NetworkUris.Add($_net.uri) + + } + + elseif ($_net -is [String] -and $_net.StartsWith('/rest/')) + { + + "[{0}] Network is type String, and URI of network." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + "[{0}] Adding URI to collection: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_net | Write-Verbose + + [void]$_NetworkUris.Add($_net) + + } + + elseif ($_net -is [PSCustomObject]) + { + + if (-not('HPEOneView.Networking.EthernetNetwork','HPEOneView.Networking.FCoENetwork','HPEOneView.Networking.Networks.FibreChannelNetwork' -contains $_net.PSObject.TypeNames[0])) + { + + "[{0}] Input object is not a valid Network type." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + "[{0}] Network '{1}' is [{2}]" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_net.name, $_net.GetType().Fullname | Write-Verbose + + [void]$_NetworkUris.Add($_net.uri) + + } + + } + + } + + End + { + + "[{0}] Network URIs: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), [String]::Join("," , $_NetworkUris.ToArray()) | Write-Verbose + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Return $_NetworkUris + + } + +} + +function BuildPortConfigInfos +{ + + [CmdLetBinding (DefaultParameterSetName = 'Default')] + Param + ( + + [Parameter (Mandatory, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [Object]$PortID, + + [Parameter (Mandatory, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [Object]$LogicalInterconnect + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $PortID | Write-Verbose + + } + + Process + { + + $_Port = [RegEx]::Match($PortID.ToLower(), $UplinkPortParameterRegExPattern) + + if (-not $_Port.Success) + { + + $ExceptionMessage = 'Unable to parse the provided UplinkPort value: {0}. Valid PortID value should either be Bay#:Q#, Bay#:Q#:1, Enclosure#:Bay#:Q# or Enclosure#:Bay#:Q#:# where # is an integer.' -f $PortID + $ErrorRecord = New-ErrorRecord HPEOneView.UplinkSetResourceException UnparseablePortIdValue InvalidArgument 'PortID' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + [Int]$_EnclosureID = $_Port.Groups['Enclosure'].Value.ToLower().TrimStart('enclosure') + [String]$_Bay = $_Port.Groups['Bay'].Value.ToLower().TrimStart('bay') + [String]$_UplinkPort = $_Port.Groups['FaceplatePort'].Value + + if ($_EnclosureID -eq 0) + { + + # This is for Synergy VCFC + if ([RegEx]::Match($_InputObject.enclosureType, 'SY', $RegExInsensitiveFlag).Success) + { + + "[{0}] Setting EnclosureID to -1 for Synergy VCFC." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + [Int]$_EnclosureID = -1 + + } + + else + { + + "[{0}] Setting EnclosureID to enclosureUris." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + [Int]$_EnclosureID = 1 + + } + + $_EnclosureUri = $_InputObject.enclosureUris + + } + + else + { + + $_EnclosureUri = $_InputObject.enclosureUris[$_EnclosureID - 1] + + } + + if (-not [String]::IsNullOrEmpty($_Port.Groups['Subport'].Value)) + { + + [String]$_UplinkPort = '{0}.{1}' -f $_Port.Groups['FaceplatePort'].Value, $_Port.Groups['Subport'].Value + + } + + '[{0}] Processing Frame/Enclosure "{1}", Bay "{2}", Port "{3}"' -f $MyInvocation.InvocationName.ToString().ToUpper(), $_EnclosureID, $_Bay, $_UplinkPort | Write-Verbose + + '[{0}] Looking for Interconnect URI for Bay "{1}"' -f $MyInvocation.InvocationName.ToString().ToUpper(), $_Bay | Write-Verbose + + # Loop through Interconnect Map Entry Template items looking for the provided Interconnet Bay number + ForEach ($_l in ($LogicalInterconnect.interconnectMap.interconnectMapEntries | Where-Object enclosureIndex -eq $_EnclosureID)) + { + + if ($_l.location.locationEntries | Where-Object { $_.type -eq "Bay" -and $_.value -eq $_Bay }) + { + + $_permittedIcUri = $_l.permittedInterconnectTypeUri + + "[{0}]] Found permitted Interconnect Type URI {1} for Bay {2}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_permittedIcUri, $_Bay | Write-Verbose + + } + + } + + # Generate error that Interconnect could not be found from the LI + if ($null -eq $_permittedIcUri) + { + + $ExceptionMessage = 'The Interconnect Bay ID {0} could not be identified within the provided Logical Interconnect resource object.' -f $_Bay + $ErrorRecord = New-ErrorRecord HPEOneView.UplinkSetResourceException UnsupportedLogicalInterconnectResource InvalidArgument 'InputObject' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + # Get Interconnect Type object in order to get relative port ID + Try + { + + $_interconnecttype = Send-OVRequest -Uri $_permittedIcUri -Hostname $LogicalInterconnect.ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + # Validate the Interconnect has capable Uplink Ports + if (-not ($_interconnecttype.portInfos | Where-Object uplinkCapable)) + { + + $ExceptionMessage = "The Interconnect/Fabric module in 'BAY{0}' has no uplink capable ports. Please check the value and try again." -f $_Bay, $_UplinkPort + $ErrorRecord = New-ErrorRecord HPEOneView.UplinkSetResourceException UnsupportedInterconnectResource InvalidArgument 'UplinkPorts' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + 'Looking for {0} port in portInfos Interconnect property.' -f $_UplinkPort | Write-Verbose + + # Translate the port number + $_portRelativeValue = $_interconnecttype.portInfos | Where-Object { $_.portName.Replace(':','.') -eq $_UplinkPort } + + # Didn't find relative port number, so generate terminating error + if (-not $_portRelativeValue) + { + + $ExceptionMessage = "The provided uplink port 'BAY{0}:{1}' is an invalid port ID. Did you mean 'X{1}' or 'Q{1}? Please check the value and try again." -f $_Bay, $_UplinkPort + $ErrorRecord = New-ErrorRecord HPEOneView.UplinkSetResourceException InvalidUplinkPortID InvalidArgument 'port' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + # Make sure the port found is uplinkCapable + if (-not $_portRelativeValue.uplinkCapable) + { + + $ExceptionMessage = "The provided uplink port 'BAY{0}:{1}' is not uplink capable. Please check the value and try again." -f $_Bay, $_UplinkPort + $ErrorRecord = New-ErrorRecord HPEOneView.UplinkSetResourceException UnsupportedUplinkPort InvalidArgument 'UplinkPorts' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + # Add uplink port + $_location = NewObject -UplinkSetLocation + + $_EnclosureLocation = NewObject -UplinkSetLocationEntry + $_EnclosureLocation.type = 'Enclosure' + $_EnclosureLocation.value = [String]$_EnclosureUri + [void]$_location.location.locationEntries.Add($_EnclosureLocation) + + $_BayLocation = NewObject -UplinkSetLocationEntry + $_BayLocation.type = 'Bay' + $_BayLocation.value = [Int]$_Bay + [void]$_location.location.locationEntries.Add($_BayLocation) + + $_PortLocation = NewObject -UplinkSetLocationEntry + $_PortLocation.type = 'Port' + $_PortLocation.value = [String]$_portRelativeValue.portName + [void]$_location.location.locationEntries.Add($_PortLocation) + + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Return $_location + + } + +} + +function BuildLogicalPortConfigInfos +{ + + [CmdLetBinding (DefaultParameterSetName = 'Default')] + Param + ( + + [Parameter (Mandatory, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [Object]$PortID, + + [Parameter (Mandatory, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [Object]$LogicalInterconnectGroup, + + [Parameter (Mandatory, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [Object]$ApplianceConnection + + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + } + + Process + { + + $_Port = [RegEx]::Match($PortID.ToLower(), $UplinkPortParameterRegExPattern) + + if (-not $_Port.Success) + { + + $ExceptionMessage = 'Unable to parse the provided UplinkPort value: {0}. Valid PortID value should either be Bay#:Q#, Bay#:Q#:1, Enclosure#:Bay#:Q# or Enclosure#:Bay#:Q#:# where # is an integer.' -f $PortID + $ErrorRecord = New-ErrorRecord HPEOneView.UplinkSetResourceException UnparseablePortIdValue InvalidArgument 'PortID' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + [Int]$_EnclosureID = $_Port.Groups['Enclosure'].Value.TrimStart('[E|e]nclosure') + [String]$_Bay = $_Port.Groups['Bay'].Value.TrimStart('[b|B]ay') + [String]$_UplinkPort = $_Port.Groups['FaceplatePort'].Value + + if ($_EnclosureID -eq 0) + { + + # This is for Synergy VCFC + if ([RegEx]::Match($_InputObject.enclosureType, 'SY', $RegExInsensitiveFlag).Success) + { + + "[{0}] Setting EnclosureID to -1 for Synergy VCFC" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + [Int]$_EnclosureID = -1 + + } + + else + { + + "[{0}] Setting EnclosureID to 1 for c-Class VC" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + [Int]$_EnclosureID = 1 + + } + + } + + if (-not [String]::IsNullOrEmpty($_Port.Groups['Subport'].Value)) + { + + [String]$_UplinkPort = '{0}.{1}' -f $_Port.Groups['FaceplatePort'].Value, $_Port.Groups['Subport'].Value + + } + + '[{0}] Processing Frame/Enclosure "{1}", Bay "{2}", Port "{3}"' -f $MyInvocation.InvocationName.ToString().ToUpper(), $_EnclosureID, $_Bay, $_UplinkPort | Write-Verbose + + "[{0}] Looking for Interconnect URI for Bay {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_Bay | Write-Verbose + + # Loop through Interconnect Map Entry Template items looking for the provided Interconnet Bay number + ForEach ($_l in ($LogicalInterconnectGroup.interconnectMapTemplate.interconnectMapEntryTemplates | Where-Object enclosureIndex -eq $_EnclosureID)) + { + + if ($_l.logicalLocation.locationEntries | Where-Object { $_.type -eq "Bay" -and $_.relativeValue -eq $_Bay }) + { + + $_permittedIcUri = $_l.permittedInterconnectTypeUri + + "[{0}]] Found permitted Interconnect Type URI {1} for Bay {2}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_permittedIcUri, $_Bay | Write-Verbose + + } + + } + + # Generate error that Interconnect could not be found from the LI + if ($null -eq $_permittedIcUri) + { + + $ExceptionMessage = 'The Interconnect Bay ID {0} could not be identified within the provided Logical Interconnect Group resource object.' -f $_Bay + $ErrorRecord = New-ErrorRecord HPEOneView.UplinkSetResourceException UnsupportedLogicalInterconnectResource InvalidArgument 'InputObject' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + # Get Interconnect Type object in order to get relative port ID + Try + { + + $_interconnecttype = Send-OVRequest -Uri $_permittedIcUri -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + # Validate the Interconnect has capable Uplink Ports + if (-not ($_interconnecttype.portInfos | Where-Object uplinkCapable)) + { + + $ExceptionMessage = "The Interconnect/Fabric module in 'BAY{0}' has no uplink capable ports. Please check the value and try again." -f $_Bay, $_UplinkPort + $ErrorRecord = New-ErrorRecord HPEOneView.UplinkSetResourceException UnsupportedInterconnectResource InvalidArgument 'UplinkPorts' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + 'Looking for {0} port in portInfos Interconnect property.' -f $_UplinkPort | Write-Verbose + + # Translate the port number + $_portRelativeValue = $_interconnecttype.portInfos | Where-Object { $_.portName.Replace(':','.') -eq $_UplinkPort } + + # Didn't find relative port number, so generate terminating error + if (-not $_portRelativeValue) + { + + $ExceptionMessage = "The provided uplink port 'BAY{0}:{1}' is an invalid port ID. Did you mean 'X{1}' or 'Q{1}? Please check the value and try again." -f $_Bay, $_UplinkPort + $ErrorRecord = New-ErrorRecord HPEOneView.UplinkSetResourceException InvalidUplinkPortID InvalidArgument 'port' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + # Make sure the port found is uplinkCapable + if (-not $_portRelativeValue.uplinkCapable) + { + + $ExceptionMessage = "The provided uplink port 'BAY{0}:{1}' is not uplink capable. Please check the value and try again." -f $_Bay, $_UplinkPort + $ErrorRecord = New-ErrorRecord HPEOneView.UplinkSetResourceException UnsupportedUplinkPort InvalidArgument 'UplinkPorts' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + # Add uplink port + $_logicalLocation = NewObject -UplinkSetLogicalLocation + + $_EnclosureLogicalLocation = NewObject -UplinkSetLogicalLocationEntry + $_EnclosureLogicalLocation.type = 'Enclosure' + $_EnclosureLogicalLocation.relativeValue = [Int]$_EnclosureID + + [void]$_logicalLocation.logicalLocation.locationEntries.Add($_EnclosureLogicalLocation) + + $_BayLogicalLocation = NewObject -UplinkSetLogicalLocationEntry + $_BayLogicalLocation.type = 'Bay' + $_BayLogicalLocation.relativeValue = [Int]$_Bay + + [void]$_logicalLocation.logicalLocation.locationEntries.Add($_BayLogicalLocation) + + $_PortLogicalLocation = NewObject -UplinkSetLogicalLocationEntry + $_PortLogicalLocation.type = 'Port' + $_PortLogicalLocation.relativeValue = [Int]$_portRelativeValue.portNumber + + [void]$_logicalLocation.logicalLocation.locationEntries.Add($_PortLogicalLocation) + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Return $_logicalLocation + + } + +} + +function Get-OVSwitchType +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = 'Name')] + [OutputType([HPEOneView.Networking.SwitchType])] + Param + ( + + [Parameter (Mandatory = $false, ParameterSetName = 'Name')] + [ValidateNotNullorEmpty()] + [String]$Name, + + [Parameter (Mandatory, ParameterSetName = 'PartNumber')] + [ValidateNotNullorEmpty()] + [String]$PartNumber, + + [Parameter (Mandatory = $false, ParameterSetName = 'Name')] + [Parameter (Mandatory = $false, ParameterSetName = 'PartNumber')] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $Collection = [System.Collections.ArrayList]::new() + $NotFound = [System.Collections.ArrayList]::new() + + } + + Process + { + + $_uri = '{0}?sort=name:asc' -f $SwitchTypesUri + + if ($PSboundParameters['Name']) + { + + $_uri += "&filter=name EQ '{0}'" -f $Name + + } + + elseif ($PSboundParameters['PartNumber']) + { + + $_uri += "&filter=partNumber EQ '{0}'" -f $PartNumber + + } + + + ForEach ($_appliance in $ApplianceConnection) + { + + "[{0}] Sending request" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $resp = Send-OVRequest -Uri $_uri -Appliance $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if ($resp.count -gt 0) + { + + ForEach ($_member in ($resp.members | Sort-Object name)) + { + + [HPEOneView.Networking.SwitchType]::new($_member.name, + $_member.partNumber, + $_member.minimumFirmwareVersion, + $_member.maximumFirmwareVersion, + $_member.uri, + $_member.ApplianceConnection) + + } + + } + + elseif (-not $resp.count -and $Name) + { + + $ExceptionMessage = "No Switch Types with '{0}' name were found on appliance '{1}'." -f $Name, $_appliance + $ErrorRecord = New-ErrorRecord HPEOneView.SwitchTypeResourceException SwitchTypeNameResourceNotFound ObjectNotFound 'Name' -Message $ExceptionMessage + $PSCmdlet.WriteError($ErrorRecord) + + } + + elseif (-not $resp.count -and $PartNumber) + { + + $ExceptionMessage = "No Switch Types with '{0}' partnumber were found on appliance '{1}'." -f $PartNumber, $_appliance + $ErrorRecord = New-ErrorRecord HPEOneView.SwitchTypeResourceException SwitchTypePartnumberResourceNotFound ObjectNotFound 'PartNumber' -Message $ExceptionMessage + $PSCmdlet.WriteError($ErrorRecord) + + } + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Get-OVLogicalSwitchGroup +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = 'Default')] + Param + ( + + [Parameter (ValueFromPipeline, Mandatory, ParameterSetName = 'Pipeline')] + [Object]$InputObject, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullorEmpty()] + [String]$Name, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [Object]$Scope = "AllResourcesInScope", + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [String]$Label, + + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = 'Pipeline')] + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default), + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [Alias ("x", "export")] + [ValidateScript({split-path $_ | Test-Path})] + [String]$exportFile + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if ($PSCmdlet.ParameterSetName -eq 'Pipeline') + { + + $PipelineInput = $True + + } + + Else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + $_Collection = [System.Collections.ArrayList]::new() + + } + + Process + { + + if ($PipelineInput) + { + + # Task Resource Object + if ($InputObject -is [PSCustomObject] -and $InputObject.category -eq $ResourceCategoryEnum.Task) + { + + "[{0}] Processig task resource to get created object" -f $MyInvocation.InvocationName.ToString().ToUpper() + + if ($InputObject.taskState -eq 'Completed') + { + + Try + { + + $_LogicalSwitchGroup = Send-OVRequest $InputObject.associatedResource.resourceUri -Hostname $InputObject.ApplianceConnection.Name + + $_LogicalSwitchGroup | ForEach-Object { + + $_.PSObject.TypeNames.Insert(0,'HPEOneView.Networking.LogicalSwitchGroup') + + [void]$_Collection.Add($_) + + } + + } + + Catch + { + + "[{0}] API Error Caught: $($_.Exception.Message)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + # Generate error + else + { + + $ErrorRecord = New-ErrorRecord HPEOneView.LogicalSwitchGroupResourceException TaskFailure InvalidOperation 'InputObject' -Message "The Task object provided by the pipeline did not complete successfully. Please validate the task object resource and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + else + { + + $ErrorRecord = New-ErrorRecord HPEOneView.LogicalSwitchGroupResourceException LogicalSwitchGroupNotFound ObjectNotFound 'InputObject' -Message "The Logical Switch Group associated with the pipeline input task object was not found on '$($InputObject.ApplianceConnection.Name)'. Please check the value and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + Else + { + + ForEach ($_appliance in $ApplianceConnection) + { + + "[{0}] Processing appliance {1} (of {2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name, $ApplianceConnection.Count | Write-Verbose + + $_Query = [System.Collections.ArrayList]::new() + + # Handle default cause of AllResourcesInScope + if ($Scope -eq 'AllResourcesInScope') + { + + "[{0}] Processing AllResourcesInScope." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_Scopes = $ApplianceConnection.ActivePermissions | Where-Object Active + + # If one scope contains 'AllResources' ScopeName "tag", then all resources should be returned regardless. + if ($_Scopes | Where-Object ScopeName -eq 'AllResources') + { + + $_ScopeNames = [String]::Join(', ', ($_Scopes | Where-Object ScopeName -eq 'AllResources').ScopeName) + + "[{0}] Scope(s) {1} is set to 'AllResources'. Will not add scope to URI query parameter." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_ScopeNames | Write-Verbose + + } + + # Process ApplianceConnection ActivePermissions collection + else + { + + Try + { + + $_ScopeQuery = Join-Scope $_Scopes + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + [Void]$_Query.Add(("({0})" -f $_ScopeQuery)) + + } + + } + + elseif ($Scope | Where-Object ScopeName -eq 'AllResources') + { + + $_ScopeNames = [String]::Join(', ', ($_Scopes | Where-Object ScopeName -eq 'AllResources').ScopeName) + + "[{0}] Scope(s) {1} is set to 'AllResources'. Will not add scope to URI query parameter." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_ScopeNames | Write-Verbose + + } + + elseif ($Scope -eq 'AllResources') + { + + "[{0}] Requesting scope 'AllResources'. Will not add scope to URI query parameter." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_ScopeNames | Write-Verbose + + } + + else + { + + Try + { + + $_ScopeQuery = Join-Scope $Scope + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + [Void]$_Query.Add(("({0})" -f $_ScopeQuery)) + + } + + if ($Name) + { + + if ($Name.Contains('*')) + { + + [Void]$_Query.Add(("name%3A{0}" -f $Name.Replace("*", "%2A").Replace(',','%2C').Replace(" ", "?"))) + + } + + else + { + + [Void]$_Query.Add(("name:'{0}'" -f $Name)) + + } + + } + + if ($Label) + { + + [Void]$_Query.Add(("labels:'{0}'" -f $Label)) + + } + + $_Category = 'category=logical-switch-groups' + + # Build the final URI + $_uri = '{0}?{1}&sort=name:asc&query={2}' -f $IndexUri, [String]::Join('&', $_Category), [String]::Join(' AND ', $_Query.ToArray()) + + Try + { + + [Array]$_ResourcesFromIndexCol = Get-AllIndexResources -Uri $_uri -ApplianceConnection $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if ($_ResourcesFromIndexCol.count -eq 0 -and $Name) + { + + $ExceptionMessage = "Logical Switch Group '{0}' resource not found on {1} appliance. Please check the name and try again." -f $Name, $_appliance.Name + + "[{0}] {1} Generating error" -f $MyInvocation.InvocationName.ToString().ToUpper(), $ExceptionMessage | Write-Verbose + + $ErrorRecord = New-ErrorRecord InvalidOperationException LogicalSwitchGroupNotFound ObjectNotFound 'Name' -Message $ExceptionMessage + $PSCmdlet.WriteError($ErrorRecord) + + } + + elseif ($_ResourcesFromIndexCol.count -eq 0) + { + + "[{0}] No Logical Switch Group resources found on {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name | Write-Verbose + + } + + else + { + + "[{0}] Found {1} Logical Switch Group resource(s)." -f $MyInvocation.InvocationName.ToString().ToUpper(), $ligs.count | Write-Verbose + + ForEach ($_member in $_ResourcesFromIndexCol) + { + + $_member.PSObject.TypeNames.Insert(0,'HPEOneView.Networking.LogicalSwitchGroup') + + [void]$_Collection.Add($_member) + + } + + } + + } + + } + + } + + End + { + + "[{0}] Done. $($_Collection.count) logical switch group(s) found." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if ($exportFile) + { + + $_Collection | convertto-json -Depth 99 | Set-Content -Path $exportFile -force -encoding UTF8 + + } + + else + { + + Return $_Collection | Sort-Object name + + } + + } + +} + +function New-OVLogicalSwitchGroup +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "Default")] + Param + ( + + [Parameter (Mandatory, ParameterSetName = "Default")] + [ValidateNotNullOrEmpty()] + [String]$Name, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [ValidateRange(1,2)] + [Int]$NumberOfSwitches = 1, + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = "Default")] + [ValidateNotNullOrEmpty()] + [HPEOneView.Networking.SwitchType]$SwitchType, + + [Parameter (Mandatory = $False, ValueFromPipelineByPropertyName, ParameterSetName = "Default")] + [Alias ('Appliance')] + [ValidateNotNullOrEmpty()] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default), + + [Parameter (Mandatory = $False, ParameterSetName = "Default")] + [Switch]$Async + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not $SwitchType) + { + + $PipelineInput = $true + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + } + + Process + { + + # Create new LIgObject + $_LogicalSwitchGroup = NewObject -LogicalSwitchGroup + $_LogicalSwitchGroup.name = $Name + + For ($i = 1; $i -le $NumberOfSwitches; $i++) + { + + "[{0}] Adding Location Entry {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $i | Write-Verbose + + $_SwitchLogicalLocation = NewObject -SwitchLogicalLocation + $_SwitchLogicalLocation.permittedSwitchTypeUri = $SwitchType.uri + + $_SwitchLocationEntry = NewObject -LocationEntry + $_SwitchLocationEntry.relativeValue = $i + $_SwitchLocationEntry.type = "StackingMemberId" + + [void]$_SwitchLogicalLocation.logicalLocation.locationEntries.Add($_SwitchLocationEntry) + [void]$_LogicalSwitchGroup.switchMapTemplate.switchMapEntryTemplates.Add($_SwitchLogicalLocation) + + } + + "[{0}] LS: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), (ConvertTo-Json -Depth 99 $_LogicalSwitchGroup | out-string) | Write-Verbose + + "{0}] Sending request to create '{1}'..." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_LogicalSwitchGroup.name | Write-Verbose + + Try + { + + $_Task = Send-OVRequest -Uri $LogicalSwitchGroupsUri -Method POST -Body $_LogicalSwitchGroup -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if (-not $Async.IsPresent) + { + + Try + { + + $_Task = Wait-OVTaskComplete -InputObject $_Task + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $_Task + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Remove-OVLogicalSwitchGroup +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdLetBinding (DefaultParameterSetName = "default", SupportsShouldProcess, ConfirmImpact = 'High')] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = "default")] + [ValidateNotNullOrEmpty()] + [Alias ("ls",'LogicalSwitchGroup')] + [Object]$InputObject, + + [Parameter (Mandatory = $False, ValueFromPipelineByPropertyName, ParameterSetName = "default")] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default), + + [Parameter (Mandatory = $false, ParameterSetName = "default")] + [Switch]$Force + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not($PSBoundParameters['InputObject'])) + { + + $PipelineInput = $True + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + $_lsgcollection = [System.Collections.ArrayList]::new() + + } + + Process + { + + if ($PipelineInput) + { + + "[{0}] Processing Pipeline input" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + "[{0}] Object provided: {1} ({2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject.name, $InputObject.uri | Write-Verbose + + If ('logical-switch-groups' -eq $InputObject.category) + { + + If (-not($InputObject.ApplianceConnection)) + { + + $ErrorRecord = New-ErrorRecord InvalidOperationException InvalidArgumentValue InvalidArgument "LSG:$($InputObject.Name)" -TargetType PSObject -Message "The Logical Switch Group resource provided is missing the source ApplianceConnection property. Please check the object provided and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + [void]$_lsgcollection.Add($InputObject) + + } + + else + { + + $ErrorRecord = New-ErrorRecord InvalidOperationException InvalidArgumentValue InvalidArgument "Network:$($InputObject.Name)" -TargetType PSObject -Message "The Logical Switch Group resource is not an expected category type [$($InputObject.category)]. Allowed resource category type is 'logical-switch-groups'. Please check the object provided and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + else + { + + foreach ($_resource in $InputObject) + { + + if ($_resource -is [String]) + { + + "[{0}] Received URI: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_resource | Write-Verbose + + $ExceptionMessage = "The provided Resource value is a String, only PSCustomObject types are supported." + $ErrorRecord = New-ErrorRecord InvalidOperationException UnsupportedParameterType InvalidArgumetn 'InputObject' -Message $ExceptionMessage + $PSCmdlet.WriteError($ErrorRecord) + + } + + # LIG passed is the object + elseif ($_resource -is [PSCustomObject] -and $ResourceCategoryEnum.LogicalSwitchGroup -eq $_resource.category) + { + + "[{0}] Object provided" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + [void]$_lsgcollection.Add($_resource) + + } + + elseif ($_resource -is [PSCustomObject] -and $ResourceCategoryEnum.LogicalSwitchGroup -ne $_resource.category) + { + + $ExceptionMessage = "Invalid Logical Switch Group Parameter: $($_resource )" + $ErrorRecord = New-ErrorRecord InvalidOperationException InvalidArgumentValue InvalidArgument 'InputObject' -TargetType 'PSObject' -Message $ExceptionMessage + $PSCmdlet.WriteError($ErrorRecord) + + } + + } + + } + + } + + End + { + + "[{0}] Processing $($_lsgcollection.count) resources to remove." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + # Process Resources + ForEach ($_lsg in $_lsgcollection) + { + + if ($PSCmdlet.ShouldProcess($_lsg.ApplianceConnection.Name,("Remove Logical Switch Group '{0}'" -f $_lsg.name))) + { + + "[{0}] Removing '$($_lsg.name)' from appliance '$($_lsg.ApplianceConnection.Name)'." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + if ($force.IsPresent) + { + + $_lsg.uri += "?force=true" + + } + + Send-OVRequest -Uri $_lsg.Uri -Method DELETE -AddHeader @{'If-Match' = $_lsg.eTag } -Hostname $_lsg.ApplianceConnection.Name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + elseif ($PSBoundParameters['WhatIf']) + { + + "[{0}] WhatIf Parameter was passed." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + } + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Get-OVLogicalSwitch +{ + + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = 'Default')] + Param + ( + + [Parameter (ValueFromPipeline, Mandatory, ParameterSetName = 'Pipeline')] + [Object]$InputObject, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullorEmpty()] + [String]$Name, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [Object]$Scope = "AllResourcesInScope", + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [String]$Label, + + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = 'Pipeline')] + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default), + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [Alias ("x", "export")] + [ValidateScript({split-path $_ | Test-Path})] + [String]$exportFile + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if ($PSCmdlet.ParameterSetName -eq 'Pipeline') + { + + $PipelineInput = $True + + } + + Else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + $_Collection = [System.Collections.ArrayList]::new() + + } + + Process + { + + if ($PipelineInput) + { + + # Task Resource Object + if ($InputObject -is [PSCustomObject] -and $InputObject.category -eq $ResourceCategoryEnum.Task) + { + + "[{0}] Processing task resource to get created object" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if ($InputObject.taskState -eq 'Completed') + { + + Try + { + + $_LogicalSwitchGroup = Send-OVRequest $InputObject.associatedResource.resourceUri -Hostname $InputObject.ApplianceConnection.Name + + $_LogicalSwitchGroup | ForEach-Object { + + $_.PSObject.TypeNames.Insert(0,'HPEOneView.Networking.LogicalSwitch') + + [void]$_Collection.Add($_) + + } + + } + + Catch + { + + "[{0}] API Error Caught: $($_.Exception.Message)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + # Generate error + else + { + + $InputObject + + $ErrorRecord = New-ErrorRecord HPEOneView.LogicalSwitchGroupResourceException TaskFailure InvalidOperation 'InputObject' -Message "The Task object provided by the pipeline did not complete successfully. Please validate the task object resource and try again." + $PSCmdlet.WriteError($ErrorRecord) + + } + + } + + else + { + + $ExceptionMessage = "The Logical Switch associated with the pipeline input task object was not found on '{0}'. Please check the value and try again." -f $InputObject.ApplianceConnection.Name + $ErrorRecord = New-ErrorRecord HPEOneView.LogicalSwitchResourceException LogicalSwitchNotFound ObjectNotFound 'InputObject' -Message $ExceptionMessage + $PSCmdlet.WriteError($ErrorRecord) + + } + + } + + Else + { + + ForEach ($_appliance in $ApplianceConnection) + { + + "[{0}] Processing appliance {1} (of {2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name, $ApplianceConnection.Count | Write-Verbose + + $_Query = [System.Collections.ArrayList]::new() + + # Handle default cause of AllResourcesInScope + if ($Scope -eq 'AllResourcesInScope') + { + + "[{0}] Processing AllResourcesInScope." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_Scopes = $ApplianceConnection.ActivePermissions | Where-Object Active + + # If one scope contains 'AllResources' ScopeName "tag", then all resources should be returned regardless. + if ($_Scopes | Where-Object ScopeName -eq 'AllResources') + { + + $_ScopeNames = [String]::Join(', ', ($_Scopes | Where-Object ScopeName -eq 'AllResources').ScopeName) + + "[{0}] Scope(s) {1} is set to 'AllResources'. Will not add scope to URI query parameter." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_ScopeNames | Write-Verbose + + } + + # Process ApplianceConnection ActivePermissions collection + else + { + + Try + { + + $_ScopeQuery = Join-Scope $_Scopes + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + [Void]$_Query.Add(("({0})" -f $_ScopeQuery)) + + } + + } + + elseif ($Scope | Where-Object ScopeName -eq 'AllResources') + { + + $_ScopeNames = [String]::Join(', ', ($_Scopes | Where-Object ScopeName -eq 'AllResources').ScopeName) + + "[{0}] Scope(s) {1} is set to 'AllResources'. Will not add scope to URI query parameter." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_ScopeNames | Write-Verbose + + } + + elseif ($Scope -eq 'AllResources') + { + + "[{0}] Requesting scope 'AllResources'. Will not add scope to URI query parameter." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_ScopeNames | Write-Verbose + + } + + else + { + + Try + { + + $_ScopeQuery = Join-Scope $Scope + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + [Void]$_Query.Add(("({0})" -f $_ScopeQuery)) + + } + + if ($Name) + { + + if ($Name.Contains('*')) + { + + [Void]$_Query.Add(("name%3A{0}" -f $Name.Replace("*", "%2A").Replace(',','%2C').Replace(" ", "?"))) + + } + + else + { + + [Void]$_Query.Add(("name:'{0}'" -f $Name)) + + } + + } + + if ($Label) + { + + [Void]$_Query.Add(("labels:'{0}'" -f $Label)) + + } + + $_Category = 'category=logical-switches' + + # Build the final URI + $_uri = '{0}?{1}&sort=name:asc&query={2}' -f $IndexUri, [String]::Join('&', $_Category), [String]::Join(' AND ', $_Query.ToArray()) + + Try + { + + [Array]$_ResourcesFromIndexCol = Get-AllIndexResources -Uri $_uri -ApplianceConnection $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if ($_ResourcesFromIndexCol.count -eq 0 -and $Name) + { + + "[{0}] No Logical Switch resources found on {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name | Write-Verbose + + $ExceptionMessage = "The Logical Switch '{0}' was not found on '{1}' appliance connection." -f $Name, $_appliance.Name + $ErrorRecord = New-ErrorRecord HPEOneView.LogicalSwitchResourceException LogicalSwitchNotFound ObjectNotFound 'InputObject' -Message $ExceptionMessage + $PSCmdlet.WriteError($ErrorRecord) + + } + + elseif ($_ResourcesFromIndexCol.count -eq 0) + { + + "[{0}] No Logical Switch resources found on {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name | Write-Verbose + + } + + else + { + + "[{0}] Found {1} Logical Switch resource(s)." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_ResourcesFromIndexCol.count | Write-Verbose + + ForEach ($_member in $_ResourcesFromIndexCol) + { + + $_member.PSObject.TypeNames.Insert(0,'HPEOneView.Networking.LogicalSwitch') + + [void]$_Collection.Add($_member) + + } + + } + + } + + } + + } + + End + { + + "[{0}] Done. {1} logical switch(es) found." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_Collection.count | Write-Verbose + + if ($exportFile) + { + + $_Collection | convertto-json -Depth 99 | Set-Content -Path $exportFile -force -encoding UTF8 + + } + + else + { + + Return $_Collection | Sort-Object name + + } + + } + +} + +function New-OVLogicalSwitch +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "Managed")] + Param + ( + + [Parameter (Mandatory, ParameterSetName = "Managed")] + [Parameter (Mandatory, ParameterSetName = "Monitored")] + [Parameter (Mandatory, ParameterSetName = "ManagedSnmpV3")] + [Parameter (Mandatory, ParameterSetName = "MonitoredSnmpV3")] + [ValidateNotNullOrEmpty()] + [String]$Name, + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = "Managed")] + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = "Monitored")] + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = "ManagedSnmpV3")] + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = "MonitoredSnmpV3")] + [ValidateNotNullOrEmpty()] + [Object]$LogicalSwitchGroup, + + [Parameter (Mandatory, ParameterSetName = "Managed")] + [Parameter (Mandatory, ParameterSetName = "ManagedSnmpV3")] + [Switch]$Managed, + + [Parameter (Mandatory, ParameterSetName = "Monitored")] + [Parameter (Mandatory, ParameterSetName = "MonitoredSnmpV3")] + [Switch]$Monitored, + + [Parameter (Mandatory, ParameterSetName = "Managed")] + [Parameter (Mandatory, ParameterSetName = "Monitored")] + [Parameter (Mandatory, ParameterSetName = "ManagedSnmpV3")] + [Parameter (Mandatory, ParameterSetName = "MonitoredSnmpV3")] + [ValidateNotNullOrEmpty()] + [String]$Switch1Address, + + [Parameter (Mandatory = $false, ParameterSetName = "Managed")] + [Parameter (Mandatory = $false, ParameterSetName = "Monitored")] + [Parameter (Mandatory = $false, ParameterSetName = "ManagedSnmpV3")] + [Parameter (Mandatory = $false, ParameterSetName = "MonitoredSnmpV3")] + [ValidateNotNullOrEmpty()] + [String]$Switch2Address, + + [Parameter (Mandatory, ParameterSetName = "Managed")] + [Parameter (Mandatory, ParameterSetName = "Monitored")] + [Parameter (Mandatory, ParameterSetName = "ManagedSnmpV3")] + [Parameter (Mandatory, ParameterSetName = "MonitoredSnmpV3")] + [ValidateNotNullOrEmpty()] + [String]$SshUserName, + + [Parameter (Mandatory, ParameterSetName = "Managed")] + [Parameter (Mandatory, ParameterSetName = "Monitored")] + [Parameter (Mandatory, ParameterSetName = "ManagedSnmpV3")] + [Parameter (Mandatory, ParameterSetName = "MonitoredSnmpV3")] + [ValidateNotNullOrEmpty()] + [Object]$SshPassword, + + [Parameter (Mandatory = $false, ParameterSetName = "Managed")] + [Parameter (Mandatory = $false, ParameterSetName = "Monitored")] + [Parameter (Mandatory = $false, ParameterSetName = "ManagedSnmpV3")] + [Parameter (Mandatory = $false, ParameterSetName = "MonitoredSnmpV3")] + [ValidateNotNullOrEmpty()] + [Int]$SnmpPort = 161, + + [Parameter (Mandatory = $false, ParameterSetName = "Managed")] + [Parameter (Mandatory = $false, ParameterSetName = "Monitored")] + [Switch]$SnmpV1, + + [Parameter (Mandatory, ParameterSetName = "Managed")] + [Parameter (Mandatory, ParameterSetName = "Monitored")] + [ValidateNotNullOrEmpty()] + [String]$SnmpCommunity, + + [Parameter (Mandatory = $false, ParameterSetName = "ManagedSnmpV3")] + [Parameter (Mandatory = $false, ParameterSetName = "MonitoredSnmpV3")] + [Switch]$SnmpV3, + + [Parameter (Mandatory = $false, ParameterSetName = "ManagedSnmpV3")] + [Parameter (Mandatory = $false, ParameterSetName = "MonitoredSnmpV3")] + [ValidateNotNullOrEmpty()] + [String]$SnmpUserName, + + [Parameter (Mandatory = $false, ParameterSetName = "ManagedSnmpV3")] + [Parameter (Mandatory = $false, ParameterSetName = "MonitoredSnmpV3")] + [ValidateSet ("AuthOnly","AuthAndPriv")] + [ValidateNotNullOrEmpty()] + [String]$SnmpAuthLevel = "AuthOnly", + + [Parameter (Mandatory = $false, ParameterSetName = "ManagedSnmpV3")] + [Parameter (Mandatory = $false, ParameterSetName = "MonitoredSnmpV3")] + [ValidateSet ("SHA","MD5")] + [ValidateNotNullOrEmpty()] + [String]$SnmpAuthProtocol = 'SHA', + + [Parameter (Mandatory = $false, ParameterSetName = "ManagedSnmpV3")] + [Parameter (Mandatory = $false, ParameterSetName = "MonitoredSnmpV3")] + [ValidateNotNullOrEmpty()] + [Object]$SnmpAuthPassword, + + [Parameter (Mandatory = $false, ParameterSetName = "ManagedSnmpV3")] + [Parameter (Mandatory = $false, ParameterSetName = "MonitoredSnmpV3")] + [ValidateSet ("aes128","des56")] + [ValidateNotNullOrEmpty()] + [String]$SnmpPrivProtocol, + + [Parameter (Mandatory = $false, ParameterSetName = "ManagedSnmpV3")] + [Parameter (Mandatory = $false, ParameterSetName = "MonitoredSnmpV3")] + [ValidateNotNullOrEmpty()] + [Object]$SnmpPrivPassword, + + [Parameter (Mandatory = $False, ParameterSetName = "Managed")] + [Parameter (Mandatory = $False, ParameterSetName = "Monitored")] + [Parameter (Mandatory = $False, ParameterSetName = "ManagedSnmpV3")] + [Parameter (Mandatory = $False, ParameterSetName = "MonitoredSnmpV3")] + [Switch]$Async, + + [Parameter (Mandatory = $False, ValueFromPipelineByPropertyName, ParameterSetName = "Managed")] + [Parameter (Mandatory = $False, ValueFromPipelineByPropertyName, ParameterSetName = "Monitored")] + [Parameter (Mandatory = $False, ValueFromPipelineByPropertyName, ParameterSetName = "ManagedSnmpV3")] + [Parameter (Mandatory = $False, ValueFromPipelineByPropertyName, ParameterSetName = "MonitoredSnmpV3")] + [Alias ('Appliance')] + [ValidateNotNullOrEmpty()] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not $LogicalSwitchGroup) + { + + $PipelineInput = $true + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + # Validate SNMPv3 Parameters that are required + if ('ManagedSnmpV3','MonitoredSnmpV3' -contains $PSCmdlet.ParameterSetName) + { + + if ($SnmpAuthLevel -eq "AuthOnly" -and + (-not $SnmpAuthProtocol -or + -not $SnmpAuthPassword)) + { + + # Generate Terminateing error + $ErrorRecord = New-ErrorRecord HPEOneView.LogicalSwitchResourceException MissingRequiredParameters InvalidArgument 'SnmpAuthLevel' -Message "The -SnmpAuthLevel Parameter was set to 'AuthOnly', but did not include both -SnmpAuthProtocol and -SnmpAuthPassword Parameters." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + } + + if ($SnmpAuthLevel -eq "AuthAndPriv" -and ( + -not $SnmpAuthProtocol -or + -not $SnmpAuthPassword -or + -not $SnmpPrivProtocol -or + -not $SnmpPrivPassword )) + { + + # Generate Terminateing error + $ErrorRecord = New-ErrorRecord HPEOneView.LogicalSwitchResourceException MissingRequiredParameters InvalidArgument 'SnmpAuthLevel' -Message "The -SnmpAuthLevel Parameter was set to 'AuthAndPriv', but did not include -SnmpAuthProtocol, -SnmpAuthPassword, -SnmpPrivProtocol and -SnmpPrivPassword Parameters." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + } + + Process + { + + # Create new LIgObject + $_LogicalSwitch = NewObject -LogicalSwitch + $_LogicalSwitch.logicalSwitch.name = $Name + $_LogicalSwitch.logicalSwitch.managementLevel = $LogicalSwitchManagementLevelEnum[$PSCmdlet.ParameterSetName] + + if ($SshPassword -is [SecureString]) + { + + $SshPassword = [Runtime.InteropServices.Marshal]::PtrToStringBSTR([Runtime.InteropServices.Marshal]::SecureStringToBSTR($SshPassword)) + + } + + if ($PSBoundParameters['SnmpAuthPassword'] -and $SnmpAuthPassword -is [SecureString]) + { + + $SnmpAuthPassword = [Runtime.InteropServices.Marshal]::PtrToStringBSTR([Runtime.InteropServices.Marshal]::SecureStringToBSTR($SnmpAuthPassword)) + + } + + if ($PSBoundParameters['SnmpPrivPassword'] -and $SnmpPrivPassword -is [SecureString]) + { + + $SnmpPrivPassword = [Runtime.InteropServices.Marshal]::PtrToStringBSTR([Runtime.InteropServices.Marshal]::SecureStringToBSTR($SnmpPrivPassword)) + + } + + # Validate Logic Switch + if ($LogicalSwitchGroup -isnot [PSCustomObject]) + { + + # Generate Error + "[{0}] Invalid LogicalSwitchGroup resource. Generating Terminating Error" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_Message = 'The provided Logical Switch Group {0} is not a supported object type. Expected [PSCustomObject], Received "{1}".' -f $LogicalSwitchGroup.name, $SwitchType.GetType().FullName + + $ErrorRecord = New-ErrorRecord HPEOneView.SwitchTypeResourceException InvalidSwitchTypeResource InvalidArgument 'LogicalSwitchGroup' -TargetType $LogicalSwitchGroup.GetType().Name -Message $_Message + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + if ($LogicalSwitchGroup.category -ne 'logical-switch-groups') + { + + # Generate error + "[{0}] Invalid LogicalSwitchGroup resource. Generating Terminating Error" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_Message = 'The provided Logical Switch Group {0} is not a supported object category type. Expected logical-switch-groups", Received "{1}".' -f $LogicalSwitchGroup.name, $LogicalSwitchGroup.category + + $ErrorRecord = New-ErrorRecord HPEOneView.SwitchTypeResourceException InvalidSwitchTypeResource InvalidArgument 'LogicalSwitchGroup' -TargetType 'PSObject' -Message $_Message + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + $_LogicalSwitch.logicalSwitch.logicalSwitchGroupUri = $LogicalSwitchGroup.uri + $NumberOfSwitches = $LogicalSwitchGroup.switchMapTemplate.switchMapEntryTemplates.count + + "[{0}] Processing number of switches from Switch Group: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $NumberOfSwitches | Write-Verbose + + # Add Switch Credentials to connection Object + For ($i = 1; $i -le $NumberOfSwitches; $i++) + { + + "[{0}] Processing switch: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $i | Write-Verbose + + # SNMP and Management Address + $_SwitchCredentialConfig = NewObject -LogicalSwitchCredentials + $_SwitchCredentialConfig.snmpPort = $SnmpPort + + if ($i -eq 1) + { + + $_SwitchCredentialConfig.logicalSwitchManagementHost = $Switch1Address + + } + + elseif ($i -eq 2) + { + + $_SwitchCredentialConfig.logicalSwitchManagementHost = $Switch2Address + + } + + if ($PSBoundParameters['SnmpV1']) + { + + $_SwitchCredentialConfig.snmpV1Configuration.communityString = $SnmpCommunity + + } + + else + { + + $_SwitchCredentialConfig.snmpVersion = 'SNMPv3' + + } + + [void]$_LogicalSwitch.logicalSwitch.switchCredentialConfiguration.Add($_SwitchCredentialConfig) + + # SSH + $_LogialSwitchConnectionProperties = NewObject -LogialSwitchConnectionProperties + + # SSH User Account + $_LogicalSwitchConnectionProperty = NewObject -LogicalSwitchConnectionProperty + $_LogicalSwitchConnectionProperty.propertyName = 'SshBasicAuthCredentialUser' + $_LogicalSwitchConnectionProperty.value = $SshUserName + $_LogicalSwitchConnectionProperty.valueType = 'String' + + [void]$_LogialSwitchConnectionProperties.connectionProperties.Add($_LogicalSwitchConnectionProperty) + + # SSH User Password + $_LogicalSwitchConnectionProperty = NewObject -LogicalSwitchConnectionProperty + $_LogicalSwitchConnectionProperty.propertyName = 'SshBasicAuthCredentialPassword' + $_LogicalSwitchConnectionProperty.value = $SshPassword + $_LogicalSwitchConnectionProperty.valueFormat = 'SecuritySensitive' + $_LogicalSwitchConnectionProperty.valueType = 'String' + + [void]$_LogialSwitchConnectionProperties.connectionProperties.Add($_LogicalSwitchConnectionProperty) + + # Add + [Void]$_LogicalSwitch.logicalSwitchCredentials.Add($_LogialSwitchConnectionProperties) + + } + + # Handle Device SNMP Configuration + if ('ManagedSnmpV3','MonitoredSnmpV3' -contains $PSCmdlet.ParameterSetName) + { + + For ($i = 0; $i -lt $NumberOfSwitches; $i++) + { + + "[{0}] Processing SNMPv3 Auth credentials" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + # Add SNMPv3 AuthOnly Protocol + $_LogicalSwitch.logicalSwitch.switchCredentialConfiguration[$i].snmpV3Configuration.authorizationProtocol = $SnmpAuthProtocolEnum[$SnmpAuthProtocol] + $_LogicalSwitch.logicalSwitch.switchCredentialConfiguration[$i].snmpV3Configuration.securityLevel = 'Auth' + + # Add SNMPv3 Credentials + $_LogicalSwitchConnectionProperty = NewObject -LogicalSwitchConnectionProperty + $_LogicalSwitchConnectionProperty.propertyName = 'SnmpV3User' + $_LogicalSwitchConnectionProperty.value = $SnmpUserName + $_LogicalSwitchConnectionProperty.valueType = 'String' + [void]$_LogicalSwitch.logicalSwitchCredentials[$i].connectionProperties.Add($_LogicalSwitchConnectionProperty) + + $_LogicalSwitchConnectionProperty = NewObject -LogicalSwitchConnectionProperty + $_LogicalSwitchConnectionProperty.propertyName = 'SnmpV3AuthorizationPassword' + $_LogicalSwitchConnectionProperty.value = $SnmpAuthPassword + $_LogicalSwitchConnectionProperty.valueFormat = 'SecuritySensitive' + $_LogicalSwitchConnectionProperty.valueType = 'String' + [void]$_LogicalSwitch.logicalSwitchCredentials[$i].connectionProperties.Add($_LogicalSwitchConnectionProperty) + + # Add SNMPv3 Privacy settings if specified + if ($SnmpAuthLevel -eq "AuthAndPriv") + { + + "[{0}] Processing SNMPv3 AuthAndPrivacy credentials" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_LogicalSwitch.logicalSwitch.switchCredentialConfiguration[$i].snmpV3Configuration.privacyProtocol = $SnmpPrivProtocolEnum[$SnmpPrivProtocol] + $_LogicalSwitch.logicalSwitch.switchCredentialConfiguration[$i].snmpV3Configuration.securityLevel = 'AuthPrivacy' + + $_LogicalSwitchConnectionProperty = NewObject -LogicalSwitchConnectionProperty + $_LogicalSwitchConnectionProperty.propertyName = 'SnmpV3PrivacyPassword' + $_LogicalSwitchConnectionProperty.value = $SnmpPrivPassword + $_LogicalSwitchConnectionProperty.valueFormat = 'SecuritySensitive' + $_LogicalSwitchConnectionProperty.valueType = 'String' + [void]$_LogicalSwitch.logicalSwitchCredentials[$i].connectionProperties.Add($_LogicalSwitchConnectionProperty) + + } + + } + + } + + "[{0}] LS: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), (ConvertTo-Json -Depth 99 $_LogicalSwitch | out-string) | Write-Verbose + + "{0}] Sending request to create '{1}'..." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_LogicalSwitch.name | Write-Verbose + + Try + { + + $_Task = Send-OVRequest -Uri $LogicalSwitchesUri -Method POST -Body $_LogicalSwitch -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if (-not $Async.IsPresent) + { + + Try + { + + $_Task = Wait-OVTaskComplete -InputObject $_Task + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $_Task + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Remove-OVLogicalSwitch +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdLetBinding (DefaultParameterSetName = "default", SupportsShouldProcess, ConfirmImpact = 'High')] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = "default")] + [ValidateNotNullOrEmpty()] + [Alias ("ls",'LogicalSwitch')] + [Object]$InputObject, + + [Parameter (Mandatory = $False, ValueFromPipelineByPropertyName, ParameterSetName = "default")] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default), + + [Parameter (Mandatory = $false, ParameterSetName = "default")] + [Switch]$Force, + + [Parameter (Mandatory = $false, ParameterSetName = "default")] + [Switch]$Async + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not($PSBoundParameters['InputObject'])) + { + + $PipelineInput = $True + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + $_taskcollection = [System.Collections.ArrayList]::new() + $_logicalswitchcollection = [System.Collections.ArrayList]::new() + + } + + Process + { + + if ($PipelineInput) + { + + "[{0}] Processing Pipeline input" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + "[{0}] Object provided: {1} ({2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject.name, $InputObject.uri | Write-Verbose + + If ('logical-switches' -eq $InputObject.category) + { + + If (-not($InputObject.ApplianceConnection)) + { + + $ErrorRecord = New-ErrorRecord InvalidOperationException InvalidArgumentValue InvalidArgument "InputObject" -TargetType PSObject -Message "The Logical Switch resource provided is missing the source ApplianceConnection property. Please check the object provided and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + [void]$_logicalswitchcollection.Add($InputObject) + + } + + else + { + + $ErrorRecord = New-ErrorRecord InvalidOperationException InvalidArgumentValue InvalidArgument "InputObject" -TargetType PSObject -Message "The Logical Switch resource is not an expected category type [$($InputObject.category)]. Allowed resource category type is 'logical-switches'. Please check the object provided and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + else + { + + foreach ($_resource in $InputObject) + { + + if ($_resource -is [String]) + { + + "[{0}] Received URI: $($_resource)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $ErrorRecord = New-ErrorRecord InvalidOperationException UnsupportedParameterType InvalidArgumetn 'InputObject' -Message "The provided Resource value is a String, only PSCustomObject types are supported." + $PSCmdlet.WriteError($ErrorRecord) + + } + + # LIG passed is the object + elseif ($_resource -is [PSCustomObject] -and 'logical-switches' -eq $_resource.category) + { + + "[{0}] Object provided: $($_resource )" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + [void]$_logicalswitchcollection.Add($_resource) + + } + + elseif ($_resource -is [PSCustomObject] -and 'logical-switches' -ne $_resource.category) + { + + $ErrorRecord = New-ErrorRecord InvalidOperationException InvalidArgumentValue InvalidArgument 'Resource' -TargetType 'PSObject' -Message "Invalid Logical Switch Parameter: $($_lig )" + $PSCmdlet.WriteError($ErrorRecord) + + } + + } + + } + + } + + End + { + + "[{0}] Processing $($_logicalswitchcollection.count) resources to remove." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + # Process Resources + ForEach ($_ls in $_logicalswitchcollection) + { + + if ($PSCmdlet.ShouldProcess($_ls.ApplianceConnection.Name,("Remove Logical Switch '{0}'" -f $_ls.name))) + { + + "[{0}] Removing '$($_ls.name)' from appliance '$($_ls.ApplianceConnection.Name)'." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + if ($force.IsPresent) + { + + $_ls.uri += "?force=true" + + } + + $_reply = Send-OVRequest -Uri $_ls.uri -Method DELETE -AddHeader @{'If-Match' = $_ls.eTag } -Hostname $_ls.ApplianceConnection.Name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if ($PSboundParameters['Async']) + { + + $_reply + + } + + else + { + + $_reply | Wait-OVTaskComplete + + } + + } + + elseif ($PSBoundParameters['WhatIf']) + { + + "[{0}] WhatIf Parameter was passed." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + } + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Set-OVLogicalSwitch +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "Ethernet")] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = "Ethernet")] + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = "FibreChannel")] + [ValidateNotNullOrEmpty()] + [Alias ('LogialSwitch')] + [Object]$InputObject, + + [Parameter (Mandatory = $false, ParameterSetName = "Ethernet")] + [Parameter (Mandatory = $false, ParameterSetName = "FibreChannel")] + [ValidateNotNullOrEmpty()] + [String]$Name, + + [Parameter (Mandatory = $false, ParameterSetName = "Ethernet")] + [Parameter (Mandatory = $false, ParameterSetName = "FibreChannel")] + [ValidateNotNullOrEmpty()] + [String]$Prefix, + + [Parameter (Mandatory = $false, ParameterSetName = "Ethernet")] + [Parameter (Mandatory = $false, ParameterSetName = "FibreChannel")] + [ValidateNotNullOrEmpty()] + [String]$Suffix, + + [Parameter (Mandatory = $false, ParameterSetName = "Ethernet")] + [ValidateNotNullOrEmpty()] + [ValidateSet ("General", "Management", "VMMigration", "FaultTolerance")] + [String]$Purpose, + + [Parameter (Mandatory = $false, ParameterSetName = "Ethernet")] + [Bool]$Smartlink, + + [Parameter (Mandatory = $false, ParameterSetName = "Ethernet")] + [Bool]$PrivateNetwork, + + [Parameter (Mandatory = $false, ParameterSetName = "Ethernet")] + [Parameter (Mandatory = $false, ParameterSetName = "FibreChannel")] + [validaterange(2,20000)] + [int32]$TypicalBandwidth, + + [Parameter (Mandatory = $false, ParameterSetName = "Ethernet")] + [Parameter (Mandatory = $false, ParameterSetName = "FibreChannel")] + [validaterange(100,20000)] + [int32]$MaximumBandwidth, + + [Parameter (Mandatory = $false, ParameterSetName = "FibreChannel")] + [ValidateRange(1,1800)] + [Alias ('lst')] + [int32]$LinkStabilityTime, + + [Parameter (Mandatory = $false, ParameterSetName = "FibreChannel")] + [Alias ('ald')] + [Bool]$AutoLoginRedistribution, + + [Parameter (Mandatory = $false, ParameterSetName = "FibreChannel")] + [ValidateNotNullOrEmpty()] + [Object]$ManagedSan, + + [Parameter (ValueFromPipelineByPropertyName, Mandatory = $false, ParameterSetName = "Ethernet")] + [Parameter (ValueFromPipelineByPropertyName, Mandatory = $false, ParameterSetName = "FibreChannel")] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + Write-Warning 'IN DEV' + BREAK + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not($PSBoundParameters['InputObject'])) + { + + "[{0}] Network resource passed via pipeline." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $PipelineInput = $True + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + $_NetworksToUpdate = [System.Collections.ArrayList]::new() + $NetCollection = [System.Collections.ArrayList]::new() + + } + + Process + { + + #build collection of networks to modify + foreach ($net in $InputObject) + { + + if ($PSBoundParameters['LinkStabilityTime'] -and $net.category -eq $ResourceCategoryEnum.FCoENetwork) + { + + $ErrorRecord = New-ErrorRecord HPEOneView.NetworkResourceException InvalidArgumentValue InvalidArgument 'LinkStabilityTime' -TargetType 'Int' -Message "The -LinkStabilityTime Parameter is not supported with FCoE Network resources, only FibreChannel network resources. Please check your call and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + if ($PSBoundParameters['AutoLoginRedistribution'] -and $net.category -eq $ResourceCategoryEnum.FCoENetwork) + { + + $ErrorRecord = New-ErrorRecord HPEOneView.NetworkResourceException InvalidArgumentValue InvalidArgument 'AutoLoginRedistribution' -TargetType 'Boolean' -Message "The -AutoLoginRedistribution Parameter is not supported with FCoE Network resources, only FibreChannel network resources. Please check your call and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + # Check the name Parameter value if the caller inadvertantly provided an object for name Parameter + if ($name -and ([RegEx]::Match($name, "category=ethernet-networks", $RegExInsensitiveFlag).Success -or [RegEx]::Match($name, "category=fc-networks", $RegExInsensitiveFlag).Success -or [RegEx]::Match($name, "category=fcoe-networks", $RegExInsensitiveFlag).Success)) + { + + $ErrorRecord = New-ErrorRecord HPEOneView.NetworkResourceException InvalidArgumentValue InvalidArgument 'Name' -Message "The -name Parameter value appears to have been passed the network resource object, which is converted to type [String] and is an invalid operation. Please verify that you provided the Network Name attribute in the -name Parameter value and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($name -and $name.length -gt 255) + { + + $ErrorRecord = New-ErrorRecord HPEOneView.NetworkResourceException InvalidArgumentValue InvalidArgument 'Name' -Message "The -name Parameter value is greater than 255 characters. Please check the -name Parameter value and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + switch ($net.Gettype().Name) + { + + "PSCustomObject" + { + + if ($net -is [PSCustomObject] -and ($net.category -eq $ResourceCategoryEnum.EthernetNetwork -or $net.category -eq $ResourceCategoryEnum.FibreChannelNetwork -or $net.category -eq $ResourceCategoryEnum.FCoENetwork)) + { + + "[{0}] Collecting $($net.type) $($net.name) resource." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + [void]$_NetworksToUpdate.Add($net) + + } + + else + { + + $ErrorRecord = New-ErrorRecord HPEOneView.NetworkResourceException InvalidArgumentValue InvalidArgument 'InputObject' -TargetType 'PSObject' -Message "[$($net.gettype().name)] is an unspported data type. Only [System.String] or [PSCustomObject] or an [Array] of [System.String] or [PSCustomObject] network resources are allowed. Please check the -network Parameter value and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + "String" + { + + # User provided Network 'name' and 1 or more Appliance Connections + if ($net -is [String] -and (-not ($net.StartsWith('/rest/')))) + { + + ForEach ($_appliance in $ApplianceConnection) + { + + "[{0}] Getting '$($net)' resource from appliance." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $_tempNet = Get-OVNetwork $net -type $PSCmdlet.ParameterSetName -ApplianceConnection $_appliance + + } + + Catch [HPEOneView.NetworkResourceException] + { + + if ($_.CategoryInfo.Category -eq 'ObjectNotFound') + { + + $ErrorRecord = New-ErrorRecord HPEOneView.NetworkResourceException NetworkResourceNotFound ObjectNotFound 'InputObject' -Message "'$net' Network was not found. Please check the value and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + else + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + if ($_tempNet.count -gt 1) + { + + $ErrorRecord = New-ErrorRecord HPEOneView.NetworkResourceException NonUniqueNetworkName InvalidResult 'InputObject' -Message "Multiple '$_tempNet' Network resource found with the same name. Please check the value and try again, or provide the Network Resource Object instead of the name." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + [void]$_NetworksToUpdate.Add($_tempNet) + + } + + } + + elseif ($net -is [String] -and ($net.StartsWith($EthernetNetworksUri) -or $net.StartsWith($FCNetworksUri))) + { + + "[{0}] Getting '$($net)' resource from appliance." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $net = Send-OVRequest $net -Appliance $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + [void]$NetCollection.Add($net) + + } + + } + + } + + } + + } + + End + { + + ForEach ($_net in $_NetworksToUpdate) + { + + # Set Specific Network Type settings + switch ($_net.category) + { + + "ethernet-networks" + { + + "[{0}] Updating $($_net.name) Ethernet Network." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + switch ($PSBoundParameters.keys) + { + + "purpose" + { + + "[{0}] Setting network Purpose to: $purpose" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + $_net.purpose = $EthernetNetworkPurposeEnum[$Purpose] + + } + + "smartlink" + { + + "[{0}] Setting smartlink Enabled to: $([Bool]$smartlink)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + $_net.smartlink = [Bool]$smartlink + + } + + "privateNetwork" + { + + "[{0}] Setting privateNetwork Enabled to: $([Bool]$privateNetwork)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + $_net.privateNetwork = [Bool]$privateNetwork + + } + + } + + } + + "fc-networks" + { + + switch ($PSBoundParameters.keys) + { + + "LinkStabilityTime" + { + + "[{0}] Setting LinkStabilityTime to '$LinkStabilityTime' seconds" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if ($_net.fabricType -eq 'DirectAttach') + { + + $ErrorRecord = New-ErrorRecord HPEOneView.NetworkResourceException InvalidFabricOperation InvalidOperation 'LinkStabilityTime' -TargetType $LinkStabilityTime.Gettype().Name -Message ("Cannot set LinkStabilityTime value to a DirectAttach FibreChannel resource, {0}." -f $_net.name) + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + $_net.linkStabilityTime = [Int]$linkStabilityTime + + } + + "AutoLoginRedistribution" + { + + "[{0}] Setting AutoLoginRedistribution Enabled to: $([Bool]$AutoLoginRedistribution)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if ($_net.fabricType -eq 'DirectAttach') + { + + $ErrorRecord = New-ErrorRecord HPEOneView.NetworkResourceException InvalidFabricOperation InvalidOperation 'AutoLoginRedistribution' -TargetType $AutoLoginRedistribution.Gettype().Name -Message ("Cannot set AutoLoginRedistribution value to a DirectAttach FibreChannel resource, {0}" -f $_net.name) + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + $_net.autoLoginRedistribution = [Bool]$autoLoginRedistribution + + if ($_net.linkStabilityTime -eq 0 -and (-not($LinkStabilityTime)) -and [Bool]$AutoLoginRedistribution) + { + + $ErrorRecord = New-ErrorRecord HPEOneView.NetworkResourceException InvalidLinkStabilityTimeValue InvalidOperation 'AutoLoginRedistribution' -Message ("The '{0}' FC Network resource is a Direct Attach fabric. The Managed SAN resource cannot be modified." -f $_net.name) + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + "managedSan" + { + + if ($_net.fabricType -eq 'DirectAttach') + { + + $ErrorRecord = New-ErrorRecord HPEOneView.NetworkResourceException InvalidFabricOperation InvalidResult 'Network' -Message ("The '{0}' FC Network resource is a Direct Attach fabric. The Managed SAN resource cannot be modified." -f $_net.name) + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + else + { + + "[{0}] Processing ManagedSAN for FC Network." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $_net.managedSanUri = (VerifyManagedSan $managedSan $_net.ApplianceConnection.Name) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + } + + } + + "fcoe-networks" + { + + switch ($PSBoundParameters.keys) + { + + "managedSan" + { + + "[{0}] Processing ManagedSAN for FC Network." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_net.managedSanUri = (VerifyManagedSan $managedSan $_net.ApplianceConnection.Name) + + } + + } + + } + + } + + # Shared Parameters for each Network Type + if ($PSBoundParameters["name"]) + { + + "[{0}] Updating Network name to '$name'." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + # Validate name Parameter is [String] + $_net.name = $name + + } + + if ($PSBoundParameters["prefix"]) + { + + "[{0}] Updating Network name to include '$prefix' prefix to Network Name." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + "[{0}] Updated Network Name: $($prefix + $_net.name)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + # Validate name Parameter is [String] + $_net.name = $prefix + $_net.name + + } + + if ($PSBoundParameters["suffix"]) + { + + "[{0}] Updating Network name to include '$suffix' suffix to Network Name." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + "[{0}] Updated Network Name: $($_net.name + $suffix)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + # Validate name Parameter is [String] + $_net.name += $suffix + + } + + if ($PSBoundParameters["typicalBandwidth"] -or $PSBoundParameters["maximumBandwidth"]) + { + + "[{0}] Updating Network bandwidth assignment." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + "[{0}] Getting Connection Template resource." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $ct = Send-OVRequest $_net.connectionTemplateUri -Appliance $_net.ApplianceConnection.Name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if ($PSBoundParameters["maximumBandwidth"]) + { + + "[{0}] Original Maximum bandwidth assignment: $($ct.bandwidth.maximumBandwidth)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + "[{0}] New Maximum bandwidth assignment: $maximumBandwidth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $ct.bandwidth.maximumBandwidth = $maximumBandwidth + + } + + if($PSBoundParameters["typicalBandwidth"]) + { + + "[{0}] Original Typical bandwidth assignment: $($ct.bandwidth.typicalBandwidth)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + "[{0}] New Typical bandwidth assignment: $typicalBandwidth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $ct.bandwidth.typicalBandwidth = $typicalBandwidth + + } + + # "[{0}] Updating Connection Template: $($ct | Format-List * )" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $ct = Send-OVRequest $ct.uri PUT $ct -Appliance $ct.ApplianceConnection.Name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + + } + + $_net = $_net | Select-Object * -ExcludeProperty defaultTypicalBandwidth, defaultMaximumBandwidth, created, modified + + # "[{0}] Updating Network Resource object: $($_net )" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + Try + { + + $resp = Send-OVRequest $_net.uri PUT $_net -Appliance $_net.ApplianceConnection.Name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + [void]$NetCollection.Add($resp) + + } + + Return $NetCollection + + } + +} + +function Update-OVLogicalSwitch +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "default", SupportsShouldProcess, ConfirmImpact = 'High')] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = "default")] + [Alias ('LogicalSwitch')] + [Alias ('LS')] + [ValidateNotNullorEmpty()] + [object]$InputObject, + + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = "default")] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default), + + [Parameter (Mandatory = $false, ParameterSetName = "default")] + [Switch]$Async + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not $PSBoundParameters['InputObject']) + { + + $PiplineInput = $true + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + $_lsobjects = [System.Collections.ArrayList]::new() + + } + + Process + { + + "[{0}] Processing $($InputObject.count) LI objects." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + foreach ($_logicalswitch in $InputObject) + { + + if (($_logicalswitch -is [PSCustomObject]) -and ($_logicalswitch.category -ieq 'logical-switches')) + { + + "[{0}] Logical Switch Object was provided: {1} ({2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_logicalswitch.name, $_logicalswitch.uri | Write-Verbose + + [void]$_lsobjects.Add($_logicalswitch) + + } + + else + { + + $ErrorRecord = New-ErrorRecord InvalidOperationException InvalidArgumentValue InvalidArgument 'InputObject' -TargetType $_li.GetType().Name -Message "An invalid Resource object was provided. $($_li.GetType()) $($_li.category) was provided. Only type String or PSCustomObject, and 'logical-interconnects' object category are permitted." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + } + + End + { + + # Loop through liobject collection to perform action + ForEach ($_ls in $_lsobjects) + { + + "[{0}] Processing Logical Switch: $($_ls.name)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if ($PSCmdlet.ShouldProcess($_ls.name,"Refresh Logical Switch")) + { + + Try + { + + "[{0}] Sending request to refresh Logical Switch." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $uri = $_ls.uri + "/refresh" + + $_reply = Send-OVRequest $uri PUT -Hostname $_ls.ApplianceConnection.Name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if ($PSBoundParameters['Async']) + { + + $_reply + + } + + else + { + + $_reply | Wait-OVTaskComplete + + } + + } + + elseif ($PSBoundParameters['WhatIf']) + { + + "[{0}] User included -WhatIf." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + else + { + + "[{0}] User cancelled." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + + } + + } + +} + +function Get-OVSwitch +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = 'Default')] + Param + ( + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullorEmpty()] + [String]$Name, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [Object]$Scope = "AllResourcesInScope", + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [Parameter (Mandatory = $false, ParameterSetName = 'Label')] + [ValidateNotNullOrEmpty()] + [String]$Label, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [Parameter (Mandatory = $false, ParameterSetName = 'Label')] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $_Collection = [System.Collections.ArrayList]::new() + + } + + Process + { + + ForEach ($_appliance in $ApplianceConnection) + { + + "[{0}] Processing appliance {1} (of {2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name, $ApplianceConnection.Count | Write-Verbose + + $_Query = [System.Collections.ArrayList]::new() + + # Handle default cause of AllResourcesInScope + if ($Scope -eq 'AllResourcesInScope') + { + + "[{0}] Processing AllResourcesInScope." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_Scopes = $ApplianceConnection.ActivePermissions | Where-Object Active + + # If one scope contains 'AllResources' ScopeName "tag", then all resources should be returned regardless. + if ($_Scopes | Where-Object ScopeName -eq 'AllResources') + { + + $_ScopeNames = [String]::Join(', ', ($_Scopes | Where-Object ScopeName -eq 'AllResources').ScopeName) + + "[{0}] Scope(s) {1} is set to 'AllResources'. Will not add scope to URI query parameter." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_ScopeNames | Write-Verbose + + } + + # Process ApplianceConnection ActivePermissions collection + else + { + + Try + { + + $_ScopeQuery = Join-Scope $_Scopes + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + [Void]$_Query.Add(("({0})" -f $_ScopeQuery)) + + } + + } + + elseif ($Scope | Where-Object ScopeName -eq 'AllResources') + { + + $_ScopeNames = [String]::Join(', ', ($_Scopes | Where-Object ScopeName -eq 'AllResources').ScopeName) + + "[{0}] Scope(s) {1} is set to 'AllResources'. Will not add scope to URI query parameter." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_ScopeNames | Write-Verbose + + } + + elseif ($Scope -eq 'AllResources') + { + + "[{0}] Requesting scope 'AllResources'. Will not add scope to URI query parameter." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_ScopeNames | Write-Verbose + + } + + else + { + + Try + { + + $_ScopeQuery = Join-Scope $Scope + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + [Void]$_Query.Add(("({0})" -f $_ScopeQuery)) + + } + + if ($Name) + { + + if ($Name.Contains('*')) + { + + [Void]$_Query.Add(("name%3A{0}" -f $Name.Replace("*", "%2A").Replace(',','%2C').Replace(" ", "?"))) + + } + + else + { + + [Void]$_Query.Add(("name:'{0}'" -f $Name)) + + } + + } + + if ($Label) + { + + [Void]$_Query.Add(("labels:'{0}'" -f $Label)) + + } + + $_Category = 'category=switches' + + # Build the final URI + $_uri = '{0}?{1}&sort=name:asc&query={2}' -f $IndexUri, [String]::Join('&', $_Category), [String]::Join(' AND ', $_Query.ToArray()) + + Try + { + + [Array]$_ResourcesFromIndexCol = Get-AllIndexResources -Uri $_uri -ApplianceConnection $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if ($_ResourcesFromIndexCol.count -eq 0 -and $Name) + { + + "[{0}] Switch '{1}' resource not found on appliance {2}. Generating error" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Name, $_appliance.Name | Write-Verbose + + $ExceptionMessage = "Specified Switch '{0}' was not found on {1} appliance connection. Please check the name and try again." -f $Name, $_appliance.Name + $ErrorRecord = New-ErrorRecord InvalidOperationException SwitchNotFound ObjectNotFound 'Name' -Message $ExceptionMessage + $PSCmdlet.WriteError($ErrorRecord) + + } + + else + { + + ForEach ($_member in $_ResourcesFromIndexCol) + { + + $_member.PSObject.TypeNames.Insert(0,'HPEOneView.Networking.Switch') + + [void]$_Collection.Add($_member) + + } + + } + + } + + } + + End + { + + "[{0}] Done. {1} switch(es) found." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_Collection.count | Write-Verbose + + if ($exportFile) + { + + $_Collection | convertto-json -Depth 99 | Set-Content -Path $exportFile -force -encoding UTF8 + + } + + else + { + + Return $_Collection | Sort-Object name + + } + + } + +} + +####################################################### +# Image Streamer +# + +function Get-OVImageStreamerAppliance +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = 'Default')] + Param + ( + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [String]$Name, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = ($ConnectedSessions | Where-Object Default) + + ) + + Begin + { + + "[{0}] Bound PS Parameters: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(),($PSBoundParameters | out-string) | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not($ConnectedSessions)) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command agian." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $_ImageStreamerCollection = [System.Collections.ArrayList]::new() + + } + + Process + { + + $_uri = $AvailableDeploymentServersUri + + if ($Name) + { + + $_uri = "{0}?filter=name matches '{1}'" -f $_uri, $Name.Replace('*','%25').Replace('?','%26') + + } + + ForEach ($_appliance in $ApplianceConnection) + { + + [ObsoleteMessage]::Write($_appliance) + + "[{0}] Processing '{1}' Appliance (of $($ApplianceConnection.Count))" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name | Write-Verbose + + If ($_appliance.ApplianceType -ne 'Composer') + { + + $ExceptionMessage = 'The ApplianceConnection {0} ({1}) is not a Synergy Composer. This Cmdlet only support Synergy Composer management appliances.' -f $_appliance.Name, $_appliance.ApplianceType + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.ComposerNodeException InvalidOperation InvalidOperation 'ApplianceConnection' -Message $ExceptionMessage + $PSCmdlet.WriteError($ErrorRecord) + + } + + else + { + + Try + { + + $_CollectionResults = Send-OVRequest -uri $_uri -Hostname $_appliance.Name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if ($Name -and -not $_CollectionResults.members) + { + + $ExceptionMessage = 'Image Streamer Appliance "{0}" was not found on "{1}" appliance connection.' -f $Name, $_appliance.Name + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.ImageStreamerResourceException ResourceNotFound ObjectNotFound "Name" -Message $ExceptionMessage + $PSCmdlet.WriteError($ErrorRecord) + + } + + else + { + + $_CollectionResults.members | ForEach-Object { + + $_.PSObject.TypeNames.Insert(0,'HPEOneview.Appliance.ImageStreamerAppliance') + + $_ + + } + + } + + } + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Get-OVOSDeploymentServer +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = 'Default')] + Param + ( + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [String]$Name, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [String]$Label, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = ($ConnectedSessions | Where-Object Default) + + ) + + Begin + { + + "[{0}] Bound PS Parameters: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(),($PSBoundParameters | out-string) | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not($ConnectedSessions)) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command agian." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + Process + { + + $_uri = $DeploymentServersUri + + if ($Name) + { + + if ($Name.Contains('*')) + { + + $Name = $Name.Replace("*","%25").Replace("&","%26") + + } + + $_uri = '{0}?filter=name matches "{1}"' -f $_uri, $Name + + } + + ForEach ($_appliance in $ApplianceConnection) + { + + [ObsoleteMessage]::Write($_appliance) + + "[{0}] Processing '{1}' Appliance (of {2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name, $ApplianceConnection.Count | Write-Verbose + + If ($_appliance.ApplianceType -ne 'Composer') + { + + $ExceptionMessage = 'The ApplianceConnection {0} ({1}) is not a Synergy Composer. This Cmdlet only support Synergy Composer management appliances.' -f $_appliance.Name, $_appliance.ApplianceType + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.ComposerNodeException InvalidOperation InvalidOperation 'ApplianceConnection' -Message $ExceptionMessage + $PSCmdlet.WriteError($ErrorRecord) + + } + + else + { + + if ($PSBoundParameters['Label']) + { + + $_uri = '{0}?category:deployment-servers&query=labels:{1}' -f $IndexUri, $Label + + Try + { + + "[{0}] Getting OS Deployment Servers from Index for Label lookup" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_IndexMembers = Send-OVRequest -Uri $_uri -Hostname $_appliance + + # Loop through all found members and get full SVT object + ForEach ($_member in $_IndexMembers.members) + { + + Try + { + + $_member = Send-OVRequest -Uri $_member.uri -Hostname $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $_member.PSObject.TypeNames.Insert(0,'HPEOneview.Appliance.OSDeploymentServer') + + $_member + + } + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + else + { + + "[{0}] Getting OS Deployment servers from primary URI" -f $MyInvocation.InvocationName.ToString().ToUpper()| Write-Verbose + + Try + { + + $_CollectionResults = Send-OVRequest -uri $_uri -Hostname $_appliance.Name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if ($Name -and -not $_CollectionResults.members) + { + + $ExceptionMessage = 'OS Deployment Server "{0}" was not found on "{1}" appliance connection.' -f $Name, $_appliance.Name + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.ImageStreamerResourceException ResourceNotFound ObjectNotFound "Name" -Message $ExceptionMessage + $PSCmdlet.WriteError($ErrorRecord) + + } + + else + { + + ForEach ($_DeploymentServer in $_CollectionResults.members) + { + + $_DeploymentServer.PSObject.TypeNames.Insert(0,'HPEOneview.Appliance.OSDeploymentServer') + + $_DeploymentServer + + } + + } + + } + + } + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function New-OVOSDeploymentServer +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "Default")] + Param + ( + + [Parameter (Mandatory, ParameterSetName = "Default")] + [ValidateNotNullOrEmpty()] + [String]$Name, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [ValidateNotNullOrEmpty()] + [String]$Description, + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = "Default")] + [Alias ('ImageStreamer','I3S')] + [ValidateNotNullOrEmpty()] + [Object]$InputObject, + + [Parameter (Mandatory, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [Object]$ManagementNetwork, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [Switch]$Async, + + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = ($ConnectedSessions | Where-Object Default) + + ) + + Begin + { + + "[{0}] Bound PS Parameters: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(),($PSBoundParameters | out-string) | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not $PSBoundParameters['InputObject']) + { + + $PipelineInput = $true + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not($ConnectedSessions)) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command agian." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + } + + Process + { + + if ($PipelineInput) + { + + $ApplianceConnection = $ConnectedSessions | Where-Object Name -eq $ApplianceConnection.Name + + } + + If ($ApplianceConnection.ApplianceType -ne 'Composer') + { + + $ExceptionMessage = 'The ApplianceConnection {0} ({1}) is not a Synergy Composer. This Cmdlet only support Synergy Composer management appliances.' -f $ApplianceConnection.Name, $ApplianceConnection.ApplianceType + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.ComposerNodeException InvalidOperation InvalidOperation 'ApplianceConnection' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + [ObsoleteMessage]::Write($ApplianceConnection) + + # Validate the Management Network resource + if ($ManagementNetwork -is [String]) + { + + "[{0}] ManagementNetwork Name: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $ManagementNetwork | Write-Verbose + + Try + { + + $ManagementNetwork = Get-OVNetwork -Name $ManagementNetwork -Type Ethernet -ApplianceConnection $ApplianceConnection -ErrorAction Stop + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + # Validation rules + if ($ManagementNetwork.category -ne 'ethernet-networks') + { + + "[{0}] Unsupported Network: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $ManagementNetwork.name | Write-Verbose + + $ExceptionMessage = 'The ManagementNetwork {0} is not a valid "ethernet-network".' -f $ManagementNetwork.name + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.ImageStreamerManagementNetworkException UnsupportedNetwork InvalidArgument 'ManagementNetwork' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + if ([System.String]::IsNullOrWhiteSpace($ManagementNetwork.subnetUri)) + { + + $ExceptionMessage = 'The ManagementNetwork {0} resource is not assigned to a valid IPv4 Address Pool.' -f $ManagementNetwork.name + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.ImageStreamerManagementNetworkException UnsupportedEthernetNetwork InvalidArgument 'ManagementNetwork' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + # Get Subnet resource + Try + { + + $_ManagementNetworkSubnet = Send-OVRequest -Uri $ManagementNetwork.subnetUri -Hostname $ApplianceConnection + $_ApplianceNetwork = Send-OVRequest -uri $ApplianceNetworkConfigUri -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if ($_ManagementNetworkSubnet.subnetMask -ne $_ApplianceNetwork.applianceNetworks.ipv4Subnet) + { + + $ExceptionMessage = 'The ManagementNetwork "{0}" resource Subnet Mask "{1}" does not match the appliance Subnet Mask "{2}".' -f $ManagementNetwork.name, $_ManagementNetworkSubnet.subnetMask, $_ApplianceNetwork.applianceNetworks.ipv4Subnet + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.ImageStreamerManagementNetworkException UnsupportedEthernetNetwork InvalidArgument 'ManagementNetwork' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + if (-not [HPEOneView.Appliance.AddressPool]::IsInSameSubnet($_ManagementNetworkSubnet.networkId + '/' + $_ApplianceNetwork.applianceNetworks.ipv4Subnet, $_ApplianceNetwork.applianceNetworks.virtIpv4Addr)) + { + + $ExceptionMessage = "The ManagementNetwork's associated IPv4 Subnet {0} is not local to the appliance. ImageStreamer requires the IPv4 Subnet be on the same NetworkID as the appliance." -f $_ManagementNetworkSubnet.name + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.ImageStreamerManagementNetworkException UnsupportedEthernetNetwork InvalidArgument 'ManagementNetwork' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + # Validate InputObject + if (-not $InputObject.uri.StartsWith($AvailableDeploymentServersUri)) + { + + $ExceptionMessage = 'The InputObject is not a valid ImageStreamer resource.' -f $InputObject.name + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.ImageStreamerManagementNetworkException InvalidInputObject InvalidArgument 'InputObject' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + $_AddI3S = NewObject -I3SAdd + + $_AddI3S.description = $Description + $_AddI3S.name = $Name + $_AddI3S.imageStreamerData.mgmtNetworkUri = $ManagementNetwork.uri + $_AddI3S.imageStreamerData.applianceUri = $InputObject.Uri.ToString() + + Try + { + + $_Results = Send-OVRequest -Uri $DeploymentServersUri -Method POST -Body $_AddI3S -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if (-not $PSBoundParameters['Async']) + { + + $_Results | Wait-OVTaskComplete + + } + + else + { + + $_Results + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Remove-OVOSDeploymentServer +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "Default", SupportsShouldProcess, ConfirmImpact = 'High')] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = "Default")] + [ValidateNotNullOrEmpty()] + [Object]$InputObject, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [Switch]$Force, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [Switch]$Async, + + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = ($ConnectedSessions | Where-Object Default) + + ) + + Begin + { + + "[{0}] Bound PS Parameters: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(),($PSBoundParameters | out-string) | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not $PSBoundParameters['InputObject']) + { + + $PipelineInput = $true + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not($ConnectedSessions)) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command agian." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + } + + Process + { + + if ($PipelineInput) + { + + $ApplianceConnection = $ConnectedSessions | Where-Object Name -eq $ApplianceConnection.Name + + } + + If ($ApplianceConnection.ApplianceType -ne 'Composer') + { + + $ExceptionMessage = 'The ApplianceConnection {0} ({1}) is not a Synergy Composer. This Cmdlet only support Synergy Composer management appliances.' -f $ApplianceConnection.Name, $ApplianceConnection.ApplianceType + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.ComposerNodeException InvalidOperation InvalidOperation 'ApplianceConnection' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + [ObsoleteMessage]::Write($ApplianceConnection) + + # Validate InputObject + if ($InputObject.category -ne 'deployment-managers') + { + + $ExceptionMessage = 'The InputObject is not a valid OS Deployment Server resource.' -f $InputObject.name + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.ImageStreamerManagementNetworkException InvalidInputObject InvalidArgument 'InputObject' -Message $ExceptionMessage + $PSCmdlet.WriteError($ErrorRecord) + + } + + elseif ($PSCmdlet.ShouldProcess($InputObject.ApplianceConnection.Name, ("Remove OS Deployment Server from appliance '{0}'" -f $InputObject.name))) + { + + "[{0}] Remove OS Deployment Server '{1}' from appliance '{2}'." -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject.name, $InputObject.ApplianceConnection.Name | Write-Verbose + + $Uri = $InputObject.Uri.ToString() + + if ($Force) + { + + $Uri += '?force=true' + + } + + Try + { + + $_resp = Send-OVRequest -Uri $Uri -Method DELETE -AddHeader @{'If-Match' = $InputObject.eTag } -Hostname $InputObject.ApplianceConnection.Name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if (-not $PSBoundParameters['Async']) + { + + $_resp | Wait-OVTaskComplete + + } + + else + { + + $_resp + + } + + } + + elseif ($PSBoundParameters['WhatIf']) + { + + "[{0}] WhatIf Parameter was passed." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Get-OVOSDeploymentPlan +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = 'Default')] + Param + ( + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [String]$Name, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [Object]$Scope = "AllResourcesInScope", + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = ($ConnectedSessions | Where-Object Default) + + ) + + Begin + { + + "[{0}] Bound PS Parameters: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(),($PSBoundParameters | out-string) | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not($ConnectedSessions)) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command agian." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $_OSDeploymentPlanCollection = [System.Collections.ArrayList]::new() + + } + + Process + { + + ForEach ($_appliance in $ApplianceConnection) + { + + [ObsoleteMessage]::Write($_appliance) + + "[{0}] Processing '{1}' Appliance (of {2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name, $ApplianceConnection.Count | Write-Verbose + + If ($_appliance.ApplianceType -ne 'Composer') + { + + $ExceptionMessage = 'The ApplianceConnection {0} ({1}) is not a Synergy Composer. This Cmdlet only support Synergy Composer management appliances.' -f $_appliance.Name, $_appliance.ApplianceType + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.ComposerNodeException InvalidOperation InvalidOperation 'ApplianceConnection' -Message $ExceptionMessage + $PSCmdlet.WriteError($ErrorRecord) + + } + + else + { + + $_Query = [System.Collections.ArrayList]::new() + + # Handle default cause of AllResourcesInScope + if ($Scope -eq 'AllResourcesInScope') + { + + "[{0}] Processing AllResourcesInScope." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_Scopes = $ApplianceConnection.ActivePermissions | Where-Object Active + + # If one scope contains 'AllResources' ScopeName "tag", then all resources should be returned regardless. + if ($_Scopes | Where-Object ScopeName -eq 'AllResources') + { + + $_ScopeNames = [String]::Join(', ', ($_Scopes | Where-Object ScopeName -eq 'AllResources').ScopeName) + + "[{0}] Scope(s) {1} is set to 'AllResources'. Will not add scope to URI query parameter." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_ScopeNames | Write-Verbose + + } + + # Process ApplianceConnection ActivePermissions collection + else + { + + Try + { + + $_ScopeQuery = Join-Scope $_Scopes + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + [Void]$_Query.Add(("({0})" -f $_ScopeQuery)) + + } + + } + + elseif ($Scope | Where-Object ScopeName -eq 'AllResources') + { + + $_ScopeNames = [String]::Join(', ', ($_Scopes | Where-Object ScopeName -eq 'AllResources').ScopeName) + + "[{0}] Scope(s) {1} is set to 'AllResources'. Will not add scope to URI query parameter." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_ScopeNames | Write-Verbose + + } + + elseif ($Scope -eq 'AllResources') + { + + "[{0}] Requesting scope 'AllResources'. Will not add scope to URI query parameter." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_ScopeNames | Write-Verbose + + } + + else + { + + Try + { + + $_ScopeQuery = Join-Scope $Scope + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + [Void]$_Query.Add(("({0})" -f $_ScopeQuery)) + + } + + if ($Name) + { + + if ($Name.Contains('*')) + { + + [Void]$_Query.Add(("name%3A{0}" -f $Name.Replace("*", "%2A").Replace(',','%2C').Replace(" ", "?"))) + + } + + else + { + + [Void]$_Query.Add(("name:'{0}'" -f $Name)) + + } + + } + + # if ($Label) + # { + + # [Void]$_Query.Add(("labels:'{0}'" -f $Label)) + + # } + + $_Category = 'category=os-deployment-plans' + + # Build the final URI + $_uri = '{0}?{1}&sort=name:asc&query={2}' -f $IndexUri, [String]::Join('&', $_Category), [String]::Join(' AND ', $_Query.ToArray()) + + Try + { + + [Array]$_ResourcesFromIndexCol = Get-AllIndexResources -Uri $_uri -ApplianceConnection $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if ($Name -and -not $_ResourcesFromIndexCol) + { + + $ExceptionMessage = 'OS Deployment Plan "{0}" was not found on "{1}" appliance connection.' -f $Name, $_appliance.Name + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.ImageStreamerResourceException ResourceNotFound ObjectNotFound "Name" -Message $ExceptionMessage + $PSCmdlet.WriteError($ErrorRecord) + + } + + else + { + + ForEach ($_member in $_ResourcesFromIndexCol) + { + + $_member.PSObject.TypeNames.Insert(0,'HPEOneview.Appliance.OSDeploymentPlan') + + [void]$_OSDeploymentPlanCollection.Add($_member) + + } + + } + + } + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Return $_OSDeploymentPlanCollection + + } + +} + +function Get-OVOSDeploymentPlanAttribute +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdLetBinding (DefaultParameterSetName = "Default")] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = "Default")] + [ValidateNotNullOrEmpty()] + [Object]$InputObject, + + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = ($ConnectedSessions | Where-Object Default) + + ) + + Begin + { + + "[{0}] Bound PS Parameters: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(),($PSBoundParameters | out-string) | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not $PSBoundParameters['InputObject']) + { + + $PipelineInput = $true + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not($ConnectedSessions)) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command agian." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + $_PlanAttributesCol = [System.Collections.ArrayList]::new() + + } + + Process + { + + if ($PipelineInput) + { + + $ApplianceConnection = $ConnectedSessions | Where-Object Name -eq $ApplianceConnection.Name + + } + + If ($ApplianceConnection.ApplianceType -ne 'Composer') + { + + $ExceptionMessage = 'The ApplianceConnection {0} ({1}) is not a Synergy Composer. This Cmdlet only support Synergy Composer management appliances.' -f $ApplianceConnection.Name, $ApplianceConnection.ApplianceType + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.ComposerNodeException InvalidOperation InvalidOperation 'ApplianceConnection' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + [ObsoleteMessage]::Write($ApplianceConnection) + + $_OSDeploymentSettingsCollection = [HPEOneView.ServerProfile.OSDeployment.OsDeploymentPlanParametersCollection[HPEOneView.ServerProfile.OSDeployment.OSDeploymentParameter]]::new() + + if ($InputObject.category -eq $ResourceCategoryEnum.ServerProfileTemplate) + { + + # Process the osDeploymentSettings.osCustomAttributes for plan attributs to return + + ForEach ($_SptDeploymentPlanAttribute in $InputObject.osDeploymentSettings.osCustomAttributes) + { + + '[{0}] Add {1} = {2} into OsCustomAttributesCollection' -f $MyInvocation.InvocationName.ToString().ToUpper(), $_SptDeploymentPlanAttribute.name, $_SptDeploymentPlanAttribute.value | Write-Verbose + + $_PlanAttribute = [HPEOneView.ServerProfile.OSDeployment.OSDeploymentParameter]::new($_SptDeploymentPlanAttribute.name, $_SptDeploymentPlanAttribute.value) + + [void]$_OSDeploymentSettingsCollection.Add($_PlanAttribute) + + } + + } + + elseif ($InputObject.category -eq $ResourceCategoryEnum.OSDeploymentPlan) + { + + $ExpectedParamForNic = @{ + connectionid = $null; + dhcp = $False; + ipv4disable = $False; + networkuri = $null; + constraint = "auto" + } + + #Build initial collection of Build Plan Parameters + ForEach ($_PlanAttribute in $InputObject.additionalParameters) + { + + '[{0}] Attribute name: {1}, type: {2}' -f $MyInvocation.InvocationName.ToString().ToUpper(), $_PlanAttribute.name, $_PlanAttribute.caType | Write-Verbose + + if ($_PlanAttribute.caType -eq 'nic') + { + + ForEach ($AdditionalNicParam in ($ExpectedParamForNic.GetEnumerator() | Sort-Object keys )) + { + + $_ParameterName = '{0}.{1}' -f $_PlanAttribute.name, $AdditionalNicParam.key + + '[{0}] Add "{1}" NIC "{2}" = "{3}" into OsCustomAttributesCollection' -f $MyInvocation.InvocationName.ToString().ToUpper(), $_PlanAttribute.name, $_ParameterName, $AdditionalNicParam.value | Write-Verbose + + $_Attribute = [HPEOneView.ServerProfile.OSDeployment.OSDeploymentParameter]::new($_ParameterName, $AdditionalNicParam.value) + + [void]$_OSDeploymentSettingsCollection.Add($_Attribute) + + } + + } + + if ([System.Convert]::ToBoolean($_PlanAttribute.caEditable) -and $_PlanAttribute.caType -ne 'nic') + { + + '[{0}] Add {1} = {2} into OsCustomAttributesCollection' -f $MyInvocation.InvocationName.ToString().ToUpper(), $_PlanAttribute.name, $_PlanAttribute.value | Write-Verbose + + $_PlanAttribute = [HPEOneView.ServerProfile.OSDeployment.OSDeploymentParameter]::new($_PlanAttribute.name, $_PlanAttribute.value) + + [void]$_OSDeploymentSettingsCollection.Add($_PlanAttribute) + + } + + } + } + + $_OSDeploymentSettingsCollection + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +####################################################### +# Server Profiles: +# + +function Get-OVServerProfile +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "Default")] + Param + ( + + [Parameter (Mandatory = $false, ValueFromPipeline = $false, ParameterSetName = "Default")] + [Parameter (Mandatory = $false, ValueFromPipeline = $false, ParameterSetName = "Detailed")] + [Parameter (Mandatory = $false, ValueFromPipeline = $false, ParameterSetName = "Export")] + [Alias ('profile')] + [ValidateNotNullOrEmpty()] + [String]$Name, + + [Parameter (Mandatory, ValueFromPipeline = $false, ParameterSetName = "Detailed")] + [Switch]$Detailed, + + [Parameter (Mandatory = $false, ValueFromPipeline = $false, ParameterSetName = "Default")] + [Switch]$NonCompliant, + + [Parameter (Mandatory = $false, ValueFromPipeline = $false, ParameterSetName = "Default")] + [Parameter (Mandatory = $false, ValueFromPipeline = $false, ParameterSetName = "Export")] + [Switch]$Unassigned, + + [Parameter (Mandatory = $false, ValueFromPipeline, ParameterSetName = "Default")] + [Parameter (Mandatory = $false, ValueFromPipeline, ParameterSetName = "Export")] + [ValidateNotNullOrEmpty()] + [Object]$InputObject, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Parameter (Mandatory = $false, ParameterSetName = "Detailed")] + [Parameter (Mandatory = $false, ParameterSetName = "Export")] + [ValidateNotNullOrEmpty()] + [String]$Label, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Parameter (Mandatory = $false, ParameterSetName = "Detailed")] + [Parameter (Mandatory = $false, ParameterSetName = "Export")] + [ValidateNotNullOrEmpty()] + [Object]$Scope = "AllResourcesInScope", + + [Parameter (Mandatory = $false, ParameterSetName = "Default", ValueFromPipelinebyPropertyName)] + [Parameter (Mandatory = $false, ParameterSetName = "Detailed", ValueFromPipelinebyPropertyName)] + [Parameter (Mandatory = $false, ParameterSetName = "Export", ValueFromPipelinebyPropertyName)] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default), + + [Parameter (Mandatory, ValueFromPipeline = $false, ParameterSetName = "Export")] + [Alias ("x")] + [Switch]$export, + + [Parameter (Mandatory, ValueFromPipeline = $false, ParameterSetName = "Export")] + [ValidateNotNullOrEmpty()] + [Alias ("save")] + [String]$location + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + # Validate the path exists. If not, create it. + if (($Export) -and (-not(Test-Path $Location))) + { + + "[{0}] Directory does not exist. Creating directory..." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + New-Item -path $Location -ItemType Directory + + } + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $ProfileCollection = [System.Collections.ArrayList]::new() + + } + + Process + { + + ForEach ($_appliance in $ApplianceConnection) + { + + if ($_appliance -isnot [HPEOneView.Appliance.Connection]) + { + + $_appliance = $ConnectedSessions | Where-Object Name -eq $_appliance.Name + + } + + "[{0}] Processing appliance {1} (of {2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name, $ApplianceConnection.Count | Write-Verbose + + $_Query = [System.Collections.ArrayList]::new() + + # Handle default cause of AllResourcesInScope + if ($Scope -eq 'AllResourcesInScope') + { + + "[{0}] Processing AllResourcesInScope." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_Scopes = $_appliance.ActivePermissions | Where-Object Active + + # If one scope contains 'AllResources' ScopeName "tag", then all resources should be returned regardless. + if ($_Scopes | Where-Object ScopeName -eq 'AllResources') + { + + $_ScopeNames = [String]::Join(', ', ($_Scopes | Where-Object ScopeName -eq 'AllResources').ScopeName) + + "[{0}] Scope(s) {1} is set to 'AllResources'. Will not add scope to URI query parameter." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_ScopeNames | Write-Verbose + + } + + # Process ApplianceConnection ActivePermissions collection + else + { + + Try + { + + $_ScopeQuery = Join-Scope $_Scopes + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + [Void]$_Query.Add(("({0})" -f $_ScopeQuery)) + + } + + } + + elseif ($Scope | Where-Object ScopeName -eq 'AllResources') + { + + $_ScopeNames = [String]::Join(', ', ($_Scopes | Where-Object ScopeName -eq 'AllResources').ScopeName) + + "[{0}] Scope(s) {1} is set to 'AllResources'. Will not add scope to URI query parameter." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_ScopeNames | Write-Verbose + + } + + elseif ($Scope -eq 'AllResources') + { + + "[{0}] Requesting scope 'AllResources'. Will not add scope to URI query parameter." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_ScopeNames | Write-Verbose + + } + + else + { + + Try + { + + $_ScopeQuery = Join-Scope $Scope + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + [Void]$_Query.Add(("({0})" -f $_ScopeQuery)) + + } + + if ($Name) + { + + "[{0}] Filtering for Name: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Name | Write-Verbose + + if ($Name.Contains('*')) + { + + [Void]$_Query.Add(("name%3A{0}" -f $Name.Replace("*", "%2A").Replace(',','%2C').Replace(" ", "?"))) + + } + + else + { + + [Void]$_Query.Add(("name:'{0}'" -f $Name)) + + } + + } + + if ($Label) + { + + "[{0}] Filtering for Label: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Label | Write-Verbose + + [Void]$_Query.Add(("labels:'{0}'" -f $Label)) + + } + + if ($PSBoundParameters['NonCompliant']) + { + + "[{0}] Filtering for non-compliant profiles." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + [Void]$_Query.Add("templateCompliance:'NonCompliant'") + + } + + $_Category = 'category={0}' -f $ResourceCategoryEnum.ServerProfile + + # Build the final URI + $_uri = '{0}?{1}&sort=name:asc&query={2}' -f $IndexUri, [String]::Join('&', $_Category), [String]::Join(' AND ', $_Query.ToArray()) + + Try + { + + [Array]$_ResourcesFromIndexCol = Get-AllIndexResources -Uri $_uri -ApplianceConnection $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if ($PSBoundParameters['Unassigned']) + { + + $_ResourcesFromIndexCol = $_ResourcesFromIndexCol | Where-Object { $null -eq $_.serverHardwareUri } + + } + + if ($PSBoundParameters['InputObject']) + { + + "[{0}] Processing InputObject property." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + switch ($InputObject.category) + { + + $ResourceCategoryEnum.ServerHardware + { + + "[{0}] Filtering for Server Hardware resource '{1}' assigned to a server profile." -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject.name | Write-Verbose + + if ($InputObject.serverProfileUri) + { + + "[{0}] Resource is assigned to a server profile." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_ResourcesFromIndexCol = $_ResourcesFromIndexCol | Where-Object serverHardwareUri -eq $InputObject.uri + + } + + else + { + + "[{0}] Resource is not assigned to a server profile. Filtering based on ServerHardwareType" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_ResourcesFromIndexCol = $_ResourcesFromIndexCol | Where-Object serverHardwareTypeUri -eq $InputObject.serverHardwareTypeUri + + } + + } + + $ResourceCategoryEnum.ServerHardwareType + { + + "[{0}] Filtering for Server Hardware Type: {1} [{2}]" -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject.name, $InputObject.model | Write-Verbose + + $_ResourcesFromIndexCol = $_ResourcesFromIndexCol | Where-Object serverHardwareTypeUri -eq $InputObject.uri + + } + + $ResourceCategoryEnum.ServerProfileTemplate + { + + "[{0}] Filtering for Server Profile Template: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject.name | Write-Verbose + + $_ResourcesFromIndexCol = $_ResourcesFromIndexCol | Where-Object serverProfileTemplateUri -eq $InputObject.uri + + } + + } + + } + + if ($_ResourcesFromIndexCol.count -eq 0 -and $Name) + { + + "[{0}] Profile Resource Name '{1}' was not found on appliance {2}. Generate Error." -f $MyInvocation.InvocationName.ToString().ToUpper(), $Name, $_appliance.Name | Write-Verbose + + $Exceptionmessage = "The specified Server Profile '{0}' was not found on '{1}' appliance connection. Please check the name again, and try again." -f $Name, $_appliance.Name + $ErrorRecord = New-ErrorRecord HPEOneView.ServerProfileResourceException ServerProfileResourceNotFound ObjectNotFound "Name" -Message $ExceptionMessage + $PSCmdlet.WriteError($ErrorRecord) + + } + + foreach ($_member in $_ResourcesFromIndexCol) + { + + $_member.PSObject.TypeNames.Insert(0,'HPEOneView.ServerProfile') + + [void]$ProfileCollection.Add($_member) + + } + + } + + } + + End + { + + $ProfileCollection = $ProfileCollection | Sort-Object name + + "Done. {0} server profile resource(s) found." -f $ProfileCollection.count | Write-Verbose + + if ($PSBoundParameters['Detailed']) + { + + # Display Pertinant Server Profile data in Table format + $a1 = @{Expression={$_.name};Label="Name"}, + @{Expression={$profileCache[$serverHardwareTypeUri]};Label="Server Hardware Type"}, + @{Expression={ if ($profileCache[$enclosureGroupUri]) {$profileCache[$enclosureGroupUri]} + else { 'N/A' } + };Label="Enclosure Group"}, + @{Expression={ if ($_.serverHardwareUri){ (Send-OVRequest -Uri $_.serverHardwareUri ).name } + else { "Unassigned" } + };Label="Assigned"}, + @{Expression={ + + switch ($_.affinity) { + + "Bay" { "Device bay" } + "BayAndServer" { "Device bay + Server Hardware" } + + + } + + };Label="Server Affinity"}, + @{Expression={$_.state};Label="State"}, + @{Expression={$_.status};Label="Status"} + + $a2 = @{Expression={$_.bios.manageBios};Label="Manage BIOS";align="Left"}, + @{Expression={$_.boot.manageBoot};Label="Manage Boot Order";align="Left"}, + @{Expression={$_.firmware.manageFirmware};Label="Manage Firmware";align="Left"}, + @{Expression={if ($_.serialNumberType -eq "Virtual") { $_.serialNumber + " (v)" } else { $_.serialNumber + " (p)" }};Label="Serial Number"}, + @{Expression={if ($_.serialNumberType -eq "Virtual") { $_.uuid + " (v)" } else { $_.uuid + " (p)" }};Label="UUID"} + + + # Firmware Details + $f = @{Expression={ + if ($_.manageFirmware) { + + $baseline = Send-OVRequest $_.firmwareBaselineUri + "$($baseline.name) version $($baseline.version)" + + } + else { "none" } + + };Label="Firmware Baseline"} + + $c = @{Expression={$_.id};Label="ID";width=2}, + @{Expression={$_.functionType};Label="Type";width=12}, + @{Expression={ + + $address = @() + + # Mac Address + if ($_.macType -eq "Virtual" -and $_.mac) { $address += "MAC $($_.mac) (V)" } + elseif ($_.macType -eq "Physical" -and $_.mac) { $address += "MAC $($_.mac) (p)" } + + # WWNN + if ($_.wwpnType -eq "Virtual" -and $_.wwnn) { $address += "WWNN $($_.wwnn) (v)"} + elseif ($_.wwpnType -eq "Physical" -and $_.wwnn) { $address += "WWNN $($_.wwnn) (p)" } + + # WWPN + if ($_.wwpnType -eq "Virtual" -and $_.wwpn) { $address += "WWPN $($_.wwpn) (v)"} + elseif ($_.wwpnType -eq "Physical" -and $_.wwpn) { $address += "WWPN $($_.wwpn) (p)" } + + $addressCol = $address | Out-String | ForEach-Object { $_ -replace '^\s+|\s+$' } + $addressCol + + };Label="Address";width=32}, + @{Expression={$profileCache[$_.networkUri]};Label="Network"}, + @{Expression={$_.portId};Label="Port Id";width=10}, + @{Expression={[String]$_.requestedMbps};Label="Requested BW";width=12}, + @{Expression={[String]$_.maximumMbps};Label="Maximum BW";width=10}, + @{Expression={ + + $bootSetting = @() + $bootSetting += $_.boot.priority + if ($_.boot.targets) { + + for ($i=0; $i -eq $boot.targets.count; $i++) { $bootSetting += "WWN $($_.boot.targets[$i].arrayWwpn)`nLUN $($_.boot.targets[$i].lun)" } + + } + $bootSettingString = $bootSetting | Out-String | ForEach-Object { $_ -replace '^\s+|\s+$' } + $bootSettingString + + + };Label="Boot";width=20}, + @{Expression={ + + if ($_.functionType -eq "FibreChannel" -and -not ($_.boot.targets)) { "Yes" } + elseif ($_.functionType -eq "FibreChannel" -and $_.boot.targets) { "No" } + else { $Null } + + };Label="Use Boot BIOS";width=13} + + # Display extEnded BIOS settings + $b = @{Expression={$_.category};Label="BIOS Category"}, + @{Expression={$_.settingName};Label="Setting Name"}, + @{Expression={$_.valueName};Label="Configured Value"} + + $ls = @{Expression={$_.manageLocalStorage};Label="Manage Local Storage";align="Left"}, + @{Expression={$_.initialize};Label="Initialize Disk";align="Left"}, + @{Expression={ + + $logicalDriveCol = @() + $d=0 + + while ($d -lt $sp.logicalDrives.count) + { + + if ($_.logicalDrives[$d].bootable) { $logicalDriveCol += "Drive {$d} $($sp.logicalDrives[$d].raidLevel) (Bootable)" } + else { $logicalDriveCol += "Drive {$d} $($sp.logicalDrives[$d].raidLevel)" } + $d++ + } + + $logicalDriveString = $logicalDriveCol | Out-String | ForEach-Object { $_ -replace '^\s+|\s+$' } + $logicalDriveString + + };Label="Logical Disk"} + + $ss = @{Expression={$_.manageSanStorage};Label="Manage SAN Storage";align="Left"}, + @{Expression={$_.hostOSType};Label="Host OS Type";align="Left"} + + $p = @{Expression={[Int]$_.connectionId};Label="Connection ID";align="Left"}, + @{Expression={[String]$_.network};Label="Fabric";align="Left"}, + @{Expression={[String]$_.initiator};Label="Initiator";align="Left"}, + @{Expression={[String]$_.target};Label="Target";align="Left"}, + @{Expression={[Bool]$_.isEnabled};Label="Enabled";align="Left"} + + # Server Profile cache + $profileCache = @{} + + # Loop through all Server Profile objects and display details + ForEach ($profile in ($ProfileCollection | sort-object -property name)) + { + + $serverHardwareTypeUri = $profile.serverHardwareTypeUri + $enclosureGroupUri = $profile.enclosureGroupUri + + # Cache resources during runtime to reduce API calls to appliance. + if (-not ($profileCache[$serverHardwareTypeUri])) + { + + Try + { + + $_Sht = Send-OVRequest -Uri $serverHardwareTypeUri -appliance $profile.ApplianceConnection.name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $profileCache.Add($serverHardwareTypeUri, $_Sht.name) + + } + + if (-not ($profileCache[$enclosureGroupUri]) -and $profile.enclosureGroupUri) + { + + Try + { + + $_EG = Send-OVRequest -Uri $enclosureGroupUri -appliance $profile.ApplianceConnection.name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $profileCache.Add($enclosureGroupUri, $_EG.name) + + } + + foreach ($connection in $profile.connectionSettings.connections) + { + + $connection | ForEach-Object { $_.psobject.typenames.Insert(0,"HPEOneView.Profile.Connection") } + + if (-not ($profileCache[$connection.networkUri])) + { + + Try + { + + $_Net = Send-OVRequest -Uri $connection.networkUri -appliance $profile.ApplianceConnection.name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $profileCache.Add($connection.networkUri, $_Net.name) + + } + + } + + foreach ($volume in $profile.sanStorage.volumeAttachments) + { + + # Insert HPEOneView.Profile.SanVolume TypeName + $volume | ForEach-Object { $_.psobject.typenames.Insert(0,"HPEOneView.Profile.SanVolume") } + + # Cache Storage System, Storage Pool and Storage Volume Resources + if (-not ($profileCache[$volume.volumeStorageSystemUri])) { $profileCache.Add($volume.volumeStorageSystemUri,(Send-OVRequest $volume.volumeStorageSystemUri $profile.ApplianceConnection.name)) } + if (-not ($profileCache[$volume.volumeStoragePoolUri])) { $profileCache.Add($volume.volumeStoragePoolUri,(Send-OVRequest $volume.volumeStoragePoolUri $profile.ApplianceConnection.name)) } + if (-not ($profileCache[$volume.volumeUri])) { $profileCache.Add($volume.volumeUri,(Send-OVRequest $volume.volumeUri $profile.ApplianceConnection.name)) } + + } + + #$profileCache + + # Initial Server Profile information + $profile | format-table $a1 -AutoSize -wrap + $profile | format-table $a2 -AutoSize -wrap + + # Firmware Baseline + $profile.firmware | format-table $f + + # Server Profile Connection details + $profile.connectionSettings.connections | format-table -wrap + + # Local Storage + $profile.localStorage | format-table $ls -wrap -auto + + # SAN Storage + $profile.sanStorage | Format-Table $ss -auto + #$profile.sanStorage.volumeAttachments | format-table -auto + + $profile.sanStorage.volumeAttachments | ForEach-Object { + + $_ | format-table -auto + + $pathConnectionCol = @() + + foreach ($path in $_.storagePaths) + { + + $pathObject = [PSCustomObject]@{ + connectionId = $Null; + network = $Null; + initiator = $Null; + target = $Null; + isEnabled = $Null + } + + $pathConnection = $profile.connectionSettings.connections | Where-Object { $path.connectionId -eq $_.id } + + $pathObject.connectionId = $pathConnection.id + $pathObject.network = $profileCache[$pathConnection.networkUri] + $pathObject.initiator = $pathConnection.wwpn + $pathObject.target = if ($path.storageTargets) { $path.storageTargets } + else { "PEnding" } + $pathObject.isEnabled = [Bool]$path.isEnabled + $pathConnectionCol += $pathObject + + } + + # + # Display path details with a left padded view. Format-Table doesn't have the ability to pad the display + $capture = ($pathConnectionCol | Sort-Object connectionId | format-table $p -AutoSize -wrap | out-string) -split "`n" + $capture | ForEach-Object { ($_).PadLeft($_.length + 5) } + + } + + #Boot Order + $bootOrder = @() + if ($profile.boot.manageBoot) + { + + $i = 0 + while ($i -lt $profile.boot.order.count) + { + $bootOrder += "$($i+1) $($profile.boot.order[$i])" + $i++ + } + "Boot Order" + "----------" + $bootOrder + + } + else + { + + "No Boot Management" + + } + + # Display configured BIOS Settings from profile + $configedBiosSettings = @() + + foreach ($setting in $profile.bios.overriddenSettings) + { + + $shtBiosSettingDetails = $profileCache[$serverHardwareTypeUri].biosSettings | Where-Object { $setting.id -eq $_.id } + + $biosSetting = [PSCustomObject]@{ + + Category = $shtBiosSettingDetails.category; + settingName = $shtBiosSettingDetails.name; + valueName = ($shtBiosSettingDetails.options | Where-Object { $_.id -eq $setting.value } ).name; + + } + + $configedBiosSettings += $biosSetting + + } + + $configedBiosSettings | Sort-Object category,settingName | format-table $b + + "----------------------------------------------------------------------" + + } + + } + + # If user wants to export the profile configuration + elseif ($export) + { + + # Get the unique applianceConnection.name properties from the profile collection for grouping the output files + $ProfileGroupings = $ProfileCollection.ApplianceConnection.name | Select-Object -Unique + + ForEach ($pg in $ProfileGroupings) + { + + $outputProfiles = [System.Collections.ArrayList]::new() + + $profiles = $ProfileCollection | Where-Object {$_.ApplianceConnection.Name -eq $pg} + + # Loop through all profiles + foreach ($profile in $profiles) + { + + # Trim out appliance unique properties + + $_profile = $profile | select-object -Property * -excludeproperty uri,etag,created,modified,status,state,inprogress,enclosureUri,enclosureBay,serverHardwareUri,taskUri,ApplianceConnection + $_profile.serialNumberType = "UserDefined" + + # Loop through the connections to save the assigned address + $i = 0 + foreach ($connection in $profile.connectionSettings) + { + + if ($profile.connectionSettings.connections[$i].mac) + { + + $_profile.connectionSettings.connections[$i].macType = "UserDefined" + + } + + if ($profile.connectionSettings.connections[$i].wwpn) + { + + $_profile.connectionSettings.connections[$i].wwpnType = "UserDefined" + + } + + $i++ + + } + + [void]$outputProfiles.Add($_profile) + + } + + # Save profile to JSON file + "[{0}] Saving $($_profile.name) to $($location)\$($_profile.name).json" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + convertto-json -InputObject $outputProfiles -depth 99 | new-item "$location\$pg`_$($_profile.name).json" -itemtype file + + } + + } + + else + { + + Return $ProfileCollection + + } + + } + +} + +function New-OVServerProfile +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "Default", SupportsShouldProcess, ConfirmImpact = 'High')] + Param + ( + + [Parameter (Mandatory, ParameterSetName = "Default")] + [Parameter (Mandatory, ParameterSetName = "SANStorageAttach")] + [Parameter (Mandatory, ParameterSetName = "SPT")] + [ValidateNotNullOrEmpty()] + [String]$Name, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Parameter (Mandatory = $false, ParameterSetName = "SANStorageAttach")] + [Parameter (Mandatory = $false, ParameterSetName = "SPT")] + [Parameter (Mandatory = $false, ParameterSetName = "Import")] + [ValidateSet ("Bay", "Server", "Unassigned")] + [Alias ('assign')] + [String]$AssignmentType = 'Server', + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Parameter (Mandatory = $false, ParameterSetName = "SANStorageAttach")] + [Parameter (Mandatory = $false, ParameterSetName = "SPT")] + [ValidateNotNullOrEmpty()] + [object]$Enclosure, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Parameter (Mandatory = $false, ParameterSetName = "SANStorageAttach")] + [Parameter (Mandatory = $false, ParameterSetName = "SPT")] + [ValidateRange(1,16)] + [Alias ('bay')] + [int32]$EnclosureBay, + + [Parameter (Mandatory = $false, ValueFromPipeline, ParameterSetName = "Default")] + [Parameter (Mandatory = $false, ValueFromPipeline, ParameterSetName = "SANStorageAttach")] + [Parameter (Mandatory = $false, ValueFromPipeline, ParameterSetName = "SPT")] + [Parameter (Mandatory = $false, ValueFromPipeline, ParameterSetName = "Import")] + [ValidateNotNullOrEmpty()] + [object]$Server, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Parameter (Mandatory = $false, ParameterSetName = "SANStorageAttach")] + [Parameter (Mandatory = $false, ParameterSetName = "SPT")] + [String]$Description, + + [Parameter (Mandatory, ParameterSetName = "SPT")] + [Object]$ServerProfileTemplate, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Parameter (Mandatory = $false, ParameterSetName = "SANStorageAttach")] + [Parameter (Mandatory = $false, ParameterSetName = "SPT")] + [ValidateNotNullOrEmpty()] + [array]$Connections, + + [Parameter (Mandatory = $false, ParameterSetName = "SPT")] + [ValidateNotNullOrEmpty()] + [Hashtable]$FCConnectionAddresses, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Parameter (Mandatory = $false, ParameterSetName = "SANStorageAttach")] + [ValidateNotNullOrEmpty()] + [Alias ('eg')] + [object]$EnclosureGroup, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Parameter (Mandatory = $false, ParameterSetName = "SANStorageAttach")] + [ValidateNotNullOrEmpty()] + [Alias ('sht')] + [object]$ServerHardwareType, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Parameter (Mandatory = $false, ParameterSetName = "SANStorageAttach")] + [Parameter (Mandatory = $false, ParameterSetName = "SPT")] + [ValidateNotNullOrEmpty()] + [Switch]$Firmware, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Parameter (Mandatory = $false, ParameterSetName = "SANStorageAttach")] + [Parameter (Mandatory = $false, ParameterSetName = "SPT")] + [ValidateNotNullOrEmpty()] + [object]$Baseline, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Parameter (Mandatory = $false, ParameterSetName = "SANStorageAttach")] + [Parameter (Mandatory = $false, ParameterSetName = "SPT")] + [ValidateNotNullOrEmpty()] + [Version]$BaselinePatchLevel, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Parameter (Mandatory = $false, ParameterSetName = "SANStorageAttach")] + [Parameter (Mandatory = $false, ParameterSetName = "SPT")] + [ValidateSet ('LowerThanBaseline', 'NotEqualToBaseline')] + [String]$FirmwareInstallationPolicy = 'LowerThanBaseline', + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Parameter (Mandatory = $false, ParameterSetName = "SANStorageAttach")] + [Parameter (Mandatory = $false, ParameterSetName = "SPT")] + [Alias ('FirmwareMode')] + [ValidateSet ('FirmwareOnly', 'FirmwareAndSoftware', 'FirmwareOffline', 'FirmwareAndOSDrivers', 'FirmwareOnlyOfflineMode')] + [String]$FirmwareInstallMode = 'FirmwareAndSoftware', + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Parameter (Mandatory = $false, ParameterSetName = "SANStorageAttach")] + [Parameter (Mandatory = $false, ParameterSetName = "SPT")] + [ValidateSet ('Immediate', 'Scheduled', 'NotScheduled')] + [String]$FirmwareActivationMode = 'Immediate', + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Parameter (Mandatory = $false, ParameterSetName = "SANStorageAttach")] + [Parameter (Mandatory = $false, ParameterSetName = "SPT")] + [ValidateNotNullOrEmpty()] + [DateTime]$FirmwareActivateDateTime, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Parameter (Mandatory = $false, ParameterSetName = "SANStorageAttach")] + [Parameter (Mandatory = $false, ParameterSetName = "SPT")] + [Alias('ForceInstallFirmware')] + [Switch]$ReinstallFirmware, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Parameter (Mandatory = $false, ParameterSetName = "SANStorageAttach")] + [ValidateNotNullOrEmpty()] + [Switch]$Bios = $false, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Parameter (Mandatory = $false, ParameterSetName = "SANStorageAttach")] + [ValidateNotNullOrEmpty()] + [array]$BiosSettings = @(), + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Parameter (Mandatory = $false, ParameterSetName = "SANStorageAttach")] + [ValidateSet ("UEFI","UEFIOptimized","BIOS",'Unmanaged', IgnoreCase = $False)] + [String]$BootMode = "BIOS", + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Parameter (Mandatory = $false, ParameterSetName = "SANStorageAttach")] + [ValidateSet ("Auto","IPv4","IPv6","IPv4ThenIPv6","IPv6ThenIPv4", IgnoreCase = $False)] + [String]$PxeBootPolicy = "Auto", + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Parameter (Mandatory = $false, ParameterSetName = "SANStorageAttach")] + [Parameter (Mandatory = $false, ParameterSetName = "SPT")] + [Alias ('boot')] + [Switch]$ManageBoot, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Parameter (Mandatory = $false, ParameterSetName = "SANStorageAttach")] + [array]$BootOrder, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Parameter (Mandatory = $false, ParameterSetName = "SANStorageAttach")] + [ValidateSet ("Unmanaged", "Enabled", "Disabled", IgnoreCase = $False)] + [String]$SecureBoot = 'Unmanaged', + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Parameter (Mandatory = $false, ParameterSetName = "SANStorageAttach")] + [Parameter (Mandatory = $false, ParameterSetName = "SPT")] + [Switch]$LocalStorage, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Parameter (Mandatory = $false, ParameterSetName = "SANStorageAttach")] + [Parameter (Mandatory = $false, ParameterSetName = "SPT")] + [Alias ('LogicalDisk')] + [ValidateNotNullorEmpty()] + [Object]$StorageController, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Parameter (Mandatory = $false, ParameterSetName = "SANStorageAttach")] + [Parameter (Mandatory = $false, ParameterSetName = "SPT")] + [Bool]$ManageIloSettings = $false, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Parameter (Mandatory = $false, ParameterSetName = "SANStorageAttach")] + [Parameter (Mandatory = $false, ParameterSetName = "SPT")] + [ValidateNotNullOrEmpty()] + [PSCustomObject]$IloSettings, + + [Parameter (Mandatory, ParameterSetName = "SANStorageAttach")] + [Switch]$SANStorage, + + [Parameter (Mandatory, ParameterSetName = "SANStorageAttach")] + [ValidateSet ('CitrixXen','CitrixXen7','AIX','IBMVIO','RHEL4','RHEL3','RHEL','RHEV','RHEV7','VMware','Win2k3','Win2k8','Win2k12','Win2k16','Win2k19','OpenVMS','Egenera','Exanet','Solaris9','Solaris10','Solaris11','ONTAP','OEL','HPUX11iv1','HPUX11iv2','HPUX11iv3','SUSE','SUSE9','Inform','Ubuntu', IgnoreCase = $true)] + [Alias ('OS')] + [String]$HostOStype, + + [Parameter (Mandatory, ParameterSetName = "SANStorageAttach")] + [ValidateNotNullorEmpty()] + [object]$StorageVolume, + + [Parameter (Mandatory = $false, ParameterSetName = "SANStorageAttach")] + [Alias ('Even')] + [Switch]$EvenPathDisabled, + + [Parameter (Mandatory = $false, ParameterSetName = "SANStorageAttach")] + [Alias ('Odd')] + [Switch]$OddPathDisabled, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Parameter (Mandatory = $false, ParameterSetName = "SANStorageAttach")] + [ValidateSet ("Bay","BayAndServer", IgnoreCase = $false)] + [String]$Affinity = "Bay", + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Parameter (Mandatory = $false, ParameterSetName = "SANStorageAttach")] + [Parameter (Mandatory = $false, ParameterSetName = "SPT")] + [ValidateSet ("Virtual", "Physical", "UserDefined", IgnoreCase)] + [String]$MacAssignment = "Virtual", + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Parameter (Mandatory = $false, ParameterSetName = "SANStorageAttach")] + [Parameter (Mandatory = $false, ParameterSetName = "SPT")] + [ValidateSet ("Virtual", "Physical", "'UserDefined", IgnoreCase)] + [String]$WwnAssignment = "Virtual", + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Parameter (Mandatory = $false, ParameterSetName = "SANStorageAttach")] + [Parameter (Mandatory = $false, ParameterSetName = "SPT")] + [ValidateSet ("Virtual", "Physical", "UserDefined", IgnoreCase)] + [String]$SnAssignment = "Virtual", + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Parameter (Mandatory = $false, ParameterSetName = "SANStorageAttach")] + [Parameter (Mandatory = $false, ParameterSetName = "SPT")] + [ValidateNotNullOrEmpty()] + [String]$SerialNumber, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Parameter (Mandatory = $false, ParameterSetName = "SANStorageAttach")] + [Parameter (Mandatory = $false, ParameterSetName = "SPT")] + [ValidateNotNullOrEmpty()] + [String]$Uuid, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Parameter (Mandatory = $false, ParameterSetName = "SANStorageAttach")] + [Parameter (Mandatory = $false, ParameterSetName = "SPT")] + [ValidateNotNullOrEmpty()] + [Bool]$HideUnusedFlexNics = $True, + + [Parameter (Mandatory = $false, ParameterSetName = "SPT")] + [ValidateNotNullOrEmpty()] + [Array]$IscsiIPv4Address, + + [Parameter (Mandatory = $false, ParameterSetName = "SPT")] + [ValidateScript ({[RegEx]::Match($_,$iQNPattern).Success})] + [String]$ISCSIInitatorName, + + [Parameter (Mandatory = $false, ParameterSetName = "SPT")] + [ValidateNotNullOrEmpty()] + [SecureString]$ChapSecret, + + [Parameter (Mandatory = $false, ParameterSetName = "SPT")] + [ValidateNotNullOrEmpty()] + [SecureString]$MutualChapSecret, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Parameter (Mandatory = $false, ParameterSetName = "SANStorageAttach")] + [Parameter (Mandatory = $false, ParameterSetName = "SPT")] + [System.Obsolete("The OSDeploymentPlan parameter is obsolete and no longer supported.")] + [Object]$OSDeploymentPlan, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Parameter (Mandatory = $false, ParameterSetName = "SANStorageAttach")] + [Parameter (Mandatory = $false, ParameterSetName = "SPT")] + [System.Obsolete("The OSDeploymentAttributes parameter is obsolete and no longer supported.")] + [Array]$OSDeploymentAttributes, + + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = "Default")] + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = "SPT")] + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = "SANStorageAttach")] + [ValidateNotNullorEmpty()] + [HPEOneView.Appliance.ScopeCollection[]]$Scope, + + [Parameter (Mandatory = $false, ParameterSetName = "Import")] + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Parameter (Mandatory = $false, ParameterSetName = "SANStorageAttach")] + [Parameter (Mandatory = $false, ParameterSetName = "SPT")] + [Switch]$Async, + + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = "Default")] + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = "SPT")] + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = "SANStorageAttach")] + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = "Import")] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default), + + [Parameter (Mandatory, ParameterSetName = "Import")] + [Switch]$Import, + + [Parameter (Mandatory, ParameterSetName = "Import", ValueFromPipeline)] + [ValidateNotNullorEmpty()] + [Alias ("location","file")] + [Object]$ProfileObj, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Parameter (Mandatory = $false, ParameterSetName = "SANStorageAttach")] + [Parameter (Mandatory = $false, ParameterSetName = "SPT")] + [Switch]$Passthru + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if ($PSBoundParameters['Bootable']) + { + + Write-Warning 'The -Bootable Parameter has been deprecated. In order to configure local storage, please read Help New-OVServerProfile and the LocalDisk Parameter.' + + } + + if ($PSBoundParameters['RaidLevel']) + { + + Write-Warning 'The -RaidLevel Parameter has been deprecated. In order to configure local storage, please read Help New-OVServerProfile and the LocalDisk Parameter.' + + } + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + if (-not($PSBoundParameters['ServerProfileTemplate'])) + { + + if ($snAssignment -eq "UserDefined" -and (-not($serialnumber)) -and (-not($uuid))) + { + + $ErrorRecord = New-ErrorRecord HPEOneView.ServerProfileResourceException InvalidArgument InvalidArgument 'snAssignment' -Message "The -snAssignment paramter was set to 'UserDefined', however both -serialnumber and -uuid are Null. You must specify a value for both Parameters." + + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($snAssignment -eq "UserDefined" -and $serialnumber -and (-not($uuid))) + { + + $ErrorRecord = New-ErrorRecord HPEOneView.ServerProfileResourceException InvalidArgument InvalidArgument 'uuid' -Message "The -snAssignment paramter was set to 'UserDefined', however -uuid is Null. You must specify a value for both Parameters." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($snAssignment -eq "UserDefined" -and (-not($serialnumber)) -and $uuid) + { + + $ErrorRecord = New-ErrorRecord HPEOneView.ServerProfileResourceException InvalidArgument InvalidArgument 'serialnumber' -Message "The -snAssignment paramter was set to 'UserDefined', however -serialnumber is Null. You must specify a value for both Parameters." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + # Update the error information + switch ($AssignmentType) + { + + "server" + { + + if (-not($server)) + { + $ErrorRecord = New-ErrorRecord HPEOneView.ServerProfileResourceException InvalidArgument InvalidArgument 'Server' -Message "The -AssignmentType Parameter is set to 'server', but no server Parameter was supplied." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + "bay" + { + + if (-not($enclosureBay)) + { + + $ErrorRecord = New-ErrorRecord HPEOneView.ServerProfileResourceException InvalidArgument InvalidArgument 'AssignmentType' -Message "The -AssignmentType Parameter is set to 'bay', but no bay Parameter was supplied." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + if (-not($enclosure)) + { + + $ErrorRecord = New-ErrorRecord HPEOneView.ServerProfileResourceException InvalidArgument InvalidArgument 'AssignmentType' -Message "The -AssignmentType Parameter is set to 'bay', but no Enclosure Parameter was supplied." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + if (-not($ServerHardwareType)) + { + + $ErrorRecord = New-ErrorRecord HPEOneView.ServerProfileResourceException InvalidArgument InvalidArgument 'AssignmentType' -Message "The -AssignmentType Parameter is set to 'bay', but no ServerHardwareType Parameter was supplied." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + if ($ApplianceConnection.Count -gt 1) + { + + if($enclosure -is [String] -and $enclosure.StartsWith("/rest")) + { + + $ErrorRecord = New-ErrorRecord HPEOneView.ServerProfileResourceException InvalidServerHardwareTypeObject InvalidArgument 'Enclosure' -Message "Enclosure as URI is not supported for multiple appliance connections." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + } + + "unassigned" + { + + # If the profile is not based on a template, the SHT is required + if ((-not($PSBoundParameters['Template'])) -and (-not($PSBoundParameters['ServerHardwareType']))) + { + + $ErrorRecord = New-ErrorRecord HPEOneView.ServerProfileResourceException InvalidArgument InvalidArgument 'ServerHardwareType' -Message "The -AssignmentType Parameter is set to 'unassigned', but no server hardware type was supplied." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + if ($PSBoundParameters['Server']) + { + + $ErrorRecord = New-ErrorRecord HPEOneView.ServerProfileResourceException InvalidArgument InvalidArgument 'ServerHardwareType' -Message "The -AssignmentType Parameter is set to 'unassigned', and a Server object/name was provided. You cannot both assign and unassign a Server Profile." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + } + + # Check for URI values in Parameters and validate that only one appliance connection is provided in the call + if($ApplianceConnection.Count -gt 1) + { + + # SHT + if($serverHardwareType -is [String] -and $serverHardwareType.StartsWith($ServerHardwareTypesUri)) + { + + $ErrorRecord = New-ErrorRecord HPEOneView.ServerProfileResourceException InvalidServerHardwareTypeObject InvalidArgument 'New-OVPropfile' -Message "Server Hardware Type as URI is not supported for multiple appliance connections" + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + if($serverHardwareType -is [String] -and $serverHardwareType.StartsWith("/rest")) + { + + $ErrorRecord = New-ErrorRecord HPEOneView.ServerProfileResourceException InvalidServerHardwareTypeObject InvalidArgument 'New-OVPropfile' -Message "Server Hardware Type as URI is not supported for multiple appliance connections." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + # EG + if(($enclosureGroup -is [String] -and $enclosureGroup.StartsWith("/rest"))) + { + + $ErrorRecord = New-ErrorRecord HPEOneView.ServerProfileResourceException InvalidServerHardwareTypeObject InvalidArgument 'New-OVPropfile' -Message "Enclosure Group as URI is not supported for multiple appliance connections." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + # Server + if ($server -is [String] -and $server.StartsWith("/rest")) + { + + $ErrorRecord = New-ErrorRecord HPEOneView.ServerProfileResourceException InvalidServerHardwareTypeObject InvalidArgument 'New-OVPropfile' -Message "Server as URI is not supported for multiple appliance connections." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + #Baseline + if (($baseline -is [String]) -and ($baseline.StartsWith('/rest'))) + { + + $ErrorRecord = New-ErrorRecord HPEOneView.ServerProfileResourceException InvalidServerHardwareTypeObject InvalidArgument 'New-OVPropfile' -Message "Baseline as URI is not supported for multiple appliance connections." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + # Import + if($Import) + { + + $ErrorRecord = New-ErrorRecord HPEOneView.ServerProfileResourceException InvalidServerHardwareTypeObject InvalidArgument 'New-OVPropfile' -Message "Import functionality is not supported for multiple appliance connections." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + } + + if ($PSBoundParameters['IscsiIPv4Address']) + { + + $_TmpCollection = [System.Collections.ArrayList]::new() + + $IscsiIPv4Address | ForEach-Object { [void]$_TmpCollection.Add($_) } + + $IscsiIPv4Address = $_TmpCollection.Clone() + + } + + $uri = $ServerProfilesUri + + $colStatus = [System.Collections.ArrayList]::new() + + } + + Process + { + + if ($AssignmentType -eq 'Server' -and -not $Server) + { + + $ExceptionMessage = 'A Server resource object or name must be provided when using the "Server" AssignmentType parameter.' + $ErrorRecord = New-ErrorRecord HPEOneView.ServerProfileResourceException NullServerNotAllowed InvalidArgument 'Server' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + # Import Server Profile JSON to appliance + if ($PSBoundParameters['Import']) + { + + "[{0}] Import server profile" -f $($MyInvocation.InvocationName.ToString().ToUpper()) | Write-Verbose + + if (($ProfileObj -is [System.String]) -and (Test-Path $ProfileObj)) + { + + # Received file location + "[{0}] Received JSON file as input: {1}" -f $($MyInvocation.InvocationName.ToString().ToUpper()), $ProfileObj | Write-Verbose + + $ServerProfile = (get-content $ProfileObj) -join "`n" | convertfrom-json + + # Remove unique values with Select-Object + $ServerProfile = $ServerProfile | Select-Object * -Exclude uri,created,modified,eTag,ApplianceConnection + + } + + # Input object could be the JSON object, which is type [System.String] + elseif ($ProfileObj -is [System.String]) + { + + "[{0}] Received JSON resource object as input {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), ($ProfileObj | out-string) | Write-Verbose + + $ServerProfile = $ProfileObj -join "`n" | convertfrom-json + + } + + # Input object is PsCustomObject of a Server Profile + elseif ($ProfileObj -is [PsCustomObject]) + { + + "[{0}] Received JSON PsCustomObject as input {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), ($ProfileObj | out-string) | Write-Verbose + + $ServerProfile = $ProfileObj.PSObject.Copy() + + } + + # Inavlid input type for $ProfileObj and Generate Terminating Error + else + { + + $ErrorRecord = New-ErrorRecord HPEOneView.ServerProfileResourceException InvalidImportObject InvalidArgument 'ProfileObj' -Message "Invalid `$Import input object. Please check the object you provided for ProfileObj Parameter and try again" + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + else + { + + if ($PSBoundParameters['ServerProfileTemplate']) + { + + # Validate ServerProfileTemplate Parameter value + switch ($ServerProfileTemplate.GetType().Name) + { + + 'PSCustomObject' + { + + "[{0}] Received PSCustomObject for ServerProfileTemplate." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + "[{0}] Resource Name: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $ServerProfileTemplate.name | Write-Verbose + + "[{0}] Resource Category: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $ServerProfileTemplate.category | Write-Verbose + + if ($ServerProfileTemplate.category -ne $ResourceCategoryEnum.ServerProfileTemplate) + { + + $ExceptionMessage = "Invalid ServerProfileTemplate input object. The input object category '{0}' is not the expected value '{1}'. Please check the value and try again." -f $ServerProfileTemplate.category, $ResourceCategoryEnum.ServerProfileTemplate + $ErrorRecord = New-ErrorRecord HPEOneView.ServerProfileTemplateResourceException InvalidServerProfileTemplateObject InvalidArgument 'ServerProfileTemplate' -TargetType 'PSObject' -Message $ExceptionMessage + + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + # Validate the String data value + 'String' + { + + if ($ServerProfileTemplate.StartsWith($ServerProfileTemplatesUri)) + { + + "[{0}] Resource URI Received. Getting resource object from API." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $ServerProfileTemplate = Send-OVRequest -Uri $ServerProfileTemplate -Hostname $ApplianceConnection.Name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + else + { + + "[{0}] Resource Name Received." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $ServerProfileTemplate = Get-OVServerProfileTemplate -Name $ServerProfileTemplate -ApplianceConnection $ApplianceConnection.Name -ErrorAction Stop + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + } + + "[{0}] Requesting new Server Profile from API." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $ServerProfile = Send-OVRequest -Uri ($ServerProfileTemplate.uri + "/new-profile") -Hostname $ApplianceConnection.Name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $ServerProfile = $ServerProfile | Select-Object * -ExcludeProperty templateCompliance,uri,taskUri,inProgress,state,status,modified,created,associatedServer,eTag,category + + # If there are existing connections, handle the iSCSI ones for IPAddress and CHAP password + if ($ServerProfile.connectionSettings.connections) + { + + # Rebuild Connections into an ArrayList + $_TmpConnections = $ServerProfile.connectionSettings.connections.Clone() + + $ServerProfile.connectionSettings.connections = [System.Collections.ArrayList]::new() + + ForEach ($_con in $_TmpConnections) + { + + [void]$ServerProfile.connectionSettings.connections.Add($_con) + + } + + # Start counter should have been 1, not 0, as we don't have a Connection ID 0 in OneView. + For ([Int]$c = 1; $c -le $ServerProfile.connectionSettings.connections.Count; $c++) + { + + # Perform Param validation + if ($ServerProfile.connectionSettings.connections[$c].functionType -eq 'iSCSI') + { + + # ISCSI Connection is Bootable + if ($ServerProfile.connectionSettings.connections[$c].boot.priority -ne 'NotBootable') + { + + # An IPv4 Address was not provided, generate error + if (-not($PSBoundParameters['IscsiIPv4Address']) -and $ApplianceConnection.Type -ne 'Composer') + { + + $Message = 'Connection ID {0} is configured for {1}, but the -IscsiIPv4Address Parameter was not provided. Please specify an IPv4Address in your command.' -f $ServerProfile.connections[$c].id , $ServerProfile.connections[$c].boot.priority + $ErrorRecord = New-ErrorRecord HPEOneView.ServerProfileConnectionException IscsiIPv4AddressParamRequired InvalidArgument 'Connections' -TargetType 'PSObject' -Message $Message + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + # This is NOT an error, do don't generate one. Set initiatorNameSource -> UserDefined, and also need to set Profile to + if ($PSBoundParameters['ISCSIInitatorName']) + { + + $ServerProfileTemplate.iscsiInitiatorNameType = 'UserDefined' + $ServerProfile.connectionSettings.connections[$c].boot.initiatorName = $ISCSIInitatorName + $ServerProfile.connectionSettings.connections[$c].boot.initiatorNameSource = 'UserDefined' + + } + + switch ($ServerProfile.connectionSettings.connections[$c].boot.chapLevel) + { + + 'Chap' + { + + if (-not($PSBoundParameters['ChapSecret'])) + { + + $Message = 'Connection ID {0} is configured for "CHAP" Authentication, but the -ChapSecret Parameter was not provided.' -f $ServerProfile.connections[$c].id + $ErrorRecord = New-ErrorRecord HPEOneView.ServerProfileConnectionException ChapSecretParamRequired InvalidArgument 'Connections' -TargetType 'PSObject' -Message $Message + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + $ServerProfile.connectionSettings.connections[$c].boot.chapPassword = [Runtime.InteropServices.Marshal]::PtrToStringBSTR([Runtime.InteropServices.Marshal]::SecureStringToBSTR($ChapSecret)) + + } + + 'MutualChap' + { + + if (-not($PSBoundParameters['ChapSecret'])) + { + + $Message = 'Connection ID {0} is configured for "CHAP" Authentication, but the -ChapSecret Parameter was not provided.' + $ErrorRecord = New-ErrorRecord HPEOneView.ServerProfileConnectionException ChapSecretParamRequired InvalidArgument 'Connections' -TargetType 'PSObject' -Message $Message + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + if (-not($PSBoundParameters['MutualChapSecret'])) + { + + $Message = 'Connection ID {0} is configured for "MutualChap" Authentication, but the -MutualChapSecret Parameter was not provided.' + $ErrorRecord = New-ErrorRecord HPEOneView.ServerProfileConnectionException MutualChapSecretParamRequired InvalidArgument 'Connections' -TargetType 'PSObject' -Message $Messag + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + $ServerProfile.connectionSettings.connections[$c].boot.chapSecret = [Runtime.InteropServices.Marshal]::PtrToStringBSTR([Runtime.InteropServices.Marshal]::SecureStringToBSTR($ChapSecret)) + $ServerProfile.connectionSettings.connections[$c].boot.mutualChapSecret = [Runtime.InteropServices.Marshal]::PtrToStringBSTR([Runtime.InteropServices.Marshal]::SecureStringToBSTR($MutualChapSecret)) + + } + + } + + if ($IscsiIPv4Address.count -gt 0) + { + + "[{0}] Assigning {1} IPv4Address to Connection ID {2}." -f $MyInvocation.InvocationName.ToString().ToUpper(), $IscsiIPv4Address[0], $ServerProfile.connections[$c].id | Write-Verbose + + $_IPv4Address = $IscsiIPv4Address[0] + + [void]$IscsiIPv4Address.Remove($_IPv4Address) + + $ServerProfile.connectionSettings.connections[$c].boot.initiatorIp = $_IPv4Address + + } + + else + { + + $Message = 'Connection ID {0} is configured as a Bootable iSCSI Connection, however no additional IPv4Address is available to allocate.' -f $ServerProfile.connections[$c].id + $ErrorRecord = New-ErrorRecord HPEOneView.ServerProfileConnectionException MutualChapSecretParamRequired InvalidArgument 'Connections' -TargetType 'PSObject' -Message $Messag + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + } + + # Handle FC connections that require the adapter WWNN be provided at runtime with the FCConnectionAddresses parameter + elseif ($ServerProfile.connectionSettings.connections[$c].functionType -eq 'FibreChannel' -and -not $ServerProfile.connectionSettings.connections[$c].managed -and $ServerProfile.wwnType -eq 'Physical') + { + + if (-not $PSBoundParameters['FCConnectionAddresses']) + { + + # Generate warning message that unmanaged connections were found and no addresses were provided + $Message = 'FC connections with UserDefined values, must provide the FCConnectionAddresses parameter.' + $ErrorRecord = New-ErrorRecord HPEOneView.ServerProfileConnectionException RequiredFCConnectionAddresses InvalidArgument 'FCConnectionAddresses' -TargetType 'PSObject' -Message $Messag + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + else + { + + "[{0}] Setting connection id '{1}' to '{2}' WWPN address." -f $MyInvocation.InvocationName.ToString().ToUpper(), $FCConnectionAddresses.$c.Name, $FCConnectionAddresses.$c.Value | Write-Verbose + + $ServerProfile.connectionSettings.connections[$c].wwpn = $FCConnectionAddresses.$c.Value + + } + + } + + } + + } + + else + { + + $ServerProfile.connectionSettings.connections = [System.Collections.ArrayList]::new() + + } + + # Handle firmware differently + if ($ServerProfile.firmware.manageFirmware -and $ServerProfile.firmware.firmwareActivationType -eq 'Scheduled') + { + + $ServerProfile.firmware.forceInstallFirmware = $ReinstallFirmware.IsPresent + + if ($PSBoundParameters['FirmwareInstallMode']) + { + + "[{0}] Overriding SPT Firmware Install Type: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $ServerProfileFirmwareControlModeEnum[$FirmwareInstallMode] | Write-Verbose + $ServerProfile.firmware.firmwareInstallType = $ServerProfileFirmwareControlModeEnum[$FirmwareInstallMode] + + } + + if ($PSBoundParameters['FirmwareActivationMode']) + { + + $ServerProfile.firmware.firmwareActivationType = $ServerProfileFirmareActivationModeEnum[$FirmwareActivationMode] + + } + + if ('FirmwareOffline', 'FirmwareOnlyOfflineMode' -contains $ServerProfile.firmware.firmwareActivationType -and $PSBoundParameters['FirmwareActivateDateTime']) + { + + $ExceptionMessage = "The Server Profile Template is not configured to schedule firmware activation, and the use of -FirmwareActivationDateTime parameter is not supported. Please choose a different Server Profile Template with Online updates, or overrride using the -FirmwareInstallMode parameter." + $ErrorRecord = New-ErrorRecord HPEOneView.ServerProfileResourceException InvalidFirmwareInstallMode InvalidArgument 'FirmwareActivateDateTime' -TargetType 'Switch' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ServerProfile.firmware.firmwareActivationType -eq 'Scheduled' -and -not $PSBoundParameters['FirmwareActivateDateTime']) + { + + $ExceptionMessage = "The Server Profile Template provided is set to schedule firmware activation, which requires the -FirmwareActivateDateTime parameter." + $ErrorRecord = New-ErrorRecord HPEOneView.ServerProfileResourceException InvalidFirmwareInstallMode InvalidArgument 'FirmwareActivateDateTime' -TargetType 'Switch' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ServerProfile.firmware.firmwareActivationType -eq 'Scheduled' -and $PSBoundParameters['FirmwareActivateDateTime']) + { + + # Convert DateTime to UTC time for the appliance + "[{0}] Setting firmware activation schedule: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $FirmwareActivateDateTime.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ss.fffZ") | Write-Verbose + $ServerProfile.firmware.firmwareScheduleDateTime = $FirmwareActivateDateTime.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ss.fffZ") + + } + + } + + # Get SHT from Template + # Get the SHT of the SH that we are going to assign. + Try + { + + $ServerHardwareType = Send-OVRequest -Uri $ServerProfile.serverHardwareTypeUri -appliance $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if ($ServerProfile.enclosureGroupUri) + { + + Try + { + + $EnclosureGroup = Send-OVRequest -Uri $ServerProfile.enclosureGroupUri -appliance $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + # # Process OSDeploymentAttributes for SP from SPT + # # Do we need to first look at the osDeploymentSettings at all for Constraints? + # if ($PSBoundParameters['OSDeploymentAttributes']) + # { + + # If ($ApplianceConnection.ApplianceType -ne 'Composer') + # { + + # $ExceptionMessage = 'The ApplianceConnection {0} is not a Synergy Composer. The OSDeploymentAttributes parameter is only supported with HPE Synergy and HPE ImageStreamer.' -f $ApplianceConnection.Name + # $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.ComposerNodeException InvalidOperation InvalidOperation 'ApplianceConnection' -Message $ExceptionMessage + # $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + # } + + # ForEach ($_PlanAttribute in $ServerProfile.osDeploymentSettings.osCustomAttributes) + # { + + # if (($ServerProfile.osDeploymentSettings.osCustomAttributes | Where-Object { $_.Name -match ('{0}.constraint' -f $_PlanAttribute.name)}) -and 'Auto', 'DHCP' -notcontains $_PlanAttribute.value -and -not ($OSDeploymentAttributes | Where-Object name -eq $_PlanAttribute.name)) + # { + + # $ExceptionMessage = 'The attribute {0} requires a value and is not provided in the OSDeploymentAttributes.' -f $_PlanAttribute.name + # $ErrorRecord = New-ErrorRecord HPEOneView.ServerProfile.OSDeploymentAttributeResourceException InvalidOperation InvalidArgument 'OSDeploymentAttributes' -Message $ExceptionMessage + # $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + # } + + # '[{0}] Setting {1} attribute to {2}' -f $MyInvocation.InvocationName.ToString().ToUpper(), $_PlanAttribute.name, ($OSDeploymentAttributes | Where-Object name -eq $_PlanAttribute.name).value | Write-Verbose + + # ($ServerProfile.osDeploymentSettings.osCustomAttributes | Where-Object name -eq $_PlanAttribute.name).value = ($OSDeploymentAttributes | Where-Object name -eq $_PlanAttribute.name).value + + # } + + # } + + } + + else + { + + "[{0}] Get generic Server Profile object" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + # New Server Resource Object + $ServerProfile = NewObject -ServerProfile + + $ServerProfile.affinity = $Affinity + $ServerProfile.hideUnusedFlexNics = [Bool]$HideUnusedFlexNics + $ServerProfile.bios.manageBios = [Bool]$Bios + $ServerProfile.boot.manageBoot = $ManageBoot.IsPresent + $ServerProfile.boot.order = $BootOrder + + + # # Process OSDeploymentPlan + # if ($PSBoundParameters['OSDeploymentPlan']) + # |{ + + # If ($ApplianceConnection.ApplianceType -ne 'Composer') + # { + + # $ExceptionMessage = 'The ApplianceConnection {0} is not a Synergy Composer. The OSDeploymentPlan parameter is only supported with HPE Synergy and HPE ImageStreamer.' -f $ApplianceConnection.Name + # $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.ComposerNodeException InvalidOperation InvalidOperation 'ApplianceConnection' -Message $ExceptionMessage + # $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + # } + + # if ($OSDeploymentPlan.type -ne 'Osdp') + # { + + # $ExceptionMessage = 'The provided OSDeploymentPlan parameter value is not a valid OS Deployment Plan resource.' -f $ApplianceConnection.Name + # $ErrorRecord = New-ErrorRecord HPEOneView.ServerProfile.OSDeploymentPlanResourceException InvalidOperation InvalidArgument 'OSDeploymentPlan' -Message $ExceptionMessage + # $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + # } + + # $_OSDeploymentSettings = NewObject -OSDeploymentSettings + # $_OSDeploymentSettings.osDeploymentPlanUri = $OSDeploymentPlan.uri + + # ForEach ($_PlanAttribute in $OSDeploymentAttributes) + # { + + # if ($_PlanAttribute -isnot [HPEOneView.ServerProfile.OSDeployment.OSDeploymentParameter]) + # { + + # $ExceptionMessage = 'The provided OSDeploymentAttribute parameter value is not a valid resource.' -f $ApplianceConnection.Name + # $ErrorRecord = New-ErrorRecord HPEOneView.ServerProfile.OSDeploymentAttributeResourceException InvalidOperation InvalidArgument 'OSDeploymentAttributes' -Message $ExceptionMessage + # $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + # } + + # $_PlanAttributeSetting = NewObject -OSDeploymentPlanSetting + # $_PlanAttributeSetting.name = $_PlanAttribute.name + # $_PlanAttributeSetting.value = $_PlanAttribute.value + + # '[{0}] Setting {1} attribute to {2}' -f $MyInvocation.InvocationName.ToString().ToUpper(), $_PlanAttribute.name, $_PlanAttribute.value | Write-Verbose + + # [void]$_OSDeploymentSettings.osCustomAttributes.Add($_PlanAttributeSetting) + + # } + + # $ServerProfile | Add-Member -NotePropertyName osDeploymentSettings -NotePropertyValue $null -Force + + # $ServerProfile.osDeploymentSettings = $_OSDeploymentSettings + + # } + + } + + if ('Unassigned', 'Bay' -Contains $AssignmentType) + { + + "[{0}] Profile assignmentType: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $AssignmentType | Write-Verbose + + # Check to see if the serverHardwareType is null, and generate error(s) then break. + if (-not $ServerHardwareType) + { + + $ExceptionMessage = "Server Hardware Type is missing. Please provide a Server Hardware Type using the -sht Parameter and try again." + $ErrorRecord = New-ErrorRecord HPEOneView.ServerProfileResourceException InvalidServerHardwareTypeObject InvalidArgument 'ServerHardwareType' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + # If the URI is passed as the Server Hardware Type, then set the serverHardwareTypeUri variable + If ($ServerHardwareType -is [String]) + { + + if ($ServerHardwareType.StartsWith($ServerHardwareTypesUri)) + { + + "[{0}] SHT URI Provided: {1}" -f $($MyInvocation.InvocationName.ToString().ToUpper()), $ServerHardwareType | Write-Verbose + + Try + { + + $ServerHardwareType = Send-OVRequest -Uri $ServerHardwareType -appliance $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + # Otherwise, perform a lookup ofthe SHT based on the name + else + { + + "[{0}] SHT Name Provided: {1}" -f $($MyInvocation.InvocationName.ToString().ToUpper()), $ServerHardwareType | Write-Verbose + + Try + { + + $ServerHardwareType = Get-OVServerHardwareType -name $ServerHardwareType -ErrorAction Stop -ApplianceConnection $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + # Else the SHT object is passed + elseif ($ServerHardwareType) + { + + $ServerHardwareType = $ServerHardwareType | Where-Object { $_.ApplianceConnection.name -eq $ApplianceConnection.name } + + "[{0}] ServerHardwareType object provided" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + "[{0}] ServerHardwareType Name: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $ServerHardwareType.name | Write-Verbose + "[{0}] ServerHardwareType Uri: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $ServerHardwareType.uri | Write-Verbose + + } + + if (-not($PSBoundParameters['EnclosureGroup']) -and (-not([RegEx]::Match($ServerHardwareType.model, "DL", $RegExInsensitiveFlag).Success)) -and $AssignmentType -eq 'unassigned' -and $null -eq $ServerProfileTemplate) + { + + $ExceptionMessage = "Enclosure Group is missing. Please provide an Enclosure Group using the -EnclosureGroup Parameter and try again." + $ErrorRecord = New-ErrorRecord HPEOneView.ServerProfileResourceException InvalidEnclosureGroupObject InvalidArgument 'EnclosureGroup' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($PSBoundParameters['EnclosureGroup'] -is [String] -and $AssignmentType -eq 'unassigned') + { + + # If the URI is passed as the Enclosure Group, then set the enclosureGroupUri variable + if ($EnclosureGroup.StartsWith('/rest')) + { + + Try + { + + $EnclosureGroup = Send-OVRequest -Uri $EnclosureGroup -appliance $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + # Otherwise, perform a lookup ofthe Enclosure Group + else + { + + Try + { + + $EnclosureGroup = Get-OVEnclosureGroup -name $EnclosureGroup -ErrorAction Stop -appliance $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + "[{0}] EG URI: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $EnclosureGroup.uri | Write-Verbose + + } + + # Else the EG object is passed + elseif (($EnclosureGroup -is [Object]) -and ($EnclosureGroup.category -eq $ResourceCategoryEnum.EnclosureGroup) -and $AssignmentType -eq 'unassigned') + { + + $EnclosureGroup = $EnclosureGroup | Where-Object { $ApplianceConnection.name -eq $_.applianceConnection.name } + + "[{0}] Enclosure Group object provided" -f $MyInvocation.InvocationName.ToString().ToUpper(), $EnclosureGroup.name | Write-Verbose + "[{0}] Enclosure Group Name: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $EnclosureGroup.name | Write-Verbose + "[{0}] Enclosure Group Uri: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $EnclosureGroup.uri | Write-Verbose + + } + + elseif (-not $EnclosureGroup -and ($ServerHardwareType.platform -eq "RackServer")) + { + + "[{0}] Server is a ProLiant DL model. Enclosure Group not required." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + # EG Param not required if assignment is to a bay + elseif (-not $PSBoundParameters['EnclosureGroup'] -and $AssignmentType -eq 'bay') + { + + # First check for $enclosure Param + if (-not $PSBoundParameters['Enclosure']) + { + + $ExceptionMessage = "Enclosure parameter is missing. Please provide an Enclosure using the -enclosure Parameter and try again." + $ErrorRecord = New-ErrorRecord HPEOneView.ServerProfileResourceException InvalidEnclosureObject InvalidArgument 'Enclosure' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + # Retrieve the enclosure group uri from passed in enclosure uri Param + elseif($Enclosure -is [String]) + { + + if($Enclosure.StartsWith('/rest')) + { + + try + { + + $Enclosure = Send-OVRequest -Uri $Enclosure -appliance $ApplianceConnection + + } + + catch + { + + $ErrorRecord = New-ErrorRecord HPEOneView.ServerProfileResourceException InvalidEnclosureGroupObject InvalidArgument 'Enclosure' -Message "Enclosure is missing. Please provide an Enclosure using the -enclosure Parameter and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + # Enclosure is a name + else + { + + try + { + + $Enclosure = Get-OVEnclosure -Name $Enclosure -ErrorAction Stop -appliance $ApplianceConnection + + } + + catch + { + + $ErrorRecord = New-ErrorRecord HPEOneView.ServerProfileResourceException InvalidEnclosureGroupObject InvalidArgument 'Enclosure' -Message "Enclosure is missing. Please provide an Enclosure using the -enclosure Parameter and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + } + + elseif ($Enclosure -is [object] -and [RegEx]::Match($Enclosure.category, 'enclosures', $RegExInsensitiveFlag).Success) + { + + $Enclosure = $Enclosure | Where-Object { $_.ApplianceConnection.Name -eq $ApplianceConnection.name } + + "[{0}] Enclosure object provided" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + "[{0}] Enclosure Name: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Enclosure.uri | Write-Verbose + "[{0}] Enclosure's Enclosure Group Uri: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Enclosure.enclosureGroupUri | Write-Verbose + + $serverProfile.enclosureUri = $Enclosure.uri + $serverProfile.enclosureGroupUri = $Enclosure.enclosureGroupUri + $serverProfile.enclosureBay = $EnclosureBay + + } + + else + { + + $ExceptionMessage = "Enclosure Group is invalid. Please specify a correct Enclosure Group name, URI or object and try again." + $ErrorRecord = New-ErrorRecord HPEOneView.ServerProfileResourceException InvalidEnclosureGroupObject InvalidArgument 'EnclosureGroup' -TargetType $EnclosureGroup.GetType().Name -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + # Creating an assigned profile + else + { + + # Looking for the $server DTO to be string + if ($Server -is [String]) + { + + # If the server URI is passed, look up the server object + if ($Server.StartsWith($ServerHardwareUri)) + { + + "[{0}] Server URI passed: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Server | Write-Verbose + + Try + { + + $Server = Send-OVRequest -Uri $Server -appliance $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + # Else the name is passed and need to look it up. + else + { + + Try + { + + $Server = Get-OVServer -name $Server -appliance $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + "[{0}] Server object: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), ($Server | Out-String) | Write-Verbose + + # Check to make sure the server NoProfileApplied is true + if ($Server.serverProfileUri) + { + + Try + { + + $ServerProfileConflict = Send-OVRequest -Uri $Server.serverProfileUri -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $ExceptionMessage = "{0} already has a profile assigned, '{1}'. Please specify a different Server Hardware object." -f $Server.name, $ServerProfileConflict.name + $ErrorRecord = New-ErrorRecord HPEOneView.ServerProfileResourceException ServerProfileAlreadyAssigned ResourceExists 'Server' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + # Get the SHT of the SH that we are going to assign. + Try + { + + $ServerHardwareType = Send-OVRequest -Uri $Server.serverHardwareTypeUri -appliance $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + # Set the server hardware URI value in the profile + $ServerProfile.serverHardwareUri = $Server.uri + + if($AssignmentType -eq 'bay' -and $EnclosureBay) + { + + $ServerProfile | Add-Member -NotePropertyName enclosureBay -NotePropertyValue $EnclosureBay + + } + + if ($Server.serverGroupUri) + { + + "[{0}] Getting Enclosure Group object." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $EnclosureGroup = Send-OVRequest -Uri $Server.serverGroupUri -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + # User provided UEFI or UEFIOptimized for a non-Gen9 platform. + if ($BootMode -ne "BIOS" -and ("Gen9", "Gen10", "Gen11" -notcontains $ServerHardwareType.Generation)) + { + + $ExceptionMessage = "The -BootMode Parameter was provided and the Server Hardware model '{0}' does not support this Parameter. Please verify the Server Hardware Type is at least an HPE ProLiant Gen9." -f $ServerHardwareType.model + $ErrorRecord = New-ErrorRecord HPEOneView.ServerProfileResourceException BootModeNotSupported InvalidArgument 'BootMode' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + # Handle Boot Order and BootManagement + # Perform Device Model specific functions? + + # Handle DL Server Profiles by setting BL-specific properties to NULL + if ($ServerHardwareType.platform -eq "RackServer") + { + + "[{0}] Server Hardware Type is a DL, setting 'macType', 'wwnType', 'serialNumberType', 'affinity' and 'hideUnusedFlexNics' to supported values." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not $PSboundParameters['ServerProfileTemplate']) + { + + $ServerProfile.macType = 'Physical' + $ServerProfile.wwnType = 'Physical' + $ServerProfile.serialNumberType = 'Physical' + $ServerProfile.hideUnusedFlexNics = $true + $ServerProfile.affinity = $Null + + } + + } + + else + { + + if ($PSBoundParameters['MacAssignment']) + { + + "[{0}] MacAssignment override specified. Setting to: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $MacAssignment | Write-Verbose + + $ServerProfile.macType = $MacAssignment + + } + + if ($PSBoundParameters['WwnAssignment']) + { + + "[{0}] MacAsWwnAssignmentsignment override specified. Setting to: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $MacAssignment | Write-Verbose + + $ServerProfile.wwnType = $WwnAssignment + + } + + if ($PSBoundParameters['SnAssignment']) + { + + "[{0}] User is overriding SnAssignment type to: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $SnAssignment | Write-Verbose + + $ServerProfile.serialNumberType = $SnAssignment + + if ($SnAssignment -eq 'UserDefined') + { + + if (-not $PSBoundParameters['SerialNumber']) + { + + $ExceptionMessage = "The -SerialNumber Parameter is required when -SnAssignment is set to UserDefined. Provide a valid serial number value." + $ErrorRecord = New-ErrorRecord HPEOneView.ServerProfileResourceException MissingRequiredSerialNumberParameter InvalidOperation 'UserDefined' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + if (-not $PSBoundParameters['Uuid']) + { + + $ExceptionMessage = "The -Uuid Parameter is required when -SnAssignment is set to UserDefined. Provide a valid UUID value." + $ErrorRecord = New-ErrorRecord HPEOneView.ServerProfileResourceException MissingRequiredUuidParameter InvalidOperation 'UserDefined' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + "[{0}] User is overriding serialNumber to: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Serialnumber | Write-Verbose + "[{0}] User is overriding uuid to: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Uuid | Write-Verbose + + $ServerProfile.serialNumber = $Serialnumber + $ServerProfile.uuid = $Uuid + + } + + } + + } + + if ('Gen7', 'Gen8' -contains $ServerHardwareType.generation) + { + + if (-not($PSboundParameters['BootOrder']) -and $ManageBoot) + { + + "[{0}] No boot order provided for Gen8 Server resource type. Defaulting to 'CD','Floppy','USB','HardDisk','PXE'" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + [System.Collections.ArrayList]$serverProfile.boot.order = ('CD','Floppy','USB','HardDisk','PXE') + + } + + } + + else + { + + if (-not $ServerProfileTemplate) + { + + "[{0}] Gen 9/10 Server, setting BootMode to: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $BootMode | Write-Verbose + + $serverProfile.bootMode = NewObject -ServerProfileBootMode + + switch ($BootMode) + { + + 'Unmanaged' + { + + $serverProfile.bootMode.manageMode = $false + + } + + "BIOS" + { + + $serverProfile.bootMode = NewObject -ServerProfileBootModeLegacyBios + + $serverProfile.bootMode.manageMode = $true; + $serverProfile.bootMode.mode = $BootMode; + + } + + { "UEFI","UEFIOptimized" -match $_ } + { + + $serverProfile.bootMode.manageMode = $true; + $serverProfile.bootMode.mode = $BootMode; + $serverProfile.bootMode.pxeBootPolicy = $PxeBootPolicy + + if ([RegEx]::Match($ServerHardwareType.model, 'DL|XL|ML', $RegExInsensitiveFlag).Success) + { + + $serverProfile.boot.manageBoot = $false + + } + + if (-not $PSBoundParameters['SecureBoot'] -and $BootMode -eq 'UEFI' -and $ServerHardwareType.capabilities.Contains('SecureBoot')) + { + + $serverProfile.bootMode.secureBoot = 'Disabled' + + } + + } + + } + + } + + if ($BootOrder -or (-not $BootOrder -and -not $ServerProfileTemplate)) + { + + "[{0}] Processing Gen9/10 Server BootOrder settings." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if ($ManageBoot -and ($BootOrder -contains "Floppy") -and ([RegEx]::Match($BootMode, "UEFI", $RegExInsensitiveFlag).Success)) + # If ($BootOrder -contains "Floppy" -and [RegEx]::Match($BootMode, "UEFI", $RegExInsensitiveFlag).Success) + { + + $ExceptionMessage = "The -BootOrder Parameter contains 'Floppy' which is an invalid boot option for a UEFI-based system." + $ErrorRecord = New-ErrorRecord HPEOneView.ServerProfileResourceException InvalidUEFIBootOrderParameterValue InvalidArgument 'BootOrder' -TargetType 'Array' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ((-not ($PSBoundParameters["BootOrder"])) -and $ManageBoot -and ('Unmanaged','UEFI' -notcontains $BootMode)) + # Elseif ((-not ($PSBoundParameters["BootOrder"])) -and ('Unmanaged','UEFI' -notcontains $BootMode)) + { + + "[{0}] No boot order provided for Gen9 Server resource type. Defaulting to 'CD','USB','HardDisk','PXE'" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + [System.Collections.ArrayList]$serverProfile.boot.order = @('CD','USB','HardDisk','PXE') + + } + + elseif ((-not ($PSBoundParameters["BootOrder"])) -and $ManageBoot -and [RegEx]::Match($BootMode, 'UEFI' -and $ServerHardwareType.model -notmatch 'DL|XL|ML', $RegExInsensitiveFlag).Success) + # Elseif ((-not ($PSBoundParameters["BootOrder"])) -and [RegEx]::Match($BootMode, 'UEFI' -and $ServerHardwareType.model -notmatch 'DL', $RegExInsensitiveFlag).Success) + { + + "[{0}] No boot order provided for BL Gen9 Server resource type. Defaulting to 'HardDisk'." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + [System.Collections.ArrayList]$serverProfile.boot.order = @('HardDisk') + + } + + elseif (($BootOrder.count -gt 1) -and $ManageBoot -and [RegEx]::Match($BootMode, 'UEFI', $RegExInsensitiveFlag).Success) + # Elseif (($BootOrder.count -gt 1) -and [RegEx]::Match($BootMode, 'UEFI', $RegExInsensitiveFlag).Success) + { + + $ExceptionMessage = "The -BootOrder Parameter contains more than 1 entry, and the system BootMode is set to {0}, which is invalud for a UEFI-based system. Please check the -BootOrder Parameter and make sure either 'HardDisk' or 'PXE' are the only option." -f $BootMode + $ErrorRecord = New-ErrorRecord HPEOneView.ServerProfileResourceException InvalidUEFIBootOrderParameterValue InvalidArgument 'BootOrder' -TargetType 'Array' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($BootOrder -and $serverProfile.boot.manageBoot -and [RegEx]::Match($BootMode, 'UEFI' -and $ServerHardwareType.model -notmatch 'DL|XL|ML', $RegExInsensitiveFlag).Success) + # Elseif ($BootOrder -and $serverProfile.boot.manageBoot -and [RegEx]::Match($BootMode, 'UEFI' -and $ServerHardwareType.model -notmatch 'DL', $RegExInsensitiveFlag).Success) + { + + "[{0}] Adding provided BootOrder {1} to Server Profile object." -f $MyInvocation.InvocationName.ToString().ToUpper(), ($BootOrder -join ', ') | Write-Verbose + + [System.Collections.ArrayList]$serverProfile.boot.order = $BootOrder + + } + + } + + } + + $ServerProfile.name = $Name + $ServerProfile.description = $Description + $ServerProfile.serverHardwareTypeUri = $ServerHardwareType.uri + + if ($EnclosureGroup -and $null -eq $ServerProfile.enclsosureGroupUri) + { + + $ServerProfile.enclosureGroupUri = $EnclosureGroup.uri + + } + + if ($EnclosureBay -and $null -eq $ServerProfile.enclosureBay) + { + + $ServerProfile.enclosureBay = $EnclosureBay + + } + + # Check to make sure Server Hardware Type supports Firmware Management (OneView supported G7 blade would not support this feature) + if ($PSBoundParameters['Firmware']) + { + + "[{0}] Firmware Baseline: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Baseline | Write-Verbose + + if ([RegEx]::Match($ServerHardwareType.capabilities, "firmwareUpdate", $RegExInsensitiveFlag).Success) + { + + "[{0}] SHT is capable of firmware management" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $ServerProfile.firmware.manageFirmware = [Bool]$firmware + $ServerProfile.firmware.forceInstallFirmware = $ReinstallFirmware.IsPresent + + # Refactor to check if the $Baseline value is a baseline or update object + switch ($Baseline.GetType().FullName) + { + + # Baseline resource from Get-OVBaseline + 'HPEOneView.Appliance.Baseline' + { + + "[{0}] Setting firmware baseline: {1} - {2} - {3}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Baseline.name, $Baseline.version, $Baseline.releaseDate | Write-Verbose + + $ServerProfile.firmware.firmwareBaselineUri = $Baseline.uri + + # If the caller provided the -PatchLevel parameter, generate a non-terminating error it is not supported with the baseline resource provided + if ($PSBoundParameters['PatchLevel']) + { + + $ExceptionMessage = "The provided Baseline '{0}' does not support the PatchLevel parameter." -f $Baseline.name + $ErrorRecord = New-ErrorRecord HPEOneView.Appliance.BaselineResourceException InvalidPatchLevel InvalidArgument 'PatchLevel' -Message $ExceptionMessage + $PSCmdlet.WriteError($ErrorRecord) + + } + + } + + # Bundle Update from Get-OVFirmwareBundleUpdate + 'HPEOneView.Appliance.FirmwareBundleUpdate' + { + + "[{0}] Setting firmware bundle update: {1} - {2} - {3}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Baseline.name, $Baseline.version, $Baseline.releaseDate | Write-Verbose + + # Validate Patch level + if ($PSBoundParameters['PatchLevel']) + { + + "[{0}] Setting firmware patch level: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $PatchLevel | Write-Verbose + + # Check to make sure the requested patch level exists within the firmware update bundle + $FoundPatchLevel = $Baseline.servicePackData.supplements | ? { [version]$_.version -eq $patchlevel } + + if (-not $FoundPatchLevel) + { + + "[{0}] Patch Level '{1}' not found in firmware bundle update '{2}'." -f $MyInvocation.InvocationName.ToString().ToUpper(), $PatchLevel, $Baseline.name | Write-Verbose + + $ExceptionMessage = "The provided Patch Level '{0}' is not found in the firmware bundle update '{1}'." -f $PatchLevel, $Baseline + $ErrorRecord = New-ErrorRecord HPEOneView.ServerHardwareResourceException InvalidPatchLevel InvalidArgument 'PatchLevel' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + $_PatchLevel = "{0:0000}.{1:00}.{2:00}.{3:00}" -f $PatchLevel.Major, $PatchLevel.Minor, $PatchLevel.Build, $PatchLevel.Revision + $ServerProfile.firmware | Add-Member -NotePropertyName patchLevel -NotePropertyValue $_PatchLevel + + $ServerProfile.firmware.firmwareBaselineUri = $Baseline.uri + + } + + } + + 'System.String' + { + + if ($Baseline.StartsWith('/rest') -or $Baseline.EndsWith('.iso')) + { + + $ServerProfile.firmware.firmwareBaselineUri = $Baseline + + } + + else + { + + $ExceptionMessage = "The provided Baseline '{0}' is not a valid Baseline resource." -f $Baseline + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.BaselineResourceException InvalidBaselineResource InvalidArgument 'Baseline' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + # Unknown value and throw error + default + { + + $ExceptionMessage = "The provided Baseline '{0}' is not a valid Baseline resource." -f $Baseline + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.BaselineResourceException InvalidBaselineResource InvalidArgument 'Baseline' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + # This policy setting is only supported with Gen10 and newer platforms + if ([enum]::IsDefined([FirmwarePolicyGenerationSupportEnum], $ServerHardwareType.generation.Replace(" ", $null))) + { + + $ServerProfile.firmware.installationPolicy = $FirmwareInstallationPolicy + + } + + else + { + + $ExceptionMessage = "Baseline installation policy is only available with Gen10 and newer platforms. It is not supported with '{0}'." -f $ServerHardwareType.generation + $ErrorRecord = New-ErrorRecord HPEOneView.ServerProfileResourceException InvalidFirmwareInstallPolicy InvalidArgument 'FirmwareInstallationPolicy' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + $ServerProfile.firmware.firmwareInstallType = $ServerProfileFirmwareControlModeEnum[$FirmwareInstallMode] + $ServerProfile.firmware.firmwareActivationType = $ServerProfileFirmareActivationModeEnum[$FirmwareActivationMode] + + if ('FirmwareOffline', 'FirmwareOnlyOfflineMode' -contains $FirmwareInstallMode -and $PSBoundParameters['FirmwareActivateDateTime']) + { + + $ExceptionMessage = "The specifying of a scheduled firmware installation and performing offline method is not supported. Please choose an online method." + $ErrorRecord = New-ErrorRecord HPEOneView.ServerProfileResourceException InvalidFirmwareInstallMode InvalidArgument 'FirmwareActivateDateTime' -TargetType 'Switch' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($FirmwareActivationMode -eq 'Scheduled' -and -not $PSBoundParameters['FirmwareActivateDateTime']) + { + + $ExceptionMessage = "The specifying a scheduled firmware installation requires the -FirmwareActivateDateTime parameter." + $ErrorRecord = New-ErrorRecord HPEOneView.ServerProfileResourceException InvalidFirmwareInstallMode InvalidArgument 'FirmwareActivateDateTime' -TargetType 'Switch' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($FirmwareActivationMode -eq 'Scheduled' -and $PSBoundParameters['FirmwareActivateDateTime']) + { + + # Convert DateTime to UTC time for the appliance + "[{0}] Setting firmware activation schedule: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $FirmwareActivateDateTime.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ss.fffZ") | Write-Verbose + $ServerProfile.firmware.firmwareScheduleDateTime = $FirmwareActivateDateTime.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ss.fffZ") + + } + + + } + + else + { + + $ExceptionMessage = '"{0}" Server Hardware Type does not support Firmware Management.' -f $serverHardwareType.name + $ErrorRecord = New-ErrorRecord HPEOneView.ServerProfileResourceException ServerHardwareMgmtFeatureNotSupported InvalidOperation 'Firmware' -TargetType 'SwitchParameter' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + # Exmamine the profile connections Parameter and pull only those connections for this appliance connection + If ($PSBoundParameters['Connections']) + { + + # Rebuild the connections configuration if SPT is provided + if ($PSBoundParameters['ServerProfileTemplate']) + { + + $__OriginalConnectionConfig = $serverProfile.connectionSettings.connections.Clone() + + $serverProfile.connectionSettings.connections = [System.Collections.ArrayList]::new() + + ForEach ($__c in $__OriginalConnectionConfig) + { + + [void]$serverProfile.connectionSettings.connections.Add($__c) + + } + + } + + $BootableConnections = [System.Collections.ArrayList]::new() + + # Check if non BL or SY, and set the search value to only get the list of Fibre Channel networks that are not Direct Attach? + if ($ServerHardwareType.capabilities -notcontains 'VCConnections') + { + + ForEach ($c in $Connections) + { + + # Validate the connection specified is FibreChannel; throw error if not + if ($c.functionType -ne 'FibreChannel') + { + + $ExceptionMessage = 'The provided connection {0} is an Ethernet connection, which is not allowed. Only unmanaged Fibre Channel connections can be provisioned with non-Virtual Connect configurations.' -f $c.id + $ErrorRecord = New-ErrorRecord HPEOneView.ServerProfileConnectionException UnsupportedConnectionType InvalidArgument 'Connections' -TargetType 'PSObject' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + # Check for duplicate WWPN + if ($_duplicateConnectionAddress = $ServerProfile.connectionSettings.connections | ? wwpn -eq $c.wwpn) + { + + $ExceptionMessage = 'Connection {0} with the same WWPN is found. WWPNs must be unique within the server profile.' -f $_duplicateConnectionAddress.id + $ErrorRecord = New-ErrorRecord HPEOneView.ServerProfileConnectionException DuplicateWwpnAddressFound InvalidArgument 'Connections' -TargetType 'PSObject' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + "[{0}] Adding unmanaged connection {1} to profile." -f $MyInvocation.InvocationName.ToString().ToUpper(), $c.id | Write-Verbose + + [void]$ServerProfile.connectionSettings.connections.Add([ServerProfileUnmanagedFCConnection]::new($c)) + + } + + } + + else + { + + "[{0}] Getting available Network resources based on SHT and EG." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + # Need to have a statement to check for connections that this URI will not return a value for + # Get avaialble Networks based on the EG and SHT + $_uri = '{0}?serverHardwareTypeUri={1}&enclosureGroupUri={2}' -f $ServerProfilesAvailableNetworksUri, $ServerHardwareType.uri, $EnclosureGroup.uri + + Try + { + + $_AvailableNetworkResources = Send-OVRequest -Uri $_uri -Hostname $ApplianceConnection.Name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + ForEach($c in $connections) + { + + $Message = $null + + # Remove connection Parameters no permitted in Template + $c = $c | Select-Object -property * -ExcludeProperty ApplianceConnection + + # Handle network unassigned connections + if ($c.networkUri) + { + + switch ($c.networkUri) + { + + {$_.Contains($EthernetNetworksUri)} + { + + if (-not($_AvailableNetworkResources.ethernetNetworks | Where-Object uri -eq $c.networkUri)) + { + + $Message = "The Ethernet network {0} specified in Connection {1} was not found to be provisioned to the provided Enclosure Group, {2}, and SHT, {3}. Please verify that the network is a member of an Uplink Set in the associated Logical Interconnect Group." -f (Send-OVRequest $c.networkUri -Hostname $ApplianceConnection.Name).name, $c.id, $EnclosureGroup.name, $ServerHardwareType.name + + } + + else + { + + "[{0}] {1} is available for Connection {2} in this Server Profile request." -f $MyInvocation.InvocationName.ToString().ToUpper(), $c.networkUri, $c.id | Write-Verbose + + # Add check for iSCsi Initiator Name, to make sure the initiatorName property is set correctly. + + if ($MacAssignment -eq 'Physical' -and $c.macType -ne "UserDefined") + { + + $c.macType = 'Physical' + + } + + } + + } + + {$_.Contains($NetworkSetsUri)} + { + + if (-not($_AvailableNetworkResources.networkSets | Where-Object uri -eq $c.networkUri)) + { + + $Message = "The network set {0} specified in Connection {1} was not found to be provisioned to the provided Enclosure Group, {2}, and SHT, {3}. Please verify that the network is a member of an Uplink Set in the associated Logical Interconnect Group." -f (Send-OVRequest $c.networkUri -Hostname $ApplianceConnection.Name).name, $c.id, $EnclosureGroup.name, $ServerHardwareType.name + + } + + else + { + + "[{0}] {1} is available for Connection {2} in this Server Profile request." -f $MyInvocation.InvocationName.ToString().ToUpper(), $c.networkUri, $c.id | Write-Verbose + + if ($MacAssignment -eq 'Physical' -and $c.macType -ne "UserDefined") + { + + $c.macType = 'Physical' + + } + + } + + } + + {$_.Contains($FcNetworksUri)} + { + + if (-not($_AvailableNetworkResources.fcNetworks | Where-Object uri -eq $c.networkUri)) + { + + $Message = "The FC network {0} specified in Connection {1} was not found to be provisioned to the provided Enclosure Group, {2}, and SHT, {3}. Please verify that the network is a member of an Uplink Set in the associated Logical Interconnect Group." -f (Send-OVRequest $c.networkUri -Hostname $ApplianceConnection.Name).name, $c.id, $EnclosureGroup.name, $ServerHardwareType.name + + } + + else + { + + "[{0}] {1} is available for Connection {2} in this Server Profile request." -f $MyInvocation.InvocationName.ToString().ToUpper(), $c.networkUri, $c.id | Write-Verbose + + if ($MacAssignment -eq 'Physical' -and $c.macType -ne "UserDefined") + { + + $c.macType = 'Physical' + + } + + if ($WwnAssignment -eq 'Physical' -and $c.wwpnType -ne "UserDefined") + { + + $c.wwpnType = 'Physical' + + } + + } + + } + + {$_.Contains($FCoENetworksUri)} + { + + if (-not($_AvailableNetworkResources.fcNetworks | Where-Object uri -eq $c.networkUri)) + { + + $Message = "The FCoE network {0} specified in Connection {1} was not found to be provisioned to the provided Enclosure Group, {2}, and SHT, {3}. Please verify that the network is a member of an Uplink Set in the associated Logical Interconnect Group." -f (Send-OVRequest $c.networkUri -Hostname $ApplianceConnection.Name).name, $c.id, $EnclosureGroup.name, $ServerHardwareType.name + + } + + else + { + + "[{0}] {1} is available for Connection {2} in this Server Profile request." -f $MyInvocation.InvocationName.ToString().ToUpper(), $c.networkUri, $c.id | Write-Verbose + + + if ($MacAssignment -eq 'Physical' -and $c.macType -ne "UserDefined") + { + + $c.macType = 'Physical' + + } + + if ($WwnAssignment -eq 'Physical' -and $c.wwpnType -ne "UserDefined") + { + + $c.wwpnType = 'Physical' + + } + + } + + } + + } + + } + + if ($Message) + { + + $ErrorRecord = New-ErrorRecord HPEOneView.ServerProfileConnectionException NetworkResourceNotProvisioned InvalidArgument 'Connections' -TargetType 'PSObject' -Message $Message + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + [void]$ServerProfile.connectionSettings.connections.Add($c) + + if ($null -ne $c.boot -and $c.boot.priority -ne "NotBootable") + { + + "[{0}] Found bootable connection ID: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $c.id | Write-Verbose + + [void]$BootableConnections.Add($c.id) + + } + + } + + if (-not $PSBoundParameters['ManageBoot'] -and $BootableConnections.count -gt 0) + { + + $ExceptionMessage = "Bootable Connections {0} were found, however the -ManageBoot switch Parameter was not provided. Please correct your command syntax and try again." -f [String]::Join(', ', $BootableConnections.ToArray()) + $ErrorRecord = New-ErrorRecord HPEOneView.ServerProfileResourceException BootableConnectionsFound InvalidArgument 'manageBoot' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + } + + # Check to make sure Server Hardware Type supports Bios Management (OneView supported G7 blade do not support this feature) + if ($PSBoundParameters['BIOS']) + { + + if ([RegEx]::Match($serverHardwareType.capabilities, "ManageBIOS", $RegExInsensitiveFlag).Success) + { + + if ($BiosSettings.GetEnumerator().Count -gt 0) + { + + # check for any duplicate keys + $biosFlag = $false + $hash = @{} + $BiosSettings.id | ForEach-Object { $hash[$_] = $hash[$_] + 1 } + + foreach ($biosItem in ($hash.GetEnumerator() | Where-Object {$_.value -gt 1} | ForEach-Object {$_.key} )) + { + + $ErrorRecord = New-ErrorRecord HPEOneView.ServerProfileResourceException BiosSettingsNotUnique InvalidOperation 'BiosSettings' -TargetType 'Array' -Message "'$(($ServerHardwareType.biosSettings | where { $_.id -eq $biosItem }).name)' is being set more than once. Please check your BIOS Settings are unique. This setting might be a depEndency of another BIOS setting/option. Please check your BIOS Settings are unique. This setting might be a depEndency of another BIOS setting/option." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + $serverProfile.bios.overriddenSettings = $BiosSettings + + } + + else + { + + $ErrorRecord = New-ErrorRecord HPEOneView.ServerProfileResourceException ServerHardwareMgmtFeatureNotSupported NotImplemented 'New-OVServerProfile' -Message "`"$($ServerHardwareType.name)`" Server Hardware Type does not support BIOS Management." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + # Manage Secure Boot settings + if ($PSBoundParameters['SecureBoot']) + { + + if ($SecureBoot -eq 'Disabled') + { + + "[{0}] SecureBoot will be disabled." -f $MyInvocation.InvocationName.ToString().ToUpper(), $__controller.deviceSlot | Write-Verbose + + $serverProfile.bootMode.secureBoot = $SecureBoot + + } + + # Check to make sure Server Hardware supports SecureBoot + elseif ($ServerHardwareType.capabilities.Contains('SecureBoot') -and $BootMode -eq 'UEFIOptimized') + { + + $serverProfile.bootMode.secureBoot = $SecureBoot + + } + + # Generate exception if not + elseif ($ServerHardwareType.capabilities.Contains('SecureBoot') -and $BootMode -ne 'UEFIOptimized') + { + + $ExceptionMessage = 'The Server Hardware Type "{0}" supports managing SecureBoot, but BootMode was not set to "UEFIOptimized".' -f $ServerHardwareType.name + $ErrorRecord = New-ErrorRecord HPEOneView.ServerProfileResourceException InvalidBootModeManageValue InvalidArgument 'BootMode' -TargetType 'Bool' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif (-not $ServerHardwareType.capabilities.Contains('SecureBoot') -and $BootMode -eq 'UEFIOptimized') + { + + $ExceptionMessage = 'The Server Hardware Type "{0}" does not support managing SecureBoot.' -f $ServerHardwareType.name + $ErrorRecord = New-ErrorRecord HPEOneView.ServerProfileResourceException InvalidSecureBootManageValue InvalidArgument 'SecureBoot' -TargetType 'Bool' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + # Set Local Storage Management and Check to make sure Server Hardware Type supports it (OneView supported G7 blade would not support this feature) + if (($PSBoundParameters['StorageController']) -and ($ServerHardwareType.capabilities -Contains "ManageLocalStorage" )) + { + + # Rebuild the controller configuration if SPT is provided + if ($PSBoundParameters['ServerProfileTemplate']) + { + + $__OriginalControllerConfig = $serverProfile.localStorage.controllers.Clone() + + $serverProfile.localStorage.controllers = [System.Collections.ArrayList]::new() + + ForEach ($__c in $__OriginalControllerConfig) + { + + [void]$serverProfile.localStorage.controllers.Add($__c) + + } + + } + + # Loop through Controllers provided by user, which should have LogicalDisks attached. + ForEach ($_Controller in $StorageController) + { + + # //TODO: Look to see if the controller provided already exists, if so, only add the specified drives + + # Loop through Controllers provided by user, which should have LogicalDisks attached. + $__controller = $_Controller.PSObject.Copy() + + $_NewLogicalDisksCollection = [System.Collections.ArrayList]::new() + + "[{0}] Processing {1} Controller" -f $MyInvocation.InvocationName.ToString().ToUpper(), $__controller.deviceSlot | Write-Verbose + + # Validate the SHT.storageCapabilities controllerModes -> mode, raidLevels -> logicalDrives.raidLevel and maximumDrives -> numPhysicalDrives + if ($__controller.mode -eq 'RAID' -and ($ServerHardwareType.storageCapabilities.controllerModes -notcontains 'Mixed' -and $ServerHardwareType.storageCapabilities.controllerModes -notcontains 'RAID')) + { + + $_ExceptionMessage = "Unsupported LogicalDisk policy with Virtual Machine Appliance. The requested Controller Mode '{0}' is not supported with the expected Server Hardware Type, which only supports '{1}'" -f $__controller.mode, ([System.String]::Join("', '", $ServerHardwareType.storageCapabilities.controllerModes)) + $ErrorRecord = New-ErrorRecord HPEOneView.ServerProfile.LogicalDiskException UnsupportedImportConfigurationSetting InvalidOperation "StorageController" -TargetType 'PSObject' -Message $_ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + # Need to set Gen10+ controller mode to Mixed, especially if ImportConfiguration is requested + elseif ($__controller.mode -eq 'RAID' -and 'Mixed' -eq $ServerHardwareType.storageCapabilities.controllerModes) + { + + $__controller.mode = "Mixed" + + } + + $_l = 1 + + "[{0}] Storage Controller has {1} LogicalDrives to Process" -f $MyInvocation.InvocationName.ToString().ToUpper(), $__controller.logicalDrives.count | Write-Verbose + + # Validate the SHT.storageCapabilities .raidLevels -> logicalDrives.raidLevel and .maximumDrives -> numPhysicalDrives + ForEach ($_ld in $__controller.logicalDrives) + { + + "[{0}] Processing {1} of {2} LogicalDisk: {3}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_l, $__controller.logicalDrives.count, $_ld.name | Write-Verbose + + "[{0}] {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), ($_ld | Out-String) | Write-Verbose + + if ($_ld.PSObject.Properties.Match('SasLogicalJBOD').Count) + { + + "[{0}] Processing SasLogicalJbod {1} (ID:{2}) in Controller {3}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_ld.SasLogicalJBOD.name, $_ld.SasLogicalJbodId, $__controller.deviceSlot | Write-Verbose + + If ($ApplianceConnection.ApplianceType -ne 'Composer') + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.ComposerNodeException InvalidOperation InvalidOperation 'ApplianceConnection' -Message ('The ApplianceConnection {0} is not a Synergy Composer. The LogicalDisk within the StorageController contains a SasLogicalJbod configuration with is only supported with HPE Synergy.' -f $ApplianceConnection) + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + [void]$serverProfile.localStorage.sasLogicalJBODs.Add($_ld.SasLogicalJBOD) + + # Needed for D3940 RAID drive attachment + if (-not [String]::IsNullOrEmpty($_ld.raidLevel)) + { + + $_ld = $_ld | Select-Object * -ExcludeProperty SasLogicalJBOD + + [Void]$_NewLogicalDisksCollection.Add($_ld) + + } + + } + else + { + + if ($ServerHardwareType.storageCapabilities.raidLevels -notcontains $_ld.raidLevel) + { + + $_ExceptionMessage = "Unsupported LogicalDisk RAID Level {0} policy with {1} logical disk. The Server Hardware Type only supports '{2}' RAID level(s). " -f $_ld.raidLevel, $_ld.name, [System.String]::Join("', '", $ServerHardwareType.storageCapabilities.raidLevels) + $ErrorRecord = New-ErrorRecord HPEOneView.ServerProfile.LogicalDiskException UnsupportedLogicalDriveRaidLevel InvalidOperation "StorageController" -TargetType 'PSObject' -Message $_ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + if ($_ld.numPhysicalDrives -gt $ServerHardwareType.storageCapabilities.maximumDrives) + { + + $_ExceptionMessage = "Invalid number of drives requested {0}. The Server Hardware Type only supports a maximum of '{1}'." -f $_ld.numPhysicalDrives, $ServerHardwareType.storageCapabilities.maximumDrives + $ErrorRecord = New-ErrorRecord HPEOneView.ServerProfile.LogicalDiskException UnsupportedNumberofDrives InvalidOperation "StorageController" -TargetType 'PSObject' -Message $_ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + $_ld = $_ld | Select-Object * -ExcludeProperty SasLogicalJBOD + + [Void]$_NewLogicalDisksCollection.Add($_ld) + + } + + $_l++ + + } + + $__controller.logicalDrives = $_NewLogicalDisksCollection + + [void]$serverProfile.localStorage.controllers.Add($__controller) + + } + + } + + # StRM Support + if ($PSBoundParameters['SANStorage'] -and $ServerHardwareType.capabilities -Contains 'VCConnections') + { + + "[{0}] SAN Storage being requested" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $ServerProfile.sanStorage = NewObject -ServerProfileSanStorage + $ServerProfile.sanStorage.hostOSType = $ServerProfileSanManageOSType[$HostOsType]; + $ServerProfile.sanStorage.manageSanStorage = [Bool]$SANStorage; + + $_AllNetworkUrisCollection = [System.Collections.ArrayList]::new() + + # Build list of network URI's from connections + ForEach ($_Connection in ($ServerProfile.connectionSettings.connections | Where-Object { -not $_.networkUri.StartsWith($NetworkSetsUri) })) + { + + [void]$_AllNetworkUrisCollection.Add($_Connection.networkUri) + + } + + # Copy the Parameter array into a new object + $_VolumesToAttach = [System.Collections.ArrayList]::new() + + $StorageVolume | ForEach-Object { + + if ($_) + { + + [void]$_VolumesToAttach.Add($_) + + } + + } + + "[{0}] Number of Volumes to Attach: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_VolumesToAttach.Count | Write-Verbose + + $_v = 0 + + foreach ($_Volume in $_VolumesToAttach) + { + + $_VolumeToAdd = $_Volume.PSObject.Copy() + + $_v++ + + "[{0}] Processing Volume {1} of {2}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_v, $_VolumesToAttach.Count | Write-Verbose + + $_EphemeralVolProvision = $false + + # Ephemeral Volume Support + if ($null -eq $_VolumeToAdd.volumeUri -and $_VolumeToAdd.volume.properties.storagePool) + { + + $_VolumeUri = $_VolumeToAdd.volume.properties.storagePool + + $_uri = "{0}?networks='{1}'&filter=uri='{2}'" -f $ReachableStoragePoolsUri, ([String]::Join(',', $_AllNetworkUrisCollection.ToArray())), $_VolumeUri + $_VolumeName = $_VolumeToAdd.volume.properties.name + + $_EphemeralVolProvision = $true + + } + + # Provisioned Volume Support + else + { + + Try + { + + $_VolumeObject = Send-OVRequest -uri $_Volume.volumeUri -Hostname $_Volume.ApplianceConnection + + } + + catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $_uri = "{0}?networks='{1}'&filter=name='{2}'" -f $AttachableStorageVolumesUri, ([String]::Join(',', $_AllNetworkUrisCollection.ToArray())), $_VolumeObject.name + $_VolumeUri = $_Volume.uri + + } + + "[{0}] Processing Volume ID: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_Volume.id | Write-Verbose + "[{0}] Looking to see if volume/pool '{1} ({2})' is attachable" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_VolumeObject.name, $_VolumeUri | Write-Verbose + + try + { + + $_resp = Send-OVRequest -Uri $_uri -appliance $ApplianceConnection + + } + + catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + # Members found + if ($_resp.count -gt 0) + { + + "[{0}] '{1} ({2})' volume/pool is attachable" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_VolumeName, $_VolumeUri | Write-Verbose + + if (($_VolumeToAdd.id -eq 0) -or (-not($_Volume.id))) + { + + "[{0}] No VolumeID value provided. Getting next volume id value." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $id = 1 + + $Found = $false + + While (-not $Found -and $id -lt 256) + { + + if (-not($_VolumesToAttach | Where-Object id -eq $id)) + { + + "[{0}] Setting Volume ID to: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $id | Write-Verbose + + $_VolumeToAdd.id = $id + + $Found = $true + + } + + $id++ + + } + + } + + # If the storage paths array is null, Process connections to add mapping + if ($_VolumeToAdd.storagePaths.Count -eq 0) + { + + $_VolumeToAdd.storagePaths = [System.Collections.ArrayList]::new() + + "[{0}] Storage Paths value is Null. Building connection mapping." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + # This should only be 1 within members array + foreach ($_member in $_resp.members) + { + + # Not an ephemeral volume, so lets report back connections and how they could map to reachable networks + if (-not $_EphemeralVolProvision) + { + + if ($null -ne $_Member.deviceSpecificAttributes.iqn) + { + + "[{0}] Looking for Ethernet connections." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_StorageTypeUri = $EthernetNetworksUri + + } + + else + { + + "[{0}] Looking for FC/FCoE connections." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_StorageTypeUri = $FcNetworksUri + + } + + # Figure out which connections "should" map based on identified storage connectivity type + [Array]$_ProfileConnections = $ServerProfile.connectionSettings.connections | Where-Object { $_.networkUri.StartsWith($_StorageTypeUri) } + + "[{0}] Number of connections that match the volume connectivity type: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_ProfileConnections.Count | Write-Verbose + + if ($_ProfileConnections.Count -gt 0) + { + + "[{0}] Connections that match the volume connectivity type: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), [String]::Join(', ', [Array]$_ProfileConnections.id) | Write-Verbose + + } + + [Array]$_ReachableNetworkUris = $_Member.reachableNetworks | Where-Object { $_.StartsWith($_StorageTypeUri) } + + "[{0}] Number of reachable networks that match the volume connectivity type: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_ReachableNetworkUris.Count | Write-Verbose + + if ($_ReachableNetworkUris.Count -gt 0) + { + + "[{0}] Reachable networks that match the volume connectivity type: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), [String]::Join(', ', [Array]$_ReachableNetworkUris) | Write-Verbose + + } + + } + + else + { + + [Array]$_ProfileConnections = $ServerProfile.connectionSettings.connections + [Array]$_ReachableNetworkUris = $_Member.reachableNetworks + + } + + ForEach ($_ReachableNetworkUri in $_ReachableNetworkUris) + { + + "[{0}] Processing reachable network URI: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_ReachableNetworkUri | Write-Verbose + + ForEach ($_ProfileConnection in ($_ProfileConnections | Where-Object { $_.networkUri -eq $_ReachableNetworkUri })) + { + + "[{0}] Mapping connectionId '{1}' -> volumeId '{2}'" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_ProfileConnection.id, $_Volume.id | Write-Verbose + + $_StoragePath = NewObject -StoragePath + + $_StoragePath.connectionId = $_ProfileConnection.id + $_StoragePath.isEnabled = $True + + [void]$_VolumeToAdd.storagePaths.Add($_StoragePath) + + } + + } + + if ($_VolumeToAdd.storagePaths.Count -eq 0) + { + + Write-Warning ('No available connections were found that could attach to {0} Storage Volume. Storage Volumes may not be attached.' -f $_VolumeName) + + } + + } + + } + + foreach($propertyToRemove in ($_VolumeToAdd.PSObject.Properties | Where { 'TargetPortAssignmentType','TargetAddresses' -contains $_.Name })) + { + + $_VolumeToAdd.PSObject.Properties.Remove('TargetPortAssignmentType') + $_VolumeToAdd.PSObject.Properties.Remove('TargetAddresses') + + } + + [void]$ServerProfile.sanStorage.volumeAttachments.Add($_VolumeToAdd) + + } + + # No members found, generate exception + else + { + + $ExceptionMessage = "'{0}' Volume is not available to be attached to the profile. Please check the volume or available storage pools and try again." -f $VolumeName + $ErrorRecord = New-ErrorRecord InvalidOperationException StorageVolumeUnavailableForAttach ResourceUnavailable 'StorageVolume' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + # Check to see if user passed -EvenPathDisable and/or -OddPathDisable Parameter switches + if ($EvenPathDisabled.IsPresent -or $OddPathDisabled.IsPresent) + { + + "[{0}] Disable Even Path: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $EvenPathDisable.IsPresent | Write-Verbose + "[{0}] Disable Odd Path: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $OddPathDisable.IsPresent | Write-Verbose + + # Keep track of Volume Array index + $v = 0 + + foreach ($_vol in $ServerProfile.sanStorage.volumeAttachments) + { + + # Keep track of Volume Path Array index + $p = 0 + + foreach ($_Path in $_vol.storagePaths) + { + + $_IsEnabled = $true + + if ([Bool]$OddPathDisabled.IsPresent -and [Bool]($_Path.connectionID % 2)) + { + + $_IsEnabled = $false + + } + + elseif ([Bool]$EvenPathDisabled.IsPresent -and [Bool]!($_Path.connectionID % 2)) + { + + $_IsEnabled = $false + + } + + "[{0})] Setting Connection ID '{1}' path Enabled: {2}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_Path.connectionID, $_IsEnabled | Write-Verbose + + $serverProfile.sanStorage.volumeAttachments[$v].storagePaths[$p].isEnabled = $_IsEnabled + $p++ + + } + + $v++ + + } + + } + + } + + # iLO Settings + if ($PSBoundParameters['ManageIloSettings']) + { + + if ([RegEx]::Match($ServerHardwareType.capabilities, "ManageMp", $RegExInsensitiveFlag).Success) + { + + "[{0}] Enabling iLO settings." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $serverProfile.managementProcessor.manageMp = $true + $serverProfile.managementProcessor.mpSettings = $IloSettings.mpSettings + + } + + else + { + + $ExceptionMessage = "The server hardware type '{0}' does not support managing iLO settings. Only iLO4 and newer systems are supported." -f $ServerHardwareType.name + $ErrorRecord = New-ErrorRecord InvalidOperationException UnsupportedManagmenetProcessor InvalidArgument 'ManageIloSettings' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + } + + "[{0}] Profile: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), ($ServerProfile | out-string) | Write-Verbose + + # if ($PSBoundParameters['Scope'] -or (($ConnectedSessions | Where-Object Name -eq $ApplianceConnection).ActivePermissions )) + # { + + + # } + + if (-not $Passthru.IsPresent) + { + + "[{0}] Sending request" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $Resp = Send-OVRequest -Uri $ServerProfilesUri -Method POST -Body $ServerProfile -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + Try + { + + "[{0}] Waiting for task to start, to identify for any validation errors." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $Resp = $Resp | Wait-OVTaskStart + + if ($Resp.taskState -eq 'Error' -and $Resp.stateReason -eq 'ValidationError') + { + + if ($PSCmdlet.ShouldProcess($Name, ('The server profile generated a validation error: "{0}". Do you wish to override creating the Server Profile' -f $Resp.taskErrors.message))) + { + + Try + { + + $_Uri = '{0}?force=all' -f $ServerProfilesUri + + $Resp = Send-OVRequest -Uri $_Uri -Method POST -Body $ServerProfile -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + else + { + + $ExceptionMessage = ParseForJson -String $resp.taskErrors.message + $ErrorRecord = New-ErrorRecord HPEOneView.ServerProfileResourceException InvalidOperation InvalidOperation 'AsyncronousTask' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if (-not $PSBoundParameters['Async']) + { + + $Resp = Wait-OVTaskComplete -InputObject $Resp -ApplianceConnection $Resp.ApplianceConnection.Name + + } + + $Resp + + } + + else + { + + # Return the server profile object back to the caller, who can directly modify it, and then use Save-OVServerProfile + $ServerProfile + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +# // TODO: DEVELOP DOCUMENTATION TEST +function Set-OVServerProfile +{ + + Throw "Not implemented." + +} + +function Convert-OVServerProfile +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "Default", SupportsShouldProcess, ConfirmImpact = 'High')] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = "Default")] + [ValidateNotNullOrEmpty()] + [Alias ('ServerProfile', 'Profile')] + [Object]$InputObject, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [ValidateNotNullOrEmpty()] + [Object]$ServerHardwareType, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Object]$EnclosureGroup, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Switch]$Async, + + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = "Default")] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not($PSBoundParameters['InputObject'])) + { + + $PipelineInput = $True + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $_taskCollection = [System.Collections.ArrayList]::new() + + } + + Process + { + + $_TransformType = [System.Collections.ArrayList]::new() + + $_ServerHardwareTypeUri = $null + $_EnclosureGroupUri = $null + + # Process InputObject + if ($InputObject.category -ne $ResourceCategoryEnum.ServerProfile) + { + + # Throw exception + $ExceptionMessage = 'The provided object {0} is not supported. Only Server Profile is supported.' -f $InputObject.name + $ErrorRecord = New-ErrorRecord HPEOneView.InputObjectResourceException InvalidInputObjectResource InvalidArgument "InputObject" -TargetType 'PSObject' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + # Process SHT + if ($PSBoundParameters['ServerHardwareType'] -and $ServerHardwareType.category -ne $ResourceCategoryEnum.ServerHardwareType) + { + + # Throw exception + $ExceptionMessage = 'The provided object {0} is not supported. Only Server Hardware Type is supported.' -f $ServerHardwareType.name + $ErrorRecord = New-ErrorRecord HPEOneView.ServerHardwareTypeResourceException InvalidServerHardwareTypeResource InvalidArgument "ServerHardwareType" -TargetType 'PSObject' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($PSBoundParameters['ServerHardwareType']) + { + + $_ServerHardwareTypeUri = $ServerHardwareType.uri + + [void]$_TransformType.Add('server hardware type') + + } + + elseif (-not $PSBoundParameters['ServerHardwareType']) + { + + $_ServerHardwareTypeUri = $InputObject.serverHardwareTypeUri + + [void]$_TransformType.Add('server hardware type') + + } + + # Process EG + if ($PSBoundParameters['EnclosureGroup'] -and $EnclosureGroup.category -ne $ResourceCategoryEnum.EnclosureGroup) + { + + # Throw exception + $ExceptionMessage = 'The provided object {0} is not supported. Only Enclosure Group is supported.' -f $EnclosureGroup.name + $ErrorRecord = New-ErrorRecord HPEOneView.EnclosureGroupResourceException InvalidEnclosureGroupResource InvalidArgument "EnclosureGroup" -TargetType 'PSObject' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + # Allow transformation of a Server Profile Template designed for DL/ML/Apollo to BL/WS + elseif (($PSBoundParameters['EnclosureGroup'] -and $null -ne $InputObject.enclosureGroupUri) -or + ($PSBoundParameters['EnclosureGroup'] -and [RegEx]::Match($ServerHardwareType.model, 'BL|WS|SY', $RegExInsensitiveFlag).Success)) + { + + $_EnclosureGroupUri = $EnclosureGroup.uri + + [void]$_TransformType.Add('enclosure group') + + } + + elseif (-not $PSBoundParameters['EnclosureGroup'] -and $null -ne $InputObject.enclosureGroupUri) + { + + $_EnclosureGroupUri = $InputObject.enclosureGroupUri + + [void]$_TransformType.Add('enclosure group') + + } + + elseif ($PSBoundParameters['EnclosureGroup'] -and $null -eq $InputObject.enclosureGroupUri) + { + + $ExceptionMessage = 'The provided Server Profile object {0} is likely a DL/ML/Apollo resource and does not support Enclosure Group objects.' -f $InputObject.name + $ErrorRecord = New-ErrorRecord HPEOneView.EnclosureGroupResourceException InvalidEnclosureGroupResource InvalidOperation "EnclosureGroup" -TargetType 'PSObject' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + # Build final transformation URI + $_Uri = '{0}/transformation?serverHardwareTypeUri={1}&enclosureGroupUri={2}' -f $InputObject.uri, $_ServerHardwareTypeUri, $_EnclosureGroupUri + + Try + { + + $_TransformedServerProfile = Send-OVRequest -Uri $_Uri -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + # Show changes preview here. + ForEach ($_previewChange in $_TransformedServerProfile.changes.GetEnumerator()) + { + + [HPEOneView.ServerProfile.TransformPreview]::new($_previewChange) + + } + + $_ShouldProcessMessage = 'transform the server profile to new {0}' -f [String]::Join(' and ', $_TransformType.ToArray()) + + if ($PSCmdlet.ShouldProcess($InputObject.Name, $_ShouldProcessMessage)) + { + + # Saving results back to appliance + Try + { + + $_TransformedServerProfileResults = Send-OVRequest -Uri $InputObject.uri -Method PUT -Body $_TransformedServerProfile.serverProfile -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if (-not $PSBoundParameters['Async']) + { + + $_TransformedServerProfileResults | Wait-OVTaskComplete + + } + + else + { + + $_TransformedServerProfileResults + + } + + } + + } + + End + { + + '[{0}] Done.' -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Update-OVServerProfile +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (SupportsShouldProcess, ConfirmImpact = 'High', DefaultParameterSetName = 'Default')] + Param + ( + + [Parameter (ValueFromPipeline, Mandatory, ParameterSetName = 'Reapply')] + [Parameter (ValueFromPipeline, Mandatory, ParameterSetName = 'Refresh')] + [Parameter (ValueFromPipeline, Mandatory, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [Alias ('profile','ServerProfile')] + [object]$InputObject, + + [Parameter (Mandatory, ParameterSetName = 'Refresh')] + [Switch]$Refresh, + + [Parameter (Mandatory, ParameterSetName = 'Reapply')] + [Switch]$Reapply, + + [Parameter (Mandatory = $false, ParameterSetName = 'Reapply')] + [Switch]$Baseline, + + [Parameter (Mandatory = $false, ParameterSetName = 'Reapply')] + [Switch]$AdapterAndBoot, + + [Parameter (Mandatory = $false, ParameterSetName = 'Reapply')] + [Switch]$Connections, + + [Parameter (Mandatory = $false, ParameterSetName = 'Reapply')] + [Switch]$LocalStorage, + + [Parameter (Mandatory = $false, ParameterSetName = 'Reapply')] + [Switch]$SANStorage, + + [Parameter (Mandatory = $false, ParameterSetName = 'Reapply')] + [Switch]$BIOS, + + [Parameter (Mandatory = $false, ParameterSetName = 'Reapply')] + [Switch]$Ilo, + + [Parameter (Mandatory = $false, ParameterSetName = 'Reapply')] + [Switch]$OSDeployment, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [Switch]$Stage, + + [Parameter (ValueFromPipelineByPropertyName, Mandatory = $false, ParameterSetName = 'Default')] + [Parameter (ValueFromPipelineByPropertyName, Mandatory = $false, ParameterSetName = 'Refresh')] + [Parameter (ValueFromPipelineByPropertyName, Mandatory = $false, ParameterSetName = 'Reapply')] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default), + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [Parameter (Mandatory = $false, ParameterSetName = 'Refresh')] + [Parameter (Mandatory = $false, ParameterSetName = 'Reapply')] + [Switch]$Async + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not($PSBoundParameters['InputObject'])) + { + + $PipelineInput = $True + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + $_TaskCollection = [System.Collections.ArrayList]::new() + $_ServerProfileCollection = [System.Collections.ArrayList]::new() + + } + + Process + { + + if ($PipelineInput) + { + + "[{0}] Processing Pipeline input." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + # Process server profile resource name + if ($InputObject -is [String]) + { + + Try + { + + $InputObject = Get-OVServerProfile -Name $InputObject -ApplianceConnection $ApplianceConnect -ErrorAction Stop + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + elseif ($InputObject.category -eq $ResourceCategoryEnum.ServerHardware) + { + + "[{0}] Server hardware resource provided." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if ($null -eq $InputObject.serverProfileUri) + { + + $ExceptionMessage = 'The provided server hardware "{0}" does not have an assigned server profile.' -f $InputObject.name + $ErrorRecord = New-ErrorRecord HPEOneView.ServerProfileResourceException ServerHardwareNullServerProfileAssignment InvalidArgument 'InputObject' -TargetType 'PSObject' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Try + { + + $InputObject = Send-OVRequest -Uri ($InputObject.serverProfileUri) -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + # Validate the Input object is the allowed category + elseif ($InputObject.category -ne $ResourceCategoryEnum['ServerProfile']) + { + + $ExceptionMessage = "The provided InputObject object ({0}) category '{1}' is not an allowed value. Expected category value is '{2}'. Please correct your input value." -f $InputObject.name, $InputObject.category, $ResourceCategoryEnum.ServerProfile + $ErrorRecord = New-ErrorRecord HPEOneView.ServerProfileResourceException InvalidServerProfilesCategory InvalidArgument 'InputObject' -TargetType 'PSObject' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + if (-not $InputObject.ApplianceConnection) + { + + $ExceptionMessage = "The provided InputObject object ({0}) does not contain the required 'ApplianceConnection' object property. Please correct your input value." -f $InputObject.name + $ErrorRecord = New-ErrorRecord HPEOneView.ServerProfileResourceException InvalidServerProfileObject InvalidArgument 'InputObject' -TargetType 'PSObject' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + "[{0}] Processing Server Profile: '{1} [{2}]'" -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject.name, $InputObject.uri | Write-Verbose + + $_NotCompliant = $true + + $_PatchOperations = [System.Collections.ArrayList]::new() + $_ReapplyOperations = [System.Collections.ArrayList]::new() + + # Get power state of assigned profile + Try + { + + "[{0}] Getting current power state of the server" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_server = Send-OVRequest -Uri $InputObject.serverHardwareUri -Hostname $ApplianceConnection + + "[{0}] Current power state of the server: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_server.powerState | Write-Verbose + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + switch ($PSCmdlet.ParameterSetName) + { + + 'Reapply' + { + + "[{0}] Request is to reapply profile." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + # Error if the profile is not assigned to a server resource + if ($null -eq $InputObject.serverHardwareUri) + { + + "[{0}] Profile is not assigned." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $ExceptionMessage = 'The Server Profile {0} is not assigned to a server hardware resource.' -f $InputObject.name + $ErrorRecord = New-ErrorRecord HPEOneView.ServerProfileResourceException InvalidServerProfilesAssignmet InvalidArgument 'ServerProfile' -TargetType 'PSObject' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + $_SpecificOperation = $false + + Switch ($PSBoundParameters.Keys) + { + + 'Ilo' + { + + "[{0}] Reapply iLO settings." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_Operation = NewObject -PatchOperation + + $_Operation.op = "replace" + $_Operation.path = "/managementProcessor/reapplyState" + $_Operation.value = "ApplyPending" + + [void]$_PatchOperations.Add($_Operation) + [void]$_ReapplyOperations.Add('iLO') + + $_SpecificOperation = $true + + } + + 'Baseline' + { + + "[{0}] Reapply baseline." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_Operation = NewObject -PatchOperation + + $_Operation.op = "replace" + $_Operation.path = "/firmware/reapplyState" + $_Operation.value = "ApplyPending" + + [void]$_PatchOperations.Add($_Operation) + [void]$_ReapplyOperations.Add('Baseline') + + $_SpecificOperation = $true + + } + + 'AdapterAndBoot' + { + + "[{0}] Reapply AdapterAndBoot." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_Operation = NewObject -PatchOperation + + $_Operation.op = "replace" + $_Operation.path = "/serverHardwareReapplyState" + $_Operation.value = "ApplyPending" + + [void]$_PatchOperations.Add($_Operation) + [void]$_ReapplyOperations.Add('AdapterAndBoot') + + $_SpecificOperation = $true + + } + + 'Connections' + { + + "[{0}] Reapply connections." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_Operation = NewObject -PatchOperation + + $_Operation.op = "replace" + $_Operation.path = "/connectionSettings/reapplyState" + $_Operation.value = "ApplyPending" + + [void]$_PatchOperations.Add($_Operation) + [void]$_ReapplyOperations.Add('Connections') + + $_SpecificOperation = $true + + } + + 'LocalStorage' + { + + $_Operation = NewObject -PatchOperation + + $_Operation.op = "replace" + $_Operation.path = "/localStorage/reapplyState" + $_Operation.value = "ApplyPending" + + [void]$_PatchOperations.Add($_Operation) + [void]$_ReapplyOperations.Add('LocalStorage') + + $_SpecificOperation = $true + + } + + 'SANStorage' + { + + $_Operation = NewObject -PatchOperation + + $_Operation.op = "replace" + $_Operation.path = "/sanStorage/reapplyState" + $_Operation.value = "ApplyPending" + + [void]$_PatchOperations.Add($_Operation) + [void]$_ReapplyOperations.Add('SANStorage') + + $_SpecificOperation = $true + + } + + 'BIOS' + { + + $_Operation = NewObject -PatchOperation + + $_Operation.op = "replace" + $_Operation.path = "/bios/reapplyState" + $_Operation.value = "ApplyPending" + + [void]$_PatchOperations.Add($_Operation) + [void]$_ReapplyOperations.Add('BIOS') + + $_SpecificOperation = $true + + } + + 'OSDeployment' + { + + if ($ApplianceConnection.ApplianceType -ne 'Composer') + { + + $ExceptionMessage = 'The ApplianceConnection {0} is not a Synergy Composer. OS Deployment Plans are only supported with HPE Synergy.' -f $ApplianceConnection + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.ComposerNodeException InvalidOperation InvalidOperation 'ApplianceConnection' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($null -eq $InputObject.osDeploymentSettings.osDeploymentPlanUri) + { + + $ExceptionMessage = 'Server Profile {0} does not contain an OS Deployment Plan. In order to use the -OSDeployment switch, the HPE Synergy Server Profile needs to have an OS Deployment Plan associated.' -f $InputObject.name + + } + + else + { + + $_Operation = NewObject -PatchOperation + + $_Operation.op = "replace" + $_Operation.path = "/osDeploymentSettings/reapplyState" + $_Operation.value = "ApplyPending" + + [void]$_PatchOperations.Add($_Operation) + [void]$_ReapplyOperations.Add('OSDeployment') + + $_SpecificOperation = $true + + } + + } + + } + + if (-not $_SpecificOperation) + { + + [void]$_ReapplyOperations.Add('All') + + # BASELINE + $_Operation = NewObject -PatchOperation + + $_Operation.op = "replace" + $_Operation.path = "/firmware/reapplyState" + $_Operation.value = "ApplyPending" + + [void]$_PatchOperations.Add($_Operation) + + # ADAPTERANDBOOT + $_Operation = NewObject -PatchOperation + + $_Operation.op = "replace" + $_Operation.path = "/serverHardwareReapplyState" + $_Operation.value = "ApplyPending" + + [void]$_PatchOperations.Add($_Operation) + + # LOCALSTORAGE + $_Operation = NewObject -PatchOperation + + $_Operation.op = "replace" + $_Operation.path = "/localStorage/reapplyState" + $_Operation.value = "ApplyPending" + + [void]$_PatchOperations.Add($_Operation) + + # SANSTORAGE + $_Operation = NewObject -PatchOperation + + $_Operation.op = "replace" + $_Operation.path = "/sanStorage/reapplyState" + $_Operation.value = "ApplyPending" + + [void]$_PatchOperations.Add($_Operation) + + # BIOS + $_Operation = NewObject -PatchOperation + + $_Operation.op = "replace" + $_Operation.path = "/bios/reapplyState" + $_Operation.value = "ApplyPending" + + [void]$_PatchOperations.Add($_Operation) + + if ($ApplianceConnection.ApplianceType -eq 'Composer' -and $null -ne $InputObject.osDeploymentSettings.osDeploymentPlanUri) + { + + $_Operation = NewObject -PatchOperation + + $_Operation.op = "replace" + $_Operation.path = "/osDeploymentSettings/reapplyState" + $_Operation.value = "ApplyPending" + + [void]$_PatchOperations.Add($_Operation) + + } + + } + + $_ShouldProcessMessage = "reapply server profile {0} configuration" -f [String]::Join(', ', $_ReapplyOperations.ToArray()) + + } + + 'Refresh' + { + + $_Operation = NewObject -PatchOperation + + $_Operation.op = "replace" + $_Operation.path = "/refreshState" + $_Operation.value = "RefreshPending" + + [void]$_PatchOperations.Add($_Operation) + + $_ShouldProcessMessage = "refresh server profile configuration." + + } + + default + { + + $_UpdateFromTemplateOperationValue = "Compliant" + + "{0}] Is Server Profile 'Compliant': {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject.templateCompliance | Write-Verbose + + if ($InputObject.templateCompliance -ne 'Compliant') + { + + try + { + + $_spUpdateOperations = Send-OVRequest -Uri ($InputObject.uri + '/compliance-preview') -Hostname $InputObject.ApplianceConnection.Name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $_spUpdateOperationIsOnlineUpdate = $_spUpdateOperations.isOnlineUpdate + + $ReviewObject = [HPEOneView.ServerProfile.CompliancePreview]::new($InputObject.name, + $_spUpdateOperations.isOnlineUpdate, + $_spUpdateOperations.ApplianceConnection) + + $_spUpdateOperations.automaticUpdates | ForEach-Object { [void]$ReviewObject.AutomaticUpdates.Add((ConvertFromEmbeddedJsonString $_)) } + $_spUpdateOperations.manualUpdates | ForEach-Object { [void]$ReviewObject.ManualUpdates.Add((ConvertFromEmbeddedJsonString $_)) } + + $_ShouldProcessMessage = "Update Server Profile configuration. WARNING: Depending on this action, there might be a brief outage." + + if ($_server.powerState -eq 'On' -and -not $_spUpdateOperationIsOnlineUpdate -and -not $Stage.IsPresent) + { + + $ExceptionMessage = 'The associated server resource {0} to the Server Profile {1} is powered on. This operation only supports servers in a powered off state, or use the -Stage parameter. Please use Stop-OVServer before continuing.' -f $_server.name, $InputObject.name + $ErrorRecord = New-ErrorRecord HPEOneView.ServerProfileResourceException InvalidServerProfilesAssignmet InvalidArgument 'ServerProfile' -TargetType 'PSObject' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($_server.powerState -eq 'On' -and $Stage.IsPresent) + { + + "[{0}] Server hardware is powered on, and staged is requested." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_UpdateFromTemplateOperationValue = "PendingCompliance" + + } + + $_Operation = NewObject -PatchOperation + + $_Operation.op = "replace" + $_Operation.path = "/templateCompliance" + $_Operation.value = $_UpdateFromTemplateOperationValue + + [void]$_PatchOperations.Add($_Operation) + + } + + else + { + + Write-Warning ('Skipping {0} Server Profile, as it is Compliant.' -f $InputObject.name) + $_NotCompliant = $false + + } + + } + + } + + if ($_NotCompliant -and $PSCmdlet.ShouldProcess($InputObject.name, $_ShouldProcessMessage)) + { + + "[{0}] Sending request to {1} configuration" -f $MyInvocation.InvocationName.ToString().ToUpper(), $PSCmdlet.ParameterSetName | Write-Verbose + + Try + { + + $_task = Send-OVRequest -Uri $InputObject.uri -Method PATCH -Body $_PatchOperations -AddHeader @{'if-match' = $InputObject.eTag} -Hostname $InputObject.ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if (-not($PSBoundParameters['Async'])) + { + + $_task = $_task | Wait-OVTaskComplete + + } + + $_task + + } + + elseif ($PSBoundParameters['WhatIf']) + { + + "[{0}] User included -WhatIf." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + # Need to return the HPEOneView.ServerProfile.ComplianceReview object + if ($PSCmdlet.ParameterSetName -eq 'Default') + { + + $ReviewObject + + } + + } + + else + { + + "[{0}] User cancelled or server profile is compliant." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function New-OVServerProfileAssign +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "Default", SupportsShouldProcess, ConfirmImpact = 'High')] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = "Unassigned")] + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = "Default")] + [ValidateNotNullOrEmpty()] + [Alias ('Profile')] + [Object]$ServerProfile, + + [Parameter (Mandatory, ParameterSetName = "Default")] + [ValidateNotNullOrEmpty()] + [Object]$Server, + + [Parameter (Mandatory = $false, ParameterSetName = "Unassigned")] + [Switch]$Unassigned, + + [Parameter (Mandatory = $false, ParameterSetName = "Unassigned")] + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Switch]$Force, + + [Parameter (Mandatory = $false, ParameterSetName = "Unassigned")] + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Switch]$Async, + + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = "Unassigned")] + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = "Default")] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not($PSBoundParameters['ServerProfile'])) + { + + $PipelineInput = $True + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $_taskCollection = [System.Collections.ArrayList]::new() + + } + + Process + { + + # Look at Profile and Server if they are objects, and make sure ApplianceConnection.Name match + if ($ServerProfile -is [PSCustomObject] -and $Server -is [PSCustomObject]) + { + + if ($ServerProfile.ApplianceConnection.Name -ne $Server.ApplianceConnection.Name) + { + + "[{0}] Server Profile '{1}' and Server Hardware '{2}' ApplianceConnection do not match." -f $MyInvocation.InvocationName.ToString().ToUpper(), $ServerProfile.ApplianceConnection.Name, $Server.ApplianceConnection.Name | Write-Verbose + + $ErrorRecord = New-ErrorRecord HPEOneView.ServerProfileResourceException ProfileAndServerApplianceConnectionMismatch InvalidArgument 'Profile' -TargetType 'PSObject' -Message "The Server Profile ($($ServerProfile.ApplianceConnection.Name)) and Server Hardware ($($Server.ApplianceConnection.Name)) ApplianceConnection NoteProperty do not match. Please correct the value and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + # Looking for the $server DTO to be string + if ($ServerProfile -is [String]) + { + + try + { + + $ServerProfile = Get-OVServerProfile -name $ServerProfile -ApplianceConnection $ApplianceConnection -ErrorAction Stop + + } + + catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + elseif ($ServerProfile -is [PSCustomObject] -and $ServerProfile.category -ne $ResourceCategoryEnum.ServerProfile) + { + + $ErrorRecord = New-ErrorRecord HPEOneView.ServerProfileResourceException ProfileObjectInvalidCategory InvalidArgument 'Profile' -TargetType 'PSObject' -Message "The Server Profile ({0}) is an unsupported resource category type, '{1}'. Only '{2}' are supported. Please correct the value and try again." -f $ServerProfile.name, $ServerProfile.category, $ResourceCategoryEnum.ServerProfile + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + "[{0}] Server Profile Object: {1} ({2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $ServerProfile.name, $ServerProfile.uri | Write-Verbose + + # Check to make sure the server hardware the profile is assigned to is powered off + if ($ServerProfile.serverHardwareUri) + { + + Try + { + + $_ServerResource = Send-OVRequest $ServerProfile.serverHardwareUri -Hostname $ServerProfile.ApplianceConnection.Name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if ($_ServerResource.powerState -ne "Off") + { + + $ErrorRecord = New-ErrorRecord HPEOneView.ServerProfileResourceException InvalidServerPowerState InvalidResult 'Profile' -Message "The Server '$($_ServerResource.name)' is currently powered On. Please power off the server and then perform the operation again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + # Looking for the $server DTO to be string + if ($Server -is [String]) + { + + try + { + + $Server = Get-OVServer -name $Server -ErrorAction Stop -ApplianceConnection $ApplianceConnection + + } + + catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + elseif ($Server -is [PSCustomObject] -and $Server.category -ne 'server-hardware') + { + + $ErrorRecord = New-ErrorRecord HPEOneView.ServerHardwareResourceException ServerObjectInvalidCategory InvalidArgument 'Server' -TargetType 'PSObject' -Message "The Server ($($Server.name)) is an unsupported resource category type, '$($Server.category)'. Only 'server-hardware' are supported. Please correct the value and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + # "[{0}] Server Object: $($Server | Format-List * )" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if ($PSBoundParameters['Unassigned']) + { + + $ServerProfile.serverHardwareUri = $Null + + if ($ServerProfile.enclosureUri) + { + + $ServerProfile.enclosureUri = $Null + $ServerProfile.enclosureBay = $Null + + } + + } + + else + { + + if ($Server.serverHardwareTypeUri -ne $ServerProfile.serverHardwareTypeUri) + { + + "[{0}] Server Profile assigned serverHardwareTypeUri does not match the destination Server resource. Updating Server Profile with new serverHardwareTypeUri value." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $ServerProfile.serverHardwareTypeUri = $Server.serverHardwareTypeUri + + } + + $ServerProfile.serverHardwareUri = $server.uri + + if ($server.locationUri) + { + + $ServerProfile.enclosureUri = $server.locationUri + $ServerProfile.enclosureBay = $server.position + + } + + } + + $_Uri = $ServerProfile.uri + + if ($Force) + { + + $_Uri += "?force=all" + + } + + try + { + + $_resp = Send-OVRequest -Uri $_Uri -Method PUT -Body $ServerProfile -Hostname $ApplianceConnection.Name + + } + + catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + Try + { + + $_resp = $_resp | Wait-OVTaskStart + + if ($_resp.taskState -eq 'Error') + { + + if ([RegEx]::Match($_resp.taskErrors.message, 'The selected server hardware has health status other than "OK"', $RegExInsensitiveFlag).Success -and + $PSCmdlet.ShouldProcess($Server.name, 'The selected server hardware has health status other than "OK". Do you wish to override and assign the Server Profile')) + { + + Try + { + + $_Uri = '{0}?force=all' -f $ServerProfilesUri + + $_resp = Send-OVRequest -Uri $_Uri -Method PUT -Body $ServerProfile -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + else + { + + $ExceptionMessage = $_resp.taskErrors.message + $ErrorRecord = New-ErrorRecord HPEOneView.ServerProfileResourceException InvalidOperation InvalidOperation 'AsyncronousTask' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if (-not $PSBoundParameters['Async']) + { + + $_resp = Wait-OVTaskComplete -InputObject $_resp -ApplianceConnection $_resp.ApplianceConnection.Name + + } + + $_resp + + } + + End + { + + '[{0}] Done.' -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Copy-OVServerProfile +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (SupportsShouldProcess, ConfirmImpact = 'High')] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline)] + [Alias ('sname','src','SourceName')] + [ValidateNotNullOrEmpty()] + [object]$InputObject, + + [Parameter (Mandatory = $false)] + [Alias ('dname','dst')] + [String]$DestinationName, + + [Parameter (Mandatory = $false)] + [object]$Assign = "unassigned", + + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName)] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command agian." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + if($ApplianceConnection.count -gt 1) + { + + # Check for appliance specific URI Parameters and error if more than one appliance connection supplied + if (($InputObject -is [String]) -and ($InputObject.StartsWith($ServerProfilesUri))) + { + + "[{0}] InputObject is a Server Profile URI: $($InputObject)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + $ErrorRecord = New-ErrorRecord ArgumentNullException ParametersNotSpecified InvalidArgument 'InputObject' -Message "The input Parameter 'InputObject' is a URI. For multiple appliance connections this is not supported." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + if (($assign -is [String]) -and ($assign.StartsWith($ServerHardwareUri))) + { + + "[{0}] Assign is a Server Profile URI: $($SourceName)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + $ErrorRecord = New-ErrorRecord ArgumentNullException ParametersNotSpecified InvalidArgument 'Assign' -Message "The input Parameter 'Assign' is a URI. For multiple appliance connections this is not supported." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + $taskCollection = [System.Collections.ArrayList]::new() + + } + + Process + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + if (!$InputObject) + { + + $ErrorRecord = New-ErrorRecord ArgumentNullException ParametersNotSpecified InvalidArgument 'InputObject' -Message "The input Parameter 'InputObject' was Null. Please provide a value and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + if (($InputObject -is [String]) -and (!$InputObject.StartsWith($ServerProfilesUri))) + { + + "[{0}] InputObject is a Server Profile Name: $($InputObject)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + "[{0}] Getting Server Profile URI" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $_Profile = Get-OVServerProfile -Name $InputObject -appliance $ApplianceConnection -ErrorAction Stop + + $profileSourceSHT = $_Profile.serverHardwareTypeUri + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + # Checking if the input is System.String and IS a URI - Should not Process on multi-appliance connections + elseif (($InputObject -is [String]) -and ($InputObject.StartsWith($ServerProfilesUri))) + { + + "[{0}] InputObject is a Server Profile URI: $($InputObject)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $_Profile = Send-OVRequest -uri $InputObject -appliance $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $profileSourceSHT = $_Profile.serverHardwareTypeUri + + } + + # Checking if source is object or object collection + elseif (($InputObject -is [PSCustomObject]) -and ($InputObject.category -ieq $ResourceCategoryEnum.ServerProfile)) + { + + "[{0}] InputObject is a Server Profile object: $($InputObject.name)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + # For multi-appliance connections retrieve the source object only for this connection + $_Profile = $InputObject.PSObject.Copy() + + $profileSourceSHT = $InputObject.serverHardwareTypeUri + + } + + else + { + + $ErrorRecord = New-ErrorRecord InvalidOperationException InvalidArgumentValue InvalidArgument 'InputObject' -TargetType $InputObject.GetType().Name -Message "The Parameter -InputObject value is invalid. Please validate the InputObject Parameter value you passed and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + if ($assign -ine 'unassigned') + { + + # Target Server is the server device name. Could be any empty bay assignment + if (($assign -is [String]) -and (-not ($assign.StartsWith($ServerHardwareUri)))) + { + + # Get-OVServer needs to be in a try/catch since it may be an empty bay + Try + { + + $serverDevice = Get-OVServer -Name $assign -appliance $ApplianceConnection + + } + + Catch + { + + "[{0}] $($assign) server resource does not exist." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + "[{0}] Check for empty bay assignment." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + if(-not $serverDevice -and ([RegEx]::Match($assign, "bay", $RegExInsensitiveFlag).Success)) + { + + + $assign = $assign.split(',').trim() + + try + { + + $thisEnc = Get-OVEnclosure -Name $assign[0] -appliance $ApplianceConnection -ErrorAction Stop + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + [Int]$thisBay = (($assign[1]) -replace "bay", "").trim() + + $presence = $thisEnc.deviceBays[($thisBay - 1)].devicePresence + + # If presence is null, invalid device bay + if(!$presence) + { + + $ErrorRecord = New-ErrorRecord ArgumentNullException ParametersNotSpecified InvalidArgument 'Copy-OVProfile' -Message "The bay number $thisBay is not valid or not present." + + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + else + { + + $_Profile.enclosureGroupUri = $thisEnc.uri + $_Profile.enclosureBay = $thisBay + $profileDestSHT = $profileSourceSHT + + } + + } + + else + { + + $profileDestSHT = $serverDevice.serverHardwareTypeUri + + } + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + # Checking if the input is System.String and IS a URI + elseif (($assign -is [String]) -and ($assign.StartsWith($ServerHardwareUri))) + { + + "[{0}] Assign to the Server hardware URI: $($assign)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $serverDevice = Send-OVRequest $assign -appliance $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $profileDestSHT = $serverDevice.serverHardwareTypeUri + + } + + # Checking if the input is PSCustomObject, and the category type is server-profiles, which would be passed via pipeline input + elseif (($assign -is [PSCustomObject]) -and ($assign.category -ieq "server-hardware")) + { + + "[{0}] Assign to the Server object: $($assign.name)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $serverDevice = $assign | Where-Object { $_.applianceConnection.name -eq $ApplianceConnection.name } + $profileDestSHT = $serverDevice.serverHardwareTypeUri + + } + + else + { + + $ErrorRecord = New-ErrorRecord InvalidOperationException InvalidArgumentValue InvalidArgument 'Copy-OVProfile' -Message "The Parameter -Assign value is invalid. Please validate the Assign Parameter value you passed and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + # Checking if the input is PSCustomObject, and the category type is server-hardware, which would be passed via pipeline input + if ($serverDevice.serverProfileUri) + { + + $ExceptionMessage = "A server profile is already assigned to {0} ({1}). Please try specify another server." -f $serverDevice.name, (Send-OVRequest $serverDevice.serverProfileUri -appliance $ApplianceConnection).name + $ErrorRecord = New-ErrorRecord HPEOneView.ServerProfileResourceException ServerPropfileResourceAlreadyExists ResourceExists 'ServerProfile' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + elseif ($assign -ieq "unassigned") + { + + "[{0}] Server will be unassigned" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + # Check to see if the SHT is different from the Profile and Target Assign Server + if (($profileDestSHT -ine $profileSourceSHT) -and ($assign -ine "unassigned") -and (!$_Profile.enclosureBay)) + { + + $ErrorRecord = New-ErrorRecord HPEOneView.ServerProfileResourceException ServerHardwareTypeMismatch InvalidOperation 'Copy-OVProfile' -Message "The Target Server Hardware Type does not match the source Profile Server Hardware Type. Please specify a different Server Hardware Device to assign." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + # Remove Profile Specifics: + $_Profile = $_Profile | select-object -Property * -excludeproperty uri,etag,created,modified,uuid,status,state,inprogress,serialNumber,enclosureUri,enclosureBay,serverHardwareUri,taskUri #,sanStorage + + $newConnections = [System.Collections.ArrayList]::new() + # Create new connections with excluded properties and add to the newConnections array + + '[{0}] Rebuilding fabric connections' -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_Profile.connectionSettings.connections | select-object -property * -excludeproperty mac,wwnn,wwpn,deploymentstatus,interconnectUri, applianceConnection | ForEach-Object { + + # Assign the newConnections array to $_Profile.connections + [void]$newConnections.Add($_) + + } + + $_Profile.connectionSettings.connections = $newConnections + + # Null compliant property + $_Profile.templateCompliance = $null + + # Process SAN Volume Attachments + if ($_Profile.sanStorage -and $_Profile.sanStorage.volumeAttachments) + { + + $newVolumeAttachments = @() + + "[{0}] Processing SAN Volume Attachments" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + ForEach ($attachVolume in $_Profile.sanStorage.volumeAttachments ) + { + + $tempVolume = [PSCustomObject]@{} + + "[{0}] Found attached volume ID $($attachVolume.id). Getting Volume properties." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $volume = Send-OVRequest $attachVolume.volumeUri -appliance $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + # Process shared volume + if ($volume.shareable) + { + + "[{0}] Adding Shareable Volume." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $tempVolume = $attachVolume | Select-Object id,volumeUri,lunType,lun,storagePaths + $tempVolume.lun = $Null + $tempVolume.storagePaths = ($attachVolume.storagePaths | ForEach-Object { $_ | select-object * -exclude status } ) + + } + + # Process private volume + else + { + + "[{0}] Adding Private Volume." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + "[{0}] Checking for unique volume name." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + # Get list of existing volumes from Index + + Try + { + + $indexVolumes = Send-OVRequest ($indexUri + "?category=storage-volumes&count=-1&start=0&sort=name:asc") -appliance $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $regex = " \((([0-9]|[1-9][0-9]|[1-9][0-9][0-9])+)\)" + + $tempVolumeName = $volume.name -replace $regex,"" + + for ($i = 1; $i -le $volume.name.length; $i++) + { + + if (-not ($indexVolumes.members -contains ($tempVolumeName + " ($i)"))) + { + + $attachVolumeName = $tempVolumeName + " ($i)" + + # Verify the name is unique by searching the index. + Try + { + + $results = Send-OVRequest ($indexUri + "?category=storage-volumes&filter=name='$attachVolumeName'&count=-1&start=0&sort=name:asc") -appliance $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if ($results.count -eq 0) + { + + "[{0}] Setting Volume Name to '$attachVolumeName'." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + break + + } + + } + + } + + $tempVolume | Add-Member -NotePropertyName id -NotePropertyValue $attachVolume.id + $tempVolume | Add-Member -NotePropertyName volumeName -NotePropertyValue $attachVolumeName + $tempVolume | Add-Member -NotePropertyName volumeUri -NotePropertyValue $Null + $tempVolume | Add-Member -NotePropertyName volumeStoragePoolUri -NotePropertyValue $attachVolume.volumeStoragePoolUri + $tempVolume | Add-Member -NotePropertyName volumeStorageSystemUri -NotePropertyValue $attachVolume.volumeStorageSystemUri + $tempVolume | Add-Member -NotePropertyName volumeProvisionType -NotePropertyValue $volume.provisionType + $tempVolume | Add-Member -NotePropertyName volumeProvisionedCapacityBytes -NotePropertyValue $volume.provisionedCapacity + $tempVolume | Add-Member -NotePropertyName volumeShareable -NotePropertyValue $False + $tempVolume | Add-Member -NotePropertyName lunType -NotePropertyValue $attachVolume.lunType + + if ($attachVolume.lunType -eq "Auto") { $tempVolume | Add-Member -NotePropertyName lun -NotePropertyValue $Null } + else { $tempVolume | Add-Member -NotePropertyName lun -NotePropertyValue $attachVolume.lun } + + $tempVolume | Add-Member -NotePropertyName storagePaths -NotePropertyValue ($attachVolume.storagePaths | ForEach-Object { $_ | select-object * -exclude status } ) + $tempVolume | Add-Member -NotePropertyName permanent -NotePropertyValue $volume.isPermanent + + } + + # "[{0}] Copied volume details: $($tempVolume | Format-List * )" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $newVolumeAttachments += $tempVolume + + } + + $_Profile.sanStorage.volumeAttachments = $newVolumeAttachments + + } + + # Need to parse through local storage policies to null out Logical Drive ID + if ($_Profile.localStorage.controllers.Count -gt 0) + { + + Write-Warning "Local storage contents are not copied when the profile is copied. When copying a server profile with local storage, the content of the physical drives must be manually copied to the target server hardware." + + ForEach ($_controller in $_Profile.localStorage.controllers) + { + + For ($_ld = 0; $_ld -lt $_controller.logicalDrives.Count; $_ld++) + { + + if ($_controller.logicalDrives[$_ld].PSObject.Properties | ? Name -eq "driveNumber") + { + + '[{0}] Setting "{1}" Controller Logical Drive "{2}" driveNumber to null' -f $MyInvocation.InvocationName.ToString().ToUpper(), $_controller.deviceSlot, $_controller.logicalDrives[$_ld].name | Write-Verbose + + $_controller.logicalDrives[$_ld].PSObject.Properties.Remove('driveNumber') + + } + + if ($_controller.logicalDrives[$_ld].PSObject.Properties | ? Name -eq "deviceName") + { + + '[{0}] Removing deviceName from "{1}" Controller Logical Drive "{2}"' -f $MyInvocation.InvocationName.ToString().ToUpper(), $_controller.deviceSlot, $_controller.logicalDrives[$_ld].name | Write-Verbose + + $_controller.logicalDrives[$_ld].PSObject.Properties.Remove('deviceName') + + } + + if ($_controller.logicalDrives[$_ld].PSObject.Properties | ? Name -eq "deviceUuid") + { + + '[{0}] Removing deviceUuid from "{1}" Controller Logical Drive "{2}"' -f $MyInvocation.InvocationName.ToString().ToUpper(), $_controller.deviceSlot, $_controller.logicalDrives[$_ld].name | Write-Verbose + + $_controller.logicalDrives[$_ld].PSObject.Properties.Remove('deviceUuid') + + } + + } + + } + + } + + # Set iscsiInitiatorName to null + $_Profile.iscsiInitiatorName = $null + + # If DestinationName is provided, change to the profile name to value + if ($DestinationName) + { + + "[{0}] New Server Profile name provided $($DestinationName)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + $_Profile.name = $destinationName + + } + + # If no DestinationName is provided, add "Copy Of " prefix. + else + { + + "[{0}] No new Server Profile name provided. Setting to `"Copy of $($_Profile.name)`"" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + $_Profile.name = "Copy of {0}" -f $_Profile.name + + } + + # If the server hardware device is present, add the property to the object + if ($serverDevice) + { + + $_Profile | Add-Member @{ serverHardwareUri = $serverDevice.Uri } + + } + + # Send request to create new copied profile + "[{0}] Sending request" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $Resp = Send-OVRequest -Uri $ServerProfilesUri -Method POST -Body $_Profile -appliance $ApplianceConnection + + Try + { + + $Resp = $Resp | Wait-OVTaskStart + + if ($Resp.taskState -eq 'Error' -and $Resp.stateReason -eq 'ValidationError') + { + + if ($PSCmdlet.ShouldProcess($InputObject.name, ('The provided server profile generated a validation error: "{0}". Do you wish to override and save the Server Profile' -f $Resp.taskErrors.message))) + { + + Try + { + + $_Uri = '{0}?force=all' -f $ServerProfilesUri + + $Resp = Send-OVRequest -Uri $_Uri -Method POST -Body $_Profile -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + else + { + + $ExceptionMessage = $resp.taskErrors.message + $ErrorRecord = New-ErrorRecord HPEOneView.ServerProfileResourceException InvalidOperation InvalidOperation 'AsyncronousTask' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $resp + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Remove-OVServerProfile +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdLetBinding (DefaultParameterSetName = "default", SupportsShouldProcess, ConfirmImpact = 'High')] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = "default")] + [ValidateNotNullOrEmpty()] + [Alias ('uri','name','profile')] + [Object]$ServerProfile, + + [Parameter (Mandatory = $false, ValueFromPipeline, ParameterSetName = "default")] + [Switch]$RetainStorageConfig, + + [Parameter (Mandatory = $false, ParameterSetName = "default")] + [Switch]$Force, + + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = "default")] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not($PSBoundParameters['ServerProfile'])) + { + + $PipelineINput = $true + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command agian." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + if($ApplianceConnection.count -gt 1) + { + + # Check for appliance specific URI Parameters and error if more than one appliance connection supplied + if (($ServerProfile -is [String]) -and ($ServerProfile.StartsWith($ServerProfilesUri))) + { + + "[{0}] SourceName is a Server Profile URI: $($ServerProfile)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + $ErrorRecord = New-ErrorRecord ArgumentNullException ParametersNotSpecified InvalidArgument 'Remove-OVServerProfile' -Message "The input Parameter 'profile' is a resource URI. For multiple appliance connections this is not supported." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + } + + if (($ServerProfile -is [array]) -and ($ServerProfile.getvalue(0).gettype() -is [String]) -and [RegEx]::Match($ServerProfile, '/rest/', $RegExInsensitiveFlag).Success) + { + + "[{0}] Assign is a Server Profile URI: $($SourceName)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + $ErrorRecord = New-ErrorRecord ArgumentNullException ParametersNotSpecified InvalidArgument 'Remove-OVServerProfile' -Message "The input Parameter 'profile' is a resource URI. For multiple appliance connections this is not supported." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + } + + Process + { + + "[{0}] Profile input type: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $ServerProfile.gettype() | Write-Verbose + + foreach ($_profile in $ServerProfile) + { + + if ($_profile -is [String] -and (-not($_profile.StartsWith.($ServerProfilesUri)))) + { + + Try + { + + $_profile = Get-OVServerProfile -Name $_profile -ApplianceConnection $ApplianceConnection -ErrorAction Stop + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + elseif ($_profile -is [String]) + { + + Try + { + + $_profile = Send-OVRequest $_profile -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + elseif ($_profile -is [PSCustomObject] -and $_profile.category -ine $ResourceCategoryEnum.ServerProfile) + { + + $ErrorRecord = New-ErrorRecord InvalidOperationException InvalidArgumentValue InvalidArgument 'SeverProfile' -Message ("Invalid profile object provided: {0}. Please verify the object and try again." -f $_profile.name ) + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + $_ShouldProcessMessage = "remove Server Profile {0} from appliance?" -f $_profile.name + + $_uri = $_profile.uri + + $_UriParams = [System.Collections.ArrayList]::New() + $_ShouldProcessMessageParams = [System.Collections.ArrayList]::New() + + if ($PSBoundParameters['RetainStorageConfig']) + { + + Write-Warning "All attached SAN volumes and associated SAN and Storage System configuration will be left intact to allow the server to continue operating. Private volumes attached by this profile will be removed from OneView and will have to be re-added if you intend to re-create this profile." + + [void]$_UriParams.Add('suppressDeviceUpdates=true') + [void]$_ShouldProcessMessageParams.Add('retain shared storage configuration') + + } + + if ($PSBoundParameters['Force']) + { + + Write-Warning ("Forcibly deleting {0} in its current state will ignore any errors that may occur. This may leave the server hardware in a state that would prevent subsequent use." -f $_profile.name) + + [void]$_UriParams.Add('force=true') + [void]$_ShouldProcessMessageParams.Add('force') + + } + + if ($_UriParams.Count -gt 0) + { + + $_uri = "{0}?{1}" -f $_uri, [String]::Join('&', $_UriParams.ToArray()) + $_ShouldProcessMessage = "{0} {1}" -f [String]::Join(' and ', $_ShouldProcessMessageParams.ToArray()), $_ShouldProcessMessage + + } + + if ($PSCmdlet.ShouldProcess($ApplianceConnection, $_ShouldProcessMessage)) + { + + Try + { + + Send-OVRequest -Uri $_uri -Method DELETE -AddHeader @{'If-Match' = $_profile.eTag} -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + elseif ($PSBoundParameters['Whatif']) + { + + "[{0}] -WhatIf provided." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + else + { + + "[{0}] User cancelled." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Get-OVServerProfileTemplate +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "Default")] + Param + ( + + [Parameter (ParameterSetName = "Default", Mandatory = $false)] + [Parameter (ParameterSetName = "Detailed", Mandatory = $false)] + [Parameter (ParameterSetName = "Export", Mandatory = $false)] + [Alias ('profile')] + [ValidateNotNullorEmpty()] + [String]$Name, + + [Parameter (ValueFromPipeline, ParameterSetName = "Default", Mandatory = $false)] + [Parameter (ValueFromPipeline, ParameterSetName = "Detailed", Mandatory = $false)] + [Parameter (ValueFromPipeline, ParameterSetName = "Export", Mandatory = $false)] + [object]$ServerHardwareType, + + [Parameter (ParameterSetName = "Default", Mandatory = $false)] + [Parameter (ParameterSetName = "Detailed", Mandatory = $false)] + [Parameter (ParameterSetName = "Export", Mandatory = $false)] + [ValidateNotNullOrEmpty()] + [String]$Label, + + [Parameter (ParameterSetName = "Default", Mandatory = $false)] + [Parameter (ParameterSetName = "Detailed", Mandatory = $false)] + [Parameter (ParameterSetName = "Export", Mandatory = $false)] + [Object]$Scope = "AllResourcesInScope", + + [Parameter (ParameterSetName = "Detailed", Mandatory)] + [Switch]$Detailed, + + [Parameter (ValueFromPipelineByPropertyName, Mandatory = $false, ParameterSetName = "Default")] + [Parameter (ValueFromPipelineByPropertyName, Mandatory = $false, ParameterSetName = "Detailed")] + [Parameter (ValueFromPipelineByPropertyName, Mandatory = $false, ParameterSetName = "Export")] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default), + + [Parameter (ParameterSetName = "Export", Mandatory)] + [Alias ("x")] + [Switch]$Export, + + [Parameter (ParameterSetName = "Export", Mandatory)] + [ValidateNotNullOrEmpty()] + [Alias ("save")] + [String]$Location + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + # Validate the path exists. If not, create it. + if (($Export) -and (-not(Test-Path $Location))) + { + + "[{0}] Directory does not exist. Creating directory..." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + New-Item -path $Location -ItemType Directory + + } + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command agian." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $TemplateCollection = [System.Collections.ArrayList]::new() + + } + + Process + { + + ForEach ($_appliance in $ApplianceConnection) + { + + "[{0}] Processing appliance {1} (of {2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name, $ApplianceConnection.Count | Write-Verbose + + $_Query = [System.Collections.ArrayList]::new() + + # Handle default cause of AllResourcesInScope + if ($Scope -eq 'AllResourcesInScope') + { + + "[{0}] Processing AllResourcesInScope." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_Scopes = $_appliance.ActivePermissions | Where-Object Active + + # If one scope contains 'AllResources' ScopeName "tag", then all resources should be returned regardless. + if ($_Scopes | Where-Object ScopeName -eq 'AllResources') + { + + $_ScopeNames = [String]::Join(', ', ($_Scopes | Where-Object ScopeName -eq 'AllResources').ScopeName) + + "[{0}] Scope(s) {1} is set to 'AllResources'. Will not add scope to URI query parameter." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_ScopeNames | Write-Verbose + + } + + # Process ApplianceConnection ActivePermissions collection + else + { + + Try + { + + $_ScopeQuery = Join-Scope $_Scopes + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + [Void]$_Query.Add(("({0})" -f $_ScopeQuery)) + + } + + } + + elseif ($Scope | Where-Object ScopeName -eq 'AllResources') + { + + $_ScopeNames = [String]::Join(', ', ($_Scopes | Where-Object ScopeName -eq 'AllResources').ScopeName) + + "[{0}] Scope(s) {1} is set to 'AllResources'. Will not add scope to URI query parameter." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_ScopeNames | Write-Verbose + + } + + elseif ($Scope -eq 'AllResources') + { + + "[{0}] Requesting scope 'AllResources'. Will not add scope to URI query parameter." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_ScopeNames | Write-Verbose + + } + + else + { + + Try + { + + $_ScopeQuery = Join-Scope $Scope + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + [Void]$_Query.Add(("({0})" -f $_ScopeQuery)) + + } + + if ($Name) + { + + if ($Name.Contains('*')) + { + + [Void]$_Query.Add(("name%3A{0}" -f $Name.Replace("*", "%2A").Replace(',','%2C').Replace(" ", "?"))) + + } + + else + { + + [Void]$_Query.Add(("name:'{0}'" -f $Name)) + + } + + } + + if ($Label) + { + + [Void]$_Query.Add(("labels:'{0}'" -f $Label)) + + } + + $_Category = 'category={0}' -f $ResourceCategoryEnum.ServerProfileTemplate + + # Build the final URI + $_uri = '{0}?{1}&sort=name:asc&query={2}' -f $IndexUri, [String]::Join('&', $_Category), [String]::Join(' AND ', $_Query.ToArray()) + + Try + { + + [Array]$_ResourcesFromIndexCol = Get-AllIndexResources -Uri $_uri -ApplianceConnection $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if ($PSBoundParameters['ServerHardwareType']) + { + + switch ($ServerHardwareType.GetType().Name) + { + + 'String' + { + + Try + { + + $ServerHardwareType = Get-OVServerHardwareType -Name $ServerHardwareType -ApplianceConnection $ApplianceConnection -ErrorAction Stop + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + 'PSCustomObject' + { + + if ($ServerHardwareType.category -ne 'server-hardware-types') + { + + $ExceptionMessage = "The provided ServerHardwareType parameter value, '{0}', is not a supported resource type. Please check the value, and try again." -f $ServerHardwareType.name + $ErrorRecord = New-ErrorRecord HPEOneView.ServerHardwareTypeResourceException ServerHardwareTypeInvalidObject InvalidParameter 'ServerHardwareType' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + } + + $_ResourcesFromIndexCol = $_ResourcesFromIndexCol | Where-Object { $_.serverHardwareTypeUri -eq $ServerHardwareType.uri } + + } + + if($_ResourcesFromIndexCol.Count -eq 0 -and $Name) + { + + "[{0}] Profile Template Resource Name '{1}' was not found on appliance {2}. Generate Error." -f $MyInvocation.InvocationName.ToString().ToUpper(), $Name, $_appliance.Name | Write-Verbose + + $ExceptionMessage = "The specified Server Profile Template '{0}' was not found on '{1}' appliance connection. Please check the name again, and try again." -f $Name, $_appliance.Name + $ErrorRecord = New-ErrorRecord HPEOneView.ServerProfileResourceException ServerProfileResourceNotFound ObjectNotFound "Name" -Message $ExceptionMessage + $PSCmdlet.WriteError($ErrorRecord) + + } + + else + { + + foreach ($_member in $_ResourcesFromIndexCol) + { + + $_member.PSObject.TypeNames.Insert(0,'HPEOneView.ServerProfileTemplate') + + [void]$TemplateCollection.Add($_member) + + } + + } + + } + + } + + End + { + + "[{0}] Done. {1} server profile template resource(s) found." -f $MyInvocation.InvocationName.ToString().ToUpper(), $TemplateCollection.count | Write-Verbose + + # If user wants to export the profile configuration + if ($export) + { + + # Get the unique applianceConnection.name properties from the profile collection for grouping the output files + $ProfileGroupings = $TemplateCollection.ApplianceConnection.name | Select-Object -Unique + + ForEach ($pg in $ProfileGroupings) + { + + $outputProfiles = [System.Collections.ArrayList]::new() + + $templates = $TemplateCollection | Where-Object { $_.ApplianceConnection.Name -eq $pg } + + # Loop through all profiles + foreach ($_profile in $templates) + { + + # Trim out appliance unique properties + + $_profile = $_profile | select-object -Property * -excludeproperty uri,etag,created,modified,status,state,inprogress,enclosureUri,enclosureBay,serverHardwareUri,taskUri,ApplianceConnection + $_profile.serialNumberType = "UserDefined" + + # Loop through the connections to save the assigned address + $i = 0 + foreach ($connection in $profile.connectionSettings.connections) + { + + if ($profile.connectionSettings.connections[$i].mac) { $_profile.connectionSettings.connections[$i].macType = "UserDefined" } + if ($profile.connectionSettings.connections[$i].wwpn) { $_profile.connectionSettings.connections[$i].wwpnType = "UserDefined" } + $i++ + + } + + [void]$outputProfiles.Add($_profile) + + } + + # Save profile to JSON file + "[{0}] Saving Server Profile Templates to {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), ($location + '\' + $pg + '_ServerProfileTemplates.json') | Write-Verbose + + convertto-json -InputObject $outputProfiles -depth 99 | new-item ($location + '\' + $pg + '_ServerProfileTemplates.json') -itemtype file + + } + + } + + else + { + + Return $TemplateCollection + + } + + } + +} + +function New-OVServerProfileTemplate +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "Default")] + Param + ( + + [Parameter (Mandatory, ParameterSetName = "Default")] + [Parameter (Mandatory, ParameterSetName = "SANStorageAttach")] + [ValidateNotNullOrEmpty()] + [String]$Name, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Parameter (Mandatory = $false, ParameterSetName = "SANStorageAttach")] + [String]$Description, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Parameter (Mandatory = $false, ParameterSetName = "SANStorageAttach")] + [String]$ServerProfileDescription, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Parameter (Mandatory = $false, ParameterSetName = "SANStorageAttach")] + [Boolean]$ManageConnections = $true, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Parameter (Mandatory = $false, ParameterSetName = "SANStorageAttach")] + [ValidateNotNullOrEmpty()] + [array]$Connections = @(), + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Parameter (Mandatory = $false, ParameterSetName = "SANStorageAttach")] + [ValidateSet ('Exact', 'Minimum', 'None')] + [String]$ConnectionsConsistencyChecking = 'Exact', # Will need to use $ConsistencyCheckingEnum for API value + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Parameter (Mandatory = $false, ParameterSetName = "SANStorageAttach")] + [ValidateNotNullOrEmpty()] + [Alias ('eg')] + [object]$EnclosureGroup, + + [Parameter (Mandatory, ParameterSetName = "Default")] + [Parameter (Mandatory, ParameterSetName = "SANStorageAttach")] + [ValidateNotNullOrEmpty()] + [Alias ('sht')] + [object]$ServerHardwareType, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Parameter (Mandatory = $false, ParameterSetName = "SANStorageAttach")] + [ValidateNotNullOrEmpty()] + [Switch]$Firmware, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Parameter (Mandatory = $false, ParameterSetName = "SANStorageAttach")] + [ValidateNotNullOrEmpty()] + [object]$Baseline, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Parameter (Mandatory = $false, ParameterSetName = "SANStorageAttach")] + [ValidateNotNullOrEmpty()] + [Version]$BaselinePatchLevel, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Parameter (Mandatory = $false, ParameterSetName = "SANStorageAttach")] + [ValidateSet ('Exact', 'None')] + [String]$FirmwareConsistencyChecking = 'Exact', # Will need to use $ConsistencyCheckingEnum for API value, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Parameter (Mandatory = $false, ParameterSetName = "SANStorageAttach")] + [ValidateSet ('LowerThanBaseline', 'NotEqualToBaseline')] + [String]$FirmwareInstallationPolicy = 'LowerThanBaseline', + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Parameter (Mandatory = $false, ParameterSetName = "SANStorageAttach")] + [Alias ('FirmwareMode')] + [ValidateSet ('FirmwareOnly', 'FirmwareAndSoftware', 'FirmwareOffline', 'FirmwareAndOSDrivers', 'FirmwareOnlyOfflineMode')] + [String]$FirmwareInstallMode = 'FirmwareAndSoftware', + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Parameter (Mandatory = $false, ParameterSetName = "SANStorageAttach")] + [ValidateSet ('Immediate', 'Scheduled', 'NotScheduled')] + [String]$FirmwareActivationMode = 'Immediate', + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Parameter (Mandatory = $false, ParameterSetName = "SANStorageAttach")] + [Switch]$ForceInstallFirmware, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Parameter (Mandatory = $false, ParameterSetName = "SANStorageAttach")] + [System.Obsolete("The OSDeploymentPlan parameter is obsolete and no longer supported.")] + [Object]$OSDeploymentPlan, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Parameter (Mandatory = $false, ParameterSetName = "SANStorageAttach")] + [System.Obsolete("The OSDeploymentConsistencyChecking parameter is obsolete and no longer supported.")] + [String]$OSDeploymentConsistencyChecking = 'Exact', + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Parameter (Mandatory = $false, ParameterSetName = "SANStorageAttach")] + [System.Obsolete("The OSDeploymentPlanAttributes parameter is obsolete and no longer supported.")] + [HPEOneView.ServerProfile.OSDeployment.OSDeploymentParameter[]]$OSDeploymentPlanAttributes, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Parameter (Mandatory = $false, ParameterSetName = "SANStorageAttach")] + [ValidateNotNullOrEmpty()] + [Switch]$Bios, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Parameter (Mandatory = $false, ParameterSetName = "SANStorageAttach")] + [ValidateNotNullOrEmpty()] + [array]$BiosSettings=@(), + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Parameter (Mandatory = $false, ParameterSetName = "SANStorageAttach")] + [ValidateSet ('Exact', 'None')] + [String]$BiosConsistencyChecking = 'Exact', + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Parameter (Mandatory = $false, ParameterSetName = "SANStorageAttach")] + [ValidateSet ("UEFI", "UEFIOptimized", "BIOS", 'Unmanaged', IgnoreCase = $False)] + [String]$BootMode = "BIOS", + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Parameter (Mandatory = $false, ParameterSetName = "SANStorageAttach")] + [ValidateSet ('Exact', 'None')] + [String]$BootModeConsistencyChecking = 'Exact', + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Parameter (Mandatory = $false, ParameterSetName = "SANStorageAttach")] + [ValidateSet ("Auto", "IPv4", "IPv6", "IPv4ThenIPv6", "IPv6ThenIPv4", IgnoreCase = $False)] + [String]$PxeBootPolicy = "Auto", + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Parameter (Mandatory = $false, ParameterSetName = "SANStorageAttach")] + [Alias ('boot')] + [Bool]$ManageBoot = $true, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Parameter (Mandatory = $false, ParameterSetName = "SANStorageAttach")] + [ValidateNotNullOrEmpty()] + [array]$BootOrder, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Parameter (Mandatory = $false, ParameterSetName = "SANStorageAttach")] + [ValidateSet ('Exact', 'None')] + [String]$BootOrderConsistencyChecking = 'Exact', + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Parameter (Mandatory = $false, ParameterSetName = "SANStorageAttach")] + [ValidateSet ("Unmanaged", "Enabled", "Disabled", IgnoreCase = $False)] + [String]$SecureBoot = 'Unmanaged', + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Parameter (Mandatory = $false, ParameterSetName = "SANStorageAttach")] + [Switch]$LocalStorage, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Parameter (Mandatory = $false, ParameterSetName = "SANStorageAttach")] + [ValidateSet ('Exact', 'Minimum', 'None')] + [String]$LocalStorageConsistencyChecking = 'Exact', # Will need to use $ConsistencyCheckingEnum for API value, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Parameter (Mandatory = $false, ParameterSetName = "SANStorageAttach")] + [Alias('LogicalDisk')] + [ValidateNotNullorEmpty()] + [Object]$StorageController, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Parameter (Mandatory = $false, ParameterSetName = "SANStorageAttach")] + [Bool]$ManageIloSettings = $false, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Parameter (Mandatory = $false, ParameterSetName = "SANStorageAttach")] + [ValidateNotNullOrEmpty()] + [PSCustomObject]$IloSettings, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Parameter (Mandatory = $false, ParameterSetName = "SANStorageAttach")] + [ValidateSet ('Exact', 'None')] + [String]$IloSettingsConsistencyChecking = 'Exact', + + [Parameter (Mandatory, ParameterSetName = "SANStorageAttach")] + [Switch]$SANStorage, + + [Parameter (Mandatory = $false, ParameterSetName = "SANStorageAttach")] + [ValidateSet ('Exact', 'Minimum', 'None')] + [String]$SANStorageConsistencyChecking = 'Exact', # Will need to use $ConsistencyCheckingEnum for API value + + [Parameter (Mandatory, ParameterSetName = "SANStorageAttach")] + [ValidateSet ('CitrixXen','CitrixXen7','AIX','IBMVIO','RHEL4','RHEL3','RHEL','RHEV','RHEV7','VMware','Win2k3','Win2k8','Win2k12','Win2k16','Win2k19','OpenVMS','Egenera','Exanet','Solaris9','Solaris10','Solaris11','ONTAP','OEL','HPUX11iv1','HPUX11iv2','HPUX11iv3','SUSE','SUSE9','Inform','Ubuntu', IgnoreCase = $true)] + [Alias ('OS')] + [String]$HostOStype, + + [Parameter (Mandatory, ParameterSetName = "SANStorageAttach")] + [ValidateNotNullOrEmpty()] + [object]$StorageVolume, + + [Parameter (Mandatory = $false, ParameterSetName = "SANStorageAttach")] + [Alias ('Even')] + [Switch]$EvenPathDisabled, + + [Parameter (Mandatory = $false, ParameterSetName = "SANStorageAttach")] + [Alias ('Odd')] + [Switch]$OddPathDisabled, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Parameter (Mandatory = $false, ParameterSetName = "SANStorageAttach")] + [ValidateSet ("Bay","BayAndServer", IgnoreCase=$false)] + [String]$Affinity = "Bay", + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Parameter (Mandatory = $false, ParameterSetName = "SANStorageAttach")] + [ValidateSet ("Virtual", "Physical", "UserDefined", IgnoreCase = $true)] + [String]$MacAssignment = "Virtual", + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Parameter (Mandatory = $false, ParameterSetName = "SANStorageAttach")] + [ValidateSet ("Virtual", "Physical", "'UserDefined", IgnoreCase = $true)] + [String]$WwnAssignment = "Virtual", + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Parameter (Mandatory = $false, ParameterSetName = "SANStorageAttach")] + [ValidateSet ("Virtual", "Physical", "UserDefined", IgnoreCase = $true)] + [String]$SnAssignment = "Virtual", + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Parameter (Mandatory = $false, ParameterSetName = "SANStorageAttach")] + [ValidateSet ("Virtual", "UserDefined", IgnoreCase = $true)] + [String]$IscsiInitiatorNameAssignmet = "Virtual", + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Parameter (Mandatory = $false, ParameterSetName = "SANStorageAttach")] + [Bool]$HideUnusedFlexNics = $True, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Parameter (Mandatory = $false, ParameterSetName = "SANStorageAttach")] + [Switch]$Async, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Parameter (Mandatory = $false, ParameterSetName = "SANStorageAttach")] + [Switch]$PassThru, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Parameter (Mandatory = $false, ParameterSetName = "SANStorageAttach")] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command agian." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + # Check for URI values in Parameters and validate that only one appliance connection is provided in the call + if($ApplianceConnection.Count -gt 1) + { + + # SHT + if($serverHardwareType -is [String] -and $serverHardwareType.StartsWith($ServerHardwareTypesUri)) + { + + $ErrorRecord = New-ErrorRecord HPEOneView.ServerProfileResourceException InvalidServerHardwareTypeObject InvalidArgument 'New-OVPropfile' -Message "Server Hardware Type as URI is not supported for multiple appliance connections" + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + if($serverHardwareType -is [String] -and $serverHardwareType.StartsWith("/rest")) + { + + $ErrorRecord = New-ErrorRecord HPEOneView.ServerProfileResourceException InvalidServerHardwareTypeObject InvalidArgument 'New-OVPropfile' -Message "Server Hardware Type as URI is not supported for multiple appliance connections." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + # EG + if(($enclosureGroup -is [String] -and $enclosureGroup.StartsWith("/rest"))) + { + + $ErrorRecord = New-ErrorRecord HPEOneView.ServerProfileResourceException InvalidServerHardwareTypeObject InvalidArgument 'New-OVPropfile' -Message "Enclosure Group as URI is not supported for multiple appliance connections." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + #Baseline + if (($baseline -is [String]) -and ($baseline.StartsWith('/rest'))) + { + + $ErrorRecord = New-ErrorRecord HPEOneView.ServerProfileResourceException InvalidServerHardwareTypeObject InvalidArgument 'New-OVPropfile' -Message "Baseline as URI is not supported for multiple appliance connections." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + ForEach ($_key in $PSBoundParameters.keys.GetEnumerator()) + { + + if ('ImportLogicalDisk','Initialize','ControllerMode','Bootable','RaidLevel' -contains $_key) + { + + Write-Warning ("The -{0} parameter is deprecated. To configure local storage, please use the New-OVServerProfileLogicalDisk and New-OVServerProfileLogicalDiskController Cmdlets." -f $_key) + + } + + } + + $uri = $ServerProfileTemplatesUri + + $colStatus = [System.Collections.ArrayList]::new() + + } + + Process + { + + # New Server Resource Object + $_spt = NewObject -ServerProfileTemplate + + $_spt.name = $Name + $_spt.description = $Description + $_spt.serverProfileDescription = $ServerProfileDescription + $_spt.affinity = $Affinity + + if (-not $ManageBoot -and ($PSBoundParameters['BootMode'] -or $PSBoundParameters['BootOrder'] -or $PSBoundParameters['PxeBootPolicy'])) + { + + $ExceptionMessage = "Attempting to set Boot Mode or Boot Order and not enabling ManageBoot is not supported. Either remove the -BootOrder,-PxeBootPolicy and/or -BootMode parameters, or add -ManageBoot switch parameter." + $ErrorRecord = New-ErrorRecord HPEOneView.ServerProfileTemplateResourceException InvalidManageBootModeState InvalidArgument 'ManageBoot' -TargetType 'Boolean' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + # Check to see if the serverHardwareType or enclosureGroup is null, and generate error(s) then break. + if (-not($ServerHardwareType)) + { + + $ErrorRecord = New-ErrorRecord HPEOneView.ServerProfileResourceException InvalidServerHardwareTypeObject InvalidArgument 'ServerHardwareType' -Message "Server Hardware Type is missing. Please provide a Server Hardware Type using the -sht Parameter and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + # If the URI is passed as the Server Hardware Type, then set the serverHardwareTypeUri variable + If ($ServerHardwareType -is [String]) + { + + if ($ServerHardwareType.StartsWith($ServerHardwareTypesUri)) + { + + "[{0}] SHT URI Provided: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $ServerHardwareType | Write-Verbose + + $_spt.serverHardwareTypeUri = $ServerHardwareType + + Try + { + + $ServerHardwareType = Send-OVRequest -Uri $ServerHardwareType -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + # Otherwise, perform a lookup ofthe SHT based on the name + else + { + + "[{0}] SHT Name Provided: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $ServerHardwareType | Write-Verbose + + Try + { + + $ServerHardwareType = Get-OVServerHardwareType -Name $ServerHardwareType -Appliance $ApplianceConnection -ErrorAction Stop + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + "[{0}] SHT URI: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $ServerHardwareType.uri | Write-Verbose + + $_spt.serverHardwareTypeUri = $ServerHardwareType.uri + + } + + } + + # Else the SHT object is passed + else + { + + "[{0}] ServerHardwareType object provided" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + "[{0}] ServerHardwareType Name: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $ServerHardwareType.name | Write-Verbose + "[{0}] ServerHardwareType Uri: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $ServerHardwareType.uri | Write-Verbose + + $_spt.serverHardwareTypeUri = $serverHardwareType.uri + + } + + if ('BladeServer', 'ComputeModule' -contains $ServerHardwareType.platform) + { + + $_spt.hideUnusedFlexNics = $PSBoundParameters['HideUnusedFlexNics'] + $_spt.serialNumberType = $SnAssignment + $_spt.macType = $MacAssignment + $_spt.wwnType = $WwnAssignment + + if ($PSBoundParameters['IscsiInitiatorNameAssignmet']) + { + + $_spt.iscsiInitiatorNameType = $IscsiInitiatorNameAssignmetEnum[$IscsiInitiatorNameAssignmet] + + } + + + if (-not($EnclosureGroup)) + { + + $ErrorRecord = New-ErrorRecord HPEOneView.ServerProfileResourceException InvalidEnclosureGroupObject InvalidArgument 'EnclosureGroup' -Message "Enclosure Group is missing. Please provide an Enclosure Group using the -eg Parameter and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($EnclosureGroup -is [String]) + { + + # If the URI is passed as the Enclosure Group, then set the enclosureGroupUri variable + if ($EnclosureGroup.StartsWith('/rest')) + { + + $_spt.enclosureGroupUri = $EnclosureGroup + + } + + # Otherwise, perform a lookup ofthe Enclosure Group + else + { + + Try + { + + $EnclosureGroup = Get-OVEnclosureGroup -name $EnclosureGroup -appliance $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + "[{0}] EG URI: $enclosureGroupUri" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_spt.enclosureGroupUri = $EnclosureGroup.uri + + } + + } + + # Else the EG object is passed + elseif (($EnclosureGroup -is [PSObject]) -and ($EnclosureGroup.category -eq $ResourceCategoryEnum.EnclosureGroup)) + { + + # Retrieve only EG from this appliance connection + "[{0}] Enclosure Group object provided" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + "[{0}] Enclosure Group Name: $($EnclosureGroup.name)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + "[{0}] Enclosure Group Uri: $($EnclosureGroup.uri)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + # Retrieve only EG from this appliance connection + $_spt.enclosureGroupUri = $EnclosureGroup.uri + + } + + else + { + + $ErrorRecord = New-ErrorRecord HPEOneView.ServerProfileResourceException InvalidEnclosureGroupObject InvalidArgument 'EnclosureGroup' -TargetType $EnclosureGroup.GetType().Name -Message "Enclosure Group is invalid. Please specify a correct Enclosure Group name, URI or object and try again." + + # Generate Terminating Error + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + # Handle DL Server Profiles by setting BL-specific properties to NULL + else + { + + "[{0}]] Server Hardware Type platform is a RackServer, setting 'macType', 'wwnType', 'serialNumberType', 'affinity' and 'hideUnusedFlexNics' to supported values." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_spt.macType = 'Physical' + $_spt.wwnType = 'Physical' + $_spt.serialNumberType = 'Physical' + $_spt.hideUnusedFlexNics = $true + $_spt.affinity = $Null + + if (-not $ServerHardwareType.capabilities.Contains('ManageBootOrder')) + { + + $_spt.boot.manageBoot = $false + $_spt.boot.complianceControl = "Unchecked" + $_spt.boot.PSObject.Properties.Remove('order') + + } + + } + + # Handle Boot Order and BootManagement + switch ($ServerHardwareType.generation) + { + + {[RegEx]::Match($_, 'Gen7|Gen8', $RegExInsensitiveFlag).Success} + { + + # User provided UEFI or UEFIOptimized for a non-Gen9 platform. + if ('Unmanaged','BIOS' -notcontains $BootMode) + { + + $ExceptionMessage = "The -BootMode Parameter was provided and the Server Hardware model '{0}' does not support this Parameter. Please verify the Server Hardware Type is at least an HPE ProLiant Gen9." -f $ServerHardwareType.model + $ErrorRecord = New-ErrorRecord HPEOneView.ServerProfileResourceException BootModeNotSupported InvalidArgument 'BootMode' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + if (-not($PSboundParameters['BootOrder']) -and $ManageBoot) + { + + "[{0}] No boot order provided for Gen8 Server resource type. Defaulting to 'CD','Floppy','USB','HardDisk','PXE'" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + [System.Collections.ArrayList]$_spt.boot.order = ('CD','Floppy','USB','HardDisk','PXE') + + } + + } + + # {[RegEx]::Match($_, 'Gen9|Gen10', $RegExInsensitiveFlag).Success} + default + { + + "[{0}] '{1}' Server, setting BootMode to: {2}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $ServerHardwareType.generation, $BootMode | Write-Verbose + + if ($ManageBoot) + { + + $_spt.bootMode = NewObject -ServerProfileBootMode + + switch ($BootMode) + { + + 'Unmanaged' + { + + $_spt.bootMode.manageMode = $false + + } + + "BIOS" + { + + $_spt.bootMode = NewObject -ServerProfileBootModeLegacyBios + + $_spt.bootMode.manageMode = $true; + $_spt.bootMode.mode = $BootMode; + + } + + { "UEFI","UEFIOptimized" -match $_ } + { + + $_spt.bootMode.manageMode = $true; + $_spt.bootMode.mode = $BootMode; + $_spt.bootMode.pxeBootPolicy = $PxeBootPolicy + + if ([RegEx]::Match($ServerHardwareType.model, 'DL|XL|ML', $RegExInsensitiveFlag).Success) + { + + $_spt.boot.manageBoot = $false + + } + + if (-not $PSBoundParameters['SecureBoot'] -and $BootMode -eq 'UEFI' -and $ServerHardwareType.capabilities.Contains('SecureBoot')) + { + + $_spt.bootMode.secureBoot = 'Disabled' + + } + + } + + } + + $_spt.bootMode | Add-Member -NotePropertyName complianceControl -NotePropertyValue $ConsistencyCheckingEnum[$BootModeConsistencyChecking] + + "[{0}] Processing '{1}' Server BootOrder settings." -f $MyInvocation.InvocationName.ToString().ToUpper(), $ServerHardwareType.generation | Write-Verbose + + if ($_spt.boot.manageBoot -and ($BootOrder -contains "Floppy") -and ([RegEx]::Match($BootMode, "UEFI", $RegExInsensitiveFlag).Success)) + { + + $ExceptionMessage = "The -BootOrder Parameter contains 'Floppy' which is an invalid boot option for a UEFI-based system." + $ErrorRecord = New-ErrorRecord HPEOneView.ServerProfileResourceException InvalidUEFIBootOrderParameterValue InvalidArgument 'BootOrder' -TargetType 'Array' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ((-not ($PSBoundParameters["BootOrder"])) -and $_spt.boot.manageBoot -and $BootMode -eq "BIOS") + { + + "[{0}] No boot order provided for Gen9 Server resource type. Defaulting to 'CD','USB','HardDisk','PXE'" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + [System.Collections.ArrayList]$_spt.boot.order = @('CD','USB','HardDisk','PXE') + + } + + elseif ((-not ($PSBoundParameters["BootOrder"])) -and $_spt.boot.manageBoot -and [RegEx]::Match($BootMode, 'UEFI', $RegExInsensitiveFlag).Success -and $ServerHardwareType.model -notmatch 'DL') + { + + "[{0}] No boot order provided for BL Gen9 Server resource type. Defaulting to 'HardDisk'." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + [System.Collections.ArrayList]$_spt.boot.order = @('HardDisk') + + } + + elseif (($BootOrder.count -gt 1) -and $_spt.boot.manageBoot -and [RegEx]::Match($BootMode, 'UEFI', $RegExInsensitiveFlag).Success) + { + + $ExceptionMessage = "The -BootOrder Parameter contains more than 1 entry, and the system BootMode is set to {0}, which is invalud for a UEFI-based system. Please check the -BootOrder Parameter and make sure either 'HardDisk' or 'PXE' are the only option." -f $BootMode + $ErrorRecord = New-ErrorRecord HPEOneView.ServerProfileResourceException InvalidUEFIBootOrderParameterValue InvalidArgument 'BootOrder' -TargetType 'Array' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($BootOrder -and $_spt.boot.manageBoot -and [RegEx]::Match($BootMode, 'UEFI', $RegExInsensitiveFlag).Success -and $ServerHardwareType.model -notmatch 'DL') + { + + "[{0}] Adding provided BootOrder {1} to Server Profile object." -f $MyInvocation.InvocationName.ToString().ToUpper(), [String]::Join(', ', $BootOrder) | Write-Verbose + + [System.Collections.ArrayList]$_spt.boot.order = $BootOrder + + } + + $_spt.boot | Add-Member -NotePropertyName complianceControl -NotePropertyValue $ConsistencyCheckingEnum[$BootOrderConsistencyChecking] -Force + + } + + else + { + + $_spt.boot.manageBoot = $false + + if ($ServerHardwareType.capabilities.Contains('ManageBootOrder')) + { + + $_spt.boot.order = $null + + } + + if (-not $PSBoundParameters['Bios'] -and -not $PSBoundParameters['SecureBoot'] -and $_spt.bootMode.mode -eq 'BIOD') + { + + $_spt.bootMode.secureBoot = 'Disabled' + + } + + } + + } + + } + + # if ($PSBoundParameters['OSDeploymentPlan']) + # { + + # If ($ApplianceConnection.ApplianceType -ne 'Composer') + # { + + # $ExceptionMessage = 'The ApplianceConnection {0} is not a Synergy Composer. OS Deployment Plans are only supported with HPE Synergy.' -f $ApplianceConnection.Name + # $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.ComposerNodeException InvalidOperation InvalidOperation 'ApplianceConnection' -Message $ExceptionMessage + # $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + # } + + # "[{0}] Setting OS Deployment Plan." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + # $_spt | Add-Member -NotePropertyName osDeploymentSettings -NotePropertyValue (NewObject -SPTOSDeploymentSettings) + + # if ($PSBoundParameters['OSDeploymentConsistencyChecking']) + # { + + # $_spt.osDeploymentSettings.complianceControl = $ConsistencyCheckingEnum.$OSDeploymentConsistencyChecking + + # } + + # "[{0}] Setting OS Deployment Plan URI: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $OSDeploymentPlan.uri | Write-Verbose + # $_spt.osDeploymentSettings.osDeploymentPlanUri = $OSDeploymentPlan.uri + + # "[{0}] Number of OS Deployment Plan Custom Attributes to set: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $OSDeploymentPlanAttributes.Count | Write-Verbose + # "[{0}] Setting OS Deployment Plan Custom Attributes: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), ($OSDeploymentPlanAttributes | Out-String) | Write-Verbose + # $_spt.osDeploymentSettings.osCustomAttributes = $OSDeploymentPlanAttributes + + # } + + # Exmamine the profile connections Parameter and pull only those connections for this appliance connection + If ($PSBoundParameters['Connections'] -and $ManageConnections) + { + + if ($PSBoundParameters['ConnectionsConsistencyChecking']) + { + + $_spt.connectionSettings.complianceControl = $ConsistencyCheckingEnum.$ConnectionsConsistencyChecking + + } + + # Check if non BL or SY, and set the search value to only get the list of Fibre Channel networks that are not Direct Attach? + if ($ServerHardwareType.capabilities -notcontains 'VCConnections') + { + + ForEach ($c in $Connections) + { + + # Validate the connection specified is FibreChannel; throw error if not + if ($c.functionType -ne 'FibreChannel') + { + + $ExceptionMessage = 'The provided connection {0} is an Ethernet connection, which is not allowed. Only unmanaged Fibre Channel connections can be provisioned with non-Virtual Connect configurations.' -f $c.id + $ErrorRecord = New-ErrorRecord HPEOneView.ServerProfileConnectionException UnsupportedConnectionType InvalidArgument 'Connections' -TargetType 'PSObject' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + "[{0}] Adding unmanaged connection {1} to profile template." -f $MyInvocation.InvocationName.ToString().ToUpper(), $c.id | Write-Verbose + + # Remove properties that shouldn't exist for unmanaged, rack server connections + $_c = [ServerProfileTemplateUnmanagedFCConnection]::new($c) + + [void]$_spt.connectionSettings.connections.Add($_c) + + } + + } + + else + { + + "[{0}] Getting available Network resources based on SHT and EG." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + # Get avaialble Networks based on the EG and SHT + $_uri = $ServerProfilesAvailableNetworksUri + '?serverHardwareTypeUri={0}&enclosureGroupUri={1}' -f $ServerHardwareType.uri,$EnclosureGroup.uri + + Try + { + + $_AvailableNetworkResources = Send-OVRequest -Uri $_uri -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $_c = 0 + + $BootableConnections = [System.Collections.ArrayList]::new() + + ForEach ($c in $Connections) + { + + $Message = $null + + # Remove connection Parameters not permitted in Template + $c = $c | Select-Object -property * -ExcludeProperty macType, wwnType, wwpnType, mac, wwnn, wwpn, ApplianceConnection + $c.boot = $c.boot | Select-Object -property * -ExcludeProperty bootTargetName, bootTargetLun, initiatorName, initiatorIp, chapName, mutualChapName, chapSecret, mutualChapSecret + + # Handle network unassigned connections + if ($c.networkUri) + { + + switch ($c.networkUri) + { + + {$_.Contains($EthernetNetworksUri)} + { + + if (-not($_AvailableNetworkResources.ethernetNetworks | Where-Object uri -eq $c.networkUri)) + { + + $Message = "The Ethernet network {0} specified in Connection {1} was not found to be provisioned to the provided Enclosure Group, {2}, and SHT, {3}. Please verify that the network is a member of an Uplink Set in the associated Logical Interconnect Group." -f (Send-OVRequest $c.networkUri -Hostname $ApplianceConnection.Name).name, $c.id, $EnclosureGroup.name, $ServerHardwareType.name + + } + + else + { + + "[{0}] {1} is available for Connection {2} in this Server Profile request." -f $MyInvocation.InvocationName.ToString().ToUpper(), $c.networkUri, $c.id | Write-Verbose + + # Add check for iSCsi Initiator Name, to make sure the initiatorName property is set correctly. + + } + + } + + {$_.Contains($NetworkSetsUri)} + { + + if (-not($_AvailableNetworkResources.networkSets | Where-Object uri -eq $c.networkUri)) + { + + $Message = "The network set {0} specified in Connection {1} was not found to be provisioned to the provided Enclosure Group, {2}, and SHT, {3}. Please verify that the network is a member of an Uplink Set in the associated Logical Interconnect Group." -f (Send-OVRequest $c.networkUri -Hostname $ApplianceConnection.Name).name, $c.id, $EnclosureGroup.name, $ServerHardwareType.name + + } + + else + { + + "[{0}] {1} is available for Connection {2} in this Server Profile request." -f $MyInvocation.InvocationName.ToString().ToUpper(), $c.networkUri, $c.id | Write-Verbose + + } + + } + + {$_.Contains($FcNetworksUri)} + { + + if (-not($_AvailableNetworkResources.fcNetworks | Where-Object uri -eq $c.networkUri)) + { + + $Message = "The FC network {0} specified in Connection {1} was not found to be provisioned to the provided Enclosure Group, {2}, and SHT, {3}. Please verify that the network is a member of an Uplink Set in the associated Logical Interconnect Group." -f (Send-OVRequest $c.networkUri -Hostname $ApplianceConnection.Name).name, $c.id, $EnclosureGroup.name, $ServerHardwareType.name + + } + + else + { + + "[{0}] {1} is available for Connection {2} in this Server Profile request." -f $MyInvocation.InvocationName.ToString().ToUpper(), $c.networkUri, $c.id | Write-Verbose + + } + + } + + {$_.Contains($FCoENetworksUri)} + { + + if (-not($_AvailableNetworkResources.fcNetworks | Where-Object uri -eq $c.networkUri)) + { + + $Message = "The FCoE network {0} specified in Connection {1} was not found to be provisioned to the provided Enclosure Group, {2}, and SHT, {3}. Please verify that the network is a member of an Uplink Set in the associated Logical Interconnect Group." -f (Send-OVRequest $c.networkUri -Hostname $ApplianceConnection.Name).name, $c.id, $EnclosureGroup.name, $ServerHardwareType.name + + } + + else + { + + "[{0}] {1} is available for Connection {2} in this SPT." -f $MyInvocation.InvocationName.ToString().ToUpper(), $c.networkUri, $c.id | Write-Verbose + + } + + } + + } + + } + + if ($Message) + { + + $ErrorRecord = New-ErrorRecord HPEOneView.ServerProfileConnectionException NetworkResourceNotProvisioned InvalidArgument 'Connections' -TargetType 'PSObject' -Message $Message + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + if ($null -ne $c.boot -and $c.boot.priority -ne "NotBootable") + { + + "[{0}] Found bootable connection ID: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $c.id | Write-Verbose + + [void]$BootableConnections.Add($c.id) + + } + + [void]$_spt.connectionSettings.connections.Add($c) + + $_c++ + + } + + "[{0}] Server Profile Template Connections to add: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), ($_spt.connectionSettings.connections | Format-List * -force | Out-String) | Write-Verbose + + if (-not $PSBoundParameters['ManageBoot'] -and $BootableConnections.count -gt 0) + { + + $ExceptionMessage = "Bootable Connections {0} were found, however the -ManageBoot switch Parameter was not provided. Please correct your command syntax and try again." -f [String]::Join(', ', $BootableConnections.ToArray()) + $ErrorRecord = New-ErrorRecord HPEOneView.ServerProfileResourceException BootableConnectionsFound InvalidArgument 'manageBoot' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + } + + else + { + + "[{0}] Setting SPT to not track Connections with derived Server Profiles: {1}." -f $MyInvocation.InvocationName.ToString().ToUpper(), (-not [Bool]$ManageConnections.IsPresent) | Write-Verbose + + $_spt.connectionSettings.manageConnections = $ManageConnections.IsPresent + + } + + # Check to make sure Server Hardware Type supports Firmware Management (OneView supported G7 blade would not support this feature) + if ($PSBoundParameters['Firmware']) + { + + if ($PSBoundParameters['FirmwareConsistencyChecking']) + { + + $_spt.firmware.complianceControl = $ConsistencyCheckingEnum.$FirmwareConsistencyChecking + + } + + "[{0}] Firmware Baseline: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Baseline | Write-Verbose + + if ([RegEx]::Match($ServerHardwareType.capabilities, "firmwareUpdate", $RegExInsensitiveFlag).Success) + { + + "[{0}] SHT is capable of firmware management" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_spt.firmware.manageFirmware = [Bool]$firmware + $_spt.firmware.forceInstallFirmware = [Bool]$forceInstallFirmware + + # This policy setting is only supported with Gen10 and newer platforms + if ([enum]::IsDefined([FirmwarePolicyGenerationSupportEnum], $serverHardwareType.generation.Replace(" ", $null))) + { + + $_spt.firmware.installationPolicy = $FirmwareInstallationPolicy + + } + + else + { + + $ExceptionMessage = "Baseline installation policy is only available with Gen10 and newer platforms. It is not supported with '{0}'." -f $serverHardwareType.generation + $ErrorRecord = New-ErrorRecord HPEOneView.ServerProfileTemplateResourceException InvalidFirmwareInstallPolicy InvalidArgument 'FirmwareInstallationPolicy' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + $_spt.firmware.firmwareInstallType = $ServerProfileFirmwareControlModeEnum[$FirmwareInstallMode] + $_spt.firmware.firmwareActivationType = $ServerProfileFirmareActivationModeEnum[$FirmwareActivationMode] + + if ('FirmwareOffline', 'FirmwareOnlyOfflineMode' -contains $_spt.firmware.firmwareInstallType -and $FirmwareActivationMode -eq 'Scheduled') + { + + $ExceptionMessage = "The specifying of a scheduled firmware installation and performing offline method is not supported. Please choose an online method." + $ErrorRecord = New-ErrorRecord HPEOneView.ServerProfileTemplateResourceException InvalidFirmwareInstallMode InvalidArgument 'FirmwareActivateDateTime' -TargetType 'Switch' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + # Refactor to check if the $Baseline value is a baseline or update object + switch ($Baseline.GetType().FullName) + { + + # Baseline resource from Get-OVBaseline + 'HPEOneView.Appliance.Baseline' + { + + "[{0}] Setting firmware baseline: {1} - {2} - {3}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Baseline.name, $Baseline.version, $Baseline.releaseDate | Write-Verbose + + $_spt.firmware.firmwareBaselineUri = $Baseline.uri + + # If the caller provided the -PatchLevel parameter, generate a non-terminating error it is not supported with the baseline resource provided + if ($PSBoundParameters['PatchLevel']) + { + + $ExceptionMessage = "The provided Baseline '{0}' does not support the PatchLevel parameter." -f $Baseline.name + $ErrorRecord = New-ErrorRecord HPEOneView.Appliance.BaselineResourceException InvalidPatchLevel InvalidArgument 'PatchLevel' -Message $ExceptionMessage + $PSCmdlet.WriteError($ErrorRecord) + + } + + } + + # Bundle Update from Get-OVFirmwareBundleUpdate + 'HPEOneView.Appliance.FirmwareBundleUpdate' + { + + "[{0}] Setting firmware bundle update: {1} - {2} - {3}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Baseline.name, $Baseline.version, $Baseline.releaseDate | Write-Verbose + + # Validate Patch level + if ($PSBoundParameters['PatchLevel']) + { + + "[{0}] Setting firmware patch level: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $PatchLevel | Write-Verbose + + # Check to make sure the requested patch level exists within the firmware update bundle + $FoundPatchLevel = $Baseline.servicePackData.supplements | ? { [version]$_.version -eq $patchlevel } + + if (-not $FoundPatchLevel) + { + + "[{0}] Patch Level '{1}' not found in firmware bundle update '{2}'." -f $MyInvocation.InvocationName.ToString().ToUpper(), $PatchLevel, $Baseline.name | Write-Verbose + + $ExceptionMessage = "The provided Patch Level '{0}' is not found in the firmware bundle update '{1}'." -f $PatchLevel, $Baseline + $ErrorRecord = New-ErrorRecord HPEOneView.ServerHardwareResourceException InvalidPatchLevel InvalidArgument 'PatchLevel' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + $_PatchLevel = "{0:0000}.{1:00}.{2:00}.{3:00}" -f $PatchLevel.Major, $PatchLevel.Minor, $PatchLevel.Build, $PatchLevel.Revision + $_spt.firmware | Add-Member -NotePropertyName patchLevel -NotePropertyValue $_PatchLevel + + $_spt.firmware.firmwareBaselineUri = $Baseline.uri + + } + + } + + 'System.String' + { + + if ($Baseline.StartsWith('/rest') -or $Baseline.EndsWith('.iso')) + { + + $_spt.firmware.firmwareBaselineUri = $Baseline + + } + + else + { + + $ExceptionMessage = "The provided Baseline '{0}' is not a valid Baseline resource." -f $Baseline + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.BaselineResourceException InvalidBaselineResource InvalidArgument 'Baseline' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + # Unknown value and throw error + default + { + + $ExceptionMessage = "The provided Baseline '{0}' is not a valid Baseline resource." -f $Baseline + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.BaselineResourceException InvalidBaselineResource InvalidArgument 'Baseline' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + } + + else + { + + $ErrorRecord = New-ErrorRecord HPEOneView.ServerProfileResourceException ServerHardwareMgmtFeatureNotSupported NotImplemented 'Firmware' -Message "`"$($serverHardwareType.name)`" Server Hardware Type does not support Firmware Management." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + # Check to make sure Server Hardware Type supports Bios Management (OneView supported G7 blade do not support this feature) + if ($PSBoundParameters['Bios']) + { + + if ([RegEx]::Match($serverHardwareType.capabilities, "ManageBIOS", $RegExInsensitiveFlag).Success) + { + + if ($PSBoundParameters['BiosConsistencyChecking']) + { + + $_spt.bios.complianceControl = $ConsistencyCheckingEnum.$BiosConsistencyChecking + + } + + if ($BiosSettings.GetEnumerator().Count -gt 0) + { + + # Check for any duplicate keys + $biosFlag = $false + $hash = @{} + $BiosSettings.id | ForEach-Object { $hash[$_] = $hash[$_] + 1 } + + foreach ($biosItem in ($hash.GetEnumerator() | Where-Object {$_.value -gt 1} | ForEach-Object {$_.key} )) + { + + $ErrorRecord = New-ErrorRecord HPEOneView.ServerProfileResourceException BiosSettingsNotUnique InvalidOperation 'BiosSettings' -TargetType 'Array' -Message "'$(($serverHardwareType.biosSettings | where { $_.id -eq $biosItem }).name)' is being set more than once. Please check your BIOS Settings are unique. This setting might be a depEndency of another BIOS setting/option." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + $_spt.bios.manageBios = $True + $_spt.bios.overriddenSettings = $BiosSettings + + } + + else + { + + $ErrorRecord = New-ErrorRecord HPEOneView.ServerProfileResourceException ServerHardwareMgmtFeatureNotSupported NotImplemented 'New-OVServerProfile' -Message "`"$($serverHardwareType.name)`" Server Hardware Type does not support BIOS Management." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + # Manage Secure Boot settings + if ($PSBoundParameters['SecureBoot']) + { + + if ($SecureBoot -eq 'Disabled') + { + + "[{0}] SecureBoot will be disabled." -f $MyInvocation.InvocationName.ToString().ToUpper(), $__controller.deviceSlot | Write-Verbose + + $_spt.bootMode.secureBoot = $SecureBoot + + } + + # Check to make sure Server Hardware supports SecureBoot + elseif ($ServerHardwareType.capabilities.Contains('SecureBoot') -and $BootMode -eq 'UEFIOptimized') + { + + $_spt.bootMode.secureBoot = $SecureBoot + + } + + # Generate exception if not + elseif ($ServerHardwareType.capabilities.Contains('SecureBoot') -and $BootMode -ne 'UEFIOptimized') + { + + $ExceptionMessage = 'The Server Hardware Type "{0}" supports managing SecureBoot, but BootMode was not set to "UEFIOptimized".' -f $ServerHardwareType.name + $ErrorRecord = New-ErrorRecord HPEOneView.ServerProfileResourceException InvalidBootModeManageValue InvalidArgument 'BootMode' -TargetType 'Bool' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif (-not $ServerHardwareType.capabilities.Contains('SecureBoot') -and $BootMode -eq 'UEFIOptimized') + { + + $ExceptionMessage = 'The Server Hardware Type "{0}" does not support managing SecureBoot.' -f $ServerHardwareType.name + $ErrorRecord = New-ErrorRecord HPEOneView.ServerProfileResourceException InvalidSecureBootManageValue InvalidArgument 'SecureBoot' -TargetType 'Bool' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + # Set Local Storage Management and Check to make sure Server Hardware Type supports it (OneView supported G7 blade would not support this feature) + if (($PSBoundParameters['StorageController']) -and ($ServerHardwareType.capabilities.Contains("ManageLocalStorage"))) + { + + if ($PSBoundParameters['LocalStorageConsistencyChecking']) + { + + $_spt.localStorage.complianceControl = $ConsistencyCheckingEnum.$LocalStorageConsistencyChecking + + } + + # Loop through Controllers provided by user, which should have LogicalDisks attached. + ForEach ($_Controller in $StorageController) + { + + # Copy the object so PowerShell doesn't modify the original object from the caller + $__controller = $_Controller.PSObject.Copy() + + "[{0}] Processing {1} Controller" -f $MyInvocation.InvocationName.ToString().ToUpper(), $__controller.slotNumber | Write-Verbose + + # Check if controll has imporrtConfiguration set to True, which is unsupported with SPT + if ($__controller.importConfiguration) + { + + $Message = "The StorageController configuration contains the -ImportExistingConfiguration option set, which is not supported with Server Profile Templates." + $ErrorRecord = New-ErrorRecord HPEOneView.ServerProfile.LogicalDiskException UnsupportedImportConfigurationSetting InvalidOperation "StorageController" -TargetType 'PSObject' -Message $Message + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + "[{0}] SHT supports Controller RAID mode: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), ($__controller.mode -eq 'RAID' -and ('Mixed','RAID' -notcontains $ServerHardwareType.storageCapabilities.controllerModes)) | Write-Verbose + + # Validate the SHT.storageCapabilities controllerModes -> mode, raidLevels -> logicalDrives.raidLevel and maximumDrives -> numPhysicalDrives + if ($__controller.mode -eq 'RAID' -and ($ServerHardwareType.storageCapabilities.controllerModes -notcontains 'Mixed' -and $ServerHardwareType.storageCapabilities.controllerModes -notcontains 'RAID')) + { + + $_ExceptionMessage = "Unsupported LogicalDisk policy with Virtual Machine Appliance. The requested Controller Mode '{0}' is not supported with the expected Server Hardware Type, which only supports '{1}'" -f $__controller.mode, ([System.String]::Join("', '", $ServerHardwareType.storageCapabilities.controllerModes)) + $ErrorRecord = New-ErrorRecord HPEOneView.ServerProfile.LogicalDiskException UnsupportedImportConfigurationSetting InvalidOperation "StorageController" -TargetType 'PSObject' -Message $_ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + # Controller mode needs to be set to Mixed + elseif ($__controller.mode -eq 'RAID' -and 'Mixed' -eq $ServerHardwareType.storageCapabilities.controllerModes) + { + + $__controller.mode = 'Mixed' + + } + + $_l = 1 + + "[{0}] Storage Controller has {1} LogicalDrives to Process" -f $MyInvocation.InvocationName.ToString().ToUpper(), $__controller.logicalDrives.count | Write-Verbose + + "[{0}] Server Hardware supports '{1}' drives." -f $MyInvocation.InvocationName.ToString().ToUpper(), $ServerHardwareType.storageCapabilities.maximumDrives | Write-Verbose + + $_NewLogicalDisksCollection = [System.Collections.ArrayList]::new() + + # Validate the SHT.storageCapabilities .raidLevels -> logicalDrives.raidLevel and .maximumDrives -> numPhysicalDrives + ForEach ($_ld in $__controller.logicalDrives) + { + + "[{0}] Processing {1} of {2} LogicalDisk: {3}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_l, $__controller.logicalDrives.count, $_ld.name | Write-Verbose + + "[{0}] {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), ($_ld | Out-String) | Write-Verbose + + if ($_ld.PSObject.Properties.Match('SasLogicalJBOD').Count) + { + + "[{0}] Processing SasLogicalJbod {1} (ID:{2}) in Controller {3}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_ld.SasLogicalJBOD.name, $_ld.SasLogicalJbodId, $__controller.deviceSlot | Write-Verbose + + If ($ApplianceConnection.ApplianceType -ne 'Composer') + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.ComposerNodeException InvalidOperation InvalidOperation 'ApplianceConnection' -Message ('The ApplianceConnection {0} is not a Synergy Composer. The LogicalDisk within the StorageController contains a SasLogicalJbod configuration with is only supported with HPE Synergy.' -f $ApplianceConnection.Name) + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + [void]$_spt.localStorage.sasLogicalJBODs.Add($_ld.SasLogicalJBOD) + + # Needed for D3940 RAID drive attachment + if (-not [String]::IsNullOrEmpty($_ld.raidLevel)) + { + + $_ld = $_ld | Select-Object * -ExcludeProperty SasLogicalJBOD + + [Void]$_NewLogicalDisksCollection.Add($_ld) + + } + + } + + else + { + + if ($ServerHardwareType.storageCapabilities.raidLevels -notcontains $_ld.raidLevel) + { + + $_ExceptionMessage = "Unsupported LogicalDisk RAID Level '{0}' policy with '{1}' logical disk. The Server Hardware Type only supports '{2}' RAID level(s). " -f $_ld.raidLevel, $_ld.name, [System.String]::Join("', '", $ServerHardwareType.storageCapabilities.raidLevels) + $ErrorRecord = New-ErrorRecord HPEOneView.ServerProfile.LogicalDiskException UnsupportedLogicalDriveRaidLevel InvalidOperation "StorageController" -TargetType 'PSObject' -Message $_ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + if ($_ld.numPhysicalDrives -gt $ServerHardwareType.storageCapabilities.maximumDrives) + { + + $_ExceptionMessage = "Invalid number of drives requested '{0}'. The Server Hardware Type only supports a maximum of '{1}'." -f $_ld.numPhysicalDrives, $ServerHardwareType.storageCapabilities.maximumDrives + $ErrorRecord = New-ErrorRecord HPEOneView.ServerProfile.LogicalDiskException UnsupportedNumberofDrives InvalidOperation "StorageController" -TargetType 'PSObject' -Message $_ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + $_ld = $_ld | Select-Object * -ExcludeProperty SasLogicalJBOD + + [Void]$_NewLogicalDisksCollection.Add($_ld) + + } + + $_l++ + + } + + $__controller.logicalDrives = $_NewLogicalDisksCollection + + $__controller = $__controller | Select-Object * -Exclude importConfiguration + + [void]$_spt.localStorage.controllers.Add($__controller) + + } + + } + + # StRM Support + if ($PSBoundParameters['SANStorage']) # -and [RegEx]::Match($ServerHardwareType.capabilities, "VCConnections", $RegExInsensitiveFlag).Success) + { + + "[{0}] SAN Storage being requested" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_spt.sanStorage = NewObject -ServerProfileTemplateSanStorage + $_spt.sanStorage.hostOSType = $ServerProfileSanManageOSType[$HostOsType]; + $_spt.sanStorage.manageSanStorage = [Bool]$SANStorage; + + if ($PSBoundParameters['SANStorageConsistencyChecking']) + { + + $_spt.sanStorage.complianceControl = $ConsistencyCheckingEnum.$SANStorageConsistencyChecking + + } + + $_AllNetworkUrisCollection = [System.Collections.ArrayList]::new() + + #Build list of network URI's from connections + ForEach ($_Connection in ($_spt.connectionSettings.connections | Where-Object { -not $_.networkUri.StartsWith($NetworkSetsUri)})) + { + + [void]$_AllNetworkUrisCollection.Add($_Connection.networkUri) + + } + + # Copy the Parameter array into a new object + $_VolumesToAttach = [System.Collections.ArrayList]::new() + + $StorageVolume | ForEach-Object { + + if ($_) + { + + [void]$_VolumesToAttach.Add($_) + + } + + } + + "[{0}] Number of Volumes to Attach: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_VolumesToAttach.Count | Write-Verbose + + $_v = 0 + + foreach ($_Volume in $_VolumesToAttach) + { + + $_VolumeToAdd = $_Volume.PSObject.Copy() + $_v++ + + "[{0}] Processing Volume {1} of {2}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_v, $_VolumesToAttach.Count | Write-Verbose + + $_EphemeralVolProvision = $false + + # Ephemeral Volume Support + if ($null -eq $_VolumeToAdd.volumeUri -and $_VolumeToAdd.volume.properties.storagePool) + { + + "[{0}] Ephemeral volume support. Getting associated storage system from defined storage pool." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_VolumeUri = $_VolumeToAdd.volume.properties.storagePool + + $_uri = "{0}?networks='{1}'&filter=uri='{2}'" -f $ReachableStoragePoolsUri, ([String]::Join(',', $_AllNetworkUrisCollection.ToArray())), $_VolumeUri + $_VolumeName = $_VolumeToAdd.volume.properties.name + + $_EphemeralVolProvision = $true + + Try + { + + $_StoragePool = Send-OVRequest -Uri $_VolumeToAdd.volume.properties.storagePool -appliance $ApplianceConnection + $_AssociatedStorageSystem = Send-OVRequest -Uri $_StoragePool.storageSystemUri -appliance $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + # Provisioned Volume Support + else + { + + Try + { + + $_VolumeObj = Send-OVRequest -uri $_VolumeToAdd.volumeUri -appliance $ApplianceConnection + $_StoragePool = Send-OVRequest -Uri $_VolumeObj.storagePoolUri -appliance $ApplianceConnection + $_AssociatedStorageSystem = Send-OVRequest -Uri $_StoragePool.storageSystemUri -appliance $ApplianceConnection + $_VolumeName = $_VolumeObj.name + + } + + catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $_uri = "{0}?networks='{1}'&filter=name='{2}'" -f $AttachableStorageVolumesUri, ([String]::Join(',', $_AllNetworkUrisCollection.ToArray())), $_VolumeName + $_VolumeUri = $_VolumeToAdd.volumeUri + + } + + "[{0}] Processing Volume ID: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_Volume.id | Write-Verbose + "[{0}] Looking to see if volume/pool '{1} ({2})' is attachable" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_VolumeName, $_VolumeUri |Write-Verbose + + try + { + + $_resp = Send-OVRequest -Uri $_uri -appliance $ApplianceConnection + + } + + catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + # Members found + if ($_resp.count -gt 0) + { + + "[{0}] '{1} ({2})' volume/pool is attachable" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_VolumeName, $_VolumeUri | Write-Verbose + + if (($_VolumeToAdd.id -eq 0) -or (-not($_Volume.id))) + { + + "[{0}] No VolumeID value provided. Getting next volume id value." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $id = 1 + + $Found = $false + + While (-not $Found -and $id -lt 256) + { + + if (-not($_VolumesToAttach | Where-Object id -eq $id)) + { + + "[{0}] Setting Volume ID to: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $id | Write-Verbose + + $_VolumeToAdd.id = $id + + $Found = $true + + } + + $id++ + + } + + } + + # If the storage paths array is null, Process connections to add mapping + if ($_VolumeToAdd.storagePaths.Count -eq 0) + { + + $_VolumeToAdd.storagePaths = [System.Collections.ArrayList]::new() + + "[{0}] Storage Paths value is Null. Building connection mapping." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + # This should only be 1 within members array + foreach ($_member in $_resp.members) + { + + # Not an ephemeral volume, so lets report back connections and how they could map to reachable networks + if (-not $_EphemeralVolProvision) + { + + if ($null -ne $_Member.deviceSpecificAttributes.iqn) + { + + "[{0}] Looking for Ethernet connections." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_StorageTypeUri = $EthernetNetworksUri + + } + + else + { + + "[{0}] Looking for FC/FCoE connections." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_StorageTypeUri = $FcNetworksUri + + } + + # Figure out which connections "should" map based on identified storage connectivity type + [Array]$_ProfileConnections = $_spt.connectionSettings.connections | Where-Object { $_.networkUri.StartsWith($_StorageTypeUri) } + + "[{0}] Number of connections that match the volume connectivity type: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_ProfileConnections.Count | Write-Verbose + + if ($_ProfileConnections.Count -gt 0) + { + + "[{0}] Connections that match the volume connectivity type: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), [String]::Join(', ', [Array]$_ProfileConnections.id) | Write-Verbose + + } + + [Array]$_ReachableNetworkUris = $_Member.reachableNetworks | Where-Object { $_.StartsWith($_StorageTypeUri) } + + "[{0}] Number of reachable networks that match the volume connectivity type: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_ReachableNetworkUris.Count | Write-Verbose + + if ($_ReachableNetworkUris.Count -gt 0) + { + + "[{0}] Reachable networks that match the volume connectivity type: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), [String]::Join(', ', [Array]$_ReachableNetworkUris) | Write-Verbose + + } + + } + + else + { + + [Array]$_ProfileConnections = $_spt.connectionSettings.connections + [Array]$_ReachableNetworkUris = $_Member.reachableNetworks + + } + + ForEach ($_ReachableNetworkUri in $_ReachableNetworkUris) + { + + "[{0}] Processing reachable network URI: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_ReachableNetworkUri | Write-Verbose + + ForEach ($_ProfileConnection in ($_ProfileConnections | Where-Object { $_.networkUri -eq $_ReachableNetworkUri })) + { + + "[{0}] Mapping connectionId '{1}' -> volumeId '{2}'" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_ProfileConnection.id, $_VolumeToAdd.id | Write-Verbose + + $_StoragePath = NewObject -StoragePath + + $_StoragePath.connectionId = $_ProfileConnection.id + $_StoragePath.isEnabled = $True + + if ($_VolumeToAdd.TargetPortAssignmentType) + { + + "[{0}] Getting FC network to get associated SAN." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_StoragePath.targetSelector = 'TargetPorts' + + Try + { + + $_ServerProfileConnectionNetwork = Send-OVRequest -Uri $_ProfileConnection.networkUri -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $_StorageSystemExpectedMappedPorts = $_AssociatedStorageSystem.ports | Where-Object expectedSanUri -eq $_ServerProfileConnectionNetwork.managedSanUri + + ForEach ($_PortID in $_VolumeToAdd.TargetAddresses) + { + + "[{0}] Looking for {1} host port from available storage system." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_PortID | Write-Verbose + + if ($WwnAddressPattern.Match($_PortID).Success) + { + + $_PortType = 'address' + + } + + elseif ($StoreServeTargetPortIDPattern.Match($_PortID).Success) + { + + $_PortType = 'name' + + } + + ForEach ($_HostPort in ($_StorageSystemExpectedMappedPorts | Where-Object $_PortType -match $_PortID)) + { + + "[{0}] Adding {1} ({2}) host port to targets." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_HostPort.address, $_HostPort.name | Write-Verbose + + [void]$_StoragePath.targets.Add(@{name = $_HostPort.address}) + + } + + } + + if ($_StoragePath.targets.Count -eq 0) + { + + $ExceptionMessage = "Unable to find available storage system ports for '{0}' connection to map to '{1}'. Only '{2}' storage system ports map to '{0}'." -f $_ServerProfileConnectionNetwork.name, [String]::Join("', '", $_VolumeToAdd.TargetAddresses), [String]::Join("', '", ($_StorageSystemExpectedMappedPorts | ForEach $_PortType)) + $ErrorRecord = New-ErrorRecord HPEOneView.ServerProfileResourceException InvalidStorageSystemPort InvalidArgument 'StorageVolume' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + else + { + + "[{0}] Attaching '{1}' network URI to storage path." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_ProfileConnection.networkUri | Write-Verbose + + $_StoragePath | Add-Member -NotePropertyName networkUri -NotePropertyValue $_ProfileConnection.networkUri + + } + + [void]$_VolumeToAdd.storagePaths.Add($_StoragePath) + + } + + } + + if ($_VolumeToAdd.storagePaths.Count -eq 0) + { + + Write-Warning ('No available connections were found that could attach to {0} Storage Volume. Storage Volumes may not be attached.' -f $_VolumeName) + + } + + } + + } + + foreach($propertyToRemove in ($_VolumeToAdd.PSObject.Properties | Where { 'TargetPortAssignmentType','TargetAddresses' -contains $_.Name })) + { + + $_VolumeToAdd.PSObject.Properties.Remove('TargetPortAssignmentType') + $_VolumeToAdd.PSObject.Properties.Remove('TargetAddresses') + + } + + [void]$_spt.sanStorage.volumeAttachments.Add($_VolumeToAdd) + + } + + # No members found, generate exception + else + { + + $ExceptionMessage = "'{0}' Volume is not available to be attached to the profile. Please check the volume or available storage pools and try again." -f $_VolumeName + $ErrorRecord = New-ErrorRecord InvalidOperationException StorageVolumeUnavailableForAttach ResourceUnavailable 'StorageVolume' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + } + + # iLO Settings + if ($PSBoundParameters['ManageIloSettings']) + { + + if ([RegEx]::Match($ServerHardwareType.capabilities, "ManageMp", $RegExInsensitiveFlag).Success) + { + + "[{0}] Enabling iLO settings." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if ($PSBoundParameters['IloSettingsConsistencyChecking']) + { + + $_spt.managementProcessor.complianceControl = $ConsistencyCheckingEnum.$IloSettingsConsistencyChecking + + } + + else + { + + $_spt.managementProcessor.complianceControl = $ConsistencyCheckingEnum.Exact + + } + + $_spt.managementProcessor.manageMp = $true + $_spt.managementProcessor.mpSettings = $IloSettings.mpSettings + + } + + else + { + + $ExceptionMessage = "The server hardware type '{0}' does not support managing iLO settings. Only iLO4 and newer systems are supported." -f $ServerHardwareType.name + $ErrorRecord = New-ErrorRecord InvalidOperationException UnsupportedManagmenetProcessor InvalidArgument 'ManageIloSettings' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + "[{0}] Profile JSON Object: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), ($_spt | ConvertTo-Json -depth 99) | Write-Verbose + + if ($PassThru.IsPresent) + { + + $_spt + + } + + else + { + + Try + { + + $resp = Send-OVRequest -uri $ServerProfileTemplatesUri -Method POST -Body $_spt -appliance $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if ($PSBoundParameters['Async']) + { + + $Resp + + } + + else + { + + Try + { + + $Resp | Wait-OVTaskComplete -OutVariable Resp + + if ($Resp.taskState -eq 'Error') + { + + $ExceptionMessage = [String]::Join(" ", $resp.taskErrors.message) + $ErrorRecord = New-ErrorRecord HPEOneView.ServerProfileTemplateResourceException InvalidOperation InvalidOperation 'AsyncronousTask' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +# // TODO: DEVELOP DOCUMENTATION TEST +function Set-OVServerProfileTemplate +{ + + Throw "Not implemented." + +} + +function Join-OVServerProfileToTemplate +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding ()] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline)] + [ValidateNotNullOrEmpty()] + [Alias ("t")] + [object]$Template, + + [Parameter (Mandatory)] + [Alias ("p", 'Profile')] + [object]$ServerProfile, + + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName)] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = $Global:ConnectedSessions + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command agian." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + # If multiple appliance connections check for URI values in the Parameters + If($ApplianceConnection.count -gt 1) + { + + If ($template -is [String] -and $template.startswith('/rest/')) + { + + "[{0}] $template" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $ErrorRecord = New-ErrorRecord HPEOneView.ServerProfileResourceException InvalidTemplateParameter InvalidArgument 'Template' -Message "Template Parameter as URI is not supported with multiple appliance connections." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + If ($ServerProfile -is [String] -and $ServerProfile.startswith('/rest/')) + { + + "[{0}] $ServerProfile" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $ErrorRecord = New-ErrorRecord HPEOneView.ServerProfileResourceException InvalidProfileParameter InvalidArgument 'ServerProfile' -Message "ServerProfile Parameter as URI is not supported with multiple appliance connections." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + $uri = $ServerProfilesUri + + $colStatus = [System.Collections.ArrayList]::new() + + } + + Process + { + + ForEach($_Connection in $ApplianceConnection) + { + + # Process the template Parameter + # Template passed as string + if ($template -is [String]) + { + + # If the URI is passed as set the Template Uri variable. Should not Process if multiple connections identified + if ($template.StartsWith('/rest')) + { + + "[{0}] Template URI: $template" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + $templateUri = $template + + } + + # Otherwise, perform a lookup of the Enclosure Group + else + { + + "[{0}] Template Name: $template" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $templateUri = (Get-OVServerProfileTemplate -Name $template -appliance $ApplianceConnection -ErrorAction Stop).Uri + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + + } + + } + + # Else the template object or template object collection is passed + elseif (($template -is [Object]) -and ($template.category -eq $ResourceCategoryEnum.ServerProfileTemplate)) + { + + "[{0}] Template object provided" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $thisTemplate = $template | Where-Object { $_.ApplianceConnection.name -eq $_Connection.name } + + $templateUri = $thisTemplate.uri + + "[{0}] Enclosure Group Name: $($thisTemplate.name)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + "[{0}] Enclosure Group Uri: $($thisTemplate.uri)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + # Process the profile Parameter + # Profile passed as string + if ($ServerProfile -is [String]) + { + + # If the URI is passed as set the Template Uri variable. Should not Process if multiple connections identified + if ($ServerProfile.StartsWith('/rest')) + { + + "[{0}] Template URI: $ServerProfile" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $thisProfile = Send-OVRequest $ServerProfile -appliance $_Connection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + # Otherwise, perform a lookup of the Enclosure Group + else + { + + "[{0}] Template Name: $ServerProfile" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $thisProfile = Get-OVServerProfile -Name $ServerProfile -appliance $_Connection -ErrorAction Stop + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + # Else the template object or template object collection is passed + elseif (($ServerProfile -is [Object]) -and ($ServerProfile.category -eq $ResourceCategoryEnum.ServerProfile)) + { + + "[{0}] Profile object provided" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $thisProfile = $ServerProfile | Where-Object { $_.ApplianceConnection.name -eq $_Connection.name } + + "[{0}] Enclosure Group Name: $($thisProfile.name)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + "[{0}] Enclosure Group Uri: $($thisProfile.uri)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + if ($thisProfile.ApplianceConnection.name -eq $_Connection.name) + { + + $thisProfile.serverProfileTemplateUri = $templateUri + + Try + { + + $task = Set-OVResource $thisProfile -appliance $_Connection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + [void]$colStatus.Add($task) + + } + + } + + } # End Process Block + + End + { + + return $colStatus + + } + +} + +function Convert-OVServerProfileTemplate +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "Default", SupportsShouldProcess, ConfirmImpact = 'High')] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = "Default")] + [ValidateNotNullOrEmpty()] + [Alias ('ServerProfileTemplate', 'SPT')] + [Object]$InputObject, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [ValidateNotNullOrEmpty()] + [Object]$ServerHardwareType, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Object]$EnclosureGroup, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Switch]$Async, + + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = "Default")] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not($PSBoundParameters['InputObject'])) + { + + $PipelineInput = $True + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $_taskCollection = [System.Collections.ArrayList]::new() + + } + + Process + { + + $_TransformType = [System.Collections.ArrayList]::new() + + $_ServerHardwareTypeUri = $null + $_EnclosureGroupUri = $null + + # Process InputObject + if ($InputObject.category -ne $ResourceCategoryEnum.ServerProfileTemplate) + { + + # Throw exception + $ExceptionMessage = 'The provided object {0} is not supported. Only Server Profile Template is supported.' -f $InputObject.name + $ErrorRecord = New-ErrorRecord HPEOneView.InputObjectResourceException InvalidInputObjectResource InvalidArgument "InputObject" -TargetType 'PSObject' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + # Process SHT + if ($PSBoundParameters['ServerHardwareType'] -and $ServerHardwareType.category -ne $ResourceCategoryEnum.ServerHardwareType) + { + + # Throw exception + $ExceptionMessage = 'The provided object {0} is not supported. Only Server Hardware Type is supported.' -f $ServerHardwareType.name + $ErrorRecord = New-ErrorRecord HPEOneView.ServerHardwareTypeResourceException InvalidServerHardwareTypeResource InvalidArgument "ServerHardwareType" -TargetType 'PSObject' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($PSBoundParameters['ServerHardwareType']) + { + + $_ServerHardwareTypeUri = $ServerHardwareType.uri + + [void]$_TransformType.Add('server hardware type') + + } + + elseif (-not $PSBoundParameters['ServerHardwareType']) + { + + $_ServerHardwareTypeUri = $InputObject.serverHardwareTypeUri + + [void]$_TransformType.Add('server hardware type') + + } + + # Process EG + if ($PSBoundParameters['EnclosureGroup'] -and $EnclosureGroup.category -ne $ResourceCategoryEnum.EnclosureGroup) + { + + # Throw exception + $ExceptionMessage = 'The provided object {0} is not supported. Only Enclosure Group is supported.' -f $EnclosureGroup.name + $ErrorRecord = New-ErrorRecord HPEOneView.EnclosureGroupResourceException InvalidEnclosureGroupResource InvalidArgument "EnclosureGroup" -TargetType 'PSObject' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + # Allow transformation of a Server Profile Template designed for DL/ML/Apollo to BL/WS + elseif (($PSBoundParameters['EnclosureGroup'] -and $null -ne $InputObject.enclosureGroupUri) -or + ($PSBoundParameters['EnclosureGroup'] -and [RegEx]::Match($ServerHardwareType.model, 'BL|WS|SY', $RegExInsensitiveFlag).Success)) + { + + $_EnclosureGroupUri = $EnclosureGroup.uri + + [void]$_TransformType.Add('enclosure group') + + } + + elseif (-not $PSBoundParameters['EnclosureGroup'] -and $null -ne $InputObject.enclosureGroupUri) + { + + $_EnclosureGroupUri = $InputObject.enclosureGroupUri + + [void]$_TransformType.Add('enclosure group') + + } + + elseif ($PSBoundParameters['EnclosureGroup'] -and $null -eq $InputObject.enclosureGroupUri) + { + + $ExceptionMessage = 'The provided Server Profile Template object {0} is likely a DL/ML/Apollo resource and does not support Enclosure Group objects.' -f $InputObject.name + $ErrorRecord = New-ErrorRecord HPEOneView.EnclosureGroupResourceException InvalidEnclosureGroupResource InvalidOperation "EnclosureGroup" -TargetType 'PSObject' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + # Build final transformation URI + $_Uri = '{0}/transformation?serverHardwareTypeUri={1}&enclosureGroupUri={2}' -f $InputObject.uri, $_ServerHardwareTypeUri, $_EnclosureGroupUri + + Try + { + + $_TransformedServerProfileTemplate = Send-OVRequest -Uri $_Uri -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + # Show changes preview here. + ForEach ($_previewChange in $_TransformedServerProfileTemplate.changes.GetEnumerator()) + { + + [HPEOneView.ServerProfile.TransformPreview]::new($_previewChange) + + } + + $_ShouldProcessMessage = 'transform the server profile template to new {0}' -f [String]::Join(' and ', $_TransformType.ToArray()) + + if ($PSCmdlet.ShouldProcess($InputObject.Name, $_ShouldProcessMessage)) + { + + # Saving results back to appliance + Try + { + + $_TransformedServerProfileTemplateResults = Send-OVRequest -Uri $InputObject.uri -Method PUT -Body $_TransformedServerProfileTemplate.serverProfileTemplate -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if (-not $PSBoundParameters['Async']) + { + + $_TransformedServerProfileTemplateResults | Wait-OVTaskComplete + + } + + else + { + + $_TransformedServerProfileTemplateResults + + } + + } + + } + + End + { + + '[{0}] Done.' -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function ConvertTo-OVServerProfileTemplate +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding ()] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline)] + [ValidateNotNullOrEmpty()] + [Alias ("source",'ServerProfile')] + [Object]$InputObject, + + [Parameter (Mandatory = $False)] + [String]$Name, + + [Parameter (Mandatory = $False)] + [String]$Description, + + [Parameter (Mandatory = $False)] + [Switch]$Async, + + [Parameter (Mandatory = $False, ValueFromPipelineByPropertyName)] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($PSBoundParameters['InputObject'])) + { + + $PipelineInput = $True + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command agian." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $_connection -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + } + + Process + { + + # Process Pipeline Input here + if ($InputObject -is [PSCustomObject]) + { + + "[{0}] Received Server Profile object: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject.name | Write-Verbose + + $_ProfileToConvert = $InputObject.PSObject.Copy() + $_SourceName = $InputObject.name.Clone() + + } + + # Process everything else + else + { + + "[{0}] Received Server Profile name: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject.name | Write-Verbose + + Try + { + + $_ProfileToConvert = Get-OVServerProfile -Name $InputObject -ErrorAction Stop + $_SourceName = $InputObject.Clone() + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + # Generate SPT from API + try + { + + $_ConvertedSPT = NewObject -FromServerProfile + + $_ConvertedSPT.serverProfileUri = $_ProfileToConvert.uri + + if ($PSBoundParameters['Name']) + { + + $_ConvertedSPT.name = $Name + + } + + else + { + + $_ConvertedSPT.name = "Temporary Name - {0}" -f $_SourceName + + } + + if ($PSBoundParameters['Description']) + { + + $_ConvertedSPT.description = $Description + + } + + else + { + + $_ConvertedSPT.description = "Created from '{0}' source Server Profile." -f $_SourceName + + } + + $_result = Send-OVRequest -Uri $ConvertProfileToTemplateUri -Method POST -Body $_ConvertedSPT -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if (-not $PSBoundParameters['Async']) + { + + $_result | Wait-OVTaskComplete + + } + + else + { + + $_result + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Remove-OVServerProfileTemplate +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdLetBinding (DefaultParameterSetName = "default", SupportsShouldProcess, ConfirmImpact = 'High')] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = "default")] + [ValidateNotNullOrEmpty()] + [Alias ('spt','name', 'ServerProfileTemplate')] + [Object]$InputObject, + + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = "default")] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default), + + [Parameter (Mandatory = $false, ParameterSetName = "default")] + [Switch]$Force + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not($PSBoundParameters['InputObject'])) + { + + $PipelineInput = $true + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command agian." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + if ($ApplianceConnection.count -gt 1) + { + + # Check for appliance specific URI Parameters and error if more than one appliance connection supplied + if (($ServerProfileTemplate -is [String]) -and ($ServerProfileTemplate.StartsWith($ServerProfileTemplatessUri))) + { + + "[{0}] SourceName is a Server Profile Template URI: $($ServerProfileTemplate)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $ErrorRecord = New-ErrorRecord ArgumentNullException ParametersNotSpecified InvalidArgument 'ServerProfileTemplate' -Message "The input Parameter 'ServerProfileTemplate' is a resource URI. For multiple appliance connections this is not supported." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + } + + if (($ServerProfileTemplate -is [array]) -and ($ServerProfileTemplate.getvalue(0).gettype() -is [String]) -and [RegEx]::Match($ServerProfileTemplate, '/rest/', $RegExInsensitiveFlag).Success) + { + + "[{0}] Assign is a Server Profile URI: $($ServerProfileTemplate)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + $ErrorRecord = New-ErrorRecord ArgumentNullException ParametersNotSpecified InvalidArgument 'ServerProfileTemplate' -Message "The input Parameter 'ServerProfileTemplate' is a resource URI. For multiple appliance connections this is not supported." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + } + + Process + { + + "[{0}] Profile input type: $($InputObject.gettype())" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + foreach ($_spt in $InputObject) + { + + if ($_spt -is [String] -and (-not($_spt.StartsWith.($ServerProfileTemplatessUri)))) + { + + Try + { + + $_spt = Get-OVServerProfileTemplate -Name $_spt -ApplianceConnection $ApplianceConnection -ErrorAction Stop + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + elseif ($_spt -is [String]) + { + + Try + { + + $_spt = Send-OVRequest -Uri $_spt -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + elseif ($_spt -is [PSCustomObject] -and $_spt.category -ine $ResourceCategoryEnum.ServerProfileTemplate) + { + + $ErrorRecord = New-ErrorRecord InvalidOperationException InvalidArgumentValue InvalidArgument 'ServerProfileTemplate' -Message ("Invalid profile template object provided: {0}. Please verify the object and try again." -f $_spt.name ) + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + if ($PSCmdlet.ShouldProcess($ApplianceConnection.Name,("remove Server Profile Template {0} from appliance?" -f $_spt.name ))) + { + + $uri = $_spt.uri + + if ($PSBoundParameters['Force']) + { + + $uri += '?force=true' + + } + + Try + { + + Send-OVRequest -uri $uri -method DELETE -AddHeader @{'If-Match' = $_spt.eTag } -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + elseif ($PSBoundParameters['Whatif']) + { + + "[{0}] -WhatIf provided." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + else + { + + "[{0}] User cancelled." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Get-OVServerProfileConnectionList +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding ()] + Param + ( + [Parameter (Mandatory = $false)] + [ValidateNotNullOrEmpty()] + [String]$Name, + + [Parameter (Mandatory = $false)] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command agian." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $allConnections = [System.Collections.ArrayList]::new() + + } + + Process + { + + ForEach($_Connection in $ApplianceConnection) + { + + $profiles = [System.Collections.ArrayList]::new() + + # Get profiles + if ($Name) + { + + $uri = "{0}?filter=name='{1}'" -f $ServerProfilesUri, $Name + + Try + { + + $profile = (Send-OVRequest $uri -appliance $_Connection).members + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if (-not ($profile)) + { + + $ErrorRecord = New-ErrorRecord InvalidOperationException ProfileResourceNotFound ObjectNotFound 'Name' -Message "Server Profile '$name' was not found." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + [void]$profiles.Add($profile) + + } + + else + { + + Try + { + + $index = Send-OVRequest -Uri $ServerProfileIndexListUri -appliance $_Connection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if ($index.count -eq 0) + { + + $ErrorRecord = New-ErrorRecord InvalidOperationException ProfileResourceNotFound ObjectNotFound 'Get-OVServerProfileConnectionList' -Message "No Server Profile resources found. Use New-OVServerProfile to create one." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + foreach ($entry in $index.members) + { + + Try + { + + $profile = Send-OVRequest $entry.uri -appliance $_Connection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + [void]$profiles.Add($profile) + + } + + } + + # Parse connections + foreach($p in $profiles) + { + + foreach($c in $p.connectionSettings.connections) + { + + Try + { + + $c | add-member -membertype noteproperty -name cid -value $c.id; + $c | add-member -membertype noteproperty -name serverProfile -value $p.name; + + # Handle unassigned network connections correctly, as the networkUri property will be null. + if ([String]::IsNullOrEmpty($c.networkUri)) + { + + $c | add-member -membertype NoteProperty -name Network -value "Unassigned" + + } + + else + { + + $c | add-member -membertype NoteProperty -name Network -value (Send-OVRequest $c.networkUri -appliance $_Connection).Name + + } + + $c | Add-Member -NotePropertyName Appliance -NotePropertyValue $_Connection.name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if($c.boot.targets) + { + + $c | add-member -membertype noteproperty -name arrayTarget -value $c.boot.targets[0].arrayWwpn + $c | add-member -membertype noteproperty -name lun -value $c.boot.targets[0].lun + + } + + elseif ($c.boot.iscsi) + { + + $c | add-member -membertype noteproperty -name arrayTarget -value ([System.Collections.ArrayList]::new()) + + if (-not [String]::IsNullOrEmpty($c.boot.iscsi.firstBootTargetIp)) + { + + [void]$c.arrayTarget.Add($c.boot.iscsi.firstBootTargetIp) + + } + + if (-not [String]::IsNullOrEmpty($c.boot.iscsi.secondBootTargetIp)) + { + + [void]$c.arrayTarget.Add($c.boot.iscsi.secondBootTargetIp) + + } + + $c | add-member -membertype noteproperty -name lun -value ("{0}:{1}" -f $c.boot.iscsi.bootTargetName, $c.boot.iscsi.bootTargetLun) + + } + + if ($c.portId) + { + + $c.portId = $c.portId.Replace("Flexible", "") + + } + + else + { + + $name = "Dev:" + $c.deviceNumber + '-' + $c.physicalPortNumber + + $c | add-member -membertype noteproperty -name portId -value $name + + } + + if($c.boot) { $c.boot = $c.boot.priority; } + + $c.PSObject.TypeNames.Insert(0, "HPEOneView.ServerProfile.ConnectionList") + + [void]$allConnections.Add($c) + + } + + } + + + } + + } + + End + { + + $allConnections | Sort-Object serverProfile, cid + + } + +} + +function New-OVServerProfileConnection +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdLetBinding (DefaultParameterSetName = "Common")] + Param + ( + + [Parameter (Mandatory, ParameterSetName = "Common")] + [Parameter (Mandatory, ParameterSetName = "Ethernet")] + [Parameter (Mandatory, ParameterSetName = "FC")] + [Parameter (Mandatory, ParameterSetName = "ISCSI")] + [ValidateNotNullOrEmpty()] + [Alias ('id')] + [Int]$ConnectionID = 1, + + [Parameter (Mandatory = $false, ParameterSetName = "Common")] + [Parameter (Mandatory = $false, ParameterSetName = "Ethernet")] + [Parameter (Mandatory = $false, ParameterSetName = "FC")] + [Parameter (Mandatory = $false, ParameterSetName = "ISCSI")] + [ValidateNotNullOrEmpty()] + [ValidateSet ("Ethernet", "FibreChannel", "Eth", "FC", 'FCoE', 'iSCSI', IgnoreCase)] + [Alias ('type')] + [String]$ConnectionType = "Ethernet", + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = "Common")] + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = "Ethernet")] + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = "FC")] + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = "ISCSI")] + [ValidateNotNullOrEmpty()] + [object]$Network, + + [Parameter (Mandatory = $false, ParameterSetName = "Common")] + [Parameter (Mandatory = $false, ParameterSetName = "Ethernet")] + [Parameter (Mandatory = $false, ParameterSetName = "FC")] + [Parameter (Mandatory = $false, ParameterSetName = "ISCSI")] + [ValidateNotNullOrEmpty()] + [String]$PortId = "Auto", + + [Parameter (Mandatory = $false, ParameterSetName = "Common")] + [Parameter (Mandatory = $false, ParameterSetName = "Ethernet")] + [Parameter (Mandatory = $false, ParameterSetName = "FC")] + [Parameter (Mandatory = $false, ParameterSetName = "ISCSI")] + [ValidateNotNullOrEmpty()] + [String]$Name, + + [Parameter (Mandatory = $false, ParameterSetName = "Common")] + [Parameter (Mandatory = $false, ParameterSetName = "Ethernet")] + [Parameter (Mandatory = $false, ParameterSetName = "FC")] + [Parameter (Mandatory = $false, ParameterSetName = "ISCSI")] + [ValidateScript( { [String]$_ -eq 'Auto' -or ([Int]$_ -le 50000 -and [Int]$_ -ge 0) })] + [String]$RequestedBW = 2500, + + [Parameter (Mandatory = $false, ParameterSetName = "Common")] + [Parameter (Mandatory = $false, ParameterSetName = "Ethernet")] + [Parameter (Mandatory = $false, ParameterSetName = "FC")] + [Parameter (Mandatory = $false, ParameterSetName = "ISCSI")] + [ValidateNotNullOrEmpty()] + [Switch]$UserDefined, + + [Parameter (Mandatory = $false, ParameterSetName = "Common")] + [Parameter (Mandatory = $false, ParameterSetName = "Ethernet")] + [Parameter (Mandatory = $false, ParameterSetName = "FC")] + [Parameter (Mandatory = $false, ParameterSetName = "ISCSI")] + [ValidateScript({$MacAddressPattern.Match($_).Success})] + [String]$MAC, + + [Parameter (Mandatory = $false, ParameterSetName = "FC")] + [ValidateScript({$WwnAddressPattern.Match($_).Success})] + [String]$WWNN, + + [Parameter (Mandatory = $false, ParameterSetName = "FC")] + [ValidateScript({$WwnAddressPattern.Match($_).Success})] + [String]$WWPN, + + [Parameter (Mandatory = $false, ParameterSetName = "Ethernet")] + [ValidateScript( { [Int]$_ -ge 0 -or [String]$_ -eq 'Auto' } )] + [String]$Virtualfunctions, + + [Parameter (Mandatory = $false, ParameterSetName = "Common")] + [Parameter (Mandatory = $false, ParameterSetName = "Ethernet")] + [Parameter (Mandatory = $false, ParameterSetName = "FC")] + [Parameter (Mandatory = $false, ParameterSetName = "ISCSI")] + [ValidateNotNullOrEmpty()] + [Switch]$Bootable, + + [Parameter (Mandatory = $false, ParameterSetName = "Common")] + [Parameter (Mandatory = $false, ParameterSetName = "Ethernet")] + [Parameter (Mandatory = $false, ParameterSetName = "FC")] + [Parameter (Mandatory = $false, ParameterSetName = "ISCSI")] + [ValidateSet ('LAG1', 'LAG2', 'LAG3', 'LAG4', 'LAG5', 'LAG6', 'LAG7', 'LAG8', 'LAG9', 'LAG10', 'LAG11', 'LAG12', 'LAG13', 'LAG14', 'LAG15', 'LAG16', 'LAG17', 'LAG18', 'LAG19', 'LAG20', 'LAG21', 'LAG22', 'LAG23', 'LAG24')] + [String]$LagName, + + [Parameter (Mandatory = $false, ParameterSetName = "Common")] + [Parameter (Mandatory = $false, ParameterSetName = "FC")] + [Parameter (Mandatory = $false, ParameterSetName = "ISCSI")] + [ValidateSet ('AdapterBIOS', 'ManagedVolume', 'UserDefined', IgnoreCase = $false)] + [String]$BootVolumeSource = 'AdapterBIOS', + + [Parameter (Mandatory = $false, ParameterSetName = "Common")] + [Parameter (Mandatory = $false, ParameterSetName = "Ethernet")] + [Parameter (Mandatory = $false, ParameterSetName = "FC")] + [Parameter (Mandatory = $false, ParameterSetName = "ISCSI")] + [ValidateNotNullOrEmpty()] + [ValidateSet ('NotBootable', 'Primary', 'Secondary', 'IscsiPrimary', 'IscsiSecondary', 'LoadBalanced', IgnoreCase)] + [String]$Priority = "NotBootable", + + [Parameter (Mandatory = $false, ParameterSetName = "FC")] + [Alias ('ArrayWwpn')] + [ValidateScript({$WwnAddressPattern.Match($_).Success})] + [String]$TargetWwpn, + + [Parameter (Mandatory = $false, ParameterSetName = "FC")] + [Parameter (Mandatory = $false, ParameterSetName = "ISCSI")] + [ValidateRange(0,254)] + [Int]$LUN = 0, + + [Parameter (Mandatory = $false, ParameterSetName = "ISCSI")] + [ValidateSet ('DHCP', 'UserDefined', 'SubnetPool', IgnoreCase)] + [String]$IscsiIPv4AddressSource, + + [Parameter (Mandatory = $false, ParameterSetName = "ISCSI")] + [ValidateNotNullOrEmpty()] + [String]$ISCSIInitatorName, + + [Parameter (Mandatory = $false, ParameterSetName = "ISCSI")] + [ValidateNotNullOrEmpty()] + [Net.IPAddress]$IscsiIPv4Address, + + [Parameter (Mandatory = $false, ParameterSetName = "ISCSI")] + [ValidateNotNullOrEmpty()] + [String]$IscsiIPv4SubnetMask, + + [Parameter (Mandatory = $false, ParameterSetName = "ISCSI")] + [ValidateNotNullOrEmpty()] + [Net.IPAddress]$IscsiIPv4Gateway, + + [Parameter (Mandatory = $false, ParameterSetName = "ISCSI")] + [ValidateNotNullOrEmpty()] + [String]$IscsiBootTargetIqn, + + [Parameter (Mandatory = $false, ParameterSetName = "ISCSI")] + [ValidateNotNullOrEmpty()] + [Net.IPAddress]$IscsiPrimaryBootTargetAddress, + + [Parameter (Mandatory = $false, ParameterSetName = "ISCSI")] + [ValidateRange(1,65535)] + [Int]$IscsiPrimaryBootTargetPort = 3260, + + [Parameter (Mandatory = $false, ParameterSetName = "ISCSI")] + [ValidateNotNullOrEmpty()] + [Net.IPAddress]$IscsiSecondaryBootTargetAddress, + + [Parameter (Mandatory = $false, ParameterSetName = "ISCSI")] + [ValidateRange(1,65535)] + [Int]$IscsiSecondaryBootTargetPort = 3260, + + [Parameter (Mandatory = $false, ParameterSetName = "ISCSI")] + [ValidateSet ('None','CHAP','MutualCHAP')] + [String]$IscsiAuthenticationProtocol, + + [Parameter (Mandatory = $false, ParameterSetName = "ISCSI")] + [ValidateNotNullOrEmpty()] + [String]$ChapName, + + [Parameter (Mandatory = $false, ParameterSetName = "ISCSI")] + [ValidateNotNullOrEmpty()] + [SecureString]$ChapSecret, + + [Parameter (Mandatory = $false, ParameterSetName = "ISCSI")] + [ValidateNotNullOrEmpty()] + [String]$MutualChapName, + + [Parameter (Mandatory = $false, ParameterSetName = "ISCSI")] + [ValidateNotNullOrEmpty()] + [SecureString]$MutualChapSecret, + + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = "Common")] + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = "Ethernet")] + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = "FC")] + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = "ISCSI")] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + "[{0}] ParameterSetName: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $PSCmdlet.ParameterSetName | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command agian." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($PSBoundParameters['Network']) + { + + if ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + $Pipeline = $true + + } + + # Validate Boot settings + if (('FC','FibreChannel' -contains $ConnectionType) -and $BootVolumeSource -eq 'UserDefined' -and (-not $TargetWwpn)) + { + + $Message = 'A bootable Fibre Channel connection that is set for "UserDefined" must have the -TargetWwpn Parameter specified.' + $ErrorRecord = New-ErrorRecord HPEOneView.ServerProfileConnectionException NoTargetWwpnParam InvalidArgument 'BootVolumeSource' -Message $Message + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + # Init object collection + $_Connections = [System.Collections.ArrayList]::new() + + } + + Process + { + + if ($Network -ne 'Unassigned') + { + + $ApplianceConnection = $ConnectedSessions | ? Name -eq $Network.ApplianceConnection + + } + + # Also sets connection functionType property + switch ($Network.Gettype().Name) + { + + "PSCustomObject" + { + + if ("fcoe-networks", "fc-networks", "ethernet-networks", "network-sets" -contains $Network.category) + { + + "[{0}] Network resource provided via Parameter" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + "[{0}] Network Name: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Network.name | Write-Verbose + "[{0}] Network Category: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Network.category | Write-Verbose + "[{0}] Creating ConnectionType: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $ConnectionType | Write-Verbose + + switch ($Network.category) + { + + {"ethernet-networks", "network-sets" -contains $_} + { + + if ($ConnectionType -eq 'iSCSI' -or ('IscsiPrimary', 'IscsiSecondary' -contains $Priority) -or $PSCmdlet.ParameterSetName -eq "ISCSI") + { + + $_conn = NewObject -ServerProfileIscsiConnection + + } + + else + { + + $_conn = NewObject -ServerProfileEthernetConnection + + } + + $_conn.requestedMbps = [Int]$requestedBW + + } + + {"fcoe-networks", "fc-networks" -contains $_} + { + + $_conn = NewObject -ServerProfileFCConnection + + $_conn.requestedMbps = $requestedBW + + } + + } + + } + + # Generate Error due to incorrect cagtegory + else + { + + $ExceptionMessage = "The -Network value category '{0}' is not 'ethernet-networks', 'fc-networks' or 'network-sets'. Please check the value and try again." -f $Network.category + $ErrorRecord = New-ErrorRecord HPEOneView.ServerProfileConnectionException InvalidNetworkCategory InvalidArgument 'Network' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + default + { + + if ($Network -ne 'Unassigned') + { + + $ExceptionMessage = "The -Network paramter is an invalid type, {0}. Please supply a network object or object collection." -f $Network.GetType().Name + $ErrorRecord = New-ErrorRecord HPEOneView.ServerProfileConnectionException InvalidNetworkCategory InvalidArgument 'Network' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + else + { + + if (-not $PSBoundParameters['ConnectionType']) + { + + $ExceptionMessage = "The -ConnectionType paramter is required when attempting to create an unassigned network connection." + $ErrorRecord = New-ErrorRecord HPEOneView.ServerProfileConnectionException InvalidConnectionType InvalidArgument 'Network' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + switch ($ConnectionType) + { + + 'iSCSI' + { + + $_conn = NewObject -ServerProfileIscsiConnection + + $_conn.requestedMbps = [Int]$requestedBW + + } + + {"Ethernet", "Eth" -contains $_} + { + + $_conn = NewObject -ServerProfileEthernetConnection + + $_conn.requestedMbps = [Int]$requestedBW + + } + + {"FibreChannel", "FC", 'FCoE' -contains $_} + { + + $_conn = NewObject -ServerProfileFCConnection + + $_conn.requestedMbps = $requestedBW + + } + + } + + } + + } + + } + + $_conn.id = [Int]$connectionId + + if (-not $PSBoundParameters['ConnectionType']) + { + + $_conn.functionType = [String]$ServerProfileConnectionTypeEnum[$Network.category] + + } + + else + { + + $_conn.functionType = [String]$ServerProfileConnectionTypeEnum[$ConnectionType] + + } + + $_conn.name = [String]$name + $_conn.portId = [String]$portId + $_conn.ApplianceConnection = $Network.ApplianceConnection + $_conn.networkUri = $Network.uri + + if ($PSBoundParameters['LagName'] -and $_conn.functionType -eq 'Ethernet' -and $ApplianceConnection.ApplianceType -eq 'Composer') + { + + $_conn.lagName = $LagName + + } + + elseif ($PSBoundParameters['LagName'] -and $ApplianceConnection.ApplianceType -ne 'Composer') + { + + $ExceptionMessage = 'The ApplianceConnection {0} is not a Synergy Composer. The LagName is only supported with HPE Synergy.' -f $ApplianceConnection.Name + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.ComposerNodeException InvalidOperation InvalidOperation 'ApplianceConnection' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($PSBoundParameters['LagName']) + { + + $ExceptionMessage = "The -Network value category '{0}' does not support LAG configuration. The LagName parameter is only supported with Ethernet connections." -f $Network.category + $ErrorRecord = New-ErrorRecord HPEOneView.ServerProfileConnectionException InvalidLagConfiguration InvalidArgument 'Network' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + # Set conneciton boot settings + if ($PSboundParameters['Bootable']) + { + + if ($Priority -eq 'NotBootable') + { + + $ErrorRecord = New-ErrorRecord HPEOneView.ServerProfileConnectionException InvalidBootPriority InvalidArgument 'Priority' -Message "The Connection is set to be bootable, however no priority value was set. Please provide either 'Primary' or 'Secondary'." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + if ($_conn.functionType -eq 'FibreChannel') + { + + "[{0}] FibreChannel Connection. Processing boot settings." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_conn.boot = NewObject -ServerProfileFcBootableConnection + $_conn.boot.bootVolumeSource = $BootVolumeSource + + If((-not $PSBoundParameters['TargetWwpn']) -and $BootVolumeSource -eq "UserDefined") + { + + $ErrorRecord = New-ErrorRecord HPEOneView.ServerProfileConnectionException InvalidFcBootTargetParameters InvalidArgument 'TargetWwpn' -Message "FC Boot specified, and no array target WWPN is provided." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + if ($PSBoundParameters['TargetWwpn']) + { + + $_conn.boot.bootVolumeSource = 'UserDefined' + + $bootTarget = NewObject -ServerProfileConnectionFcBootTarget + + $bootTarget.arrayWwpn = $TargetWwpn + $bootTarget.lun = $lun.ToString() + + [void]$_conn.boot.targets.Add($bootTarget) + + } + + } + + else + { + + if ($PSCmdlet.ParameterSetName -eq 'ISCSI' -or $ConnectionType -eq 'iSCSI') + { + + # Software iSCSI only supported with Synergy + if ($ConnectionType -eq 'Ethernet' -and $ApplianceConnection.ApplianceType -ne 'Composer') + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.ComposerNodeException InvalidOperation InvalidOperation 'ApplianceConnection' -Message ('The ApplianceConnection {0} is not a Synergy Composer. The LogicalDisk within the StorageController contains a SasLogicalJbod configuration with is only supported with HPE Synergy.' -f $ApplianceConnection.Name) + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + # HW iSCSI Connection + if ($ConnectionType -eq 'ISCSI') + { + + "[{0}] Connection will be HW iSCSI type." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_conn.boot = NewObject -ServerProfileIscsiBootableConnectionWithTargets + + } + + # SW iSCSI Connection + elseif ($ConnectionType -eq 'Ethernet') + { + + "[{0}] Connection will be SW iSCSI type." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_conn.boot = NewObject -ServerProfileEthBootableConnectionWithTargets + $_conn.boot.ethernetBootType = 'iSCSI' + + } + + $_conn.boot.iscsi = NewObject -IscsiBootEntry + # $_conn.ipv4 | Add-Member -NotePropertyName ipv4 -NotePropertyValue (NewObject -IscsiIPv4Configuration) + $_conn.ipv4 = NewObject -IscsiIPv4Configuration + + if ($PSBoundParameters['BootVolumeSource']) + { + + $_conn.boot.bootVolumeSource = $BootVolumeSource + + } + + elseif ($_conn.functionType -eq 'Ethernet') + { + + $_conn.boot.bootVolumeSource = 'UserDefined' + + } + + else + { + + $ExceptionMessage = 'The connection is bootable, but the -BootVolumeSource parameter was not provided. Please specify a BootVOlumeSource value.' + $ErrorRecord = New-ErrorRecord HPEOneView.ServerProfileConnectionException InvalidBootableConnectionParameters InvalidArgument 'Bootable' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + if ($PSBoundParameters['IscsiIPv4AddressSource']) + { + + switch ($IscsiIPv4AddressSource) + { + + 'UserDefined' + { + + "[{0}]Setting iSCSI connection IPv4 settings will be 'UserDefined'" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_conn.ipv4.ipAddressSource = 'UserDefined' + + if ($PSBoundParameters['IscsiIPv4Address'] -or $PSBoundParameters['IscsiIPv4SubnetMask']) + { + + "[{0}]Setting iSCSI connection IPv4 Address: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $IscsiIPv4Address.IPAddressToString | Write-Verbose + "[{0}]Setting iSCSI connection IPv4 Gateway: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $IscsiIPv4Gateway.IPAddressToString | Write-Verbose + + if ($PSBoundParameters['IscsiIPv4SubnetMask'].Length -le 2) + { + + Try + { + + "[{0}] Converting Subnet CIDR Bit value to Subnet Mask Address." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + [Int64]$_Int64Value = ([convert]::ToInt64(('1' * $IscsiIPv4SubnetMask + '0' * (32 - $IscsiIPv4SubnetMask)), 2)) + + [IPAddress]$IscsiIPv4SubnetMask = '{0}.{1}.{2}.{3}' -f ([math]::Truncate($_Int64Value / 16777216)).ToString(), + ([math]::Truncate(($_Int64Value % 16777216) / 65536)).ToString(), + ([math]::Truncate(($_Int64Value % 65536)/256)).ToString(), + ([math]::Truncate($_Int64Value % 256)).ToString() + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $_conn.ipv4.ipAddress = $IscsiIPv4Address.IPAddressToString + $_conn.ipv4.subnetMask = ([IPAddress]$IscsiIPv4SubnetMask).IPAddressToString + $_conn.ipv4.gateway = $IscsiIPv4Gateway.IPAddressToString + + } + + } + + default + { + + if ($IscsiIPv4AddressSource -eq 'SubnetPool' -and $ApplianceConnection.ApplianceType -ne 'Composer') + { + + $ExceptionMessage = 'The ApplianceConnection {0} is not a Synergy Composer. The LogicalDisk within the StorageController contains a SasLogicalJbod configuration with is only supported with HPE Synergy.' -f $ApplianceConnection.Name + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.ComposerNodeException InvalidOperation InvalidOperation 'ApplianceConnection' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + $_conn.ipv4.ipAddressSource = $IscsiIPv4AddressSource + + } + + } + + } + + if ($PSBoundParameters['ISCSIInitatorName']) + { + + $_conn.boot.iscsi.initiatorNameSource = "UserDefined" + $_conn.boot.iscsi.initiatorName = $ISCSIInitatorName + + } + + if ($PSBoundParameters['IscsiAuthenticationProtocol']) + { + + "[{0}] Setting iSCSI auth protocol" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_conn.boot.iscsi.chapLevel = $IscsiAuthenticationProtocol + + switch ($IscsiAuthenticationProtocol) + { + + 'Chap' + { + + "[{0}] CHAP" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_conn.boot.iscsi.chapName = $ChapName + + if ($PSBoundParameters['ChapSecret']) + { + + "[{0}] Setting CHAP secret." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + $_conn.boot.iscsi.chapSecret = [Runtime.InteropServices.Marshal]::PtrToStringBSTR([Runtime.InteropServices.Marshal]::SecureStringToBSTR($ChapSecret)) + + } + + } + + 'MutualChap' + { + + "[{0}] MutualCHAP" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_conn.boot.iscsi.chapName = $ChapName + $_conn.boot.iscsi.mutualChapName = $MutualChapName + + if ($PSBoundParameters['ChapSecret']) + { + + "[{0}] Setting CHAP secret." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_conn.boot.iscsi.chapSecret = [Runtime.InteropServices.Marshal]::PtrToStringBSTR([Runtime.InteropServices.Marshal]::SecureStringToBSTR($ChapSecret)) + + } + + if ($PSBoundParameters['MutualChapSecret']) + { + + "[{0}] Setting MutualCHAP secret." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_conn.boot.iscsi.mutualChapSecret = [Runtime.InteropServices.Marshal]::PtrToStringBSTR([Runtime.InteropServices.Marshal]::SecureStringToBSTR($MutualChapSecret)) + + } + + } + + } + + } + + if ($PSBoundParameters['IscsiPrimaryBootTargetAddress']) + { + + "[{0}] Setting iSCSI Primary boot target: {1}:{2}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $IscsiPrimaryBootTargetAddress.IPAddressToString, $IscsiPrimaryBootTargetPort | Write-Verbose + + $_conn.boot.bootVolumeSource = 'UserDefined' + $_conn.boot.iscsi.firstBootTargetIp = $IscsiPrimaryBootTargetAddress.IPAddressToString + $_conn.boot.iscsi.firstBootTargetPort = $IscsiPrimaryBootTargetPort + + } + + + if ($PSBoundParameters['IscsiSecondaryBootTargetAddress']) + { + + "[{0}] Setting iSCSI Secondary boot target: {1}:{2}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $IscsiSecondaryBootTargetAddress.IPAddressToString, $IscsiSecondaryBootTargetPort | Write-Verbose + + $_conn.boot.iscsi.secondBootTargetIp = $IscsiSecondaryBootTargetAddress.IPAddressToString + $_conn.boot.iscsi.secondBootTargetPort = $IscsiSecondaryBootTargetPort + + } + + "[{0}] Setting iSCSI boot target name: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $IscsiBootTargetIqn | Write-Verbose + "[{0}] Setting iSCSI boot target LUN: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $LUN | Write-Verbose + + $_conn.boot.iscsi.bootTargetName = $IscsiBootTargetIqn + $_conn.boot.iscsi.bootTargetLun = $LUN + + } + + else + { + + "[{0}] Ethernet type Connection. Processing boot settings." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_conn.boot = NewObject -ServerProfileEthBootableConnection + + } + + } + + "[{0}] Connection object boot priority: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $ServerProfileConnectionBootPriorityEnum[$Priority] | Write-Verbose + + $_conn.boot.priority = $ServerProfileConnectionBootPriorityEnum[$Priority] + + } + + if ($PSboundParameters['Virtualfunctions'] -and $_conn.functionType -eq 'Ethernet' -and $PSCmdlet.ParameterSetName -ne 'ISCSI') + { + + $_conn.requestedVFs = $Virtualfunctions + + } + + if ($PSboundParameters['UserDefined']) + { + + if ($_conn.functionType -eq 'Ethernet') + { + + $_conn.macType = "UserDefined" + $_conn.mac = $mac + + } + + if ($_conn.functionType -eq "FibreChannel") + { + + if($PSBoundParameters['mac']) + { + + $_conn.macType = "UserDefined" + $_conn.mac = $mac + + } + + $_conn.wwpnType = "UserDefined" + $_conn.wwnn = $wwnn + $_conn.wwpn = $wwpn + + } + + } + + "[{0}] Connection object: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), ($_conn | ConvertTo-Json) | Write-Verbose + + $_conn + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +# // TODO: DEVELOP DOCUMENTATION TEST +function Add-OVServerProfileConnection +{ + + <# + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = 'Default')] + Param + ( + + # Server Profile resource + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = 'Default')] + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = 'PassThru')] + [ValidateNotNullOrEmpty()] + [Object]$InputObject, + + # Connections to add, from New-OVServerProfileConnection helper Cmdlet + [Parameter (Mandatory, ParameterSetName = 'Default')] + [Parameter (Mandatory, ParameterSetName = 'PassThru')] + [ValidateNotNullOrEmpty()] + [Object]$Connections, + + [Parameter (Mandatory, ParameterSetName = 'PassThru')] + [Switch]$PassThru, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [Switch]$Async, + + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = 'Default'] + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = 'PassThru'] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | ? Default) + + ) + + #> + + + + Throw "Not implemented." + +} + +# // TODO: DEVELOP DOCUMENTATION TEST +function Set-OVServerProfileConnection +{ + + <# + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "ConnectionName")] + Param + ( + + # Server Profile resource + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = "ConnectionName")] + [ValidateNotNullOrEmpty()] + [Object]$InputObject, + + [Parameter (Mandatory, ParameterSetName = "ConnectionName")] + [ValidateNotNullOrEmpty()] + [String]$ConnectionName, + + [Parameter (Mandatory, ParameterSetName = "ConnectionID")] + [ValidateNotNullOrEmpty()] + [Int]$ConnectionID + + # Should contain the simliar parameters from New-OVServerProfileConnection + + [Object]$Network, + + [Int]$TypicalBandwidth, + + [Int]$MaximumBandwidth, + + [Boolean]$Bootable, + + [String]$BootPriority, + + [Parameter (Mandatory, ParameterSetName = 'PassThru')] + [Switch]$PassThru, + + [Parameter (Mandatory = $false)] + [ValidateNotNullOrEmpty()] + [Switch]$Async, + + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName)] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | ? Default) + + ) + + #> + + Throw "Not implemented." + +} + +# // TODO: DEVELOP DOCUMENTATION TEST +function Remove-OVServerProfileConnection +{ + + <# + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "ConnectionName")] + Param + ( + + # Server Profile resource + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = "ConnectionName")] + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = "PassThru")] + [ValidateNotNullOrEmpty()] + [Object]$InputObject, + + [Parameter (Mandatory, ParameterSetName = "ConnectionName")] + [ValidateNotNullOrEmpty()] + [String]$ConnectionName, + + [Parameter (Mandatory, ParameterSetName = "ConnectionID")] + [ValidateNotNullOrEmpty()] + [Int]$ConnectionID + + [Parameter (Mandatory, ParameterSetName = 'PassThru')] + [Switch]$PassThru, + + [Parameter (Mandatory = $false)] + [ValidateNotNullOrEmpty()] + [Switch]$Async, + + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName)] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | ? Default) + + ) + + #> + + Throw "Not implemented." + +} + +function Save-OVServerProfile +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "Default")] + Param + ( + + # Server Profile resource + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = "Default")] + [ValidateNotNullOrEmpty()] + [Object]$InputObject, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [ValidateNotNullOrEmpty()] + [Switch]$Async, + + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = "Default")] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + If (-not $PSBoundParameters['InputObject']) + { + + $PipelineInput = $True + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command agian." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + } + + Process + { + + if ($InputObject.category -ne $ResourceCategoryEnum.ServerProfile) + { + + $ExceptionMessage = 'The provided object {0} is not supported. Only Server Profile are supported resources.' -f $InputObject.name + $ErrorRecord = New-ErrorRecord HPEOneView.InputObjectResourceException InvalidInputObjectResource InvalidArgument "InputObject" -TargetType 'PSObject' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + "[{0}] Attempting to save '{1}' Server Profile resource." -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject.name | Write-Verbose + + $_method = "PUT" + + # If eTag property is null, then this profile needs to be created. + if (-not $InputObject.eTag) + { + + $_method = "POST" + + } + + Try + { + + $Resp = Send-OVRequest -Uri $InputObject.uri -Method $_method -Body $InputObject -Hostname $InputObject.ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + Try + { + + $Resp = $Resp | Wait-OVTaskStart + + if ($Resp.taskState -eq 'Error' -and $Resp.stateReason -eq 'ValidationError') + { + + if ($PSCmdlet.ShouldProcess($InputObject.name, ('The provided server profile generated a validation error: {0}. Do you wish to override and save the Server Profile' -f $Resp.taskErrors.message))) + { + + Try + { + + $_Uri = '{0}?force=all' -f $ServerProfilesUri + + $Resp = Send-OVRequest -Uri $InputObject.uri -Method $_method -Body $InputObject -Hostname $InputObject.ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + else + { + + $ExceptionMessage = ParseForJson -String $resp.taskErrors.message + $ErrorRecord = New-ErrorRecord HPEOneView.ServerProfileResourceException InvalidOperation InvalidOperation 'AsyncronousTask' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if (-not $PSBoundParameters['Async']) + { + + $Resp | Wait-OVTaskComplete + + } + + else + { + + $Resp + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Save-OVServerProfileTemplate +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "Default")] + Param + ( + + # Server Profile resource + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = "Default")] + [ValidateNotNullOrEmpty()] + [Object]$InputObject, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [ValidateNotNullOrEmpty()] + [Switch]$Async, + + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = "Default")] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + If (-not $PSBoundParameters['InputObject']) + { + + $PipelineInput = $True + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command agian." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + } + + Process + { + + if ($InputObject.category -ne $ResourceCategoryEnum.ServerProfileTemplate) + { + + $ExceptionMessage = 'The provided object {0} is not supported. Only Server Profile Template are supported resources.' -f $InputObject.name + $ErrorRecord = New-ErrorRecord HPEOneView.InputObjectResourceException InvalidInputObjectResource InvalidArgument "InputObject" -TargetType 'PSObject' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + "[{0}] Attempting to save '{1}' Server Profile Template resource." -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject.name | Write-Verbose + + $_method = "PUT" + + # If eTag property is null, then this profile needs to be created. + if (-not $InputObject.eTag) + { + + $_method = "POST" + + } + + Try + { + + $_Resp = Send-OVRequest -Uri $InputObject.uri -Method $_method -Body $InputObject -Hostname $InputObject.ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if (-not $PSBoundParameters['Async']) + { + + $_Resp | Wait-OVTaskComplete + + } + + else + { + + $_Resp + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function New-OVServerProfileLogicalDisk +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "Default")] + Param + ( + + [Parameter (Mandatory, ParameterSetName = "Default")] + [Parameter (Mandatory, ParameterSetName = "VolumeDrives")] + [Parameter (Mandatory, ParameterSetName = "SynergyJBOD")] + [ValidateNotNullOrEmpty()] + [String]$Name, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Parameter (Mandatory = $false, ParameterSetName = "VolumeDrives")] + [Parameter (Mandatory = $false, ParameterSetName = "SynergyJBOD")] + [ValidateSet ('RAID0', 'RAID1', 'RAID1ADM', 'RAID10', 'RAID5', 'RAID6', 'NONE')] + [String]$RAID = 'RAID1', + + [Parameter (Mandatory, ParameterSetName = "VolumeDrives")] + [ValidateNotNullOrEmpty()] + [HPEOneView.Servers.PhysicalDrive[]]$Drives, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Parameter (Mandatory = $false, ParameterSetName = "SynergyJBOD")] + [ValidateNotNullOrEmpty()] + [Int]$NumberofDrives = 2, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Parameter (Mandatory = $false, ParameterSetName = "SynergyJBOD")] + [ValidateSet ('SAS', 'SATA', 'SASSSD', 'SATASSD', 'NVMeSas', 'NVMeSata', 'Auto')] + [String]$DriveType = 'Auto', + + [Parameter (Mandatory = $false, ParameterSetName = "SynergyJBOD")] + [ValidateSet ('DriveType', 'SizeAndTechnology')] + [String]$DriveSelectionBy = 'SizeAndTechnology', + + [Parameter (Mandatory = $false, ValueFromPipeline, ParameterSetName = "SynergyJBOD")] + [ValidateNotNullOrEmpty()] + [HPEOneView.Storage.AvailableDriveType]$AvailableDriveType, + + [Parameter (Mandatory = $false , ParameterSetName = "Default")] + [Parameter (Mandatory = $false, ParameterSetName = "SynergyJBOD")] + [ValidateSet ('Internal', 'External')] + [String]$StorageLocation = "External", + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Parameter (Mandatory = $false, ParameterSetName = "VolumeDrives")] + [ValidateSet ('Enabled', 'Disabled', "SsdSmartPath", "Unmanaged")] + [String]$Accelerator = "Unmanaged", + + [Parameter (Mandatory = $false, ParameterSetName = "SynergyJBOD")] + [ValidateNotNullOrEmpty()] + [Int]$MinDriveSize, + + [Parameter (Mandatory = $False, ParameterSetName = "SynergyJBOD")] + [ValidateNotNullOrEmpty()] + [Int]$MaxDriveSize, + + [Parameter (Mandatory = $False, ParameterSetName = "SynergyJBOD")] + [ValidateNotNullOrEmpty()] + [Bool]$EraseDataOnDelete = $false, + + [Parameter (Mandatory = $False, ParameterSetName = "SynergyJBOD")] + [ValidateNotNullOrEmpty()] + [Bool]$Permanent = $false, + + [Parameter (Mandatory = $False, ParameterSetName = "SynergyJBOD")] + [Parameter (Mandatory = $false, ParameterSetName = "VolumeDrives")] + [ValidateNotNullOrEmpty()] + [Switch]$AddSpareDrive, + + [Parameter (Mandatory = $false, ParameterSetName = "VolumeDrives")] + [HPEOneView.Servers.PhysicalDrive[]]$SpareDrives, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Parameter (Mandatory = $false, ParameterSetName = "VolumeDrives")] + [Parameter (Mandatory = $false, ParameterSetName = "SynergyJBOD")] + [ValidateNotNullOrEmpty()] + [Bool]$Bootable, + + [Parameter (Mandatory = $false, ParameterSetName = "VolumeDrives")] + [ValidateSet ('Enabled', 'Disabled', "Unmanaged")] + [String]$ReadCachePolicy, + + [Parameter (Mandatory = $false, ParameterSetName = "VolumeDrives")] + [ValidateSet ('Enabled', 'Disabled', "Unmanaged")] + [String]$WriteCachePolicy, + + [Parameter (Mandatory = $false, ParameterSetName = "VolumeDrives")] + [ValidateSet ('Enabled', 'Disabled', "Unmanaged")] + [String]$IOPerformanceMode + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Helper cmdlet does not require authentication." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + # Init object collection + $_LogicalDiskCol = [System.Collections.ArrayList]::new() + + if ($PSCmdlet.ParameterSetName -eq 'Default' -and $StorageLocation -eq 'External') + { + + $StorageLocation = 'Internal' + + } + + } + + Process + { + + switch ($PSCmdlet.ParameterSetName) + { + + {'Default', 'VolumeDrives' -contains $_ } + { + + $_LogicalDisk = NewObject -ServerProfileLocalStorageLogicalDrive + + $_LogicalDisk.name = $Name + $_LogicalDisk.bootable = [Bool]$Bootable + $_LogicalDisk.raidLevel = $RAID.ToUpper() + + # Perform validation + if ($PSCmdlet.ParameterSetName -eq "Default") + { + + if ($RAID -eq 'RAID1' -and $NumberofDrives -ne 2) + { + + $ExceptionMessage = "The specified RAID Mode 'RAID1' is invalid with more or less than 2 drives. Please correct either the -RAID or -NumberofDrives parameter to the supported value." + $ErrorRecord = New-ErrorRecord HPEOneView.ServerProfile.LogicalDiskException InvalidRaidModeForNumberofDrives InvalidArgument "NumberofDrives" -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($RAID -eq 'RAID1ADM' -and $NumberofDrives -ne 3) + { + + $ExceptionMessage = "The specified RAID Mode 'RAID1ADM' is invalid with more or less than 3 drives. Please correct either the -RAID or -NumberofDrives parameter to the supported value." + $ErrorRecord = New-ErrorRecord HPEOneView.ServerProfile.LogicalDiskException InvalidRaidModeForNumberofDrives InvalidArgument "NumberofDrives" -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + $_LogicalDisk.numPhysicalDrives = $NumberofDrives + $_LogicalDisk.driveTechnology = $LogicalDiskTypeEnum[$DriveType] + + } + + else + { + + $_LogicalDisk | Add-Member -NotePropertyName physicalDrives -NotePropertyValue $null -Force + $_LogicalDisk | Add-Member -NotePropertyName spareDrives -NotePropertyValue $null -Force + $_LogicalDisk | Add-Member -NotePropertyName numSpareDrives -NotePropertyValue $null -Force + + $_LogicalDisk.numPhysicalDrives = $Drives.Count + + switch ($PSBoundParameters.Keys) + { + + 'IOPerformanceMode' + { + + "[{0}] Processing IOPerformanceMode parameter." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_LogicalDisk | Add-Member -NotePropertyName ioPerfModeEnabled -NotePropertyValue $IOPerformanceMode + + if ($IOPerformanceMode -eq "Enabled") + { + + if ($PSBoundParameters['ReadCachePolicy'] -and $ReadCachePolicy -eq "Enabled") + { + + # Throw error -ReadCachePolicy is "Enabled" is incompatible with enabling IOPerformanceMode + $ExceptionMessage = "ReadCachePolicy parameter value is not compatible when IOPerformanceMode is Enabled." + $ErrorRecord = New-ErrorRecord HPEOneView.ServerProfile.LogicalDiskException UnsupportedControllerMode InvalidArgument "ReadCachePolicy" -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + if ($PSBoundParameters['WriteCachePolicy'] -and $ReadCachePolicy -eq "Enabled") + { + + # Throw error -WriteCachePolicy is "Enabled" is incompatible with enabling IOPerformanceMode + $ExceptionMessage = "WriteCachePolicy parameter value is not compatible when IOPerformanceMode is Enabled." + $ErrorRecord = New-ErrorRecord HPEOneView.ServerProfile.LogicalDiskException UnsupportedControllerMode InvalidArgument "WriteCachePolicy" -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + $_LogicalDisk.readCachePolicy = "Disabled" + $_LogicalDisk.writeCachePolicy = "Disabled" + + } + + } + + 'ReadCachePolicy' + { + + "[{0}] Processing ReadCachePolicy parameter." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_LogicalDisk.readCachePolicy = $ReadCachePolicy + + } + + 'WriteCachePolicy' + { + + "[{0}] Processing WriteCachePolicy parameter." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_LogicalDisk.writeCachePolicy = $WriteCachePolicy + + } + + 'Drives' + { + + "[{0}] Processing Drives parameter." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_LogicalDisk.physicalDrives = [System.Collections.Generic.List[String]]::new() + + # Clone the Drives parameter content + $_Drives = [System.Collections.Generic.List[Object]]::new() + $_Drives.AddRange($Drives) + + # Validate the Drives parameter contains the same drive technology + if (($Drives | Select DriveTechnology -Unique).Count -gt 1) + { + + $ExceptionMessage = "The Drives parameter contains different drive technology types: {0}" -f [String]::Join(" ,", ($Drives | Select DriveTechnology -Unique).DriveTechnology) + $ErrorRecord = New-ErrorRecord HPEOneView.ServerProfile.LogicalDiskException MultipleDriveTechnologyTypes InvalidArgument "Drives" -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + $_LogicalDisk.driveTechnology = ($Drives | Select DriveTechnology -Unique).DriveTechnology + + if ([regex]::match($_LogicalDisk.driveTechnology, "Hdd").Success -and $IOPerformanceMode -eq "Enabled") + { + + $ExceptionMessage = "Enabling IOPerformanceMode is only supported with SSD drive technology." + $ErrorRecord = New-ErrorRecord HPEOneView.ServerProfile.LogicalDiskException UnsupportedDriveTechnology InvalidArgument "Drives" -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + if ($PSBoundParameters['SpareDrives']) + { + + $_LogicalDisk.numSpareDrives = $SpareDrives.Count + + $_LogicalDisk.spareDrives = [System.Collections.Generic.List[String]]::new() + + # Need to validate if any spare drive is also in the Drives parameter collection and omit it + ForEach ($spareDrive in $SpareDrives) + { + + "[{0}] Processing spare drive: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $spareDrive | Write-Verbose + + # Check to see if it is allocated + if ($spareDrive.IsAllocated) + { + + $ExceptionMessage = "The '{0}' drive is allocated to another logical disk or is an existing spare." -f $spareDrive + $ErrorRecord = New-ErrorRecord HPEOneView.ServerProfile.LogicalDiskException DriveIsAllocated InvalidArgument "SpareDrives" -TargetType $SpareDrives.GetType().Fullname -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + # Check if the spare drive is of the same drive technology + if ($spareDrive.DriveTechnology -ne $_LogicalDisk.driveTechnology) + { + + $ExceptionMessage = "The '{0}' spare drive technology '{1}' does not match the expected '{2}' drive technology." -f $spareDrive, $spareDrive.DriveTechnology, $_LogicalDisk.driveTechnology + $ErrorRecord = New-ErrorRecord HPEOneView.ServerProfile.LogicalDiskException DriveIsAllocated InvalidArgument "SpareDrives" -TargetType $SpareDrives.GetType().Fullname -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + $duplicateDrive = $null + + if ($duplicateDrive = ([System.Linq.Enumerable]::Where($Drives, [Func[object,bool]]{ param ($_d) return $_d.Location -eq $spareDrive.Location }))) + { + + "[{0}] Spare drive is a member of the Drives parameter. Removing duplicate." -f $MyInvocation.InvocationName.ToString().ToUpper(), $spareDrive | Write-Verbose + + [void]$_Drives.RemoveAt([Array]::IndexOf($Drives.Location, $duplicateDrive.Location)) + + } + + [void]$_LogicalDisk.spareDrives.Add($spareDrive.Location) + + } + + } + + $_LogicalDisk.numPhysicalDrives = $_Drives.Count + + ForEach ($drive in $_Drives) + { + + "[{0}] Processing drive: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $drive | Write-Verbose + + # Check to see if it is allocated + if ($drive.IsAllocated) + { + + $ExceptionMessage = "The '{0}' drive is allocated to another logical disk or is an existing spare." -f $drive + $ErrorRecord = New-ErrorRecord HPEOneView.ServerProfile.LogicalDiskException DriveIsAllocated InvalidArgument "Drives" -TargetType $Drives.GetType().Fullname -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + $_LogicalDisk.physicalDrives.Add($drive.Location) + + } + + } + + } + + } + + if ($PSBoundParameters['Accelerator'] -and $PSCmdlet.ParameterSetName -ne "VolumeDrives") + { + + Switch ($Accelerator) + { + + 'SsdSmartPath' + { + + if ([RegEx]::Match($DriveType, "SSD", $RegExInsensitiveFlag).Success) + { + + $_LogicalDisk.accelerator = "IOBypass" + + } + + else + { + + $ExceptionMessage = "Accelerator parameter value 'SsdSmartPath' is only supported with SSD drives." + $ErrorRecord = New-ErrorRecord HPEOneView.ServerProfile.LogicalDiskException UnsupportedControllerMode InvalidArgument "Accelerator" -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + "Enabled" + { + + $_LogicalDisk.accelerator = "ControllerCache" + + } + + "Disabled" + { + + $_LogicalDisk.accelerator = "None" + + } + + # "Unmanaged" is the default setting from NewObject call + + } + + } + + } + + 'SynergyJBOD' + { + + $_SasLogicalJBOD = NewObject -ServerProfileSasLogicalJBOD + $_LogicalDisk = NewObject -ServerProfileLocalStorageLogicalDrive + + $_SasLogicalJBOD.id = 1; + $_SasLogicalJBOD.name = $Name + $_SasLogicalJBOD.eraseData = $EraseDataOnDelete + + if ($PSBoundParameters['AddSpareDrive']) + { + + $_SasLogicalJBOD.numPhysicalDrives = $NumberofDrives + 1 + + } + + else + { + + $_SasLogicalJBOD.numPhysicalDrives = $NumberofDrives + + } + + $_SasLogicalJBOD.persistent = $Permanent + + if ($AvailableDriveType) + { + + $_SasLogicalJBOD.driveTechnology = $LogicalDiskTypeEnum[$AvailableDriveType.Type] + $_SasLogicalJBOD.driveMinSizeGB = $AvailableDriveType.Capacity + $_SasLogicalJBOD.driveMaxSizeGB = $AvailableDriveType.Capacity + + } + + else + { + + $_SasLogicalJBOD.driveMinSizeGB = $MinDriveSize + $_SasLogicalJBOD.driveMaxSizeGB = if (-not $PSBoundParameters['MaxDriveSize']) { $MinDriveSize } Else { $MaxDriveSize } + $_SasLogicalJBOD.driveTechnology = $LogicalDiskTypeEnum[$DriveType] + + } + + if ($PSBoundParameters['RAID']) + { + + if ($DriveType -eq 'Auto' -and -not $AvailableDriveType -and $StorageLocation -eq 'External') + { + + $ExceptionMessage = "DriveType parameter must not be 'Auto' when configuring an HPE Synergy D3940 LogicalDisk." + $ErrorRecord = New-ErrorRecord HPEOneView.ServerProfile.LogicalDiskException UnsupportedControllerMode InvalidArgument "DriveType" -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + if ($RAID -eq 'RAID1' -and $NumberofDrives -ne 2) + { + + $ExceptionMessage = "The specified RAID Mode 'RAID1' is invalid with more or less than 2 drives. Please correct either the -RAID or -NumberofDrives parameter to the supported value." + $ErrorRecord = New-ErrorRecord HPEOneView.ServerProfile.LogicalDiskException InvalidRaidModeForNumberofDrives InvalidArgument "NumberofDrives" -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($RAID -eq 'RAID1ADM' -and $NumberofDrives -ne 3) + { + + $ExceptionMessage = "The specified RAID Mode 'RAID1ADM' is invalid with more or less than 3 drives. Please correct either the -RAID or -NumberofDrives parameter to the supported value." + $ErrorRecord = New-ErrorRecord HPEOneView.ServerProfile.LogicalDiskException InvalidRaidModeForNumberofDrives InvalidArgument "NumberofDrives" -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + $_LogicalDisk.raidLevel = $RAID.ToUpper() + $_LogicalDisk.sasLogicalJBODId = 1 + $_LogicalDisk.bootable = [Bool]$Bootable + + } + + else + { + + $_LogicalDisk.sasLogicalJBODId = 1 + + } + + $_LogicalDisk | Add-Member -NotePropertyName SasLogicalJBOD -NotePropertyValue $_SasLogicalJBOD -Force + + } + + } + + "[{0}] Created Logical Disk object: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), ($_LogicalDisk | Format-List * | Out-String) | Write-Verbose + + $_LogicalDisk + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function New-OVServerProfileLogicalDiskController +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "Default")] + Param + ( + + [Parameter (Mandatory, ParameterSetName = "SpecifyController")] + [HPEOneView.Servers.StorageController]$InputObject, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Parameter (Mandatory = $false, ParameterSetName = "Import")] + [Parameter (Mandatory = $false, ParameterSetName = "MegaRAID")] + [LogicalDiskControllerEnum]$ControllerID = 'Embedded', + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Parameter (Mandatory = $false, ParameterSetName = "SpecifyController")] + [Parameter (Mandatory = $false, ParameterSetName = "Import")] + [Parameter (Mandatory = $false, ParameterSetName = "MegaRAID")] + [ValidateSet ('HBA','RAID','MIXED')] + [String]$Mode = 'RAID', + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Parameter (Mandatory = $false, ParameterSetName = "SpecifyController")] + [Parameter (Mandatory = $false, ParameterSetName = "MegaRAID")] + [Switch]$Initialize, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Parameter (Mandatory = $false, ParameterSetName = "SpecifyController")] + [Parameter (Mandatory = $false, ParameterSetName = "Import")] + [Parameter (Mandatory = $false, ParameterSetName = "MegaRAID")] + [ValidateSet ('Enabled', 'Disabled', "Unmanaged")] + [String]$WriteCache = "Unmanaged", + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Parameter (Mandatory = $false, ParameterSetName = "SpecifyController")] + [Parameter (Mandatory = $false, ParameterSetName = "Import")] + [ValidateSet ('Enabled', 'Disabled', "Unmanaged")] + [String]$PredictiveSpareActivation = "Unmanaged", + + [Parameter (Mandatory = $false, ParameterSetName = "Import")] + [Parameter (Mandatory = $false, ParameterSetName = "SpecifyController")] + [Parameter (Mandatory = $false, ParameterSetName = "MegaRAID")] + [Switch]$ImportExistingConfiguration, + + [Parameter (Mandatory, ParameterSetName = "MegaRAID")] + [Switch]$MegaRAIDController, + + [Parameter (Mandatory = $false, ParameterSetName = "Default", ValueFromPipeline)] + [Parameter (Mandatory = $false, ParameterSetName = "SpecifyController", ValueFromPipeline)] + [Parameter (Mandatory = $false, ParameterSetName = "MegaRAID", ValueFromPipeline)] + [ValidateNotNullOrEmpty()] + [Object]$LogicalDisk + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Helper cmdlet does not require authentication." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + # Init object collection + $_ServerProfileController = NewObject -ServerProfileLocalStorageController + + if (-not $PSBoundParameters['InputObject']) + { + + $_ServerProfileController.deviceSlot = $LogicalDiskControllerEnumDict[$ControllerID.ToString()] + $_ServerProfileController.mode = $Mode + + if ($PSBoundParameters['MegaRAIDController']) + { + + [String]$_ServerProfileController.family = [ServerProfileControllerFamilyEnum]::MegaRAID.ToString() + + } + + } + + else + { + + $_ServerProfileController.deviceSlot = $InputObject.DeviceSlot + $_ServerProfileController.family = $InputObject.Family + + if ($InputObject.ControllerMode.Create.Where({ $Mode -eq $_ }).Count -eq 0) + { + + $ExceptionMessage = "The specified controller Mode '{0}' is not supported. The only supported controller modes are: '{1}' ." -f $Mode, [String]::Join("', '", $InputObject.ControllerMode.Create) + $ErrorRecord = New-ErrorRecord HPEOneView.ServerProfile.LogicalDiskException SupportedParameterUse InvalidArgument "ImportExistingConfiguration" -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + else + { + + $_ServerProfileController.mode = $Mode + + } + + } + + $_ServerProfileController.importConfiguration = $ImportExistingConfiguration.IsPresent + $_ServerProfileController.initialize = $Initialize.IsPresent + + if ($PSBoundParameters['WriteCache']) + { + + "[{0}] Setting controller write cache: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $WriteCache | Write-Verbose + + $_ServerProfileController.driveWriteCache = $WriteCache + + } + + if ($PSBoundParameters['PredictiveSpareActivation']) + { + + "[{0}] Setting controller predictive spare activation policy: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $WriteCache | Write-Verbose + + $_ServerProfileController | Add-Member -NotePropertyName predictiveSpareRebuild -NotePropertyValue $PredictiveSpareActivation + + } + + $_id = 1 + + } + + Process + { + + if ($PSBoundParameters['ImportExistingConfiguration'] -and $PSBoundParameters['LogicalDisk']) + { + + $ExceptionMessage = "Combining ImportExistingConfiguration and LogicalDisk Parameters is not supported." + $ErrorRecord = New-ErrorRecord HPEOneView.ServerProfile.LogicalDiskException SupportedParameterUse InvalidArgument "ImportExistingConfiguration" -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + "[{0}] Processing LogicalDisks collection" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + ForEach ($_ld in $LogicalDisk) + { + + "[{0}] {1} of {2}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_ld, $LogicalDisk.Count | Write-Verbose + + if ($_ld.SasLogicalJBOD) + { + + if ($_ServerProfileController.deviceSlot -eq 'Embedded') + { + + $ExceptionMessage = "The provided Logical Disks contains a SAS JBOD policy, which is not supported with the 'Embedded' Controller." + $ErrorRecord = New-ErrorRecord HPEOneView.ServerProfile.LogicalDiskException UnsupportedControllerMode InvalidArgument "LogicalDisks" -TargetType 'PSObject' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + $_ld.SasLogicalJBOD.deviceSlot = $_ServerProfileController.deviceSlot + + # Figure out new SasLogicalJBODId + if ($_ServerProfileController.logicalDrives.sasLogicalJbod.id) + { + + while ($_ServerProfileController.logicalDrives.sasLogicalJbod.id -contains $_id) + { + + $_id++ + + } + + } + + $_ld.SasLogicalJBOD.id = $_id + $_ld.sasLogicalJBODId = $_id + + } + + if (($_ld.raidLevel -and $PSBoundParameters['Mode'] -eq 'HBA') -or (-not($_ld.raidLevel) -and $PSBoundParameters['Mode'] -eq 'RAID')) + { + + $ExceptionMessage = "The Controller can only operate in a single mode: RAID or HBA. One or more of the provided LogicalDisks are defined for the opposite mode." + $ErrorRecord = New-ErrorRecord HPEOneView.ServerProfile.LogicalDiskException UnsupportedControllerMode InvalidArgument "Mode" -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + [void]$_ServerProfileController.logicalDrives.Add($_ld) + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Return $_ServerProfileController + + } + +} + +function Get-OVServerHardwareAvailableController +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdLetBinding (DefaultParameterSetName = "Default")] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = "Default")] + [ValidateScript ({ $ResourceCategoryEnum.ServerHardware -contains $_.category })] + [Object]$InputObject, + + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = "Default")] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + If (-not $PSBoundParameters['InputObject']) + { + + $PipelineInput = $True + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command agian." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + } + + Process + { + + $_uri = $AvailableServerHardwareStorageControllersUri -f $InputObject.uri + + # Get the list of available and discovered storage controllers and their inventory, including drives + try + { + + $_AvailableStorageControllers = Send-OVRequest -Uri $_uri -Method GET -Hostname $ApplianceConnection + + } + + catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + # Loop through the members collection + ForEach ($_controller in $_AvailableStorageControllers.members) + { + + $_ControllerModes = [HPEOneView.Servers.ControllerModes]::new($_controller.controllerMode.superSet, $_controller.controllerMode.create) + $_ControllerRAIDModes = [HPEOneView.Servers.RaidModes]::new($_controller.raidLevel.superSet, $_controller.raidLevel.create) + $_ControllerDriveTechnologies = [HPEOneView.Servers.DriveTechnologies]::new($_controller.driveTechnology.superSet, $_controller.driveTechnology.create) + $_ControllerReadCachePolicies = [HPEOneView.Servers.ReadCachePolicy]::new($_controller.readCachePolicy.superSet, $_controller.readCachePolicy.create) + $_ControllerWriteCachePolicies = [HPEOneView.Servers.WriteCachePolicy]::new($_controller.writeCachePolicy.superSet, $_controller.writeCachePolicy.create) + + $_DiscoveredDrives = [System.Collections.Arraylist]::new() + + ForEach ($_drive in $_controller.drives) + { + + $_drive = [HPEOneView.Servers.PhysicalDrive]::new($_drive.location, + $_drive.serialNumber, + $_drive.model, + $_drive.technology, + $_drive.capacity, + $_drive.interfaceSpeedMbps, + $_drive.rotationalSpeedRpm, + $_drive.failurePredicted, + $_drive.lifeRemaining, + $_drive.status, + $_drive.isAllocated, + $_controller.ApplianceConnection) + + [void]$_DiscoveredDrives.Add($_drive) + + } + + [HPEOneView.Servers.StorageController]::new($_controller.deviceSlot, + $_controller.family, + $_controller.deviceType, + $_controller.deviceModel, + $_controller.firmwareVersion, + $_ControllerModes, + $_ControllerRAIDModes, + $_ControllerDriveTechnologies, + $_ControllerReadCachePolicies, + $_ControllerWriteCachePolicies, + $_controller.capabilities, + $_DiscoveredDrives, + $_controller.maximumLogicalDrives, + $_controller.maximumDrives, + $_controller.ApplianceConnection + ) + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function New-OVServerProfileAttachVolume +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdLetBinding (DefaultParameterSetName = "Default")] + Param + ( + + [Parameter (Mandatory, ParameterSetName = "ServerProfileObject")] + [Parameter (Mandatory = $false, ParameterSetName = "ServerProfileObjectEphmeralVol")] + [ValidateScript ({ $ResourceCategoryEnum.ServerProfile,$ResourceCategoryEnum.ServerProfileTemplate -contains $_.category })] + [Object]$ServerProfile, + + [Parameter (Mandatory = $false, ParameterSetName = "ServerProfileObject")] + [Parameter (Mandatory = $false, ParameterSetName = "ServerProfileObjectEphmeralVol")] + [Switch]$PassThru, + + [Parameter (Mandatory = $False, ParameterSetName = "Default")] + [Parameter (Mandatory = $False, ParameterSetName = "ServerProfileObject")] + [Parameter (Mandatory = $False, ParameterSetName = "ServerProfileObjectEphmeralVol")] + [ValidateNotNullOrEmpty()] + [Alias ('id')] + [Int]$VolumeID = 1, + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = "Default")] + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = "ServerProfileObject")] + [ValidateScript({$_ | Where-Object { 'storage-volumes' -contains $_.category}})] + [Array]$Volume, + + [Parameter (Mandatory, ParameterSetName = "ServerProfileObjectEphmeralVol")] + [ValidateNotNullOrEmpty()] + [object]$Name, + + [Parameter (Mandatory = $false, ParameterSetName = "ServerProfileObjectEphmeralVol")] + [ValidateNotNullOrEmpty()] + [object]$VolumeTemplate, + + [Parameter (Mandatory = $false, ParameterSetName = "ServerProfileObjectEphmeralVol")] + [ValidateNotNullOrEmpty()] + [HPEOneView.Storage.StoragePool]$StoragePool, + + [Parameter (Mandatory = $false, ParameterSetName = "ServerProfileObjectEphmeralVol")] + [ValidateNotNullOrEmpty()] + [HPEOneView.Storage.StoragePool]$SnapshotStoragePool, + + [Parameter (Mandatory = $False, ParameterSetName = "ServerProfileObjectEphmeralVol")] + [ValidateNotNullOrEmpty()] + [object]$StorageSystem, + + [Parameter (Mandatory = $False, ParameterSetName = "ServerProfileObjectEphmeralVol")] + [ValidateNotNullOrEmpty()] + [int64]$Capacity, + + [Parameter (Mandatory = $False, ParameterSetName = "ServerProfileObjectEphmeralVol")] + [ValidateSet ('Thin', 'Full', 'ThinDeduplication')] + [String]$ProvisioningType = 'Thin', + + [Parameter (Mandatory = $False, ParameterSetName = "ServerProfileObjectEphmeralVol")] + [Switch]$Full, + + [Parameter (Mandatory = $False, ParameterSetName = "ServerProfileObjectEphmeralVol")] + [Switch]$Permanent, + + [Parameter (Mandatory = $false, ParameterSetName = "ServerProfileObjectEphmeralVol")] + [HPEOneView.Storage.PerformancePolicy]$PerformancePolicy, + + [Parameter (Mandatory = $false, ParameterSetName = "ServerProfileObjectEphmeralVol")] + [Bool]$EnableEncryption, + + [Parameter (Mandatory = $false, ParameterSetName = "ServerProfileObjectEphmeralVol")] + [Bool]$CachePinning, + + [Parameter (Mandatory = $false, ParameterSetName = "ServerProfileObjectEphmeralVol")] + [HPEOneView.Storage.VolumeSet]$VolumeSet, + + [Parameter (Mandatory = $false, ParameterSetName = "ServerProfileObjectEphmeralVol")] + [Bool]$EnableIOPSLimit, + + [Parameter (Mandatory = $false, ParameterSetName = "ServerProfileObjectEphmeralVol")] + [ValidateRange (256,4294967295)] + [Int]$IOPSLimit = 256, + + [Parameter (Mandatory = $false, ParameterSetName = "ServerProfileObjectEphmeralVol")] + [Bool]$EnableDataTransferLimit, + + [Parameter (Mandatory = $false, ParameterSetName = "ServerProfileObjectEphmeralVol")] + [Int]$DataTransferLimit, + + [Parameter (Mandatory = $false, ParameterSetName = "ServerProfileObjectEphmeralVol")] + [HPEOneView.Storage.NimbleFolder]$Folder, + + [Parameter (Mandatory = $False, ParameterSetName = "Default")] + [Parameter (Mandatory = $False, ParameterSetName = "ServerProfileObject")] + [Parameter (Mandatory = $False, ParameterSetName = "ServerProfileObjectEphmeralVol")] + [ValidateSet ("Auto","Manual", IgnoreCase = $true)] + [Alias ('type')] + [String]$LunIdType = "Auto", + + [Parameter (Mandatory = $False, ParameterSetName = "ServerProfileObject")] + [Parameter (Mandatory = $False, ParameterSetName = "ServerProfileObjectEphmeralVol")] + [ValidateRange(0,254)] + [Int]$LunID, + + [Parameter (Mandatory = $false, ParameterSetName = "ServerProfileObject")] + [Parameter (Mandatory = $false, ParameterSetName = "ServerProfileObjectEphmeralVol")] + [ValidateSet ('CitrixXen','CitrixXen7','AIX','IBMVIO','RHEL4','RHEL3','RHEL','RHEV','RHEV7','VMware','Win2k3','Win2k8','Win2k12','Win2k16','Win2k19','OpenVMS','Egenera','Exanet','Solaris9','Solaris10','Solaris11','ONTAP','OEL','HPUX11iv1','HPUX11iv2','HPUX11iv3','SUSE','SUSE9','Inform','Ubuntu', IgnoreCase = $true)] + [Alias ('OS')] + [String]$HostOStype, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Parameter (Mandatory = $false, ParameterSetName = "ServerProfileObject")] + [Parameter (Mandatory = $false, ParameterSetName = "ServerProfileObjectEphmeralVol")] + [Alias ('Bootable')] + [Switch]$BootVolume, + + [Parameter (Mandatory = $False, ParameterSetName = "Default")] + [Parameter (Mandatory = $False, ParameterSetName = "ServerProfileObject")] + [Parameter (Mandatory = $False, ParameterSetName = "ServerProfileObjectEphmeralVol")] + [ValidateSet ('Auto', 'TargetPorts')] + [String]$TargetPortAssignment = 'Auto', + + [Parameter (Mandatory = $False, ParameterSetName = "Default")] + [Parameter (Mandatory = $False, ParameterSetName = "ServerProfileObject")] + [Parameter (Mandatory = $False, ParameterSetName = "ServerProfileObjectEphmeralVol")] + [ValidateNotNullOrEmpty()] + [Alias ('wwpns')] + [Array]$TargetAddresses, + + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = "Default")] + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = "ServerProfileObject")] + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = "ServerProfileObjectEphmeralVol")] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + If (-not($PSBoundParameters['Volume'])) + { + + $PipelineInput = $True + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command agian." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + if ($LunIdType -eq "Manual" -and (-not($PSBoundParameters.ContainsKey("LunId")))) + { + + $ExceptionMessage = "'Manual' LunIdType was specified, but no LUN ID value was provided. Please include the -LunId Parameter or a value in the Parameters position and try again." + $ErrorRecord = New-ErrorRecord ArgumentNullException ParametersNotSpecified InvalidArgument 'LunIdType' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + if ($LunIdType -eq "Auto" -and $PSBoundParameters.ContainsKey("LunId")) + { + + $ExceptionMessage = "'Auto' LunIdType was specified and a specific LUN ID were provided. Please either specify -LunIdType 'Manual' or omit the -LunId Parameter and try again." + $ErrorRecord = New-ErrorRecord ArgumentException ParametersSpecifiedCollision InvalidArgument 'LunIdType' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + if ($PSBoundParameters['Full']) + { + + $ExceptionMessage = 'The -Full parameter is being deprecated. Please update your scripts to use the -ProvisioningType parameter instead.' + $ErrorRecord = New-ErrorRecord HPEOneView.Library.ParameterValidationException InvalidProvisionTypeParameter InvalidOperation 'StorageSystem' -Message $ExceptionMessage + $PSCmdlet.WriteError($ErrorRecord) + + $PSBoundParameters.Add('ProvisioningType', $StorageVolumeProvisioningTypeEnum['Full']) + + } + + if ($PSBoundParameters['ProvisioningType'] -eq 'TPDD') + { + + $ExceptionMessage = 'The -ProvisioningType "TPDD" value is being deprecated. Please update your script(s) to use the "Thin" value and -EnableCompression $True parameter.' + $ErrorRecord = New-ErrorRecord HPEOneView.Library.ParameterValidationException InvalidProvisionTypeParameter InvalidOperation 'StorageSystem' -Message $ExceptionMessage + $PSCmdlet.WriteError($ErrorRecord) + + $ProvisioningType = $StorageVolumeProvisioningTypeEnum['Thin'] + $PSBoundParameters.Add('EnableCompression', $True) + + } + + if ($PSBoundParameters['StorageSystem']) + { + + $ExceptionMessage = "The -StorageSystem is deprecated. Please update your script(s) to use Get-OVStoragePool to get the specific pool object." + $ErrorRecord = New-ErrorRecord HPEOneView.Library.ParameterValidationException InvalidProvisionTypeParameter InvalidOperation 'StorageSystem' -Message $ExceptionMessage + $PSCmdlet.WriteError($ErrorRecord) + + } + + $_AllowedNimbleParams = "PerformancePolicy", "LockPerformancePolicy", "EnableEncryption", "CachePinning", "VolumeSet", "EnableIOPSLimit", "IOPSLimit", "EnableDataTransferLimit", "DataTransferLimit", "Folder" + $_AllowedSSParams = "EnableCompression", "EnableDeduplication", "SnapshotStoragePool" + # $_AllowedSVParams = "DataProtectionLevel", "EnableAdaptiveOptimization" + $_NotAllowedNimbleParams = $_AllowedSSParams #+ $_AllowedSVParams + $_NotAllowedSSParams = $_AllowedNimbleParams #+ $_AllowedSVParams + $_NotAllowedVSParams = $_AllowedSSParams #+ $_AllowedNimbleParams + $_SafeParams = "Name", "Description", "StoragePool", "StorageSystem", "VolumeTemplate", "Capacity", "ProvisioningType", "Full", "Shared", "Scope", "Async", "ApplianceConnection" + + if ($PSBoundParameters['ServerProfile']) + { + + if ($ServerProfile -isnot [PSCustomObject]) + { + + $ExceptionMessage = "The provided Server Profile {0} is not an Object. Please provide a Server Profile object." -f $ServerProfile + $ErrorRecord = New-ErrorRecord HPEOneView.ServerProfileResourceException UnsupportedServerHardwareResource InvalidArgument 'ServerProfile' -TargetType $ServerProfile.GetType().Name -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + # Initialize collection to hold multiple volume attachments objects + $_volumeAttachments = [System.Collections.ArrayList]::new() + + } + + Process + { + + $ExceptionMessageString = "The provided {0} parameter is not supported by the {1} storage family." + + if ($PSBoundParameters['Volume']) + { + + ForEach ($_vol in $Volume) + { + + $_volumeAttachment = NewObject -ServerProfileStorageVolume + + "[{0}] Processing Volume: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), (ConvertTo-Json $_vol -Depth 99) | Write-Verbose + + $_volumeAttachment.volumeUri = $_vol.uri + $_volumeAttachment.volumeStoragePoolUri = $_vol.storagePoolUri + + if ($PSBoundParameters['SnapshotStoragePool']) + { + + $_volumeAttachment | Add-Member -NotePropertyName snapshotPool -NotePropertyValue $SnapshotStoragePool.uri + + } + + $_volumeAttachment.volumeStorageSystemUri = $_vol.storageSystemUri + + if ($PSBoundParameters['VolumeID']) + { + + $_volumeAttachment.id = $VolumeID + + } + + if ($LunIdType -ne 'Auto') + { + + $_volumeAttachment.lunType = $LunIdType + $_volumeAttachment.lun = $LunID + + } + + if ($PSBoundParameters['BootVolume']) + { + + if ($ServerProfile -and ($ServerProfile.sanStorage.volumeAttachments | Where-Object bootVolumePriority -eq 'Primary')) + { + + $_Message = 'The Server Profile already had a Bootable Device, {0}. Please omit the -BootVolume Parameter switch or set the "bootVolumePriority" poperty of the Volume Attachment to "NotBootable".' -f ($ServerProfile.sanStorage.volumeAttachments | Where-Object bootVolumePriority -eq 'Bootable').id + $ErrorRecord = New-ErrorRecord HPEOneView.StorageVolumeResourceException MultipleBootVolumesNotSupported InvalidOperation 'BootVolume' -TargetType 'SwitchParameter' -Message $_Message + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + if (-not ($_volumeAttachments | Where-Object bootVolumePriority -eq 'Primary')) + { + + "[{0}] Setting Volume as Boot Volume: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_vol.volumeName | Write-Verbose + + $_volumeAttachment.bootVolumePriority = 'Primary' + + } + + else + { + + $_ConflictVolume = $Volume | Where-Object uri -contains ($_volumeAttachments | Where-Object bootVolumePriority -eq 'Primary').volumeUri + + $_Message = 'An existing volume is already marked as a Bootable Device, {0}. Multiple Storage Volumes via Pipeline or Parameter input along with -BootVolume Parameter is not supported.' -f $_ConflictVolume.volumeName + $ErrorRecord = New-ErrorRecord HPEOneView.StorageVolumeResourceException MultipleBootVolumesNotSupported InvalidOperation 'BootVolume' -TargetType 'SwitchParameter' -Message $_Message + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + $_volumeAttachment.ApplianceConnection = $_vol.ApplianceConnection + + [void]$_volumeAttachments.Add($_volumeAttachment) + + } + + } + + # Ephmeral Volume Support + else + { + + "[{0}] Creating dynamic volume attach object." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_volumeAttachment = NewObject -EphemeralStorageVolume + + if ($PSBoundParameters['StoragePool']) + { + + switch ($StoragePool.GetType().Name) + { + + "String" + { + + if ($StoragePool.StartsWith($StoragePoolsUri)) + { + + "[{0}] Storage Pool URI provided: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $StoragePool | Write-Verbose + + Try + { + + $_StoragePool = Send-OVRequest $StoragePool -appliance $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + elseif ($StoragePool.StartsWith("/rest/")) + { + + "[{0}] Invalid storage pool URI provided: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $StoragePool | Write-Verbose + + $ErrorRecord = New-ErrorRecord ArgumentException InvalidStoragePoolURI InvalidArgument 'StoragePool' -Message "The provided URI value for the -StoragePool Parameter '$StroagePool' is invalid. The StoragePool URI must Begin with /rest/storage-pools. Please check the value and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + else + { + + if ($StorageSystem) + { + + # If both storagepool and storagesystem were provided, look that up first + Try + { + + $_StoragePool = Get-OVStoragePool -poolName $StoragePool -storageSystem $StorageSystem -appliance $ApplianceConnection -ErrorAction Stop + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + else + { + + Try + { + + # If both storagepool and storagesystem were provided, look that up first + $_StoragePool = Get-OVStoragePool -poolName $StoragePool -appliance $ApplianceConnection -ErrorAction Stop + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if ($_StoragePool -and $_StoragePool.count -gt 1) + { + + # Generate Error that StoragePool name is not unique and must supply the StorageSystem as well. + "[{0}] {1} StoragePool resource found" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $ErrorRecord = New-ErrorRecord HPEOneView.StorageVolumeResourceException MultipleStoragePoolsFound InvalidResult 'New-OVServerProfileAttachVolume' -Message "Multiple StoragePool resources found with the name '$StoragePool'. Please use the -StorageSystem Parameter to specify the Storage System the Storage Pool is to be used." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + } + + } + + 'StoragePool' + { + + $_StoragePool = $StoragePool.PSObject.Copy() + + } + + default + { + + # Validate the object + if ($StoragePool.category -eq $ResourceCategoryEnum.StoragePool) + { + + $_StoragePool = $StoragePool.PSObject.Copy() + + } + + else + { + + $ExceptionMessage = "Invalid -StoragePool Parameter value. Expected Resource Category '{0}', received '{1}'." -f $ResourceCategoryEnum.StoragePool, $VolumeTemplate.category + $ErrorRecord = New-ErrorRecord HPEOneView.StorageVolumeResourceException InvalidStoragePoolCategory InvalidArgument 'StoragePool' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + } + + # Get the associated storage system family + try + { + + "[{0}] Get storage system family associated with the provided Storage Pool." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + $StorageSystem = Send-OVRequest -Uri $_StoragePool.storageSystemUri -Hostname $_StoragePool.ApplianceConnection + + } + + catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + # Get Storage System Root Volume Template + Try + { + + "[{0}] Get storage system root volume template." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_Uri = "{0}/templates?query=isRoot EQ true" -f $_StoragePool.storageSystemUri + $_StorageSystemRootVolumeTemplate = Send-OVRequest -Uri $_Uri -ApplianceConnection $ApplianceConnection + + $VolumeTemplate = $_StorageSystemRootVolumeTemplate.members[0] + $_VolumeTemplateUri = $VolumeTemplate.uri + + "[{0}] Storage System root volume template URI: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $VolumeTemplate.uri | Write-Verbose + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + elseif ($PSBoundParameters['VolumeTemplate']) + { + + if ($VolumeTemplate.category -ne 'storage-volume-templates') + { + + $ExceptionMessage = "The value provided for VolumeTemplate is not the allowed resource type, storage-volume-templates." + $ErrorRecord = New-ErrorRecord HPEOneView.StorageVolumeTemplateResourceException InvalidStorageVolumeTemplateResource InvalidArgument 'VolumeTemplate' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + "[{0}] Storage Volume Template provided: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $VolumeTemplate.name | Write-Verbose + "[{0}] Storage Volume Template family: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $VolumeTemplate.family | Write-Verbose + + $_VolumeTemplateUri = $VolumeTemplate.uri + + Try + { + + "[{0}] Getting Storage Pool from SVT" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + $_StoragePool = Send-OVRequest -Uri $VolumeTemplate.storagePoolUri -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + Try + { + + "[{0}] Getting Storage System from Storage Pool" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $StorageSystem = Send-OVRequest -Uri $_StoragePool.storageSystemUri -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + "[{0}] Setting templateUri: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_VolumeTemplateUri | Write-Verbose + $_volumeAttachment.volume.templateUri = $_VolumeTemplateUri + + # Create properties hashtable specific to the volume template and associated storage system family + ForEach ($_Prop in ($VolumeTemplate.properties.PSObject.Members | Where-Object MemberType -eq 'NoteProperty')) + { + + $_PropName = $_Prop.Name + + "[{0}] Adding volume property to hashtable: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_PropName | Write-Verbose + $_volumeAttachment.volume.properties.Add($_PropName, $VolumeTemplate.properties.$_PropName.default) + + } + + $_Family = $StorageSystem.family + + # Look to see if $PSBoundParameters contains unallowed parameters + ForEach ($_Param in $PSBoundParameters.Keys) + { + + # First check if the param is not within the safe, allowed params for all + if ($_SafeParams -notcontains $_Param) + { + + $ExceptionMessage = $null + + switch ($_Family) + { + + 'Nimble' + { + + # Generate an error that the parameter is not supported by the storage system family + if ($_NotAllowedNimbleParams -contains $_Param) + { + + $ExceptionSource = 'Invalid{0}Parameter' -f $_Param + $ExceptionMessage = $ExceptionMessageString -f $_Param, $_Family + + } + + } + + 'StoreVirtual' + { + + # Generate an error that the parameter is not supported by the storage system family + if ($_NotAllowedVSParams -contains $_Param) + { + + $ExceptionSource = 'Invalid{0}Parameter' -f $_Param + $ExceptionMessage = $ExceptionMessageString -f $_Param, $_Family + + } + + } + + {'3Par', 'StoreServ', 'Primera' -contains $_} + { + + # Generate an error that the parameter is not supported by the storage system family + if ($_NotAllowedSSParams -contains $_Param) + { + + $ExceptionSource = 'Invalid{0}Parameter' -f $_Param + $ExceptionMessage = $ExceptionMessageString -f $_Param, $_Family + + } + + } + + } + + if (-not [String]::IsNullOrEmpty($ExceptionMessage)) + { + + $ErrorRecord = New-ErrorRecord HPEOneView.Library.ParameterValidationException $ExceptionSource InvalidOperation $_Param -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + } + + switch ($_Family) + { + + {'3Par', 'StoreServ', 'Primera' -contains $_} + { + + "[{0}] Will create StoreServe/Primera Ephemeral volume." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + 'Nimble' + { + + "[{0}] Will create Nimble Ephemeral volume." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + } + + switch ($_volumeAttachment.volume.properties.GetEnumerator().Name) + { + + # Common properties + 'name' + { + + "[{0}] Setting volume name: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Name | Write-Verbose + $_volumeAttachment.volume.properties.$_ = $Name + + } + + 'description' + { + + if ($PSBoundParameters['Description']) + { + + "[{0}] Setting volume description: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Description | Write-Verbose + $_volumeAttachment.volume.properties.$_ = $Description + + } + + } + + 'templateVersion' + { + + "[{0}] Setting volume {1}: {2}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_, $VolumeTemplate.version | Write-Verbose + $_volumeAttachment.volume.properties.$_ = $VolumeTemplate.version + + } + + 'storagePool' + { + + # If SVT enforces, set it + if ($VolumeTemplate.properties.$_.meta.locked -or -not $PSBoundParameters['StoragePool']) + { + + "[{0}] Volume Template enforces StoragePool: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $VolumeTemplate.properties.storagePool.default | Write-Verbose + + $_volumeAttachment.volume.properties.$_ = $VolumeTemplate.properties.$_.default + + } + + else + { + + "[{0}] Setting StoragePool: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_StoragePool.uri | Write-Verbose + + $_volumeAttachment.volume.properties.storagePool = $_StoragePool.uri + + } + + } + + 'size' + { + + if ($VolumeTemplate.properties.size.meta.locked -or (-not $PSBoundParameters['Capacity'] -and -not $VolumeTemplate.properties.size.meta.locked)) + { + + "[{0}] Volume Template enforces volume capacity: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $VolumeTemplate.properties.size.default | Write-Verbose + + $_volumeAttachment.volume.properties.size = $VolumeTemplate.properties.size.default + + } + + else + { + + $_volumeAttachment.volume.properties.size = $Capacity * 1GB + + } + + } + + 'provisioningType' + { + + if ($VolumeTemplate.properties.provisioningType.meta.locked -or (-not $PSBoundParameters['Full'] -and -not $PSBoundParameters['ProvisioningType'] -and -not $VolumeTemplate.properties.provisioningType.meta.locked)) + { + + "[{0}] Volume Template enforces volume provisioningType: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $VolumeTemplate.properties.provisioningType.default | Write-Verbose + $_volumeAttachment.volume.properties.provisioningType = $VolumeTemplate.properties.provisioningType.default + + } + + else + { + + if ($PSBoundParameters['ProvisioningType']) + { + + "[{0}] Setting volume provisioningType via ProvisioningType param: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $StorageVolumeProvisioningTypeEnum[$ProvisioningType] | Write-Verbose + + $_volumeAttachment.volume.properties.provisioningType = $StorageVolumeProvisioningTypeEnum[$ProvisioningType] + + } + + else + { + + "[{0}] Setting volume provisioningType via not full param: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $StorageVolumeProvisioningTypeEnum['Thin'] | Write-Verbose + + $_volumeAttachment.volume.properties.provisioningType = $StorageVolumeProvisioningTypeEnum['Thin'] + + } + + } + + } + + 'isShareable' + { + + if ($VolumeTemplate.properties.isShareable.meta.locked -or (-not $PSBoundParameters['Shared'] -and -not $VolumeTemplate.properties.isShareable.meta.locked)) + { + + "[{0}] Volume Template enforces volume shareable state: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $VolumeTemplate.properties.isShareable.default | Write-Verbose + + $_volumeAttachment.volume.properties.isShareable = $VolumeTemplate.properties.isShareable.default + + } + + else + { + + $_volumeAttachment.volume.properties.isShareable = $Shared.IsPresent + + } + + } + + # 3Par specific + 'snapshotPool' + { + + "[{0}] Family is StoreServ, attempting to set snapshot pool" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + # If SVT enforces, set it + if ($VolumeTemplate.properties.snapshotPool.meta.locked) + { + + "[{0}] Volume Template enforces Snapshot StoragePool: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $VolumeTemplate.properties.snapshotPool.default | Write-Verbose + + $_volumeAttachment.volume.properties.snapshotPool = $VolumeTemplate.properties.snapshotPool.default + + } + + else + { + + if ($PSBoundParameters['SnapshotStoragePool']) + { + + if ($SnapshotStoragePool -is [String]) + { + + try + { + + $SnapshotStoragePool = GetStoragePool -Name $SnapshotStoragePool -StorageSystem $StorageSystem -ApplianceConnection $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + "[{0}] Setting SnapshotStoragePool: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $SnapshotStoragePool.uri | Write-Verbose + + $_volumeAttachment.volume.properties.snapshotPool = $SnapshotStoragePool.uri + + } + + elseif (-not $PSBoundParameters['SnapshotStoragePool'] -and -not $PSBoundParameters['StoragePool']) + { + + "[{0}] Setting SnapshotStoragePool to StoragePool from Volume Template: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $VolumeTemplate.properties.snapshotPool.default | Write-Verbose + + $_volumeAttachment.volume.properties.snapshotPool = $VolumeTemplate.properties.snapshotPool.default + + } + + else + { + + "[{0}] Setting SnapshotStoragePool to StoragePool: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_StoragePool.uri | Write-Verbose + + $_volumeAttachment.volume.properties.snapshotPool = $_StoragePool.uri + + } + + } + + } + + {'isDeduplicated', "isDataReductionEnabled" -contains $_} + { + + "[{0}] Family is StoreServ/Primera, attempting to set Deduplicated" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + # If SVT enforces, set it + if ($VolumeTemplate.properties.$_.meta.locked -or $PSBoundParameters.Keys -NotContains 'EnableDeduplication') + { + + "[{0}] Volume Template enforces Deduplicate: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $VolumeTemplate.properties.$_.default | Write-Verbose + + $_volumeAttachment.volume.properties.$_ = $VolumeTemplate.properties.$_.default + + } + + else + { + + "[{0}] Setting Deduplicate: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $EnableDeduplication | Write-Verbose + + $_volumeAttachment.volume.properties.$_ = $EnableDeduplication + + } + + } + + 'isCompressed' + { + + "[{0}] Family is 3Par, attempting to set Compression" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + # If SVT enforces, set it + if ($VolumeTemplate.properties.isCompressed.meta.locked -or -not $PSBoundParameters['EnableCompression']) + { + + "[{0}] Volume Template enforces Compression: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $VolumeTemplate.properties.isCompressed.default | Write-Verbose + + $_volumeAttachment.volume.properties.isCompressed = $VolumeTemplate.properties.isCompressed.default + + } + + else + { + + "[{0}] Setting Deduplication: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $EnableDeduplication | Write-Verbose + + $_volumeAttachment.volume.properties.isCompressed = $EnableDeduplication + + } + + } + + # Nimble specific + 'performancePolicy' + { + + if ($VolumeTemplate.properties.performancePolicy.meta.locked -or (-not $PSBoundParameters['PerformancePolicy'] -and -not $VolumeTemplate.properties.performancePolicy.meta.locked)) + { + + "[{0}] Volume Template enforces performancePolicy state: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $VolumeTemplate.properties.PerformancePolicy.default | Write-Verbose + + $_volumeAttachment.volume.properties.performancePolicy = $VolumeTemplate.properties.performancePolicy.default + + } + + else + { + + $_volumeAttachment.volume.properties.PerformancePolicy = $PerformancePolicy.Id + + } + + } + + 'folder' + { + + if ($VolumeTemplate.properties.folder.meta.locked -or (-not $PSBoundParameters['Folder'] -and -not $VolumeTemplate.properties.folder.meta.locked)) + { + + "[{0}] Volume Template enforces folder state: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $VolumeTemplate.properties.folder.default | Write-Verbose + + $_volumeAttachment.volume.properties.folder = $VolumeTemplate.properties.folder.default + + } + + else + { + + $_volumeAttachment.volume.properties.folder = $Folder.Id + + } + + } + + 'volumeSet' + { + + if ($VolumeTemplate.properties.volumeSet.meta.locked -or (-not $PSBoundParameters['VolumeSet'] -and -not $VolumeTemplate.properties.volumeSet.meta.locked)) + { + + "[{0}] Volume Template enforces volumeSet state: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $VolumeTemplate.properties.volumeSet.default | Write-Verbose + + $_volumeAttachment.volume.properties.volumeSet = $VolumeTemplate.properties.volumeSet.default + + } + + else + { + + $_volumeAttachment.volume.properties.volumeSet = $VolumeSet.Uri + + } + + } + + 'isEncrypted' + { + + if ($VolumeTemplate.properties.$_.meta.locked -or ($PSBoundParameters.Keys -notcontains 'EnableEncryption' -and -not $VolumeTemplate.properties.$_.meta.locked)) + { + + "[{0}] Volume Template enforces isEncrypted state: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $VolumeTemplate.properties.$_.default | Write-Verbose + + $_volumeAttachment.volume.properties.$_ = $VolumeTemplate.properties.$_.default + + } + + else + { + + $_volumeAttachment.volume.properties.$_ = $EnableEncryption + + } + + } + + 'isPinned' + { + + if ($VolumeTemplate.properties.$_.meta.locked -or ($PSBoundParameters.Keys -notcontains 'CachePinning' -and -not $VolumeTemplate.properties.$_.meta.locked)) + { + + "[{0}] Volume Template enforces {1} state: {2}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_, $VolumeTemplate.properties.$_.default | Write-Verbose + + $_volumeAttachment.volume.properties.$_ = $VolumeTemplate.properties.$_.default + + } + + else + { + + $_volumeAttachment.volume.properties.$_ = $CachePinning + + } + + } + + 'iopsLimit' + { + + if ($VolumeTemplate.properties.$_.meta.locked -or ($PSBoundParameters.Keys -notcontains 'EnableIOPSLimit' -and -not $VolumeTemplate.properties.$_.meta.locked)) + { + + "[{0}] Volume Template enforces {1} state: {2}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_, $VolumeTemplate.properties.$_.default | Write-Verbose + + $_volumeAttachment.volume.properties.$_ = $VolumeTemplate.properties.$_.default + + } + + else + { + + $_volumeAttachment.volume.properties.$_ = $IOPSLimit + + } + + } + + 'dataTransferLimit' + { + + if ($VolumeTemplate.properties.$_.meta.locked -or ($PSBoundParameters.Keys -notcontains 'EnableDataTransferLimit' -and -not $VolumeTemplate.properties.$_.meta.locked)) + { + + "[{0}] Volume Template enforces {1} state: {2}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_, $VolumeTemplate.properties.$_.default | Write-Verbose + + $_volumeAttachment.volume.properties.$_ = $VolumeTemplate.properties.$_.default + + } + + else + { + + $_volumeAttachment.volume.properties.$_ = $DataTransferLimit + + } + + } + + } + + + $_volumeAttachment.isPermanent = [Bool]$PSBoundParameters['Permanent'] + + if (-not($PSBoundParameters['VolumeID']) -and $ServerProfile) + { + + "[{0}] No VolumeID value provided. Getting next volume id value." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $id = 1 + + $Found = $false + + While (-not($Found)) + { + + if (-not($ServerProfile.sanStorage.volumeAttachments | Where-Object id -eq $id)) + { + + $VolumeID = $id + + $Found = $true + + } + + $id++ + + } + + } + + $_volumeAttachment.id = $VolumeID + + if ($LunIdType -ne 'Auto') + { + + $_volumeAttachment.lunType = $LunIdType + $_volumeAttachment.lun = $LunID + + } + + if ($PSBoundParameters['BootVolume']) + { + + if (-not($_volumeAttachments | Where-Object bootVolumePriority)) + { + + "[{0}] Setting Volume as Boot Volume: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_volumeAttachment.volumeName | Write-Verbose + + $_volumeAttachment.bootVolumePriority = 'Primary' + + } + + else + { + + $_Message = 'An existing volume is already marked as a Bootable Device, {0}. Multiple Storage Volumes via Pipeline or Parameter input along with -BootVolume Parameter is not supported.' -f [String]::Join(' ', ($_volumeAttachments | Where-Object bootVolumePriority -eq 'Primary').volumeName) + $ErrorRecord = New-ErrorRecord HPEOneView.StorageVolumeResourceException MultipleBootVolumesNotSupported InvalidOperation 'BootVolume' -TargetType 'SwitchParameter' -Message $_Message + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + $_volumeAttachment.ApplianceConnection = $_Connection + + [void]$_volumeAttachments.Add($_volumeAttachment) + + } + + "[{0}] VolumeAttachments Added to collection: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_volumeAttachments.Count | Write-Verbose + + } + + End + { + + # Process server profile object + if ($PSBoundParameters['ServerProfile']) + { + + # Copy the profile object so we don't overwrite the callers copy + $_ServerProfile = $ServerProfile.PSObject.Copy() + + # Validate Server Profile and Server Hardware resource supports StRM operations + Try + { + + "[{0}] Checking SHT for SanStorage operation support" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_SHTResource = Send-OVRequest -uri $_ServerProfile.serverHardwareTypeUri -Hostname $_ServerProfile.ApplianceConnection.Name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + # TODO: This will need to be updated for 5.0 and DL support + if (-not [RegEx]::Match($_SHTResource.model,'BL|WS|SY', [System.Text.RegularExpressions.RegexOptions]::IgnoreCase).Success) + { + + $ExceptionMessage = "The provided Server Profile {0} is not assigned to a supported Server Hardware Type Resource, {1}. Only WS/BL/SY Gen 8/Gen 9 or newer are supported." -f $_ServerProfile.name, $_SHTResource.model + $ErrorRecord = New-ErrorRecord HPEOneView.ServerProfileResourceException UnsupportedServerHardwareResource InvalidArgument 'ServerProfile' -TargetType 'PSObject' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + # Validate Server Profile has SanStorage already set. If not, set it and add the necessary properties. + if (-not $_ServerProfile.sanStorage.manageSanStorage) + { + + "[{0}] Server Profile does not have manageSanStorage property set to True." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + # Generate Error that HostOSType is required + if (-not($PSBoundParameters['HostOsType'])) + { + + $ExceptionMessage = "The -HostOSType parmater is required when the Server Profile is not already configured for managing SAN Storage. Please specify the HostOSType Parameter in your call." + $ErrorRecord = New-ErrorRecord HPEOneView.ServerProfileResourceException MissingHostOSTypeParameterValue InvalidArgument 'ServerProfile' -TargetType 'PSObject' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + $_ServerProfile.sanStorage = [PSCustomObject]@{ + + hostOSType = $ServerProfileSanManageOSType[$HostOsType]; + manageSanStorage = $true; + volumeAttachments = [System.Collections.ArrayList]::new() + + } + + } + + # Rebuild VolumeAttachments property to be an ArrayList + else + { + + if ($_ServerProfile.sanStorage.volumeAttachments.Count -gt 0) + { + + "[{0}] Rebuilding Server Profile Volume Attachment object" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_ExistingVols = $_ServerProfile.sanStorage.volumeAttachments.Clone() + + $_ServerProfile.sanStorage.volumeAttachments = [System.Collections.ArrayList]::new() + + ForEach ($_vol in $_ExistingVols) + { + + if ($_vol.volumeUri -contains $_volumeAttachments.volumeUri) + { + + Try + { + + $_ExistingVolume = Send-OVRequest -Uri $_vol.volumeUri -Hostname $_ServerProfile.ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + [void]$_volumeAttachments.Remove($_) + + $ExceptionMessage = 'Storage Volume {0} is already attached at ID {1}.' -f $_ExistingVolume.name, $_vol.id + $ErrorRecord = New-ErrorRecord HPEOneView.StorageVolumeResourceException StorageVolumeAlreadyAttached ResourceExists 'Volume' -Targettype 'PSObject' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + [void]$_ServerProfile.sanStorage.volumeAttachments.Add($_vol) + + } + + } + + else + { + + $_ServerProfile.sanStorage.volumeAttachments = [System.Collections.ArrayList]::new() + + } + + } + + $_AllNetworkUrisCollection = [System.Collections.ArrayList]::new() + + # Build list of network URI's from connections + ForEach ($_Connection in ($_ServerProfile.connectionSettings.connections | Where-Object { -not $_.networkUri.StartsWith($NetworkSetsUri)})) + { + + [void]$_AllNetworkUrisCollection.Add($_Connection.networkUri) + + } + + # Generate error if the server profile does not contain valid connections + if ($_AllNetworkUrisCollection.Count -eq 0) + { + + $ExceptionMessage = "The '{0}' server profile does not contain connections necessary to manage storage attachments. Please provide a server profile with atleast 1 valid connection." -f $_ServerProfile.name + $ErrorRecord = New-ErrorRecord HPEOneView.ServerProfileResourceException NoAvailableConnections ObjectNotFound 'Connections' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + "[{0}] Volumes to Process {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), ($_volumeAttachments | Convertto-Json -Depth 99 | out-string) | Write-Verbose + + $i = 0 + + # Process volumes being passed + foreach ($_volume in $_volumeAttachments) + { + + if (-not [System.String]::IsNullOrWhiteSpace($_volume.volumeUri)) + { + + Try + { + + + $_VolumeObject = Send-OVRequest -Uri $_volume.volumeUri -Hostname $_ServerProfile.ApplianceConnection.Name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + if ($null -ne $_VolumeObject.name) + { + + $_volumeName = $_VolumeObject.name + + } + + else + { + + $_volumeName = $_volume.volume.properties.name + + } + + "[{0}] Processing '{1}' Storage Volume (of {2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_volumeName, $_volumeAttachments.count | Write-Verbose + + # Validate if the volume is attachable + if (-not [System.String]::IsNullOrWhiteSpace($_volume.volumeUri)) + { + + "[{0}] Checking if the volume is available and attachable" -f $MyInvocation.InvocationName.ToString().ToUpper()| Write-Verbose + + # Get list of available storage system targets and the associated Volumes based on the EG and SHT provided + Try + { + + $_uri = "{0}?networks='{1}'&filter=name='{2}'" -f $AttachableStorageVolumesUri, ([String]::Join(',', $_AllNetworkUrisCollection.ToArray())), $_volumeName + + $_ReachableOrAvailableStorageResource = (Send-OVRequest -Uri $_uri -Hostname $_ServerProfile.ApplianceConnection.Name).members + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + "[{0}] Attachable Storage Volume: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), ($_ReachableOrAvailableStorageResource | Out-String) | Write-Verbose + + # Error on no available storage systems + if (-not $_ReachableOrAvailableStorageResource) + { + + $ExceptionMessage = "Unable to find attachable storage volumes for '{0}' Server Profile with available connection networks and '{1}'. Verify the Server Profile contains at least 1 Connection that is mapped to the storage system the volume is provisioned from." -f $_ServerProfile.name, [String]::Join(',', $_AllNetworkUrisCollection.ToArray()) + $ErrorRecord = New-ErrorRecord HPEOneView.ServerProfileResourceException NoAvailableStorageSystems ObjectNotFound 'SANStorage' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + $_AssociatedStorageSystemUri = $_ReachableOrAvailableStorageResource.storageSystemUri + + } + + # This is an ephemeral volume, need to validate the connections to the storage pool + else + { + + Try + { + + $_uri = "{0}?networks='{1}'&filter=uri='{2}'" -f $ReachableStoragePoolsUri, ([String]::Join(',', $_AllNetworkUrisCollection.ToArray())), $_volume.volume.properties.storagePool + + $_ReachableOrAvailableStorageResource = (Send-OVRequest -Uri $_uri -Hostname $_ServerProfile.ApplianceConnection).members + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + # Error that the provided storage pool is not reachable by the profile connections + if (-not $_ReachableOrAvailableStorageResource) + { + + $ExceptionMessage = "The '{0}' Server Profile does not contain 1 or more connections that can reach the provided storage pool." -f $_ServerProfile.name + $ErrorRecord = New-ErrorRecord HPEOneView.ServerProfileResourceException NoReachableStoragePool ObjectNotFound 'SANStorage' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + $_AssociatedStorageSystemUri = $_ReachableOrAvailableStorageResource.storageSystemUri + + } + + # Figure out volume ID + if (-not $_volume.id) + { + + "[{0}] No VolumeID value provided. Getting next volume id value." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $id = 1 + + $Found = $false + + While (-not $Found) + { + + if (-not($_ServerProfile.sanStorage.volumeAttachments | Where-Object id -eq $id)) + { + + $_volume.id = $id + + $Found = $true + + } + + $id++ + + } + + } + + # If the storage paths array is null, Process connections to add mapping + if (-not $_volume.storagePaths) + { + + # Get the associated storage system to later identify the ports + Try + { + + $_AssociatedStorageSystem = Send-OVRequest -Uri $_AssociatedStorageSystemUri -Hostname $_ServerProfile.ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + "[{0}] Storage Paths value is Null. Building connection mapping." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + # Loop through profile connections + $found = 0 + + foreach ($_reachableNetwork in $_ReachableOrAvailableStorageResource.reachableNetworks) + { + + $_StoragePath = NewObject -StoragePath + + # Looking for $volConnection + $_ProfileConnection = $_ServerProfile.connectionSettings.connections | Where-Object networkUri -eq $_reachableNetwork + + if ($_ProfileConnection) + { + + # Keep track of the connections found for error reporting later + $found++ + + "[{0}] Mapping connection ID '{1}' -> volume ID '{2}'" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_ProfileConnection.id, $_volumeAttachments[$i].id | Write-Verbose + + $_StoragePath.connectionId = $_ProfileConnection.id + $_StoragePath.isEnabled = $True + + if ($PSBoundParameters['TargetAddresses']) + { + + "[{0}] Getting FC network to get associated SAN." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + # $_uri = "{0}/reachable-ports?query=expectedNetworkUri EQ '{1}'" -f $_VolumeToStorageSystem.uri, $profileConnection.networkUri + $_StoragePath.targetSelector = 'TargetPorts' + + Try + { + + $_ServerProfileConnectionNetwork = Send-OVRequest -Uri $_ProfileConnection.networkUri -Hostname $_ServerProfile.ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + # Get the list of all ports reachable by the expected managed SAN/Network + $_StorageSystemExpectedMappedPorts = $_AssociatedStorageSystem.ports | Where-Object expectedSanUri -eq $_ServerProfileConnectionNetwork.managedSanUri + + ForEach ($_PortID in $TargetAddresses) + { + + "[{0}] Looking for {1} host port from available storage system." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_PortID | Write-Verbose + + if ($WwnAddressPattern.Match($_PortID).Success) + { + + $_PortType = 'name' + + } + + elseif ($StoreServeTargetPortIDPattern.Match($_PortID).Success) + { + + $_PortType = 'address' + + } + + ForEach ($_HostPort in ($_StorageSystemExpectedMappedPorts | Where-Object $_PortType -match $_PortID)) + { + + "[{0}] Adding {1} ({2}) host port to targets." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_HostPort.address, $_HostPort.name | Write-Verbose + + $_Target = @{ name = $_HostPort.address} + + [void]$_StoragePath.targets.Add($_Target) + + } + + } + + } + + [void]$_volume.storagePaths.Add($_StoragePath) + + } + + } + + # We should NOT get here + if (-not ($found)) + { + + # Generate non-terminating error and continue + $ExceptionMessage = "Unable to find a Profile Connection that will map to '{0}'. Creating server profile resource without Volume Connection Mapping." -f $_volumeName + $ErrorRecord = New-ErrorRecord HPEOneView.ServerProfileResourceException NoProfileConnectionsMapToVolume ObjectNotFound 'Volumes' -Message $ExceptionMessage + $PSCmdlet.WriteError($ErrorRecord) + + } + + } + + "[{0}] Storage Volume Object: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), (ConvertTo-Json $_volume -depth 99) | Write-Verbose + + "[{0}] Attaching '{1}' Storage Volume to volumeAttachments collection." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_volumeName | Write-Verbose + + [void]$_ServerProfile.sanStorage.volumeAttachments.Add($_volume) + + $i++ + + } + + # Workaround to remove a possible NULL entry in the volumeAttachments collection + [void]$_ServerProfile.sanStorage.volumeAttachments.Remove($null) + + if (-not $PSBoundParameters['PassThru']) + { + + "[{0}] Updating Server Profile with new Storage Volume Attachments: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_ServerProfile.name | Write-Verbose + + Try + { + + $_Task = Send-OVRequest -Uri $_ServerProfile.uri -Method PUT -Body $_ServerProfile -Hostname $_ServerProfile.ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + Return $_Task + + } + + else + { + + "[{0}] Returning Server Profile to caller with new Storage Volume Attachments: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_ServerProfile.name | Write-Verbose + + return $_ServerProfile + + } + + } + + else + { + + if ($PSBoundParameters['TargetAddresses']) + { + + "[{0}] Adding TargetPortAssignmentType and TargetAddresses to volume attachment members." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + ForEach ($_VolAttachment in $_volumeAttachments) + { + + $_volumeAttachments | Add-Member -NotePropertyName TargetPortAssignmentType -NotePropertyValue $TargetPortAssignment + $_volumeAttachments | Add-Member -NotePropertyName TargetAddresses -NotePropertyValue $TargetAddresses + + } + + } + + return $_volumeAttachments + + } + + } + +} + +# Helper function to return collection of available BIOS settings for a given SHT +function Get-OVAvailableServerBiosSettings +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdLetBinding (DefaultParameterSetName = "Default")] + [OutputType([HPEOneView.Server.BiosSetting[]])] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = "Default")] + [ValidateNotNullorEmpty()] + [Object]$InputObject + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + } + + Process + { + + + + } + + End + { + + + } + +} + +# Helper Cmdlet to get available iLO settings for SPT and SP +function Get-OVAvailableIloSettings +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdLetBinding (DefaultParameterSetName = "Default")] + [OutputType([HPEOneView.Server.IloSetting])] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = "Default")] + [ValidateNotNullorEmpty()] + [Object]$InputObject + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + } + + Process + { + + + + } + + End + { + + + } + +} + +Function New-OVServerProfileIloPolicy +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding(DefaultParameterSetName = 'Default')] + [OutputType([System.Management.Automation.PSCustomObject])] + + Param + ( + + [Parameter(Mandatory = $false, ValueFromPipeline, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [Object]$InputObject, + + [Parameter(Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [Switch]$GenerateiLOSecurityDashboardSettings, + + [Parameter(Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [Switch]$ManageLocalAdministratorAccount, + + [Parameter(Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [SecureString]$LocalAdministratorPassword, + + [Parameter(Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [Bool]$RemoveLocalAdministratorAccount, + + [Parameter(Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [Switch]$ManageLocalAccounts, + + [Parameter(Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [Object]$LocalAccounts, + + [Parameter(Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [Switch]$ManageDirectoryConfiguration, + + [Parameter(Mandatory = $false, ParameterSetName = 'Default')] + [ValidateSet('Disabled', 'DirectoryDefault', "HPEExtended")] + [String]$LdapSchema, + + [Parameter(Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [Bool]$GenericLDAP, + + [Parameter(Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [String]$LOMObjectDistinguishedName, + + [Parameter(Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [SecureString]$IloObjectPassword, + + [Parameter(Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [String]$DirectoryServerAddress, + + [Parameter(Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [Int]$DirectoryServerPort, + + [Parameter(Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [System.IO.FileInfo]$DirectoryServerCertificate, + + [Parameter(Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [String[]]$DirectoryServerCertificateBase64, + + [Parameter(Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [String[]]$DirectoryUserContext, + + [Parameter(Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [Bool]$EnableKerberosAuthentication, + + [Parameter(Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [String]$KerberosRealm, + + [Parameter(Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [String]$KerberosKDCServerAddress, + + [Parameter(Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [Int]$KerberosKDCServerPort, + + [Parameter(Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [System.IO.FileInfo]$KerbersKeyTabFile, + + [Parameter(Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [Switch]$ManageDirectoryGroups, + + [Parameter(Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [Object]$DirectoryGroups, + + [Parameter(Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [Switch]$ManageIloHostname, + + [Parameter(Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [String]$IloHostname, + + [Parameter(Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [Switch]$ManageKeyManager, + + [Parameter(Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [String]$PrimaryKeyServerAddress, + + [Parameter(Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [Int]$PrimaryKeyServerPort, + + [Parameter(Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [String]$SecondaryKeyServerAddress, + + [Parameter(Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [Int]$SecondaryKeyServerPort, + + [Parameter(Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [Bool]$RedundancyRequired, + + [Parameter(Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [String]$KeymanagerGroupName, + + [Parameter(Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [String]$KeymanagerLocalCertificateName, + + [Parameter(Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [String]$KeymanagerLoginName, + + [Parameter(Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [SecureString]$KeymanagerPassword + + ) + + Begin + { + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + # Parameter validation + if ($PSBoundParameters['LocalAdministratorPassword'] -and $PSBoundParameters['RemoveLocalAdministratorAccount']) + { + + $ExceptionMessage = "The LocalAdministratorPassword and RemoveLocalAdministratorAccount parameters are mutually exclusive. Please ensure you are specifying one." + $ErrorRecord = New-ErrorRecord HPEOneView.Library.ParameterValidationException InvalidParameter InvalidOperation 'ManageLocalAdministratorAccount' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + if ($ManageDirectoryConfiguration -and -not $PSBoundParameters['LdapSchema']) + { + + $ExceptionMessage = "The LDAP schema must be set when managing directory configuration, by using the LdapSchema parameter." + $ErrorRecord = New-ErrorRecord HPEOneView.Library.ParameterValidationException InvalidParameter InvalidOperation 'LdapSchema' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + if ($ManageDirectoryConfiguration -and $LdapSchema -eq 'Disabled') + { + + $InvalidParameters = 'GenericLDAP', 'LOMObjectDistinguishedName', 'IloObjectPassword', 'DirectoryServerAddress', 'DirectoryServerPort', 'DirectoryServerCertificate', 'DirectoryServerCertificateBase64', 'DirectoryUserContext' + + ForEach ($_param in $PSBoundParameters.Keys) + { + + if ($InvalidParameters.Contains($_param)) + { + + $ExceptionMessage = "The specified LdapSchema parameter is set to '{0}', and does not allow the use of '{1}'." -f $LdapSchema, $_param + $ErrorRecord = New-ErrorRecord HPEOneView.Library.ParameterValidationException InvalidParameter InvalidOperation $_param -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + } + + if ($ManageDirectoryConfiguration -and -not $PSBoundParameters['DirectoryServerAddress']) + { + + $ExceptionMessage = "The DirectoryServerAddress parameter is required when configuring directory authentication." + $ErrorRecord = New-ErrorRecord HPEOneView.Library.ParameterValidationException InvalidParameter InvalidOperation 'ManageDirectoryConfiguration' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + if ($ManageDirectoryConfiguration -and $LdapSchema -ne 'DirectoryDefault' -and $GenericLDAP) + { + + $ExceptionMessage = "The specified LdapSchema parameter value '{0}' does not support Generic LDAP configuration. Either remove the GenericLDAP or set it to `$False, or change the LdapSchema parameter to DirectoryDefault." -f $LdapSchema + $ErrorRecord = New-ErrorRecord HPEOneView.Library.ParameterValidationException InvalidParameter InvalidOperation 'GenericLDAP' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + if ($ManageDirectoryConfiguration -and $EnableKerberosAuthentication) + { + + $RequiredParameters = 'KerberosRealm', 'KerberosKDCServerAddress', 'KerbersKeyTabFile' + + ForEach ($_RequiredParam in $RequiredParameters) + { + + if (-not $PSBoundParameters.Keys.Contains($_RequiredParam)) + { + + $ExceptionMessage = "The '{0}' parameter is required when managing Kerberos authentication." -f $_RequiredParam + $ErrorRecord = New-ErrorRecord HPEOneView.Library.ParameterValidationException InvalidParameter InvalidOperation 'EnableKerberosAuthentication' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + } + + if ($ManageIloHostname -and -not $PSBoundParameters['IloHostname']) + { + + $IloHostname = "{serverProfileName}-ilo" + + } + + elseif ($ManageIloHostname -and $PSBoundParameters['IloHostname']) + { + + $AllowedIloHostnameVariables = 'serverProfileName' + # Validate embedded variables + + $Found = $EmbeddedVariableNameRegEx.Matches($IloHostname) + + ForEach ($match in $Found) + { + + $ExceptionMessage = $null + + $ValidateVariable = '{' + $match.Groups['variable'].Value + '}' + + if (-not $AllowedIloHostnameVariables.Contains($match.Groups['variable'].Value)) + { + + $ExceptionMessage = "The variable '{0}' is not allowed, as it is not an approved IloHostname variable. Please ensure any embedded variable is from these values: '{1}{2}{3}'" -f $ValidateVariable, '{', [String]::Join("}', '{", $AllowedIloHostnameVariables), '}' + $ErrorRecord = New-ErrorRecord HPEOneView.Library.ParameterValidationException InvalidParameter InvalidOperation 'IloHostname' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + } + + if ($ManageKeyManager) + { + + $RequiredParameters = 'PrimaryKeyServerAddress', 'KeymanagerGroupName', 'KeymanagerLoginName', 'KeymanagerPassword' + + ForEach ($_RequiredParam in $RequiredParameters) + { + + if (-not $PSBoundParameters.Keys.Contains($_RequiredParam)) + { + + $ExceptionMessage = "The '{0}' parameter is required when managing Kerberos authentication." -f $_RequiredParam + $ErrorRecord = New-ErrorRecord HPEOneView.Library.ParameterValidationException InvalidParameter InvalidOperation 'ManageKeyManager' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + } + + if ($RedundancyRequired -and -not ($PSBoundParameters['PrimaryKeyServerAddress'] -or $PSBoundParameters['SecondaryKeyServerAddress'])) + { + + $ExceptionMessage = "Both the PrimaryKeyServerAddress and SecondaryKeyServerAddress parameters are required when RedundancyRequired is set to true." + $ErrorRecord = New-ErrorRecord HPEOneView.Library.ParameterValidationException InvalidParameter InvalidOperation 'RedundancyRequired' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + Process + { + + $_IloProfileConfig = NewObject -IloProfileSettings + + # Process Local Administrator policy + if ($ManageLocalAdministratorAccount) + { + + "[{0}] Will manage local Administrator iLO account policy." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_LocalAdministratorPolicy = NewObject -IloSetting + $_LocalAdministratorPolicy.settingType = $IloProfileSettingTypeEnum.AdministratorAccount + + $_LocalAdminSetting = NewObject -IloLocalAdministrator + + if ($RemoveLocalAdministratorAccount) + { + + "[{0}] Will set local Administrator iLO account policy to remove account." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_LocalAdminSetting.deleteAdministratorAccount = $true + + } + + else + { + + "[{0}] Will set local Administrator iLO account password." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_LocalAdminSetting | Add-Member -NotePropertyName password -NotePropertyValue ([Runtime.InteropServices.Marshal]::PtrToStringBSTR([Runtime.InteropServices.Marshal]::SecureStringToBSTR($LocalAdministratorPassword))) + + } + + $_LocalAdministratorPolicy.args = $_LocalAdminSetting + + [void]$_IloProfileConfig.mpSettings.Add($_LocalAdministratorPolicy) + + } + + # Process local user accounts + if ($ManageLocalAccounts) + { + + "[{0}] Will manage local iLO user accounts policy." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_LocalAccountPolicy = NewObject -IloSetting + $_LocalAccountPolicy.settingType = $IloProfileSettingTypeEnum.LocalAccounts + $_LocalAccountPolicy.args = @{ localAccounts = [System.Collections.ArrayList]::new() } + + ForEach ($_account in $LocalAccounts) + { + + "[{0}] Adding '{1}' iLO local account to policy (of {2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_account.userName, $LocalAccounts.Count | Write-Verbose + + [void]$_LocalAccountPolicy.args.localAccounts.Add($_account) + + } + + [void]$_IloProfileConfig.mpSettings.Add($_LocalAccountPolicy) + + } + + # Process group directory settings + if ($ManageDirectoryConfiguration) + { + + "[{0}] Will manage authentication directory group policy." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_LdapDirectoryPolicy = NewObject -IloSetting + $_LdapDirectoryPolicy.settingType = $IloProfileSettingTypeEnum.Directory + + $_LdapDirectoryConfig = NewObject -IloAuthDirectoryConfig + $_LdapDirectoryConfig.directoryAuthentication = $IloAuthDirectorySchemaEnum.$LdapSchema + + if ($LdapSchema -ne 'Disabled') + { + + $_LdapDirectoryConfig.directoryServerAddress = $DirectoryServerAddress + + if ($PSBoundParameters['DirectoryServerPort']) + { + + $_LdapDirectoryConfig.directoryServerPort = $DirectoryServerPort + } + + if ($PSBoundParameters['LOMObjectDistinguishedName']) + { + + $_LdapDirectoryConfig | Add-Member -NotePropertyName iloObjectDistinguishedName -NotePropertyValue $LOMObjectDistinguishedName + + } + + if ($PSBoundParameters['IloObjectPassword']) + { + + $_LdapDirectoryConfig | Add-Member -NotePropertyName password -NotePropertyValue ([Runtime.InteropServices.Marshal]::PtrToStringBSTR([Runtime.InteropServices.Marshal]::SecureStringToBSTR($IloObjectPassword))) + + } + + if ($PSBoundParameters['DirectoryUserContext']) + { + + ForEach ($_OU in $DirectoryUserContext) + { + + [void]$_LdapDirectoryConfig.directoryUserContext.Add($_OU) + + } + + } + + if ($PSBoundParameters['DirectoryServerCertificate']) + { + + $_LdapDirectoryConfig | Add-Member -NotePropertyName directoryServerCertificate -NotePropertyValue $null -Force + + # Read the file contents + Try + { + + $DirectoryServerCertificateBase64 = [System.IO.File]::ReadAllLines($DirectoryServerCertificate, [System.Text.Encoding]::UTF8) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $_LdapDirectoryConfig.directoryServerCertificate = $DirectoryServerCertificateBase64 + + } + + elseif ($PSBoundParameters['DirectoryServerCertificateBase64']) + { + + $_LdapDirectoryConfig | Add-Member -NotePropertyName directoryServerCertificate -NotePropertyValue $null -Force + + $_LdapDirectoryConfig.directoryServerCertificate = $DirectoryServerCertificateBase64 + + } + + if ($GenericLDAP) + { + + $_LdapDirectoryConfig.directoryGenericLDAP = $GenericLDAP + + } + + } + + if ($EnableKerberosAuthentication) + { + + $_LdapDirectoryConfig.kerberosAuthentication = $true + + $_KerberosAuthenticationConfig = NewObject -IloAuthDirectoryKerberosConfig + $_KerberosAuthenticationConfig.kerberosRealm = $KerberosRealm + $_KerberosAuthenticationConfig.kerberosKDCServerAddress = $KerberosKDCServerAddress + + if ($PSBoundParameters['KerberosKDCServerPort']) + { + + $_KerberosAuthenticationConfig.kerberosKDCServerPort = $KerberosKDCServerPort + + } + + Try + { + + $_KeyTabFile = [System.IO.File]::ReadAllBytes($KerbersKeyTabFile) + + $sb = [System.Text.StringBuilder]::new() + [void]$sb.Append("-----BEGIN KEYTAB-----`n") + [void]$sb.Append([System.Convert]::ToBase64String($_KeyTabFile, "InsertLineBreaks")) + [void]$sb.Append("`n-----END KEYTAB-----`n") + + $_KerberosAuthenticationConfig.kerberosKeytab = $sb.ToString().Clone() + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $_LdapDirectoryConfig = JoinObject $_LdapDirectoryConfig $_KerberosAuthenticationConfig + + } + + $_LdapDirectoryPolicy.args = $_LdapDirectoryConfig + + [void]$_IloProfileConfig.mpSettings.Add($_LdapDirectoryPolicy) + + } + + # Process directory groups + if ($ManageDirectoryGroups) + { + + "[{0}] Will manage directory groups policy." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_LocalAccountPolicy = NewObject -IloSetting + $_LocalAccountPolicy.settingType = $IloProfileSettingTypeEnum.DirectoryGroups + $_LocalAccountPolicy.args = @{ directoryGroupAccounts = [System.Collections.ArrayList]::new() } + + ForEach ($_group in $DirectoryGroups) + { + + "[{0}] Adding '{1}' iLO directory group to policy (of {2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_group.userName, $DirectoryGroups.Count | Write-Verbose + + [void]$_LocalAccountPolicy.args.directoryGroupAccounts.Add($_group) + + } + + [void]$_IloProfileConfig.mpSettings.Add($_LocalAccountPolicy) + + } + + # Process iLO Hostname + if ($ManageIloHostname) + { + + "[{0}] Will manage iLO hostname policy." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_IloHostanemPolicy = NewObject -IloSetting + $_IloHostanemPolicy.settingType = $IloProfileSettingTypeEnum.Hostname + $_IloHostanemPolicy.args = @{ hostName = $IloHostname} + + [void]$_IloProfileConfig.mpSettings.Add($_IloHostanemPolicy) + + } + + # Proces ESKM + if ($ManageKeyManager) + { + + "[{0}] Will manage iLO hostname policy." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_KeyManagerPolicy = NewObject -IloSetting + $_KeyManagerPolicy.settingType = $IloProfileSettingTypeEnum.KeyManager + + $_KeyManagerConfig = NewObject -IloKeyManagerConfig + + $_KeyManagerConfig.primaryServerAddress = $PrimaryKeyServerAddress + + if ($PSBoundParameters['PrimaryKeyServerPort']) + { + + $_KeyManagerConfig.primaryServerPort = $PrimaryKeyServerPort + + } + + if ($PSBoundParameters['SecondaryKeyServerAddress']) + { + + $_KeyManagerConfig.secondaryServerAddress = $SecondaryKeyServerAddress + + if ($PSBoundParameters['SecondaryKeyServerPort']) + { + + $_KeyManagerConfig.secondaryServerPort = $SecondaryKeyServerPort + + } + + } + + if ($PSBoundParameters['RedundancyRequired']) + { + + $_KeyManagerConfig.redundancyRequired = $RedundancyRequired + + } + + $_KeyManagerConfig.groupName = $KeymanagerGroupName + $_KeyManagerConfig.certificateName = $KeymanagerLocalCertificateName + $_KeyManagerConfig.loginName = $KeymanagerLoginName + $_KeyManagerConfig.password = [Runtime.InteropServices.Marshal]::PtrToStringBSTR([Runtime.InteropServices.Marshal]::SecureStringToBSTR($KeymanagerPassword)) + + $_KeyManagerPolicy.args = $_KeyManagerConfig + + [void]$_IloProfileConfig.mpSettings.Add($_KeyManagerPolicy) + + } + + # Process iLO Security Dashboard settings when caller uses -GenerateiLOSecurityDashboardSettings switch parameter + # Process the InputObject looking for SecurityDashboard within settingType property + # Loop through the args array and args sub-array looking for securityParam of the attributeName property + # Each args instance pull out the value for label + # Create a new instance of IloSecurityDashboardSettings from NewObject, and use the label value as the securityParam property value + if ($PSBoundParameters['GenerateiLOSecurityDashboardSettings']) + { + + # Validate Inputobject was provided by the caller. If not, generate a terminating error that the InputObject parameter is required + if (-not $InputObject) + { + + $ExceptionMessage = "The InputObject parameter is required when using the -GenerateiLOSecurityDashboardSettings switch parameter. Please provide a valid server hardware type resource." + $ErrorRecord = New-ErrorRecord HPEOneView.Library.ParameterValidationException InvalidParameter InvalidOperation 'InputObject' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + "[{0}] Will generate iLO Security Dashboard settings." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + "[{0}] Processing '{1}' InputObject for SecurityDashboard settings." -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject.name | Write-Verbose + + $_SecurityDashboardPolicy = NewObject -IloSetting + $_SecurityDashboardPolicy.settingType = $IloProfileSettingTypeEnum.SecurityDashboard + + $_SecurityDashboardSettings = NewObject -IloSecurityDashboard + + ForEach ($_setting in $InputObject.mpSettings.Where({ $_.settingType -eq $IloProfileSettingTypeEnum.SecurityDashboard}).args.args) + { + + if ($_setting.attributeName -eq "securityParam") + { + + ForEach ($_args in $_setting.args) + { + + "[{0}] Adding '{1}' iLO Security Dashboard setting." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_args.label | Write-Verbose + + $_SecurityDashboardSetting = NewObject -IloSecurityDashboardSettings + $_SecurityDashboardSetting.securityParam = $_args.label + + [void]$_SecurityDashboardSettings.securityDashboardSettings.Add($_SecurityDashboardSetting) + + } + + } + + } + + $_SecurityDashboardPolicy.args = $_SecurityDashboardSettings + + [void]$_IloProfileConfig.mpSettings.Add($_SecurityDashboardPolicy) + + } + + Return $_IloProfileConfig + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +Function New-OVIloLocalUserAccount +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding(DefaultParameterSetName = 'iLO4')] + [OutputType([System.Management.Automation.PSCustomObject])] + + Param + ( + + [Parameter(Mandatory, ParameterSetName = 'iLO4')] + [Parameter(Mandatory, ParameterSetName = 'iLO5')] + [ValidateNotNullOrEmpty()] + [String]$Username, + + [Parameter(Mandatory = $false, ParameterSetName = 'iLO4')] + [Parameter(Mandatory = $false, ParameterSetName = 'iLO5')] + [ValidateNotNullOrEmpty()] + [String]$DisplayName, + + [Parameter(Mandatory, ParameterSetName = 'iLO4')] + [Parameter(Mandatory, ParameterSetName = 'iLO5')] + [ValidateNotNullOrEmpty()] + [SecureString]$Password, + + [Parameter(Mandatory = $false, ParameterSetName = 'iLO4')] + [Parameter(Mandatory = $false, ParameterSetName = 'iLO5')] + [ValidateNotNullOrEmpty()] + [Bool]$AdministerUserAccounts, + + [Parameter(Mandatory = $false, ParameterSetName = 'iLO4')] + [Parameter(Mandatory = $false, ParameterSetName = 'iLO5')] + [ValidateNotNullOrEmpty()] + [Bool]$RemoteConsole, + + [Parameter(Mandatory = $false, ParameterSetName = 'iLO4')] + [Parameter(Mandatory = $false, ParameterSetName = 'iLO5')] + [ValidateNotNullOrEmpty()] + [Bool]$VirtualMedia, + + [Parameter(Mandatory = $false, ParameterSetName = 'iLO4')] + [Parameter(Mandatory = $false, ParameterSetName = 'iLO5')] + [ValidateNotNullOrEmpty()] + [Bool]$VirtualPowerAndReset, + + [Parameter(Mandatory = $false, ParameterSetName = 'iLO4')] + [Parameter(Mandatory = $false, ParameterSetName = 'iLO5')] + [ValidateNotNullOrEmpty()] + [Bool]$ConfigureIloSettings, + + [Parameter(Mandatory = $false, ParameterSetName = 'iLO5')] + [ValidateNotNullOrEmpty()] + [Bool]$Login, + + [Parameter(Mandatory = $false, ParameterSetName = 'iLO5')] + [ValidateNotNullOrEmpty()] + [Bool]$HostBIOS, + + [Parameter(Mandatory = $false, ParameterSetName = 'iLO5')] + [ValidateNotNullOrEmpty()] + [Bool]$HostNIC, + + [Parameter(Mandatory = $false, ParameterSetName = 'iLO5')] + [ValidateNotNullOrEmpty()] + [Bool]$HostStorage + + ) + + Begin + { + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + } + + Process + { + + $_CombineIloBasePermissions = $false + $_CombineIlo5Permissions = $false + + $_NewIloLocalUser = NewObject -IloLocalAccount + $_NewIloLocalUser.userName = $Username + + $_DecryptedPassword = [Runtime.InteropServices.Marshal]::PtrToStringBSTR([Runtime.InteropServices.Marshal]::SecureStringToBSTR($Password)) + + if ($_DecryptedPassword.Length -lt 8) + { + + $ExceptionMessage = "The Password length must be at least 8 characters." + $ErrorRecord = New-ErrorRecord HPEOneView.Library.ParameterValidationException InvalidParameter InvalidOperation 'Password' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + $_NewIloLocalUser.password = $_DecryptedPassword + + $_IloBasePermissions = NewObject -IloBasePriviledges + $_Ilo5Permissions = NewObject -Ilo5Priviledges + + switch ($PSBoundParameters.Keys) + { + + 'DisplayName' + { + + $_NewIloLocalUser.displayName = $DisplayName + $_CombineIloBasePermissions = $true + + } + + 'AdministerUserAccounts' + { + + $_IloBasePermissions.userConfigPriv = $AdministerUserAccounts + $_CombineIloBasePermissions = $true + + } + + 'RemoteConsole' + { + + $_IloBasePermissions.remoteConsolePriv = $RemoteConsole + $_CombineIloBasePermissions = $true + + } + + 'VirtualMedia' + { + + $_IloBasePermissions.virtualMediaPriv = $VirtualMedia + $_CombineIloBasePermissions = $true + + } + + 'VirtualPowerAndReset' + { + + $_IloBasePermissions.virtualPowerAndResetPriv = $VirtualPowerAndReset + $_CombineIloBasePermissions = $true + + } + + 'ConfigureIloSettings' + { + + $_IloBasePermissions.iLOConfigPriv = $ConfigureIloSettings + $_CombineIloBasePermissions = $true + + } + + 'Login' + { + + $_Ilo5Permissions.loginPriv = $Login + $_CombineIlo5Permissions = $true + + } + + 'HostBIOS' + { + + $_Ilo5Permissions.hostBIOSConfigPriv = $HostBIOS + $_CombineIlo5Permissions = $true + + } + + 'HostNIC' + { + + $_Ilo5Permissions.hostNICConfigPriv = $HostNIC + $_CombineIlo5Permissions = $true + + } + + 'HostStorage' + { + + $_Ilo5Permissions.hostStorageConfigPriv = $HostStorage + $_CombineIlo5Permissions = $true + + } + + } + + if ($_CombineIloBasePermissions) + { + + $_NewIloLocalUser = JoinObject $_NewIloLocalUser $_IloBasePermissions + + } + + if ($_CombineIlo5Permissions) + { + + $_NewIloLocalUser = JoinObject $_NewIloLocalUser $_Ilo5Permissions + + } + + Return $_NewIloLocalUser + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +Function New-OVIloDirectoryGroup +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "Default")] + [OutputType([System.Management.Automation.PSCustomObject])] + + Param + ( + + [Parameter(Mandatory, ParameterSetName = "Default")] + [ValidateNotNullOrEmpty()] + [String]$GroupDN, + + [Parameter(Mandatory, ParameterSetName = "Default")] + [ValidateNotNullOrEmpty()] + [String]$GroupSID, + + [Parameter(Mandatory = $false, ParameterSetName = "Default")] + [ValidateNotNullOrEmpty()] + [Bool]$AdministerUserAccounts, + + [Parameter(Mandatory = $false, ParameterSetName = "Default")] + [ValidateNotNullOrEmpty()] + [Bool]$RemoteConsole, + + [Parameter(Mandatory = $false, ParameterSetName = "Default")] + [ValidateNotNullOrEmpty()] + [Bool]$VirtualMedia, + + [Parameter(Mandatory = $false, ParameterSetName = "Default")] + [ValidateNotNullOrEmpty()] + [Bool]$VirtualPowerAndReset, + + [Parameter(Mandatory = $false, ParameterSetName = "Default")] + [ValidateNotNullOrEmpty()] + [Bool]$ConfigureIloSettings + + ) + + Begin + { + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + } + + Process + { + + $_NewIloDirectoryGroup = NewObject -IloDirectoryGroup + $_NewIloDirectoryGroup.groupDN = $GroupDN + + + $_IloBasePermissions = NewObject -IloBasePriviledges + + switch ($PSBoundParameters.Keys) + { + + 'GroupSID' + { + + $_NewIloDirectoryGroup.groupSID = $GroupSID + + } + + 'AdministerUserAccounts' + { + + $_IloBasePermissions.userConfigPriv = $AdministerUserAccounts + + } + + 'RemoteConsole' + { + + $_IloBasePermissions.remoteConsolePriv = $RemoteConsole + + } + + 'VirtualMedia' + { + + $_IloBasePermissions.virtualMediaPriv = $VirtualMedia + + } + + 'VirtualPowerAndReset' + { + + $_IloBasePermissions.virtualPowerAndResetPriv = $VirtualPowerAndReset + + } + + 'ConfigureIloSettings' + { + + $_IloBasePermissions.iLOConfigPriv = $ConfigureIloSettings + + } + + + } + + $_NewIloDirectoryGroup = JoinObject $_NewIloDirectoryGroup $_IloBasePermissions + + Return $_NewIloDirectoryGroup + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +####################################################### +# Cluster Profile: +# + +function Get-OVClusterManager +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "Default")] + [OutputType([HPEOneView.Cluster.HypervisorManager])] + Param + ( + + [Parameter (ParameterSetName = "Default", Mandatory = $false)] + [ValidateNotNullorEmpty()] + [String]$Name, + + [Parameter (ParameterSetName = "Default", Mandatory = $false)] + [ValidateNotNullorEmpty()] + [String]$Version, + + [Parameter (ParameterSetName = "Default", Mandatory = $false)] + [ValidateNotNullOrEmpty()] + [String]$Label, + + [Parameter (ParameterSetName = "Default", Mandatory = $false)] + [Object]$Scope = "AllResourcesInScope", + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command agian." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + Process + { + + ForEach ($_appliance in $ApplianceConnection) + { + + "[{0}] Processing appliance {1} (of {2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name, $ApplianceConnection.Count | Write-Verbose + + $_Query = [System.Collections.ArrayList]::new() + + # Handle default cause of AllResourcesInScope + if ($Scope -eq 'AllResourcesInScope') + { + + "[{0}] Processing AllResourcesInScope." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_Scopes = $_appliance.ActivePermissions | Where-Object Active + + # If one scope contains 'AllResources' ScopeName "tag", then all resources should be returned regardless. + if ($_Scopes | Where-Object ScopeName -eq 'AllResources') + { + + $_ScopeNames = [String]::Join(', ', ($_Scopes | Where-Object ScopeName -eq 'AllResources').ScopeName) + + "[{0}] Scope(s) {1} is set to 'AllResources'. Will not add scope to URI query parameter." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_ScopeNames | Write-Verbose + + } + + # Process ApplianceConnection ActivePermissions collection + else + { + + Try + { + + $_ScopeQuery = Join-Scope $_Scopes + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + [Void]$_Query.Add(("({0})" -f $_ScopeQuery)) + + } + + } + + elseif ($Scope | Where-Object ScopeName -eq 'AllResources') + { + + $_ScopeNames = [String]::Join(', ', ($_Scopes | Where-Object ScopeName -eq 'AllResources').ScopeName) + + "[{0}] Scope(s) {1} is set to 'AllResources'. Will not add scope to URI query parameter." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_ScopeNames | Write-Verbose + + } + + elseif ($Scope -eq 'AllResources') + { + + "[{0}] Requesting scope 'AllResources'. Will not add scope to URI query parameter." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_ScopeNames | Write-Verbose + + } + + else + { + + Try + { + + $_ScopeQuery = Join-Scope $Scope + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + [Void]$_Query.Add(("({0})" -f $_ScopeQuery)) + + } + + if ($Name) + { + + if ($Name.Contains('*')) + { + + [Void]$_Query.Add(("name%3A{0}" -f $Name.Replace("*", "%2A").Replace(',','%2C').Replace(" ", "?"))) + + } + + else + { + + [Void]$_Query.Add(("name:'{0}'" -f $Name)) + + } + + } + + if ($Version) + { + + [Void]$_Query.Add(("version:'{0}'" -f $Version)) + + } + + if ($Label) + { + + [Void]$_Query.Add(("labels:'{0}'" -f $Label)) + + } + + $_Category = 'category={0}' -f $ResourceCategoryEnum.HypervisorManager + + # Build the final URI + $_uri = '{0}?{1}&sort=name:asc&query={2}' -f $IndexUri, [String]::Join('&', $_Category), [String]::Join(' AND ', $_Query.ToArray()) + + Try + { + + [Array]$_ResourcesFromIndexCol = Get-AllIndexResources -Uri $_uri -ApplianceConnection $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if($_ResourcesFromIndexCol.Count -eq 0 -and $Name) + { + + "[{0}] Resource Name '{1}' was not found on appliance {2}. Generate Error." -f $MyInvocation.InvocationName.ToString().ToUpper(), $Name, $_appliance.Name | Write-Verbose + + $ExceptionMessage = "The specified resource name '{0}' was not found on '{1}' appliance connection. Please check the name again, and try again." -f $Name, $_appliance.Name + $ErrorRecord = New-ErrorRecord HPEOneView.ServerProfileResourceException ServerProfileResourceNotFound ObjectNotFound "Name" -Message $ExceptionMessage + $PSCmdlet.WriteError($ErrorRecord) + + } + + else + { + + foreach ($_member in $_ResourcesFromIndexCol) + { + + $_Preferences = [HPEOneView.Cluster.HypervisorManager+ConfigPreferences]::new($_member.preferences.virtualSwitchType, + $_member.preferences.distributedSwitchVersion, + $_member.preferences.distributedSwitchUsage, + $_member.preferences.multiNicVMotion, + $_member.preferences.drsEnabled, + $_member.preferences.haEnabled) + + $_ResourcePath = [System.Collections.Generic.List[HPEOneView.Cluster.HypervisorManager+ResourcePath]]::new() + + ForEach ($_Path in $_member.resourcePaths) + { + + $__resourcepath = [HPEOneView.Cluster.HypervisorManager+ResourcePath]::new($_Path.userPath, $_Path.actualPath) + $_ResourcePath.Add($__resourcepath) + + } + + [HPEOneView.Cluster.HypervisorManager]::new($_member.name, + $_member.displayName, + $_member.uuid, + $_member.port, + $_member.version, + $_member.state, + $_member.stateReason, + $_member.status, + $_member.username, + $_Preferences, + $_ResourcePath, + $_member.availableDvsVersions, + $_member.uri, + $_member.applianceConnection) + + } + + } + + } + + } + + End + { + + '[{0}] Done.' -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Add-OVClusterManager +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = 'Default')] + [OutputType([HPEOneView.Appliance.TaskResource])] + Param + ( + + [Parameter (Mandatory, ParameterSetName = 'Default')] + [Alias('Name', 'ComputerName')] + [String]$Hostname, + + [Parameter (ParameterSetName = 'Default', Mandatory = $false)] + [ValidateNotNullOrEmpty()] + [String]$DisplayName = "", + + [Parameter (ParameterSetName = 'Default', Mandatory)] + [ValidateNotNullOrEmpty()] + [PSCredential]$Credential, + + [Parameter (ParameterSetName = 'Default', Mandatory = $false)] + [ValidateRange(1, 65535)] + [Int]$Port = 443, + + [Parameter (ParameterSetName = 'Default', Mandatory = $false)] + [ValidateNotNullOrEmpty()] + [Switch]$TrustLeafCertificate, + + [Parameter (ParameterSetName = 'Default', Mandatory = $false)] + [ValidateNotNullOrEmpty()] + [HPEOneView.Appliance.ScopeCollection[]]$Scope, + + [Parameter (ParameterSetName = 'Default', Mandatory = $false)] + [Switch]$Async, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = ($ConnectedSessions | Where-Object Default) + + ) + + Begin + { + + "[{0}] Bound PS Parameters: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(),($PSBoundParameters | out-string) | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not($ConnectedSessions)) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command agian." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -gt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + Process + { + + ForEach ($_appliance in $ApplianceConnection) + { + + if ($PSBoundParameters['TrustLeafCertificate']) + { + + "[{0}] Caller provide the -TrustLeafCertificate switch. Adding SSL certificate to appliance trust store." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + "[{0}] Getting SSL certificate." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + # This is not an async task operation + Try + { + + $_uri = '{0}/{1}' -f $RetrieveHttpsCertRemoteUri, $Hostname + + $_DeviceCertificate = Send-OVRequest -Uri $_uri -Hostname $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $_DeviceCertificateToImport = NewObject -CertificateToImport + $_DeviceCertificateToImport.certificateDetails[0].base64Data = $_DeviceCertificate.certificateDetails.base64Data + $_DeviceCertificateToImport.certificateDetails[0].aliasName = $_DeviceCertificate.certificateDetails.commonName + + Try + { + + "[{0}] Adding SSL certificate to appliance trust store." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_uri = '{0}' -f $ApplianceTrustedSslHostStoreUri + + $_TaskResults = Send-OVRequest -Uri $_uri -Method POST -Body $_DeviceCertificateToImport -Hostname $_appliance | Wait-OVTaskComplete + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if ($_TaskResults.taskErrors) + { + + "[{0}] Task errors adding SSL certificate." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if ($_TaskResults.taskErrors.errorCode -eq '409' -and [RegEx]::Match($_TaskResults.taskErrors.message, 'The certificate already exists for the alias', $RegExInsensitiveFlag).Success) + { + + "[{0}] Certificate already exists." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + else + { + + $ErrorRecord = New-ErrorRecord InvalidOperationException $_TaskResults.taskErrors.errorCode InvalidResult 'Hostname' -Message $_TaskResults.taskErrors.message + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + } + + $_Uri = $HypervisorManagersUri.Clone() + + $_NewClusterProfileManager = NewObject -ClusterProfileManager + $_NewClusterProfileManager.name = $Hostname + + if ($PSBoundParameters['DisplayName']) + { + + $_NewClusterProfileManager.displayName = $DisplayName + + } + + else + { + + $_NewClusterProfileManager.displayName = $Hostname + + } + + $_NewClusterProfileManager.username = $Credential.UserName + $_NewClusterProfileManager.password = [Runtime.InteropServices.Marshal]::PtrToStringBSTR([Runtime.InteropServices.Marshal]::SecureStringToBSTR($Credential.Password)) + + if ($PSBoundParameters['Scope']) + { + + ForEach ($_Scope in $Scope) + { + + "[{0}] Adding to Scope: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_Scope.Name | Write-Verbose + + [void]$_NewClusterProfileManager.initialScopeUris.Add($_Scope.Uri) + + } + + } + + Try + { + + $_resp = Send-OVRequest -Uri $_Uri -Method POST -Body $_NewClusterProfileManager -Hostname $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + # Wait for task to get into Starting stage + Try + { + + $_resp = Wait-OVTaskStart $_resp + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + # Check to see if the task errored, which should be in the Task Validation stage + if ($_resp.taskState -ne "Running" -and $_resp.taskState -eq "Error" -and $_resp.stateReason -eq "ValidationError") + { + + "[{0}] Task error found {1} {2} " -f $MyInvocation.InvocationName.ToString().ToUpper(), $resp.taskState, $resp.stateReason | Write-Verbose + + if ($_resp.taskErrors | Where-Object { $_.errorCode -eq "HYPERVISOR_MANAGER_SECURE_CONNECTION_FAILED" }) + { + + $ExceptionMessage = 'The leaf certificate for {0} is untrusted by the appliance. Either provide the -TrustLeafCertificate parameter or manually add the certificate using the Add-OVApplianceTrustedCertificate Cmdlet.' -f $Hostname + $ErrorRecord = New-ErrorRecord InvalidOperationException UntrustedLeafCertificate InvalidResult 'Hostname' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + } + + elseif ($_resp.taskErrors) + { + + $_errorMessage = $_resp.taskErrors + + $ErrorRecord = New-ErrorRecord InvalidOperationException $_errorMessage.errorCode InvalidResult 'Hostname' -Message ($_errorMessage.details + " " + $_errorMessage.message) + + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + if ($Async) + { + + $_resp + + } + + else + { + + $_resp | Wait-OVTaskComplete + + } + + } + + } + + end + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Set-OVClusterManager +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = 'Default')] + [OutputType([HPEOneView.Appliance.TaskResource])] + param + ( + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = 'Default')] + [Alias('Name')] + [HPEOneView.Cluster.HypervisorManager]$InputObject, + + [Parameter (ParameterSetName = 'Default', Mandatory = $false)] + [ValidateNotNullOrEmpty()] + [String]$Hostname, + + [Parameter (ParameterSetName = 'Default', Mandatory = $false)] + [ValidateNotNullOrEmpty()] + [String]$DisplayName, + + [Parameter (ParameterSetName = 'Default', Mandatory = $false)] + [ValidateRange (1, 65535)] + [Int]$Port, + + [Parameter (ParameterSetName = 'Default', Mandatory = $false)] + [ValidateNotNullOrEmpty()] + [PSCredential]$Credential, + + [Parameter (ParameterSetName = 'Default', Mandatory = $false)] + [ValidateSet ('Distributed', 'Standard')] + [String]$VirtualSwitchType, + + [Parameter (ParameterSetName = 'Default', Mandatory = $false)] + [ValidateSet ('AllNetworks', 'GeneralNetworks')] + [String]$DistributedSwitchUsage, + + [Parameter (ParameterSetName = 'Default', Mandatory = $false)] + [ValidateSet ('4.0', '4.1.0', '5.0.0', '5.1.0', '5.5.0', '6.0', '6.7')] + [String]$DistributedSwitchVersion, + + [Parameter (ParameterSetName = 'Default', Mandatory = $false)] + [ValidateNotNullOrEmpty()] + [Bool]$HAEnabled, + + [Parameter (ParameterSetName = 'Default', Mandatory = $false)] + [ValidateNotNullOrEmpty()] + [Bool]$DRSEnabled, + + [Parameter (ParameterSetName = 'Default', Mandatory = $false)] + [ValidateNotNullOrEmpty()] + [Bool]$MultiNicVMotionEnabled, + + [Parameter (ParameterSetName = 'Default', Mandatory = $false)] + [Switch]$Async, + + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = ($ConnectedSessions | Where-Object Default) + + ) + + Begin + { + + "[{0}] Bound PS Parameters: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(),($PSBoundParameters | out-string) | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not($PSBoundParameters['InputObject'])) + { + + $Pipelineinput = $True + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not($ConnectedSessions)) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command agian." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -gt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + } + + Process + { + + $_UpdateHypervisorManagerDetails = [PSCustomObject]@{ + type = 'HypervisorManagerV2'; + name = $InputObject.Name + username = $InputObject.Username; + password = $InputObject.Password; + displayName = $InputObject.DisplayName; + preferences = [PSCustomObject]@{ + type = 'Vmware'; + virtualSwitchType = $InputObject.Preferences.VirtualSwitchType + distributedSwitchVersion = $InputObject.Preferences.DistributedSwitchVersion + distributedSwitchUsage = $InputObject.Preferences.DistributedSwitchUsage + multiNicVMotion = $InputObject.Preferences.MultiNicVMotion + drsEnabled = $InputObject.Preferences.DRSEnabled + haEnabled = $InputObject.Preferences.HAEnabled + } + } + + Switch ($PSBoundParameters.Keys) + { + + 'DisplayName' + { + + "[{0}] Updating displayname to: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $DisplayName | Write-Verbose + + $_UpdateHypervisorManagerDetails.displayName = $DisplayName + + } + + 'Hostname' + { + + "[{0}] Updating name to: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Hostname | Write-Verbose + + $_UpdateHypervisorManagerDetails.name = $Hostname + + } + + 'Credential' + { + + "[{0}] Updating credential to: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Credential.Username | Write-Verbose + + $_UpdateHypervisorManagerDetails.username = $Credential.Username + $_UpdateHypervisorManagerDetails.password = [Runtime.InteropServices.Marshal]::PtrToStringBSTR([Runtime.InteropServices.Marshal]::SecureStringToBSTR($Credential.Password)) + + } + + 'VirtualSwitchType' + { + + # If Standard, check if $PSBoundParameters['DistributedSwitchUsage'] is provided, error if true + if ($PSBoundParameters['VirtualSwitchType'] -eq 'Standard' -and $PSBoundParameters['DistributedSwitchUsage']) + { + + $ExceptionMessage = "Setting the hypervisor VirtualSwitchType to 'Standard' and also setting the DistributeSwitchUsage is not supported." + $ErrorRecord = New-ErrorRecord HPEOneView.HypervisorManagerException InvalidVirtualSwitchTypeParameters InvalidOperation 'VirtualSwitchType' -Message $ExceptionMessage + + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + if ($PSBoundParameters['VirtualSwitchType'] -eq 'Standard' -and $PSBoundParameters['DistributedSwitchVersion']) + { + + $ExceptionMessage = "Setting the hypervisor VirtualSwitchType to 'Standard' and also setting the DistributedSwitchVersion is not supported." + $ErrorRecord = New-ErrorRecord HPEOneView.HypervisorManagerException InvalidVirtualSwitchTypeParameters InvalidOperation 'VirtualSwitchType' -Message $ExceptionMessage + + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + if (-not $PSBoundParameters['DistributedSwitchUsage']) + { + + $ExceptionMessage = "Setting the hypervisor VirtualSwitchType to 'Distributed' requires the -DistributedSwitchUsage parameter." + $ErrorRecord = New-ErrorRecord HPEOneView.HypervisorManagerException InvalidVirtualSwitchTypeParameters InvalidOperation 'VirtualSwitchType' -Message $ExceptionMessage + + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + if (-not $PSBoundParameters['DistributedSwitchVersion']) + { + + $ExceptionMessage = "Setting the hypervisor VirtualSwitchType to 'Distributed' requires the -DistributedSwitchVersion parameter." + $ErrorRecord = New-ErrorRecord HPEOneView.HypervisorManagerException InvalidVirtualSwitchTypeParameters InvalidOperation 'VirtualSwitchType' -Message $ExceptionMessage + + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + "[{0}] Updating VirtualSwitchType to: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $VirtualSwitchType | Write-Verbose + + $_UpdateHypervisorManagerDetails.preferences.virtualSwitchType = $VirtualSwitchType + + } + + 'DistributedSwitchVersion' + { + + # Error due to VirtualSwitchType not set to 'Distributed' + if ($InputObject.Preferences.VirtualSwitchType -eq 'Standard' -and -not $PSBoundParameters['VirtualSwitchType']) + { + + $ExceptionMessage = "The Hypervisor Manager '{0}' is not currently configured to manage distributed virtual switch type. You must specify to use Distributed virtual switch type before setting the version." -f $InputObject.name + $ErrorRecord = New-ErrorRecord HPEOneView.HypervisorManagerException InvalidVirtualSwitchType InvalidOperation 'DistributedSwitchVersion' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + # Check to make sure provided version is within $InputObject.AvailableDvsVersions.Contains($DistributedSwitchVersion) + if (-not $InputObject.AvailableDvsVersions.Contains($DistributedSwitchVersion)) + { + + $ExceptionMessage = "The Hypervisor Manager '{0}' does not support the requested DistributedSwitchVersion '{1}'. Please specify one of the valid supported versions: {2}" -f $InputObject.name, $DistributedSwitchVersion, [String]::Join(', ', $InputObject.AvailableDvsVersions) + $ErrorRecord = New-ErrorRecord HPEOneView.HypervisorManagerException UnsupportedVirtualSwitchVersion InvalidOperation 'DistributedSwitchVersion' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + "[{0}] Updating DistributedSwitchVersion to: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $DistributedSwitchVersion | Write-Verbose + + $_UpdateHypervisorManagerDetails.preferences.distributedSwitchVersion = $DistributedSwitchVersion + + } + + 'DistributedSwitchUsage' + { + + # If supplied, and existing manager does not have virtualSwitchType set to Distributed or if $PSBoundParameters['VirtualSwitchType'] not supplied, error + if ($InputObject.Preferences.VirtualSwitchType -eq 'Standard' -and -not $PSBoundParameters['VirtualSwitchType']) + { + + $ExceptionMessage = "The Hypervisor Manager '{0}' is not currently configured to manage distributed virtual switch type. You must specify to use Distributed virtual switch type before setting the version." -f $InputObject.name + $ErrorRecord = New-ErrorRecord HPEOneView.HypervisorManagerException InvalidVirtualSwitchType InvalidOperation 'DistributedSwitchVersion' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + "[{0}] Updating DistributedSwitchUsage to: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $DistributedSwitchUsage | Write-Verbose + + $_UpdateHypervisorManagerDetails.preferences.distributedSwitchUsage = $DistributedSwitchUsage + + } + + 'HAEnabled' + { + + $_UpdateHypervisorManagerDetails.preferences.haEnabled = $HAEnabled + + } + + 'DRSEnabled' + { + + "[{0}] Updating DRSEnabled to: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $DRSEnabled | Write-Verbose + + $_UpdateHypervisorManagerDetails.preferences.drsEnabled = $DRSEnabled + + } + + 'MultiNicVMotionEnabled' + { + + "[{0}] Updating MultiNicVMotionEnabled to: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $MultiNicVMotionEnabled | Write-Verbose + + $_UpdateHypervisorManagerDetails.preferences.multiNicVMotion = $MultiNicVMotionEnabled + + } + + } + + Try + { + + $_resp = Send-OVRequest -Uri $InputObject.Uri -Method PUT -Body $_UpdateHypervisorManagerDetails -AddHeader @{'If-Match' = "*"} -Hostname $InputObject.ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if (-not $Async) + { + + $_resp = Wait-OVTaskComplete -InputObject $_resp + + } + + $_resp + + } + + end + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Remove-OVClusterManager +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "Default", SupportsShouldProcess, ConfirmImpact = 'High')] + [OutputType([HPEOneView.Appliance.TaskResource])] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [HPEOneView.Cluster.HypervisorManager]$InputObject, + + [Parameter (Mandatory = $False, ParameterSetName = 'Default')] + [Switch]$Force, + + [Parameter (Mandatory = $False, ValueFromPipelineByPropertyName, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not($PSBoundParameters['InputObject'])) + { + + $Pipelineinput = $True + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ExceptionMessage = "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command agian." + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + } + + Process + { + + $RemoveMessage = "remove '{0}' {1}" -f $InputObject.name, $ResourceCategoryEnum.HypervisorManager + + if ($PSCmdlet.ShouldProcess($InputObject.ApplianceConnection, $RemoveMessage)) + { + + "[{0}] Removing resource: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), ($InputObject | Out-String) | Write-Verbose + "[{0}] URI: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject.uri | Write-Verbose + + $_Uri = '{0}' -f $InputObject.uri + + if ($Force) + { + + $_Uri += '?force=true' + + } + + try + { + + Send-OVRequest -Uri $_Uri -Method DELETE -AddHeader @{'If-Match' = $InputObject.eTag } -Hostname $InputObject.ApplianceConnection + + } + + catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + elseif ($PSBoundParameters['whatif']) + { + + "[{0}] -WhatIf was passed" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Get-OVClusterProfile +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = 'Default')] + param + ( + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [String]$Name, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [Switch]$NonCompliant, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = ($ConnectedSessions | Where-Object Default) + + ) + + Begin + { + + "[{0}] Bound PS Parameters: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(),($PSBoundParameters | out-string) | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not($ConnectedSessions)) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command agian." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -gt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $_ClustersCol = [System.Collections.ArrayList]::new() + + } + + Process + { + + ForEach ($_appliance in $ApplianceConnection) + { + + "[{0}] Processing appliance {1} (of {2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name, $ApplianceConnection.Count | Write-Verbose + + $_Query = [System.Collections.ArrayList]::new() + + if ($Name) + { + + "[{0}] Filtering for Name: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Name | Write-Verbose + + if ($Name.Contains('*')) + { + + "[{0}] Filtering for Name: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Name | Write-Verbose + + [Void]$_Query.Add(("name%3A{0}" -f $Name.Replace("*", "%2A").Replace(',','%2C').Replace(" ", "?"))) + + } + + else + { + + [Void]$_Query.Add(("name:'{0}'" -f $Name)) + + } + + } + + # ($InputObject.complianceState -ne $ClusterProfileComplianceStateEnum.Consistent.State) + if ($PSBoundParameters['NonCompliant']) + { + + "[{0}] Filtering for non-compliant profiles." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + [Void]$_Query.Add(("NOT complianceState:'{0}'" -f $ClusterProfileComplianceStateEnum.Consistent.State)) + + } + + $_Category = 'category={0}' -f $ResourceCategoryEnum.HypervisorCluster + + # Build the final URI + $_uri = '{0}?{1}&sort=name:asc&query={2}' -f $IndexUri, [String]::Join('&', $_Category), [String]::Join(' AND ', $_Query.ToArray()) + + Try + { + + [Array]$_ResourcesFromIndexCol = Get-AllIndexResources -Uri $_uri -ApplianceConnection $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if($_ResourcesFromIndexCol.Count -eq 0 -and $Name) + { + + "[{0}] Cluster Resource Name '{1}' was not found on appliance {2}. Generate Error." -f $MyInvocation.InvocationName.ToString().ToUpper(), $Name, $_appliance.Name | Write-Verbose + + $ExceptionMessage = "The specified Cluster '{0}' was not found on '{1}' appliance connection. Please check the name again, and try again." -f $Name, $_appliance.Name + $ErrorRecord = New-ErrorRecord HPEOneView.Cluster.ClusterResourceException ClusterResourceNotFound ObjectNotFound "Name" -Message $ExceptionMessage + + $PSCmdlet.WriteError($ErrorRecord) + + } + + else + { + + ForEach ($_member in $_ResourcesFromIndexCol) + { + + $_member.PSObject.TypeNames.Insert(0,'HPEOneView.Cluster.ClusterProfile') + + $_member + + } + + } + + } + + } + + end + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Get-OVClusterNode +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = 'Default')] + param + ( + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [String]$Name, + + [Parameter (ParameterSetName = 'Default', Mandatory = $false)] + [ValidateNotNullOrEmpty()] + [String]$Label, + + [Parameter (ParameterSetName = 'Default', Mandatory = $false)] + [ValidateNotNullOrEmpty()] + [Object]$Scope = "AllResourcesInScope", + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = ($ConnectedSessions | Where-Object Default) + + ) + + Begin + { + + "[{0}] Bound PS Parameters: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(),($PSBoundParameters | out-string) | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not($ConnectedSessions)) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command agian." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -gt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $_ClusterNodeCol = [System.Collections.ArrayList]::new() + + } + + Process + { + + ForEach ($_appliance in $ApplianceConnection) + { + + "[{0}] Processing appliance {1} (of {2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name, $ApplianceConnection.Count | Write-Verbose + + $_Query = [System.Collections.ArrayList]::new() + + # Handle default cause of AllResourcesInScope + if ($Scope -eq 'AllResourcesInScope') + { + + "[{0}] Processing AllResourcesInScope." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_Scopes = $_appliance.ActivePermissions | Where-Object Active + + # If one scope contains 'AllResources' ScopeName "tag", then all resources should be returned regardless. + if ($_Scopes | Where-Object ScopeName -eq 'AllResources') + { + + $_ScopeNames = [String]::Join(', ', ($_Scopes | Where-Object ScopeName -eq 'AllResources').ScopeName) + + "[{0}] Scope(s) {1} is set to 'AllResources'. Will not add scope to URI query parameter." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_ScopeNames | Write-Verbose + + } + + # Process ApplianceConnection ActivePermissions collection + else + { + + Try + { + + $_ScopeQuery = Join-Scope $_Scopes + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + [Void]$_Query.Add(("({0})" -f $_ScopeQuery)) + + } + + } + + elseif ($Scope | Where-Object ScopeName -eq 'AllResources') + { + + $_ScopeNames = [String]::Join(', ', ($_Scopes | Where-Object ScopeName -eq 'AllResources').ScopeName) + + "[{0}] Scope(s) {1} is set to 'AllResources'. Will not add scope to URI query parameter." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_ScopeNames | Write-Verbose + + } + + elseif ($Scope -eq 'AllResources') + { + + "[{0}] Requesting scope 'AllResources'. Will not add scope to URI query parameter." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_ScopeNames | Write-Verbose + + } + + else + { + + + Try + { + + $_ScopeQuery = Join-Scope $Scope + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + [Void]$_Query.Add(("({0})" -f $_ScopeQuery)) + + } + + if ($Name) + { + + "[{0}] Filtering for Name: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Name | Write-Verbose + + if ($Name.Contains('*')) + { + + "[{0}] Filtering for Name: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Name | Write-Verbose + + [Void]$_Query.Add(("name%3A{0}" -f $Name.Replace("*", "%2A").Replace(',','%2C').Replace(" ", "?"))) + + } + + else + { + + [Void]$_Query.Add(("name:'{0}'" -f $Name)) + + } + + } + + if ($Label) + { + + [Void]$_Query.Add(("labels:'{0}'" -f $Label)) + + } + + $_Category = 'category={0}' -f $ResourceCategoryEnum.ClusterNode + + # Build the final URI + $_uri = '{0}?{1}&sort=name:asc&query={2}' -f $IndexUri, [String]::Join('&', $_Category), [String]::Join(' AND ', $_Query.ToArray()) + + Try + { + + [Array]$_ResourcesFromIndexCol = Get-AllIndexResources -Uri $_uri -ApplianceConnection $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if($_ResourcesFromIndexCol.Count -eq 0 -and $Name) + { + + "[{0}] Cluster Node Resource Name '{1}' was not found on appliance {2}. Generate Error." -f $MyInvocation.InvocationName.ToString().ToUpper(), $Name, $_appliance.Name | Write-Verbose + + $ExceptionMessage = "The specified Cluster Node '{0}' was not found on '{1}' appliance connection. Please check the name again, and try again." -f $Name, $_appliance.Name + $ErrorRecord = New-ErrorRecord HPEOneView.ClusterNodeResourceException ClusterNodeResourceNotFound ObjectNotFound "Name" -Message $ExceptionMessage + + $PSCmdlet.WriteError($ErrorRecord) + + } + + else + { + + ForEach ($_member in $_ResourcesFromIndexCol) + { + + $_member.PSObject.TypeNames.Insert(0,'HPEOneView.Cluster.ClusterNode') + + $_member + + } + + } + + } + + } + + end + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +# // TODO: DEV TEST DOCUMENT +# Use to get existing VMware hypervisor clusters from hypervisor manager +function Show-OVHypervisorCluster +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding ()] + Param + ( + + [Parameter (Mandatory = $false)] + [ValidateNotNullOrEmpty()] + [String]$Name, + + [Parameter (Mandatory = $false)] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command agian." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + Process + { + + ForEach ($_appliance in $ApplianceConnection) + { + + "[{0}] Processing Appliance Connection '{1}' (of {2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance, $ApplianceConnection.count | Write-Verbose + + $_HypervisorManagerUris = [System.Collections.ArrayList]::new() + + # Get all hypervisor managers on the appliance + try + { + + $_HypervisorManagers = Send-OVRequest -Uri $HypervisorManagersUri -Hostname $_appliance + + } + + catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + ForEach ($_manager in $_HypervisorManagers.members) + { + + $_uri = "hypervisorManagerUri='{0}'" -f $_manager.uri + + [void]$_HypervisorManagerUris.Add($_uri) + + } + + $_Filter = [System.Collections.ArrayList]::new() + + if ($Name) + { + + "[{0}] Filtering for Name: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Name | Write-Verbose + + if ($Name.Contains('*')) + { + + "[{0}] Filtering for Name: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Name | Write-Verbose + + [Void]$_Filter.Add(("name%3A{0}" -f $Name.Replace("*", "%2A").Replace(',','%2C').Replace(" ", "?"))) + + } + + else + { + + [Void]$_Filter.Add(("name:'{0}'" -f $Name)) + + } + + } + + # Build the final URI + $_uri = '{0}?filter="{1}{2}{3}"' -f $HypervisorClustersUri, [String]::Join(' OR ', $_HypervisorManagerUris.ToArray()), [String]::Join(' AND ', $_Filter.ToArray()), " AND state = 'Unmanaged'" + + Try + { + + $_resp = Send-OVRequest -Uri $_uri -Hostname $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + # This is DIFFERENT than a Cluster Profile + if ($_resp.Count -eq 0 -and $Name) + { + + "[{0}] Hypervisor Cluster Resource Name '{1}' was not found on appliance {2}. Generate Error." -f $MyInvocation.InvocationName.ToString().ToUpper(), $Name, $_appliance.Name | Write-Verbose + + $ExceptionMessage = "The specified Cluster '{0}' was not found on '{1}' appliance connection. Please check the name again, and try again." -f $Name, $_appliance.Name + $ErrorRecord = New-ErrorRecord HPEOneView.Cluster.ClusterResourceException ClusterResourceNotFound ObjectNotFound "Name" -Message $ExceptionMessage + + $PSCmdlet.WriteError($ErrorRecord) + + } + + else + { + + ForEach ($_member in $_resp.members) + { + + $_member.PSObject.TypeNames.Insert(0,'HPEOneView.Cluster.HypervisorCluster') + + $_member + + } + + } + + } + + } + +} + +# // TODO: DEV TEST DOCUMENT +# Do members need to be shown? Maybe have the Add-OVClusterNode handle discovering new members that have yet to be added to cluster instead? +function Show-OVHypervisorClusterMember +{ + # .ExternalHelp HPEOneView.900.psm1-help.xml + [CmdletBinding (DefaultParameterSetName = 'Default')] + [OutputType([HPEOneView.Appliance.TaskResource])] + param + ( + ) +} +function New-OVClusterProfile +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = 'Default')] + [OutputType([HPEOneView.Appliance.TaskResource])] + param + ( + + [Parameter (Mandatory, ParameterSetName = 'Default')] + [Parameter (Mandatory, ParameterSetName = 'OverrideSettings')] + [Parameter (Mandatory, ParameterSetName = 'UnmanageVSwitch')] + [String]$Name, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [Parameter (Mandatory = $false, ParameterSetName = 'OverrideSettings')] + [Parameter (Mandatory = $false, ParameterSetName = 'UnmanageVSwitch')] + [String]$Description, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [Parameter (Mandatory = $false, ParameterSetName = 'OverrideSettings')] + [Parameter (Mandatory = $false, ParameterSetName = 'UnmanageVSwitch')] + [String]$ClusterPrefix, + + [Parameter (Mandatory, ParameterSetName = 'Default')] + [Parameter (Mandatory, ParameterSetName = 'OverrideSettings')] + [Parameter (Mandatory, ParameterSetName = 'UnmanageVSwitch')] + [ValidateNotNullOrEmpty()] + [HPEOneView.Cluster.HypervisorManager]$ClusterManager, + + [Parameter (Mandatory, ParameterSetName = 'Default')] + [Parameter (Mandatory, ParameterSetName = 'OverrideSettings')] + [Parameter (Mandatory, ParameterSetName = 'UnmanageVSwitch')] + [ValidateNotNullOrEmpty()] + [String]$ClusterManagerLocation, + + [Parameter (Mandatory, ParameterSetName = 'Default')] + [Parameter (Mandatory, ParameterSetName = 'OverrideSettings')] + [Parameter (Mandatory, ParameterSetName = 'UnmanageVSwitch')] + [ValidateNotNullOrEmpty()] + [Object]$ServerProfileTemplate, + + [Parameter (Mandatory, ParameterSetName = 'Default')] + [Parameter (Mandatory, ParameterSetName = 'OverrideSettings')] + [Parameter (Mandatory, ParameterSetName = 'UnmanageVSwitch')] + [ValidateNotNullOrEmpty()] + [SecureString]$ClusterPassword, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [Parameter (Mandatory = $false, ParameterSetName = 'OverrideSettings')] + [Parameter (Mandatory = $false, ParameterSetName = 'UnmanageVSwitch')] + [ValidateNotNullOrEmpty()] + [HPEOneView.Cluster.AddHostRequest[]]$Servers, + + [Parameter (Mandatory = $false, ParameterSetName = 'OverrideSettings')] + [Switch]$OverrideManagementAddressAssignmet, + + [Parameter (Mandatory = $false, ParameterSetName = 'OverrideSettings')] + [ValidateNotNullOrEmpty()] + [IPAddress]$SubnetMask, + + [Parameter (Mandatory = $false, ParameterSetName = 'OverrideSettings')] + [ValidateNotNullOrEmpty()] + [IPAddress]$Gateway, + + [Parameter (Mandatory = $false, ParameterSetName = 'OverrideSettings')] + [ValidateNotNullOrEmpty()] + [IPAddress]$PrimaryDNS, + + [Parameter (Mandatory = $false, ParameterSetName = 'OverrideSettings')] + [ValidateNotNullOrEmpty()] + [IPAddress]$SecondaryDNS, + + [Parameter (Mandatory = $false, ParameterSetName = 'OverrideSettings')] + [ValidateNotNullOrEmpty()] + [IPAddress]$TertiaryDNS, + + [Parameter (Mandatory = $false, ParameterSetName = 'OverrideSettings')] + [ValidateNotNullOrEmpty()] + [String]$Domain, + + [Parameter (Mandatory = $False, ParameterSetName = 'Default')] + [Parameter (Mandatory = $false, ParameterSetName = 'OverrideSettings')] + [Bool]$UseIPAddressAsHostName, + + [Parameter (Mandatory = $False, ParameterSetName = 'Default')] + [Parameter (Mandatory = $false, ParameterSetName = 'OverrideSettings')] + [Bool]$LeaveHostsInMaintenanceMode, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [Parameter (Mandatory = $false, ParameterSetName = 'OverrideSettings')] + [ValidateNotNullOrEmpty()] + [Object[]]$StorageVolume, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [Parameter (Mandatory = $false, ParameterSetName = 'OverrideSettings')] + [ValidateSet ('VMFS', 'Unmanaged')] + [String]$StorageVolumeFileSystem = "Unmanaged", + + [Parameter (Mandatory, ParameterSetName = 'UnmanageVSwitch')] + [ValidateNotNullOrEmpty()] + [Bool]$UnmanageVSwitch, + + [Parameter (Mandatory = $false, ParameterSetName = 'OverrideSettings')] + [Switch]$OverrideNetworkingConfig, + + [Parameter (Mandatory = $false, ParameterSetName = 'OverrideSettings')] + [ValidateNotNullOrEmpty()] + [Bool]$ConfigurePortGroups, + + [Parameter (Mandatory = $False, ParameterSetName = 'OverrideSettings')] + [ValidateNotNullOrEmpty()] + [HashTable]$VSwitchNameOverride, + + [Parameter (Mandatory = $False, ParameterSetName = 'OverrideSettings')] + [ValidateNotNullOrEmpty()] + [HashTable]$PortGroupNameOverride, + + [Parameter (Mandatory = $false, ParameterSetName = 'OverrideSettings')] + [Switch]$OverrideClusterManagerConfig, + + [Parameter (Mandatory = $false, ParameterSetName = 'OverrideSettings')] + [ValidateSet ('Distributed', 'Standard')] + [String]$VirtualSwitchType, + + [Parameter (Mandatory = $false, ParameterSetName = 'OverrideSettings')] + [ValidateSet ('AllNetworks', 'GeneralNetworks')] + [String]$DistributedSwitchUsage, + + [Parameter (Mandatory = $false, ParameterSetName = 'OverrideSettings')] + [ValidateSet ('4.0', '4.1.0', '5.0.0', '5.1.0', '5.5.0', '6.0', '6.7')] + [String]$DistributedSwitchVersion, + + [Parameter (Mandatory = $false, ParameterSetName = 'OverrideSettings')] + [Parameter (Mandatory = $false, ParameterSetName = 'UnmanageVSwitch')] + [ValidateNotNullOrEmpty()] + [Bool]$HAEnabled, + + [Parameter (Mandatory = $false, ParameterSetName = 'OverrideSettings')] + [Parameter (Mandatory = $false, ParameterSetName = 'UnmanageVSwitch')] + [ValidateNotNullOrEmpty()] + [Bool]$DRSEnabled, + + [Parameter (Mandatory = $false, ParameterSetName = 'OverrideSettings')] + [Parameter (Mandatory = $false, ParameterSetName = 'UnmanageVSwitch')] + [ValidateNotNullOrEmpty()] + [Bool]$MultiNicVMotionEnabled, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [Parameter (Mandatory = $false, ParameterSetName = 'OverrideSettings')] + [Parameter (Mandatory = $false, ParameterSetName = 'UnmanageVSwitch')] + [ValidateNotNullOrEmpty()] + [HPEOneView.Appliance.ScopeCollection[]]$Scope, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [Parameter (Mandatory = $false, ParameterSetName = 'OverrideSettings')] + [Parameter (Mandatory = $false, ParameterSetName = 'UnmanageVSwitch')] + [Switch]$Async, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [Parameter (Mandatory = $false, ParameterSetName = 'OverrideSettings')] + [Parameter (Mandatory = $false, ParameterSetName = 'UnmanageVSwitch')] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = ($ConnectedSessions | Where-Object Default) + + ) + + Begin + { + + "[{0}] Bound PS Parameters: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(),($PSBoundParameters | out-string) | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not($ConnectedSessions)) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command agian." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -gt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + # Parameter validation + if ($OverrideClusterManagerConfig.IsPresent -and -not $PSBoundParameters['VirtualSwitchType']) + { + + $ExceptionMessage = "The option to override the cluster manager networking configuration was selected, but the 'VirtualSwitchType' parameter is missing." + $ErrorRecord = New-ErrorRecord HPEOneView.Library.ParameterValidationException MissingParameter InvalidOperation 'VirtualSwitchType' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($OverrideClusterManagerConfig.IsPresent -and -not $PSBoundParameters['DistributedSwitchUsage']) + { + + $ExceptionMessage = "The option to override the cluster manager networking configuration was selected, but the 'DistributedSwitchUsage' parameter is missing." + $ErrorRecord = New-ErrorRecord HPEOneView.Library.ParameterValidationException MissingParameter InvalidOperation 'DistributedSwitchUsage' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($OverrideClusterManagerConfig.IsPresent -and -not $PSBoundParameters['DistributedSwitchVersion']) + { + + $ExceptionMessage = "The option to override the cluster manager networking configuration was selected, but the 'DistributedSwitchVersion' parameter is missing." + $ErrorRecord = New-ErrorRecord HPEOneView.Library.ParameterValidationException MissingParameter InvalidOperation 'DistributedSwitchVersion' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + # If Standard, check if $PSBoundParameters['DistributedSwitchUsage'] is provided, error if true + if ($PSBoundParameters['VirtualSwitchType'] -eq $ClusterProfileDistributedSwitchTypeEnum.Standard -and $PSBoundParameters['DistributedSwitchUsage']) + { + + $ExceptionMessage = "Setting the hypervisor VirtualSwitchType to 'Standard' and also setting the DistributeSwitchUsage is not supported." + $ErrorRecord = New-ErrorRecord HPEOneView.Library.ParameterValidationException InvalidVirtualSwitchTypeParameters InvalidOperation 'VirtualSwitchType' -Message $ExceptionMessage + + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + if ($PSBoundParameters['VirtualSwitchType'] -eq $ClusterProfileDistributedSwitchTypeEnum.Standard -and $PSBoundParameters['DistributedSwitchVersion']) + { + + $ExceptionMessage = "Setting the hypervisor VirtualSwitchType to 'Standard' and also setting the DistributedSwitchVersion is not supported." + $ErrorRecord = New-ErrorRecord HPEOneView.Library.ParameterValidationException InvalidVirtualSwitchTypeParameters InvalidOperation 'VirtualSwitchType' -Message $ExceptionMessage + + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + Process + { + + # When processing connections in the SPT, look to see if a subnetUri is provided for the network with Management purpose, + # and pull mask, gateway, and DNS from it. Or error the user hasn't provided that information. + + $_NewClusterProfile = NewObject -ClusterProfile + + switch ($PSBoundParameters.Keys) + { + + 'Name' + { + + $_NewClusterProfile.name = $Name + + if (-not $PSBoundParameters['ClusterPrefix']) + { + + $_NewClusterProfile.hypervisorHostProfileTemplate.hostPrefix = $Name + + } + + } + + 'Description' + { + + $_NewClusterProfile.description = $Description + + } + + 'ClusterPrefix' + { + + $_NewClusterProfile.hypervisorHostProfileTemplate.hostPrefix = $ClusterPrefix + + } + + 'ServerProfileTemplate' + { + + $_ClusterNetworkingLayoutRequest = $null + + $_NewClusterProfile.hypervisorHostProfileTemplate.serverProfileTemplateUri = $ServerProfileTemplate.uri + + # Need to process vSwitch configuration based on connections property of SPT and if UnmanageVSwitch is $false + if (-not $UnmanageVSwitch) + { + + "[{0}] Will manage cluster profile networking." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_ClusterNetworkingLayoutRequest = NewObject -ClusterNetworkingLayout + + # Set the SPT URI + $_ClusterNetworkingLayoutRequest.serverProfileTemplateUri = $ServerProfileTemplate.uri + + if ($OverrideClusterManagerConfig) + { + + "[{0}] Overriding cluster networking configuration." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + "[{0}] Overriding virtualSwitchType: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $VirtualSwitchType | Write-Verbose + + $_ClusterNetworkingLayoutRequest.hypervisorClusterSettings.virtualSwitchType = $VirtualSwitchType + + "[{0}] Overriding distributedSwitchUsage: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $DistributedSwitchUsage | Write-Verbose + + $_ClusterNetworkingLayoutRequest.hypervisorClusterSettings.distributedSwitchUsage = $DistributedSwitchUsage + + "[{0}] Overriding distributedSwitchVersion: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $DistributedSwitchVersion | Write-Verbose + + # Check to make sure provided version is within $InputObject.AvailableDvsVersions.Contains($DistributedSwitchVersion) + if (-not $ClusterManager.AvailableDvsVersions.Contains($DistributedSwitchVersion)) + { + + $ExceptionMessage = "The Hypervisor Manager '{0}' does not support the requested DistributedSwitchVersion '{1}'. Please specify one of the valid supported versions: {2}" -f $ClusterManager.name, $DistributedSwitchVersion, [String]::Join(', ', $ClusterManager.AvailableDvsVersions) + $ErrorRecord = New-ErrorRecord HPEOneView.HypervisorManagerException UnsupportedVirtualSwitchVersion InvalidOperation 'DistributedSwitchVersion' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + $_ClusterNetworkingLayoutRequest.hypervisorClusterSettings.distributedSwitchVersion = $DistributedSwitchVersion + + if ($PSBoundParameters.Keys -contains 'MultiNicVMotionEnabled') + { + + "[{0}] Overriding multiNicVMotion: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $MultiNicVMotionEnabled | Write-Verbose + + $_ClusterNetworkingLayoutRequest.hypervisorClusterSettings.multiNicVMotion = $MultiNicVMotionEnabled + + } + + } + + # Use the Hypervisor Manager settings + else + { + + "[{0}] Will use default cluster manager network settings." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_ClusterNetworkingLayoutRequest.hypervisorClusterSettings.virtualSwitchType = $ClusterManager.Preferences.VirtualSwitchType + + if ($ClusterManager.Preferences.VirtualSwitchType -ne $ClusterProfileDistributedSwitchTypeEnum.Standard) + { + + $_ClusterNetworkingLayoutRequest.hypervisorClusterSettings.distributedSwitchUsage = $ClusterManager.Preferences.DistributedSwitchUsage + $_ClusterNetworkingLayoutRequest.hypervisorClusterSettings.distributedSwitchVersion = $ClusterManager.Preferences.DistributedSwitchVersion + + } + + $_ClusterNetworkingLayoutRequest.hypervisorClusterSettings.multiNicVMotion = $ClusterManager.Preferences.MultiNicVMotion + + } + + if ($PSBoundParameters.Keys -contains 'ConfigurePortGroups') + { + + "[{0}] Will not create port groups." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_ClusterNetworkingLayoutRequest.virtualSwitchConfigPolicy.configurePortGroups = $ConfigurePortGroups + + } + + # Generate a new vSwitch Layout + Try + { + + $_ClusterNetworkingLayoutResults = Send-OVRequest -Uri $GenerateClusterProfileNetworkingLayoutUri -Method POST -Body $_ClusterNetworkingLayoutRequest -Hostname $ServerProfileTemplate.ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + # Or based on the override vswitch configuration + + # [Parameter (Mandatory = $False, ParameterSetName = 'Default')] + # [Parameter (Mandatory = $False, ParameterSetName = 'OverrideVswitchConfig')] + # [ValidateNotNullOrEmpty()] + # [HashTable]$VSwitchNameOverride, # @{ "NetworkName" = "OverrideName" } + + # [Parameter (Mandatory = $False, ParameterSetName = 'Default')] + # [Parameter (Mandatory = $False, ParameterSetName = 'OverrideVswitchConfig')] + # [ValidateNotNullOrEmpty()] + # [HashTable]$PortGroupNameOverride, # @{ "NetworkName" = "OverrideName" } + + ForEach ($_NetConf in $_ClusterNetworkingLayoutResults) + { + + [void]$_NewClusterProfile.hypervisorHostProfileTemplate.virtualSwitches.Add($_NetConf) + + } + + } + + else + { + + "[{0}] Will not manage cluster profile networking." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + if ($OverrideManagementAddressAssignmet) + { + + # Check if the SPT is set to auto or static IP Address management + if (($ServerProfileTemplate.osDeploymentSettings.osCustomAttributes | Where-Object name -match '.dhcp').value -ne $true -and -not ($ServerProfileTemplate.osDeploymentSettings.osCustomAttributes | Where-Object name -match '.ipaddress')) + { + + $ExceptionMessage = "IP configuration in server profile template is set to Auto but static IP configuration is provided in cluster profile." + $ErrorRecord = New-ErrorRecord HPEOneView.Library.ParameterValidationException InvalidOverrideManagementAddressAssignmetParameter InvalidOperation 'OverrideManagementAddressAssignmet' -Message $ExceptionMessage + + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif (($ServerProfileTemplate.osDeploymentSettings.osCustomAttributes | Where-Object name -match '.dhcp').value -eq $true -and -not ($ServerProfileTemplate.osDeploymentSettings.osCustomAttributes | Where-Object name -match '.ipaddress')) + { + + $ExceptionMessage = "IP configuration in server profile template is set to DHCP but static IP configuration is provided in cluster profile." + $ErrorRecord = New-ErrorRecord HPEOneView.Library.ParameterValidationException InvalidOverrideManagementAddressAssignmetParameter InvalidOperation 'OverrideManagementAddressAssignmet' -Message $ExceptionMessage + + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + "[{0}] Overriding cluster management address assignment." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_NewClusterProfile | Add-Member -NotePropertyName mgmtIpSettingsOverride -NotePropertyValue (NewObject -ClusterProfileOverrideMgmtIPSettings) + + $_NewClusterProfile.mgmtIpSettingsOverride.netMask = $SubnetMask + $_NewClusterProfile.mgmtIpSettingsOverride.gateway = $Gateway + + if ($PSBoundParameters['PrimaryDNS']) + { + + $_NewClusterProfile.mgmtIpSettingsOverride.primaryDns = $PrimaryDNS + + } + + if ($PSBoundParameters['SecondaryDNS']) + { + + $_NewClusterProfile.mgmtIpSettingsOverride.secondaryDns = $SecondaryDNS + + } + + if ($PSBoundParameters['TertiaryDNS']) + { + + $_NewClusterProfile.mgmtIpSettingsOverride.tertiaryDNS = $TertiaryDNS + + } + + if ($PSBoundParameters['Domain']) + { + + $_NewClusterProfile.mgmtIpSettingsOverride.dnsDomain = $Domain + + } + + } + + } + + 'ClusterPassword' + { + + $_NewClusterProfile.hypervisorHostProfileTemplate.deploymentPlan.serverPassword = [Runtime.InteropServices.Marshal]::PtrToStringBSTR([Runtime.InteropServices.Marshal]::SecureStringToBSTR($ClusterPassword)) + + } + + 'Scope' + { + + ForEach ($_Scope in $Scope) + { + + "[{0}] Adding resource to Scope: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_Scope.Name | Write-Verbose + + [void]$_NewClusterProfile.initialScopeUris.Add($_Scope.Uri) + + } + + } + + 'VirtualSwitchType' + { + + "[{0}] Setting VirtualSwitchType to: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $VirtualSwitchType | Write-Verbose + + $_NewClusterProfile.hypervisorClusterSettings.virtualSwitchType = $VirtualSwitchType + + } + + 'DistributedSwitchVersion' + { + + # Check to make sure provided version is within $InputObject.AvailableDvsVersions.Contains($DistributedSwitchVersion) + if (-not $ClusterManager.AvailableDvsVersions.Contains($DistributedSwitchVersion)) + { + + $ExceptionMessage = "The Hypervisor Manager '{0}' does not support the requested DistributedSwitchVersion '{1}'. Please specify one of the valid supported versions: {2}" -f $InputObject.name, $DistributedSwitchVersion, [String]::Join(', ', $InputObject.AvailableDvsVersions) + $ErrorRecord = New-ErrorRecord HPEOneView.HypervisorManagerException UnsupportedVirtualSwitchVersion InvalidOperation 'DistributedSwitchVersion' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + "[{0}] Setting DistributedSwitchVersion to: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $DistributedSwitchVersion | Write-Verbose + + $_NewClusterProfile.hypervisorClusterSettings.distributedSwitchVersion = $DistributedSwitchVersion + + } + + 'DistributedSwitchUsage' + { + + "[{0}] Setting DistributedSwitchUsage to: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $DistributedSwitchUsage | Write-Verbose + + $_NewClusterProfile.hypervisorClusterSettings.distributedSwitchUsage = $DistributedSwitchUsage + + } + + 'HAEnabled' + { + + "[{0}] Updating HAEnabled to: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $HAEnabled | Write-Verbose + + $_NewClusterProfile.hypervisorClusterSettings.haEnabled = $HAEnabled + + } + + 'DRSEnabled' + { + + "[{0}] Updating DRSEnabled to: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $DRSEnabled | Write-Verbose + + $_NewClusterProfile.hypervisorClusterSettings.drsEnabled = $DRSEnabled + + } + + 'MultiNicVMotionEnabled' + { + + "[{0}] Updating MultiNicVMotionEnabled to: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $MultiNicVMotionEnabled | Write-Verbose + + $_NewClusterProfile.hypervisorClusterSettings.multiNicVMotion = $MultiNicVMotionEnabled + + } + + 'ClusterManager' + { + + if ($PSCmdlet.ParameterSetName -eq 'Default' -and -not $OverrideClusterManagerConfig.IsPresent) + { + + "[{0}] Using hypervisor managers default networking preferences" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if ($ClusterManager.Preferences.VirtualSwitchType -eq 'Distributed') + { + + $_NewClusterProfile.hypervisorClusterSettings.distributedSwitchVersion = $ClusterManager.Preferences.DistributedSwitchVersion + $_NewClusterProfile.hypervisorClusterSettings.distributedSwitchUsage = $ClusterManager.Preferences.DistributedSwitchUsage + + } + + $_NewClusterProfile.hypervisorClusterSettings.drsEnabled = $ClusterManager.Preferences.DrsEnabled + $_NewClusterProfile.hypervisorClusterSettings.haEnabled = $ClusterManager.Preferences.HaEnabled + $_NewClusterProfile.hypervisorClusterSettings.multiNicVMotion = $ClusterManager.Preferences.MultiNicVMotion + $_NewClusterProfile.hypervisorClusterSettings.virtualSwitchType = $ClusterManager.Preferences.VirtualSwitchType + + } + + $_NewClusterProfile.hypervisorManagerUri = $ClusterManager.Uri + $_NewClusterProfile.path = $Path + + } + + 'ClusterManagerLocation' + { + + # Generate error that path is not valid + $_FilterDelegate = [Func[object,bool]]{ param ($p) return $p.UserPath -eq $ClusterManagerLocation } + + if (-not [Linq.Enumerable]::ToArray([System.Linq.Enumerable]::Where($ClusterManager.Locations, $_FilterDelegate))) + { + + $ExceptionMessage = "The provided cluster manager location '{0}' is not found in '{1}' cluster manager." -f $ClusterManagerLocation, $ClusterManager.Name + $ErrorRecord = New-ErrorRecord HPEOneView.Library.ParameterValidationException InvalidClusterManagerLocationParameter InvalidOperation 'ClusterManagerLocation' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + "[{0}] Setting hypervisor manager location: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $ClusterManagerLocation | Write-Verbose + + $_NewClusterProfile.path = $ClusterManagerLocation + + } + + 'UnmanageVSwitch' + { + + $_NewClusterProfile.hypervisorHostProfileTemplate.virtualSwitchConfigPolicy.manageVirtualSwitches = -not $UnmanageVSwitch + + # If UnmanageVSwitch is True, then ConfigurePortGroups needs to be disabled + if ($UnmanageVSwitch) + { + + $_NewClusterProfile.hypervisorHostProfileTemplate.virtualSwitchConfigPolicy.configurePortGroups = -not $UnmanageVSwitch + + } + + } + + 'ConfigurePortGroups' + { + + $_NewClusterProfile.hypervisorHostProfileTemplate.virtualSwitchConfigPolicy.configurePortGroups = $ConfigurePortGroups + + } + + # Add hypervisor nodes + 'Servers' + { + + ForEach ($_Server in $Servers) + { + + # Generate error that overrride management address assignment was set, but the Add Hosts request contains an empty mgmtIp value + if ($OverrideManagementAddressAssignmet -and [String]::IsNullOrEmpty($_Server.mgmtIp) -and + ($ServerProfileTemplate.osDeploymentSettings.osCustomAttributes | Where-Object name -match '.dhcp').value -eq $false -and + ($ServerProfileTemplate.osDeploymentSettings.osCustomAttributes | Where-Object name -match '.ipaddress')) + { + + $ExceptionMessage = "IP configuration in server profile template is set to DHCP but static IP configuration is provided in cluster profile." + $ErrorRecord = New-ErrorRecord HPEOneView.Library.ParameterValidationException InvalidOverrideManagementAddressAssignmetParameter InvalidOperation 'OverrideManagementAddressAssignmet' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + [Void]$_NewClusterProfile.addHostRequests.Add($_Server) + + } + + } + + 'StorageVolume' + { + + ForEach ($_Volume in $StorageVolume) + { + + $_SharedVolumeToAdd = NewObject -ClusterProfileSharedStorageVolume + + $_SharedVolumeToAdd.storageVolumeUri = $_Volume.uri + $_SharedVolumeToAdd.volumeFileSystemType = $StorageVolumeFileSystem + + [void]$_NewClusterProfile.sharedStorageVolumes.Add($_SharedVolumeToAdd) + + } + + } + + 'LeaveHostsInMaintenanceMode' + { + + $_NewClusterProfile.hypervisorHostProfileTemplate.hostConfigPolicy.leaveHostInMaintenance = $LeaveHostsInMaintenanceMode + + } + + 'UseIPAddressAsHostName' + { + + $_NewClusterProfile.hypervisorHostProfileTemplate.hostConfigPolicy.useHostnameToRegister = -not $UseIPAddressAsHostName + + } + + } + + Try + { + + $_resp = Send-OVRequest -Uri $ClusterProfilesUri -Method POST -Body $_NewClusterProfile -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if (-not $Async.IsPresent) + { + + $_resp | Wait-OVTaskComplete + + } + + else + { + + $_resp + + } + + } + + end + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper(), $Namreposie, $_appliance.Name | Write-Verbose + + } + +} + +function New-OVClusterProfileMember +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = 'Default')] + [OutputType([HPEOneView.Cluster.AddHostRequest])] + param + ( + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [Alias('Server')] + [Object]$InputObject, + + [Parameter (ParameterSetName = 'Default', Mandatory = $false)] # Not needed if management network is associated with an IP Address Pool + [ValidateNotNullOrEmpty()] + [IPAddress]$IPv4Address, + + [Parameter (ParameterSetName = 'Default', Mandatory = $false)] + [ValidateNotNullOrEmpty()] + [HPEOneView.ServerProfile.OSDeployment.OSDeploymentParameter[]]$OSDeploymentAttributes + + ) + + Begin + { + + "[{0}] Bound PS Parameters: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(),($PSBoundParameters | out-string) | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + } + + Process + { + + if ($PSBoundParameters['OSDeploymentAttributes'] -and $PSBoundParameters['IPv4Address']) + { + + [HPEOneView.Cluster.AddHostRequest]::new($InputObject.uri, $IPv4Address, $OSDeploymentAttributes) + + } + + elseif ($PSBoundParameters['OSDeploymentAttributes']) + { + + [HPEOneView.Cluster.AddHostRequest]::new($InputObject.uri, $OSDeploymentAttributes) + + } + + elseif ($PSBoundParameters['IPv4Address']) + { + + [HPEOneView.Cluster.AddHostRequest]::new($InputObject.uri, $IPv4Address) + + } + + else + { + + [HPEOneView.Cluster.AddHostRequest]::new($InputObject.uri) + + } + + } + + end + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper(), $Name, $_appliance.Name | Write-Verbose + + } + +} + +# //TODO: DEV, Document, Test +function Import-OVClusterProfile +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = 'Default')] + [OutputType([HPEOneView.Appliance.TaskResource])] + param + ( + + [Parameter (Mandatory, ParameterSetName = 'Default')] + [Alias('Name')] + [String]$Name, + + [Parameter (Mandatory, ParameterSetName = 'Default')] # GET FROM SHOW-OVHypervisorCluster + [Object]$Cluster, + + [Parameter (Mandatory, ParameterSetName = 'Default')] + [ValidateScript ({if (-not ($_.category -eq $ResourceCategoryEnum.ClusterProfile)) { + + Throw "'$($_.category)' is not an allowed resource category. The resource object category must be '$($ResourceCategoryEnum.ClusterProfile)'. Please check the value and try again." + } + else { $True }})] + [Object[]]$ServerProfile, + + [Parameter (ParameterSetName = 'Default', Mandatory = $false)] + [ValidateNotNullOrEmpty()] + [HPEOneView.Appliance.ScopeCollection[]]$Scope, + + [Parameter (ParameterSetName = 'Default', Mandatory = $false)] + [Switch]$Async, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = ($ConnectedSessions | Where-Object Default) + + ) + + Begin + { + + "[{0}] Bound PS Parameters: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(),($PSBoundParameters | out-string) | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not($ConnectedSessions)) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command agian." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -gt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + Process + { + + ForEach ($_appliance in $ApplianceConnection) + { + + "[{0}] Processing appliance {1} (of {2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name, $ApplianceConnection.Count | Write-Verbose + + $_Query = [System.Collections.ArrayList]::new() + + # Handle default cause of AllResourcesInScope + if ($Scope -eq 'AllResourcesInScope') + { + + "[{0}] Processing AllResourcesInScope." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_Scopes = $_appliance.ActivePermissions | Where-Object Active + + # If one scope contains 'AllResources' ScopeName "tag", then all resources should be returned regardless. + if ($_Scopes | Where-Object ScopeName -eq 'AllResources') + { + + $_ScopeNames = [String]::Join(', ', ($_Scopes | Where-Object ScopeName -eq 'AllResources').ScopeName) + + "[{0}] Scope(s) {1} is set to 'AllResources'. Will not add scope to URI query parameter." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_ScopeNames | Write-Verbose + + } + + # Process ApplianceConnection ActivePermissions collection + else + { + + Try + { + + $_ScopeQuery = Join-Scope $_Scopes + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + [Void]$_Query.Add(("({0})" -f $_ScopeQuery)) + + } + + } + + elseif ($Scope | Where-Object ScopeName -eq 'AllResources') + { + + $_ScopeNames = [String]::Join(', ', ($_Scopes | Where-Object ScopeName -eq 'AllResources').ScopeName) + + "[{0}] Scope(s) {1} is set to 'AllResources'. Will not add scope to URI query parameter." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_ScopeNames | Write-Verbose + + } + + elseif ($Scope -eq 'AllResources') + { + + "[{0}] Requesting scope 'AllResources'. Will not add scope to URI query parameter." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_ScopeNames | Write-Verbose + + } + + else + { + + Try + { + + $_ScopeQuery = Join-Scope $Scope + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + [Void]$_Query.Add(("({0})" -f $_ScopeQuery)) + + } + + if ($Name) + { + + "[{0}] Filtering for Name: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Name | Write-Verbose + + if ($Name.Contains('*')) + { + + "[{0}] Filtering for Name: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Name | Write-Verbose + + [Void]$_Query.Add(("name%3A{0}" -f $Name.Replace("*", "%2A").Replace(',','%2C').Replace(" ", "?"))) + + } + + else + { + + [Void]$_Query.Add(("name:'{0}'" -f $Name)) + + } + + } + + if ($Label) + { + + [Void]$_Query.Add(("labels:'{0}'" -f $Label)) + + } + + $_Category = 'category={0}' -f $ResourceCategoryEnum.ClusterProfiles + + # Build the final URI + $_uri = '{0}?{1}&sort=name:asc&query={2}' -f $IndexUri, [String]::Join('&', $_Category), [String]::Join(' AND ', $_Query.ToArray()) + + Try + { + + [Array]$_ResourcesFromIndexCol = Get-AllIndexResources -Uri $_uri -ApplianceConnection $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if($_ResourcesFromIndexCol.Count -eq 0 -and $Name) + { + + "[{0}] ClusterProfile Resource Name '{1}' was not found on appliance {2}. Generate Error." -f $MyInvocation.InvocationName.ToString().ToUpper(), $Name, $_appliance.Name | Write-Verbose + + $ExceptionMessage = "The specified ClusterProfile '{0}' was not found on '{1}' appliance connection. Please check the name again, and try again." -f $Name, $_appliance.Name + $ErrorRecord = New-ErrorRecord HPEOneView.Cluster.ClusterProfileResourceException ClusterProfileResourceNotFound ObjectNotFound "Name" -Message $ExceptionMessage + + $PSCmdlet.WriteError($ErrorRecord) + + } + + else + { + + ForEach ($_member in $_ResourcesFromIndexCol) + { + + $_member.PSObject.TypeNames.Insert(0,'HPEOneView.Cluster.ClusterProfile') + + $_member + + } + + } + + } + + } + + end + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +# //TODO: DEV, Document, Test +# Maybe this Cmdlet supports two cases: +# 1. Add a new member to an existing cluster, which would require Synergy and I3S +# 2. Import deployed cluster node outside of OV +function Add-OVClusterNode +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "Default")] + [OutputType([HPEOneView.Appliance.TaskResource])] + param + ( + + [Parameter (Mandatory, ParameterSetName = "Default")] + [Alias("Name")] + [String]$ComputerName, + + [Parameter (Mandatory, ParameterSetName = "Default")] + [PSCredential]$Credential, + + [Parameter (ParameterSetName = "Default", Mandatory = $false)] + [ValidateNotNullOrEmpty()] + [HPEOneView.Appliance.ScopeCollection[]]$Scope, + + [Parameter (ParameterSetName = "Default", Mandatory = $false)] + [Switch]$Async, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [ValidateNotNullOrEmpty()] + [Alias ("Appliance")] + [Object]$ApplianceConnection = ($ConnectedSessions | Where-Object Default) + + ) + + Begin + { + + "[{0}] Bound PS Parameters: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(),($PSBoundParameters | out-string) | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not($ConnectedSessions)) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command agian." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -gt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + Process + { + + if ($PSBoundParameters["Scope"]) + { + + $_InitialScopeUris = [System.Collections.Generic.List[String]]::new() + + ForEach ($_Scope in $Scope) + { + + "[{0}] Adding resource to Scope: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_Scope.Name | Write-Verbose + + $_InitialScopeUris.Add($_Scope.Uri) + + } + + } + + $_Import = NewObject -AddCategoryType + + Try + { + + $_resp = Send-OVRequest -Uri Uri -Method POST -Body $_Import -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if (-not $Async.IsPresent) + { + + $_resp | Wait-OVTaskComplete + + } + + else + { + + $_resp + + } + + } + + end + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Update-OVClusterProfile +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = 'Default', SupportsShouldProcess, ConfirmImpact = 'High')] + [OutputType([HPEOneView.Cluster.CompliancePreview])] + [OutputType([HPEOneView.Appliance.TaskResource])] + param + ( + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = 'Default')] + [Alias('Name')] + [Object]$InputObject, + + [Parameter (ParameterSetName = 'Default', Mandatory = $false)] + [Switch]$Async, + + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = ($ConnectedSessions | Where-Object Default) + + ) + + Begin + { + + "[{0}] Bound PS Parameters: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(),($PSBoundParameters | out-string) | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not($PSBoundParameters['InputObject'])) + { + + $Pipelineinput = $True + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not($ConnectedSessions)) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command agian." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -gt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + } + + Process + { + + if ($PipelineInput) + { + + "[{0}] Processing Pipeline input." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + # Process server profile resource name + if ($InputObject -is [String]) + { + + Try + { + + $InputObject = Get-OVClusterProfile -Name $InputObject -ApplianceConnection $ApplianceConnect -ErrorAction Stop + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + # Not sure if I want to support this. Should 1 server hardware of a cluster be provided? + # Validate the Input object is the allowed category + elseif ($InputObject.category -ne $ResourceCategoryEnum.ClusterProfile) + { + + $ExceptionMessage = "The provided InputObject object ({0}) category '{1}' is not an allowed value. Expected category value is '{2}'. Please correct your input value." -f $InputObject.name, $InputObject.category, $ResourceCategoryEnum.ClusterProfile + $ErrorRecord = New-ErrorRecord HPEOneView.InputObjectResourceException InvalidResourceObject InvalidArgument 'InputObject' -TargetType 'PSObject' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + if (-not $InputObject.ApplianceConnection) + { + + $ExceptionMessage = "The provided InputObject object ({0}) does not contain the required 'ApplianceConnection' object property. Please correct your input value." -f $InputObject.name + $ErrorRecord = New-ErrorRecord HPEOneView.InputObjectResourceException MissingApplianceConnectionProperty InvalidArgument 'InputObject' -TargetType 'PSObject' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + "[{0}] Processing Server Profile: '{1} [{2}]'" -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject.name, $InputObject.uri | Write-Verbose + + "{0}] Is Server Profile 'Compliant': {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject.templateCompliance | Write-Verbose + + if ($InputObject.complianceState -ne $ClusterProfileComplianceStateEnum.Consistent.State) + { + + try + { + + $_cpUpdateOperations = Send-OVRequest -Uri ($InputObject.uri + '/compliance-preview') -Hostname $InputObject.ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $ReviewObject = [HPEOneView.Cluster.CompliancePreview]::new($InputObject.hostProfileName, + $_cpUpdateOperations.isOnlineUpdate, + $_cpUpdateOperations.ApplianceConnection) + + $_cpUpdateOperations.serverProfileComplianceDetails.automaticUpdates | ForEach-Object { [void]$ReviewObject.AutomaticUpdates.Add((ConvertFromEmbeddedJsonString $_)) } + $_cpUpdateOperations.hypervisorProfileComplianceDetails.automaticUpdates | ForEach-Object { [void]$ReviewObject.AutomaticUpdates.Add((ConvertFromEmbeddedJsonString $_)) } + $_cpUpdateOperations.serverProfileComplianceDetails.manualUpdates | ForEach-Object { [void]$ReviewObject.ManualUpdates.Add((ConvertFromEmbeddedJsonString $_)) } + $_cpUpdateOperations.hypervisorProfileComplianceDetails.manualUpdates | ForEach-Object { [void]$ReviewObject.ManualUpdates.Add((ConvertFromEmbeddedJsonString $_)) } + + $_ShouldProcessMessage = "Update Cluster Profile configuration. WARNING: Depending on this action, there might be a brief outage." + + if ($PSCmdlet.ShouldProcess($InputObject.name, $ClusterProfileComplianceStateEnum.($InputObject.complianceState).Message)) + { + + "[{0}] Sending request to {1} configuration" -f $MyInvocation.InvocationName.ToString().ToUpper(), $PSCmdlet.ParameterSetName | Write-Verbose + + Try + { + + $_task = Send-OVRequest -Uri $InputObject.uri -Method PATCH -Body $_Operation -Hostname $InputObject.ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if (-not($PSBoundParameters['Async'])) + { + + $_task = $_task | Wait-OVTaskComplete + + } + + $_task + + } + + elseif ($PSBoundParameters['WhatIf']) + { + + "[{0}] User included -WhatIf." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + # Need to return the HPEOneView.Cluster.CompliancePreview object + $ReviewObject + + } + + else + { + + "[{0}] User cancelled." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + } + + else + { + + Write-Warning ('Skipping {0} Cluster Profile, as it is Compliant.' -f $InputObject.name) + + } + + } + + end + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper(), $Name, $_appliance.Name | Write-Verbose + + } + +} + +# //TODO: DEV, Document, Test +function Update-OVClusterNode +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = 'Default', SupportsShouldProcess, ConfirmImpact = 'High')] + [OutputType([HPEOneView.Cluster.CompliancePreview])] + [OutputType([HPEOneView.Appliance.TaskResource])] + param + ( + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = 'Default')] + [Alias('Name')] + [Object]$InputObject, + + [Parameter (ParameterSetName = 'Default', Mandatory = $false)] + [Switch]$Async, + + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = ($ConnectedSessions | Where-Object Default) + + ) + + Begin + { + + "[{0}] Bound PS Parameters: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(),($PSBoundParameters | out-string) | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not($PSBoundParameters['InputObject'])) + { + + $Pipelineinput = $True + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not($ConnectedSessions)) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command agian." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -gt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + } + + Process + { + + if ($PipelineInput) + { + + "[{0}] Processing Pipeline input." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + # Process server profile resource name + if ($InputObject -is [String]) + { + + Try + { + + $InputObject = Get-OVClusterNode -Name $InputObject -ApplianceConnection $ApplianceConnect -ErrorAction Stop + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + # Not sure if I want to support this. Should 1 server hardware of a cluster be provided? + # Validate the Input object is the allowed category + elseif ($InputObject.category -ne $ResourceCategoryEnum.ClusterProfile) + { + + $ExceptionMessage = "The provided InputObject object ({0}) category '{1}' is not an allowed value. Expected category value is '{2}'. Please correct your input value." -f $InputObject.name, $InputObject.category, $ResourceCategoryEnum.ClusterProfile + $ErrorRecord = New-ErrorRecord HPEOneView.InputObjectResourceException InvalidResourceObject InvalidArgument 'InputObject' -TargetType 'PSObject' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + if (-not $InputObject.ApplianceConnection) + { + + $ExceptionMessage = "The provided InputObject object ({0}) does not contain the required 'ApplianceConnection' object property. Please correct your input value." -f $InputObject.name + $ErrorRecord = New-ErrorRecord HPEOneView.InputObjectResourceException MissingApplianceConnectionProperty InvalidArgument 'InputObject' -TargetType 'PSObject' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + "[{0}] Processing Cluster Profile Host: '{1} [{2}]'" -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject.name, $InputObject.uri | Write-Verbose + + "{0}] Is Cluster Profile Host 'Compliant': {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject.templateCompliance | Write-Verbose + + if ($InputObject.complianceState -ne $ClusterProfileComplianceStateEnum.Consistent.State) + { + + try + { + + $_cpUpdateOperations = Send-OVRequest -Uri ($InputObject.uri + '/compliance-preview') -Hostname $InputObject.ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $ReviewObject = [HPEOneView.Cluster.CompliancePreview]::new($InputObject.hostProfileName, + $_cpUpdateOperations.isOnlineUpdate, + $_cpUpdateOperations.ApplianceConnection) + + $_cpUpdateOperations.serverProfileComplianceDetails.automaticUpdates | ForEach-Object { [void]$ReviewObject.AutomaticUpdates.Add((ConvertFromEmbeddedJsonString $_)) } + $_cpUpdateOperations.hypervisorProfileComplianceDetails.automaticUpdates | ForEach-Object { [void]$ReviewObject.AutomaticUpdates.Add((ConvertFromEmbeddedJsonString $_)) } + $_cpUpdateOperations.serverProfileComplianceDetails.manualUpdates | ForEach-Object { [void]$ReviewObject.ManualUpdates.Add((ConvertFromEmbeddedJsonString $_)) } + $_cpUpdateOperations.hypervisorProfileComplianceDetails.manualUpdates | ForEach-Object { [void]$ReviewObject.ManualUpdates.Add((ConvertFromEmbeddedJsonString $_)) } + + $_ShouldProcessMessage = "Update Cluster Profile Host configuration. WARNING: Depending on this action, there might be a brief outage." + + if ($PSCmdlet.ShouldProcess($InputObject.name, $ClusterProfileComplianceStateEnum.($InputObject.complianceState).Message)) + { + + "[{0}] Sending request to {1} configuration" -f $MyInvocation.InvocationName.ToString().ToUpper(), $PSCmdlet.ParameterSetName | Write-Verbose + + Try + { + + $_task = Send-OVRequest -Uri $InputObject.uri -Method PATCH -Body $_Operation -Hostname $InputObject.ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if (-not($PSBoundParameters['Async'])) + { + + $_task = $_task | Wait-OVTaskComplete + + } + + $_task + + } + + elseif ($PSBoundParameters['WhatIf']) + { + + "[{0}] User included -WhatIf." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + # Need to return the HPEOneView.Cluster.CompliancePreview object + $ReviewObject + + } + + else + { + + "[{0}] User cancelled." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + } + + else + { + + Write-Warning ('Skipping {0} Cluster Profile, as it is Compliant.' -f $InputObject.name) + + } + + } + + end + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper(), $Name, $_appliance.Name | Write-Verbose + + } + +} + +function Remove-OVClusterProfile +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "Default", SupportsShouldProcess, ConfirmImpact = 'High')] + [OutputType([HPEOneView.Appliance.TaskResource])] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [Object]$InputObject, + + [Parameter (Mandatory = $False, ParameterSetName = 'Default')] + [Switch]$Force, + + [Parameter (Mandatory = $False, ValueFromPipelineByPropertyName, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not($PSBoundParameters['InputObject'])) + { + + $Pipelineinput = $True + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ExceptionMessage = "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command agian." + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + } + + Process + { + + Write-Warning -Message "**** WARNING **** - Removing a Cluster Profile from OneView also destroys the cluster within the cluster manager. Do not remove the cluster profile unless you intend to also destroy the cluster within the cluster manager." + + $RemoveMessage = "remove '{0}' {1}" -f $InputObject.name, $ResourceCategoryEnum.ClusterProfile + + if ($PSCmdlet.ShouldProcess($InputObject.ApplianceConnection, $RemoveMessage)) + { + + "[{0}] Removing resource: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), ($InputObject | Out-String) | Write-Verbose + "[{0}] URI: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject.uri | Write-Verbose + + $_Uri = '{0}' -f $InputObject.uri + + if ($Force) + { + + $_Uri += '?force=true' + + } + + try + { + + Send-OVRequest -Uri $_Uri -Method DELETE -AddHeader @{'If-Match' = $InputObject.eTag } -Hostname $InputObject.ApplianceConnection + + } + + catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + elseif ($PSBoundParameters['whatif']) + { + + "[{0}] -WhatIf was passed" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Enter-OVClusterNodeMaintenanceMode +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = 'Default', SupportsShouldProcess, ConfirmImpact = 'High')] + [OutputType([HPEOneView.Appliance.TaskResource])] + param + ( + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = 'Default')] + [Alias('Name')] + [Object]$InputObject, + + [Parameter (ParameterSetName = 'Default', Mandatory = $false)] + [Switch]$Async, + + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = ($ConnectedSessions | Where-Object Default) + + ) + + Begin + { + + "[{0}] Bound PS Parameters: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(),($PSBoundParameters | out-string) | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not($PSBoundParameters['InputObject'])) + { + + $Pipelineinput = $True + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not($ConnectedSessions)) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command agian." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -gt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + } + + Process + { + + if ($InputObject.type -notmatch $ClusterProfileHostType) + { + + "[{0}] Invalid InputObject provided. Generate Error." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $ExceptionMessage = "The provided InputObject parameter value is not a valid ClusterProfileHost resource." + $ErrorRecord = New-ErrorRecord HPEOneView.InputObjectResourceException InvalidResourceObject InvalidArgument "InputObject" -TargetType $InputObject.GetType().Name -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + if ($InputObject.powerState -ne $ClusterProfileHostPowerStateEnum.On) + { + + "[{0}] ClusterProfileHost not in PoweredOn state, '{1}'. Generating error." -f $MyInvocation.InvocationName.ToString().ToUpper(), $ClusterProfileHostPowerStateEnum[$InputObject.powerState].Value | Write-Verbose + + $ExceptionMessage = "The provided InputObject parameter value is not a valid ClusterProfileHost resource." + $ErrorRecord = New-ErrorRecord HPEOneView.InputObjectResourceException InvalidResourceObject InvalidArgument "InputObject" -TargetType $InputObject.GetType().Name -Message $ExceptionMessage + $PSCmdlet.WriteError($ErrorRecord) + + } + + else + { + + $_InputObject = $InputObject.PSObject.Copy() + + $_InputObject.powerState = $ClusterProfileHostPowerStateEnum.EnterMaintenanceMode + + Try + { + + $_resp = Send-OVRequest -Uri $_InputObject.uri -Method PUT -Body $_InputObject -Hostname $_InputObject.ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + if ($Async) + { + + $_resp = Wait-OVTaskComplete -InputObject $_resp + + } + + $_resp + + } + + end + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper(), $Name, $_appliance.Name | Write-Verbose + + } + +} + +function Exit-OVClusterNodeMaintenanceMode +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = 'Default', SupportsShouldProcess, ConfirmImpact = 'High')] + [OutputType([HPEOneView.Appliance.TaskResource])] + param + ( + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = 'Default')] + [Alias('Name')] + [Object]$InputObject, + + [Parameter (ParameterSetName = 'Default', Mandatory = $false)] + [Switch]$Async, + + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = ($ConnectedSessions | Where-Object Default) + + ) + + Begin + { + + "[{0}] Bound PS Parameters: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(),($PSBoundParameters | out-string) | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not($PSBoundParameters['InputObject'])) + { + + $Pipelineinput = $True + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not($ConnectedSessions)) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command agian." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -gt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + } + + Process + { + + if ($InputObject.type -notmatch $ClusterProfileHostType) + { + + "[{0}] Invalid InputObject provided. Generate Error." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $ExceptionMessage = "The provided InputObject parameter value is not a valid ClusterProfileHost resource." + $ErrorRecord = New-ErrorRecord HPEOneView.InputObjectResourceException InvalidResourceObject InvalidArgument "InputObject" -TargetType $InputObject.GetType().Name -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + if ($InputObject.powerState -ne $ClusterProfileHostPowerStateEnum.InMaintenanceMode) + { + + "[{0}] ClusterProfileHost not in the InMaintenance state, '{1}'. Generating error." -f $MyInvocation.InvocationName.ToString().ToUpper(), $ClusterProfileHostPowerStateEnum[$InputObject.powerState].Value | Write-Verbose + + $ExceptionMessage = "ClusterProfileHost not in the InMaintenance state, '{0}'." -f $InputObject.powerState + $ErrorRecord = New-ErrorRecord HPEOneView.InputObjectResourceException InvalidResourceObject InvalidArgument "InputObject" -TargetType $InputObject.GetType().Name -Message $ExceptionMessage + $PSCmdlet.WriteError($ErrorRecord) + + } + + else + { + + $_InputObject = $InputObject.PSObject.Copy() + + $_InputObject.powerState = $ClusterProfileHostPowerStateEnum.ExitMaintenanceMode + + Try + { + + $_resp = Send-OVRequest -Uri $_InputObject.uri -Method PUT -Body $_InputObject -Hostname $_InputObject.ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + if ($Async) + { + + $_resp = Wait-OVTaskComplete -InputObject $_resp + + } + + $_resp + + } + + end + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper(), $Name, $_appliance.Name | Write-Verbose + + } + +} + +####################################################### +# Index: +# + +function Search-OVIndex +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding ()] + Param + ( + + [Parameter (Mandatory = $false)] + [ValidateNotNullorEmpty()] + [String]$Search, + + [Parameter (Mandatory = $false)] + [ValidateNotNullorEmpty()] + [String]$Category, + + [Parameter (Mandatory = $false)] + [ValidateNotNullorEmpty()] + [Int]$Count = 50, + + [Parameter (Mandatory = $false)] + [ValidateNotNullorEmpty()] + [Int]$Start = 0, + + [Parameter (Mandatory = $false)] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command agian." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + # Initialize collection to hold multiple volume attachments objects + $_IndexSearchResults = [System.Collections.ArrayList]::new() + + } + + Process + { + + ForEach ($_appliance in $ApplianceConnection) + { + + "[$($MyInvocation.InvocationName.ToString().ToUpper())] Processing Appliance Connection '{0}' (of {1})" -f $_appliance.Name, $ApplianceConnection.count | Write-Verbose + + $uri = $indexuri + '?start=' + $start.ToString() + '&count=' + $count.ToString() + + if ($search) + { + + $uri = $uri + "&userQuery=" + $search + + } + + if ($category) + { + + $uri = $uri + "&category=" + $category + + } + + $uri = $uri.Replace(" ", "%20") + + Try + { + + $r = Send-OVRequest $uri -Hostname $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if ($r.count -eq 0 -and $PSBoundParameters['Search']) + { + + $ErrorRecord = New-ErrorRecord InvalidOperationException NoIndexResults ObjectNotFound 'Search' -Message ("No Index results found for '{0}' on '{1}." -f $Search, $_appliance.Name) + $PSCmdlet.WriteError($ErrorRecord) + } + + else + { + + $r.members | ForEach-Object { + + $_.PSObject.TypeNames.Insert(0,'HPEOneview.Appliance.IndexResource') + + [void]$_IndexSearchResults.Add($_) + + } + + } + + } + + } + + End + { + + "Done. {0} index resource(s) found." -f $_IndexSearchResults.count | Write-Verbose + + Return $_IndexSearchResults + + } + +} + +function Search-OVAssociations +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding ()] + Param + ( + + [Parameter (Mandatory = $false)] + [ValidateNotNullorEmpty()] + [String]$AssociationName, + + [Parameter (Mandatory = $false, ValueFromPipeline)] + [ValidateNotNullorEmpty()] + [object]$Parent, + + [Parameter (Mandatory = $false)] + [ValidateNotNullorEmpty()] + [object]$Child, + + [Parameter (Mandatory = $false)] + [ValidateNotNullorEmpty()] + [Int]$Count = 50, + + [Parameter (Mandatory = $false)] + [ValidateNotNullorEmpty()] + [Int]$Start = 0, + + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName)] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if ($PSBoundParameters['Parent']) + { + + if (-not($Parent -is [PSCustomObject])) + { + + $ErrorRecord = New-ErrorRecord InvalidOperationException InvalidArgumentValue InvalidArgument 'Parent' -Message "The provided -Parent Parameter value is not an Object. Please correct the value." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + $ApplianceConnection = $Parent.ApplianceConnection + + } + + elseif ($PSBoundParameters['Child']) + { + + if (-not($Child -is [PSCustomObject])) + { + + $ErrorRecord = New-ErrorRecord InvalidOperationException InvalidArgumentValue InvalidArgument 'Chuld' -Message "The provided -Child Parameter value is not an Object. Please correct the value." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + $ApplianceConnection = $Child.ApplianceConnection + + } + + if ($PSBoundParameters['ApplianceConnection']) + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command agian." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + # Initialize collection to hold multiple volume attachments objects + $_IndexSearchResults = [System.Collections.ArrayList]::new() + + } + + Process + { + + $uri = "{0}?start={1}&count={2}" -f $AssociationsUri, $Start, $Count + + if ($PSBoundParameters['AssociationName']) + { + + $uri = $uri + "&name=" + $associationName + + } + + if ($Parent) + { + + "[$($MyInvocation.InvocationName.ToString().ToUpper())] Parent resource: {0}" -f ($Parent | Out-String) | Write-Verbose + + if (-not($Parent -is [PSCustomObject])) + { + + $ErrorRecord = New-ErrorRecord InvalidOperationException InvalidArgumentValue InvalidArgument 'Parent' -Message "The provided -Parent Parameter value is not an Object. Please correct the value." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + $uri = $uri + "&parentUri=" + $Parent.uri + + } + + if ($PSBoundParameters['Child']) + { + + "[$($MyInvocation.InvocationName.ToString().ToUpper())] Child resource: {0}" -f ($Child | Out-String) | Write-Verbose + + if (-not($Child -is [PSCustomObject])) + { + + $ErrorRecord = New-ErrorRecord InvalidOperationException InvalidArgumentValue InvalidArgument 'Child' -Message "The provided -Child Parameter value is not an Object. Please correct the value." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + $uri = $uri + "&childUri=" + $Child.uri + + } + + $uri = $uri.Replace(" ", "%20") + + Try + { + + $r = Send-OVRequest $uri -Hostname $ApplianceConnection.Name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $r.members | ForEach-Object { + + [void]$_IndexSearchResults.Add($_) + + } + + } + + End + { + + Return $_IndexSearchResults + + } + +} + +####################################################### +# Tasks: +# + +function Get-OVTask +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "Default")] + Param + ( + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Parameter (Mandatory = $false, ParameterSetName = "ResourceCategory")] + [ValidateNotNullorEmpty()] + [Alias ("TaskName")] + [String]$Name, + + [Parameter (Mandatory = $false, ValueFromPipeline, ParameterSetName = "Default")] + [Alias('Resource')] + [ValidateNotNullorEmpty()] + [Object]$InputObject, + + [Parameter (Mandatory = $false, ParameterSetName = "ResourceCategory")] + [ValidateNotNullorEmpty()] + [Alias ("Category")] + [String]$ResourceCategory, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Parameter (Mandatory = $false, ParameterSetName = "ResourceCategory")] + [ValidateNotNullorEmpty()] + [ValidateSet ("Unknown","New","Running","Pending","Stopping","Suspended","Terminated","Killed","Completed","Error","Warning")] + [String[]]$State, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Parameter (Mandatory = $false, ParameterSetName = "ResourceCategory")] + [ValidateScript({ if ([Int]$_ -gt -1) {$true} else {Throw "The Count Parameter value '$_' is invalid."}})] + [Int]$Count = 0, + + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = "Default")] + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = "ResourceCategory")] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command agian." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $_TaskCollection = [System.Collections.ArrayList]::new() + + } + + Process + { + + ForEach ($_appliance in $ApplianceConnection) + { + + $uri = $TasksUri + '?sort=modified:desc' + + if ($PSBoundParameters['Name']) + { + + "[{0}] Name Parameter value: $($Name)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $Uri += "&filter=name='$Name'" + + } + + if ($PSBoundParameters['State']) + { + + $_State = [string]::Join(" OR ", $State) + + "[{0}] State Parameter value: $($_State)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $Uri += "&filter=taskState='$_State'" + + } + + if ($PSBoundParameters['Count']) + { + + "[{0}] Count Parameter value: $($Count)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $Uri += "&count=$Count&sort=created:descEnding" + + } + + "[{0}] Parameter Set Name resolved to: $($PSCmdlet.ParameterSetName)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + switch ($PSCmdlet.ParameterSetName) + { + + "Default" + { + + if ($PSBoundParameters['InputObject']) + { + + # If the Resource value is a Name + if (($InputObject -is [String]) -and (-not($InputObject.StartsWith("/rest/")))) + { + + "[{0}] Resource Parameter Name: $($InputObject)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $Uri += "&filter=associatedResource.resourceName='$InputObject'" + + } + + # Checking if the input is System.String and IS a URI + elseif (($InputObject -is [String]) -and ($InputObject.StartsWith("/rest/"))) + { + + "[{0}] Resource Parameter URI: $($InputObject)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $Uri += "&filter=associatedResource.resourceUri='$InputObject'" + + + } + + # Checking if the input is PSCustomObject, and the category type is not null, which would be passed via pipeline input + elseif (($InputObject -is [PSCustomObject]) -and ($InputObject.category)) + { + + "[{0}] Resource is an object: '$($InputObject.name)' of type '$($InputObject.Category)'" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + "[{0}] Using URI value ($($InputObject.Uri)) from input object." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $Uri += "&filter=associatedResource.resourceUri='$($InputObject.Uri)'" + + } + + else + { + + $ErrorRecord = New-ErrorRecord InvalidOperationException InvalidArgumentValue InvalidArgument 'InputObject' -Message "The Resource input Parameter was not recognized as a valid type or format." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + } # End Default + + "ResourceCategory" + { + + "[{0}] Resource Category was specified: $($ResourceCategory)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $Uri += "&filter=associatedResource.resourceCategory='$($ResourceCategory)'" + + } # End ResourceCategory + + } # End switch + + "[{0}] URI: $($Uri)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if ($Count -gt 0 ) + { + + "[{0}] Getting $($Count) task objects." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + else + { + + "[{0}] ($($Count)) Returning all available task objects." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + try + { + + $_tasks = Send-OVRequest $Uri -Hostname $_appliance + + if ($_tasks.count -eq 0) + { + + "[{0}] No tasks found on Appliance '$($_appliance.Name)'." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if ($Name) + { + + $ExceptionMessage = "Task '{0}' name was not found on '{1}' appliance connection." -f $Name, $_appliance.Name + $ErrorRecord = New-ErrorRecord InvalidOperationException ResourceNotFound ObjectNotFound 'Name' -Message $ExceptionMessage + $PSCmdlet.WriteError($ErrorRecord) + + } + + } + + else + { + + $_tasks.members | ForEach-Object { + + $_.PSObject.TypeNames.Insert(0,"HPEOneview.Appliance.TaskResource") + + [void]$_TaskCollection.Add($_) + + } + + } + + } + + catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + End + { + + "[$($MyInvocation.InvocationName.ToString().ToUpper())] Done. {0} task resource(s) found." -f $_TaskCollection.count | Write-Verbose + + Return $_TaskCollection + + } + +} + +function Stop-OVTask +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (SupportsShouldProcess, ConfirmImpact = 'High')] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline)] + [Alias ('taskuri', 'task')] + [object]$InputObject, + + [Parameter (ValueFromPipelineByPropertyName, Mandatory = $false)] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not $PSBoundParameters['InputObject']) + { + + $PipelineInput = $True + + } + + else + { + + if ($InputObject -is [String] -and $ApplianceConnection.Count -gt 1) + { + + $ErrorRecord = New-ErrorRecord InvalidOperationException InvalidArgumentValue InvalidArgument 'Task' -Message "The -Task Parameter requires an Appliance to be specified. Please provide the Appliance Connection object or name by using the -ApplianceConnection Parameter." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command agian." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + } + + } + + Process + { + + if ($PipelineInput) + { + + "[{0}] Task resource passed via pipeline input." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + # Validate the task object + if (($InputObject -is [String]) -and ($InputObject.StartsWith($TasksUri))) + { + + "[{0}] Task is System.String $($InputObject)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_uri = $InputObject + + } + + elseif (($InputObject -is [PSCustomObject] -or $InputObject -is [HPEOneView.Appliance.TaskResource]) -and ($InputObject.category -ieq 'tasks')) + { + + "[{0}] Task is $($InputObject.GetType()). Task URI: $($taInputObjectsk.uri)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $ApplianceConnection = $InputObject.ApplianceConnection + + $_uri = $InputObject.Uri.ToString() + + } + + else + { + + $ErrorRecord = New-ErrorRecord InvalidOperationException InvalidArgumentValue InvalidArgument 'InputObject' -Message "Invalid task. Please verify the task object you are passing and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Try + { + + $taskObj = Send-OVRequest -uri $_uri -HostName $ApplianceConnection.name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if ($taskObj.isCancelleable -and $PSCmdlet.ShouldProcess($taskObj.name, 'Cancel task')) + { + + Try + { + + Send-OVRequest -Uri $taskObj.uri -Method PATCH + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + elseif (-not $taskObj.isCancelleable) + { + + $ExceptionMessage = "The task cannot be cancelled because it or one of its subtasks is in a non-cancellable state. No action is necessary. The task is running normally. As the task continues to run, it may change to a cancellable state where it would be appropriate to retry the action." + $ErrorRecord = New-ErrorRecord InvalidOperationException TaskIsNotCancelleable InvalidArgument 'InputObject' -Message $ExceptionMessage + + $PSCmdlet.WriteError($ErrorRecord) + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Wait-OVTaskStart +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding ()] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline)] + [Alias ('taskuri', 'task')] + [object]$InputObject, + + [Parameter (Mandatory = $false)] + [String]$resourceName, + + [Parameter (Mandatory = $false)] + [timespan]$Timeout = $DefaultTimeout, + + [Parameter (ValueFromPipelineByPropertyName, Mandatory = $false)] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not $PSBoundParameters['InputObject']) + { + + $PipelineInput = $True + + } + + else + { + + if ($InputObject -is [String] -and $ApplianceConnection.Count -gt 1) + { + + $ErrorRecord = New-ErrorRecord InvalidOperationException InvalidArgumentValue InvalidArgument 'Task' -Message "The -Task Parameter requires an Appliance to be specified. Please provide the Appliance Connection object or name by using the -ApplianceConnection Parameter." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command agian." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + } + + } + + Process + { + + if ($PipelineInput) + { + + "[{0}] Task resource passed via pipeline input." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + # Validate the task object + if (($InputObject -is [String]) -and ($InputObject.StartsWith($TasksUri))) + { + + "[{0}] Task is System.String $($InputObject)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_uri = $InputObject + + } + + elseif (($InputObject -is [PSCustomObject] -or $InputObject -is [HPEOneView.Appliance.TaskResource]) -and ($InputObject.category -ieq 'tasks')) + { + + "[{0}] Task is $($InputObject.GetType()). Task URI: $($taInputObjectsk.uri)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $ApplianceConnection = $InputObject.ApplianceConnection + + $_uri = $InputObject.Uri.ToString() + + } + + else + { + + $ErrorRecord = New-ErrorRecord InvalidOperationException InvalidArgumentValue InvalidArgument 'InputObject' -Message "Invalid task. Please verify the task object you are passing and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + $sw = [diagnostics.stopwatch]::StartNew() + + Try + { + + $taskObj = Send-OVRequest -uri $_uri -HostName $ApplianceConnection.name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $i = 0 + + if ($resourceName) + { + + $taskname = "Waiting for '{0} {1}' task to start" -f (ParseForJson $taskObj.name), (ParseForJson $resourceName) + + } + + else + { + + $taskName = "Waiting for '{0}' task to start" -f (ParseForJson $taskObj.name) + + } + + "[{0}] $taskName" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if ($PSBoundParameters['Verbose'] -or $VerbosePreference -eq 'Continue') + { + + "[{0}] Skipping Write-Progress display." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + while ($taskObj.taskState -ieq "Adding" -or + $taskObj.taskState -ieq "New" -or + $taskObj.taskState -ieq "Starting") + { + + Try + { + + $taskObj = Send-OVRequest -Uri $taskObj.uri -Hostname $taskObj.ApplianceConnection.Name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if ($sw.Elapsed -gt $timeout) + { + + $ErrorRecord = New-ErrorRecord InvalidOperationException TaskWaitExceededTimeout OperationTimeout 'Wait-OVTaskStart' -Message "The time-out period expired before waiting for task '$taskName' to start." #-verbos + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + # Display Progress Bar + + # Display the task status + if ($taskObject.taskStatus) + { + + $progressStatus = (ParseForJson $taskObj.taskStatus) + + } + + elseif ($taskObject.taskState) + { + + $progressStatus = (ParseForJson $taskObj.taskStatus) + + } + + else + { + + $progressStatus = "Waiting $($taskObject.Name)" + + } + + if ($taskObj.expectedDuration) + { + + $percentComplete = ($i / $taskObj.expectedDuration * 100) + + } + + else + { + + $percentComplete = $taskObj.percentComplete + + } + + # Handle the call from -Verbose so Write-Progress does not get borked on display. + if ($PSBoundParameters['Verbose'] -or $VerbosePreference -eq 'Continue') + { + + "[{0}] Task Status: '$taskName' $progressStatus $($percentComplete)% Complete" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + else + { + + Write-Progress -activity $taskName -status $progressStatus -percentComplete $percentComplete + + } + + Start-Sleep 1 + + $i++ + + } + + Write-Progress -activity $taskName -Completed + + $taskObj + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Wait-OVTaskComplete +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding ()] + Param + ( + + [Parameter (ValueFromPipeline, Mandatory)] + [Alias ('TaskUri','Task')] + [Object]$InputObject, + + [Parameter (Mandatory = $false)] + [timespan]$Timeout = $DefaultTimeout, + + [Parameter (Mandatory = $false)] + [Switch]$ApplianceWillReboot, + + [Parameter (ValueFromPipelineByPropertyName, Mandatory = $false)] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not $PSBoundParameters['InputObject']) + { + + $PipelineInput = $True + + } + + # Task isn't provided by pipeline, but check for ApplianceConnection property + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command agian." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + $TaskCollection = [System.Collections.ArrayList]::new() + $FinishedTasksCollection = [System.Collections.ArrayList]::new() + $_TaskIds = [System.Collections.ArrayList]::new() + + $i = 1 + + } + + Process + { + + if ($PipelineInput) + { + + "[{0}] Task resource passed via pipeline input." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + # Validate the task object + ForEach ($_task in $InputObject) + { + + "[{0}] Processing task resources." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (($_task -is [String]) -and ($_task.StartsWith($TasksUri))) + { + + "[{0}] Task is URI $($_task)"-f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + # Use to track -ID in Write-Progress, as we will get the task object in the End block. + $_task = [PSCustomObject]@{ + id = $i; + uri = $_task; + taskState = $Null; + ApplianceConnection = $ApplianceConnection + } + + } + + elseif ($_task -is [PSCustomObject] -and $_task.category -ieq 'tasks') + { + + "[{0}] Task is $($_task.GetType()). Task URI: $($_task.uri)"-f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + # Use to track -ID in Write-Progress + $_task | Add-Member -NotePropertyName id -NotePropertyValue $i -force + + } + + else + { + + $ExceptionMessage = "Invalid task object provided. Please verify the task object you are passing and try again." + $ErrorRecord = New-ErrorRecord InvalidOperationException InvalidArgumentValue InvalidArgument $_task -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + [void]$TaskCollection.Add($_task) + [void]$_TaskIds.Add($i) + + $i++ + + } + + } + + End + { + + $_taskCollection = $TaskCollection.Clone() + + # Start Stopwatch + $sw = [diagnostics.stopwatch]::StartNew() + + while ($_taskCollection.Count -gt 0 -and $sw.Elapsed -lt $timeout) + { + + "[{0}] Processing taskcollection." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if ($sw.Elapsed -gt $timeout) + { + + # Tear down Write-Progress + $_taskCollection | ForEach-Object { Write-Progress -id $_.id -Activity $_.Activity -Completed } + + # Return 'finished' collection to caller then display error + if ($_taskCollection.Count -gt 0) + { + + $_taskCollection + + } + + if ($FinishedTasksCollection.Count -gt 0) + { + + $FinishedTasksCollection + + } + + # UPDATE ERROR MESSAGE to state timeout waiting for tasks to complete + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.TaskResourceException TaskWaitExceededTimeout OperationTimeout 'Wait-OVTaskComplete' -Message "The time-out period expired before waiting for task '$taskName' to start." #-verbos + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + $_t = 1 + $_displayedRebootMessage = $false + + ForEach ($_taskFromTrackerCol in ($_taskCollection | ? { $null -eq $_.parentId })) + { + + "[{0}] Processing parent or single level task." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + # Get task object from API + Try + { + + "[{0}] Getting task object from API." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_taskObj = Send-OVRequest ($_taskFromTrackerCol.uri + "?view=tree") -Hostname $_taskFromTrackerCol.ApplianceConnection + + $_ParentTaskObj = $_taskObj.resource + + } + + Catch + { + + if ($ApplianceWillReboot.IsPresent -and [RegEx]::Match($_ParentTaskObj.progressUpdates.statusUpdate, 'Rebooting', $RegExInsensitiveFlag).Success) + { + + if (-not $_displayedRebootMessage) + { + + Write-Host "`r`n" + Write-Warning "Appliance is rebooting..." + + $_displayedRebootMessage = $true + + } + + # Sleep for 30 seconds so the web service isn't available, and should trigger Wait-OVApplianceStart + Start-Sleep -Seconds 30 + + } + + else + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $Activity = '{0} - {1}' -f (ParseForJson $_ParentTaskObj.name), (ParseForJson $_ParentTaskObj.associatedResource.resourceName) + + # Parent Task is in a finished state + if ($TaskFinishedStatesEnum -contains $_ParentTaskObj.taskState) + { + + "[{0}] Task is finished, removing from collection." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + "[{0}] Task Collection size: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $TaskCollection.count | Write-Verbose + + # Locate any of the child task objects, removing them from the master task tracker, and mark them complete + ForEach ($_childTask in ($TaskCollection | ? ParentId -eq $_taskFromTrackerCol.id)) + { + + $_ChildActivity = '{0} - {1}' -f (ParseForJson $_childTask.resource.name), (ParseForJson $_childTask.resource.associatedResource.resourceName) + + Write-Progress -Id $_childTask.id -Activity $_ChildActivity -Completed + + [void]$TaskCollection.Remove($_childTask) + + } + + # Remove task object from base arraylist + [void]$TaskCollection.Remove($_taskFromTrackerCol) + + "[{0}] Updated Task Collection size: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $TaskCollection.count | Write-Verbose + + # Add Task Object from API to return back to caller + [void]$FinishedTasksCollection.Add($_taskFromTrackerCol) + + if ($PSBoundParameters['Verbose'] -or $VerbosePreference -eq 'Continue') + { + + "[{0}] {1} [{2}{3}] Task finished. " -f $MyInvocation.InvocationName.ToString().ToUpper(), $_ParentTaskObj.name, $_ParentTaskObj.ApplianceConnection, $_ParentTaskObj.uri | Write-Verbose + + } + + else + { + + Write-Progress -id $_taskFromTrackerCol.id -activity $Activity -Completed + + } + + } + + # Display Progress Bar + else + { + + # # Check to see if there are child tasks + # if ($_taskObj.children.count -gt 0) + # { + + ForEach ($_childTask in $_taskObj.children) + { + + # Check to see if the task exists within the collection + if ($_childTaskFromCol = $TaskCollection | ? uri -eq $_childTask.resource.uri) + { + + "[{0}] Child task is within tracker collection. ID: {1}, PARENTID: {2}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_childTaskObj.id, $_childTaskObj.parentId | Write-Verbose + + $_childTask.resource | Add-Member -NotePropertyName Id -NotePropertyValue $_childTaskFromCol.id -Force + $_childTask.resource | Add-Member -NotePropertyName ParentId -NotePropertyValue $_childTaskFromCol.parentId -Force + $_childTask.resource | Add-Member -NotePropertyName ApplianceConnection -NotePropertyValue $_childTaskFromCol.ApplianceConnection -Force + + } + + else + { + + "[{0}] Adding child task to tracker collection." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_childTaskId = $_taskFromTrackerCol.id + 100 + + # Figure out child task ID to keep track of + while ($_TaskIds -contains $_childTaskId) + { + + $_childTaskId++ + + } + + # Keep track of the ID + [void]$_TaskIds.Add($_childTaskId) + + $_childTaskObj = $_childTask.resource.PSObject.Copy() + + $_childTaskObj | Add-Member -NotePropertyName Id -NotePropertyValue $_childTaskId + $_childTaskObj | Add-Member -NotePropertyName ParentId -NotePropertyValue $_taskFromTrackerCol.id + $_childTaskObj | Add-Member -NotePropertyName ApplianceConnection -NotePropertyValue $_taskFromTrackerCol.ApplianceConnection + + $_childTask.resource = $_childTaskObj.PSObject.Copy() + + # Keep track of the task object + [void]$TaskCollection.Add($_childTaskObj) + + } + + } + + # } + + $CurrentOperation = $null + + if ($_ParentTaskObj.progressUpdates.Count -gt 0) + { + + if ($StatusMessage = ($_ParentTaskObj.progressUpdates | Sort-Object -Property timeStamp -Descending | Select -First 1).statusUpdate) + { + + $CurrentOperation = ParseForJson -String $StatusMessage + + } + + } + + $StatusMessage = $_ParentTaskObj.taskState + + $_ProgressMessage = @{ + Id = $_taskFromTrackerCol.id; + Activity = $Activity; + Status = $StatusMessage; + PercentComplete = $_ParentTaskObj.percentComplete + } + + if ($null -ne $CurrentOperation) + { + + $_ProgressMessage.Add("CurrentOperation", $CurrentOperation) + + } + + # Handle the call from -Verbose so Write-Progress does not get borked on display. + if ($PSBoundParameters['Verbose'] -or $VerbosePreference -eq 'Continue') + { + + "[{0}] Skipping Write-Progress display." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + "[{0}] CMDLET Task Track ID: {1}`nTask Object Name: {2}`nStatus: {3}`nAssociated Resource Name: {4}`nPrecent Complete: {5}" -f $MyInvocation.InvocationName.ToString().ToUpper(), ` + $_ProgressMessage.Id, ` + $_ProgressMessage.Activity, ` + $_ProgressMessage.CurrentOperation, ` + $_ParentTaskObj.associatedResource.resourceName, ` + $_ProgressMessage.PercentComplete | Write-Verbose + + # Report any children tasks here + if ($_taskObj.children.count -gt 0) + { + + ForEach ($_childTask in $_taskObj.children) + { + + $_childTaskObj = $_childTask.resource + + if ($_childTaskObj.resource.progressUpdates.Count -gt 0) + { + + if ($CurrentChildOperation = ($_childTaskObj.progressUpdates | Sort-Object -Property timeStamp -Descending | Select -First 1).statusUpdate) + { + + $CurrentOperation = ParseForJson -String $StatusMessage + + } + + } + + else + { + + $CurrentChildOperation = "N/A" + + } + + "[{0}] CMDLET Task Track ID: {1} child of {2}`nTask Object Name: {3}`nStatus: {4}`nAssociated Resource Name: {5}`nPrecent Complete: {6}" -f $MyInvocation.InvocationName.ToString().ToUpper(), ` + $_childTaskObj.id, ` + $_ProgressMessage.Id, ` + $_childTaskObj.name, ` + $CurrentChildOperation, ` + $_childTaskObj.associatedResource.resourceName, ` + $_childTaskObj.percentComplete | Write-Verbose + + } + + } + + } + + else + { + + # Display parent progress bar + Write-Progress @_ProgressMessage + + # if ($_taskObj.children.count -gt 0) + # { + + ForEach ($_Child in $_taskObj.children) + { + + $_ChildTaskObject = $_Child.resource.PSObject.Copy() + + # If child task is still running, process it. + if ($TaskFinishedStatesEnum -notcontains $_ChildTaskObject.taskState) + { + + $ChildActivity = '{0} - {1}' -f $_ChildTaskObject.name, $_ChildTaskObject.associatedResource.resourceName + $ChildStatus = $_ChildTaskObject.taskState + + $_ChildProgressMessage = @{ + Id = $_ChildTaskObject.Id; + ParentId = $_ProgressMessage.Id; + Activity = $ChildActivity; + Status = $ChildStatus; + PercentComplete = $_ChildTaskObject.percentComplete + } + + if ($_childTaskObj.resource.progressUpdates.Count -gt 0) + { + + if ($CurrentChildOperation = ($_childTaskObj.progressUpdates | Sort-Object -Property timeStamp -Descending | Select -First 1).statusUpdate) + { + + $CurrentChildOperation = ParseForJson -String ($_childTaskObj.progressUpdates | Sort-Object -Property timeStamp -Descending | Select -First 1).statusUpdate + $_ProgressMessage.Add("CurrentOperation", $CurrentChildOperation) + + } + + } + + else + { + + $CurrentChildOperation = "N/A" + + } + + Write-Progress @_ChildProgressMessage + + } + + else + { + + + + } + + } + + # } + + } + + } + + if ($_t -ge $_taskCollection.count) + { + + Start-Sleep -seconds 2 + $_t = 1 # Reset counter + + } + + else + { + + $_t++ + + } + + } + + # Reclone $_taskCollection object to update array with current task ArrayList + $_taskCollection = $TaskCollection.Clone() + + } + + # Tear down any remaining Write-Progress displays before returning back to the user + $_TaskIds | ForEach-Object { Write-Progress -id $_ -Activity "Completed" -Completed } + + ForEach ($_Task in $FinishedTasksCollection) + { + + Try + { + + $Task = Send-OVRequest -Uri $_Task.uri -Hostname $_Task.ApplianceConnection + $Task.PSObject.TypeNames.Insert(0, 'HPEOneview.Appliance.TaskResource') + $Task + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + +} + +function ParseForJson +{ + + [CmdletBinding ()] + Param + ( + + [Parameter (ValueFromPipeline, Mandatory = $false, Position = 0)] + [String]$String + + ) + + $regexpattern = '\{(?[^{}])*\}' + + if (-not [String]::IsNullOrEmpty($String)) + { + + $Matches = [regex]::Match($String, $regexpattern, [System.Text.RegularExpressions.RegexOptions]::IgnoreCase) + + if ($Matches.Success) + { + + "Found embedded JSON within string." | Write-Debug + $ConvertedEmbeddedJson = $Matches.Value | ConvertFrom-Json + $StringToAdd = '{0}' -f $ConvertedEmbeddedJson.name + return [regex]::Replace($string, $regexpattern, $StringToAdd) + + } + + else + { + + "No embedded JSON within string found. Returning original string." | Write-Debug + + return $String + + } + + } + +} + +####################################################### +# Securty and LDAP functions +# + +function Get-OVUser +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding ()] + Param + ( + + [Parameter (Mandatory = $false)] + [Alias ('Username')] + [ValidateNotNullorEmpty()] + [String]$Name, + + [Parameter (Mandatory = $false)] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $_UserCollection = [System.Collections.ArrayList]::new() + + } + + Process + { + + ForEach ($_appliance in $ApplianceConnection) + { + + "[{0}] Processing '{1}' Appliance (of {2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name, $ApplianceConnection.Count | Write-Verbose + + $_Query = [System.Collections.ArrayList]::new() + + $_Category = "category=users&" + + if ($Name) + { + + if ($Name.Contains('*')) + { + + [Void]$_Query.Add(("user_name%3A{0}" -f $Name.Replace(" ","?").Replace("*", "%2A"))) + + } + + else + { + + [Void]$_Query.Add(("user_name:'{0}'" -f $Name)) + + } + + } + + # Build the final URI + $_uri = '{0}?{1}sort=name:asc&query={2}' -f $IndexUri, $_Category.ToString(), [String]::Join(' AND ', $_Query.ToArray()) + + Try + { + + $_users = Get-AllIndexResources -Uri $_uri -ApplianceConnection $_appliance + + if ($_users.count -eq 0 -and $Name) + { + + $_Message = "Username '{0}' was not found on {1} Appliance Connection. Please check the spelling, or create the user and try again." -f $Name, $_appliance.Name + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.UserResourceException UserNotFound ObjectNotFound "Name" -Message $_Message + $PSCmdlet.WriteError($ErrorRecord) + + } + + } + + # User isn't authorized, so let's display their user account + Catch [HPEOneView.Appliance.AuthPrivilegeException] + { + + Try + { + + $_user = Send-OVRequest ($ApplianceUserAccountsUri + '/' + $_appliance.Username) -Hostname $_appliance.Name + + $_user.PSObject.TypeNames.Insert(0,'HPEOneview.Appliance.User') + + [void]$_UserCollection.Add($_user) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + "[{0}] Found {1} user resources on '{2}' appliance." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_users.count, $_appliance.Name | Write-Verbose + + if ($_users) + { + + ForEach ($u in $_users) + { + + $u.PSObject.TypeNames.Insert(0,'HPEOneview.Appliance.User') + + [void]$_UserCollection.Add($u) + + } + + } + + } + + } + + End + { + + "Done. {0} user(s) found." -f $_UserCollection.count | Write-Verbose + + Return $_UserCollection + + } + +} + +function New-OVUser +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = 'Default')] + Param + ( + + [Parameter (Mandatory, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [String]$UserName, + + [Parameter (Mandatory, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [String]$Password, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [String]$FullName, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [Array]$Roles = @(), + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [Array]$ScopePermissions, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [validatescript({$_ -as [Net.Mail.MailAddress]})] + [String]$EmailAddress, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [String]$OfficePhone, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [String]$MobilePhone, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [Switch]$Enabled, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + + if ($PSBoundParameters['Enabled']) + { + + Write-Warning 'The -Enabled Parameter is now deprecated. By default, all new user accounts will be enabled. In order to disable a user account, use the Set-OVUser Cmdlet.' + + } + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command agian." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $_UserStatus = [System.Collections.ArrayList]::new() + + } + + Process + { + + ForEach ($_appliance in $ApplianceConnection) + { + + "[{0}] Processing '{1}' Appliance (of {2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name, $ApplianceConnection.Count | Write-Verbose + + "[{0}] Validating requested role values" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_unsupportedRoles = [System.Collections.ArrayList]::new() + $_NewUserRoles = [System.Collections.ArrayList]::new() + + $_user = NewObject -UserAccount + + $_user.userName = $userName + $_user.fullName = $fullName + $_user.password = $password + $_user.emailAddress = $emailAddress + $_user.officePhone = $officePhone + $_user.mobilePhone = $mobilePhone + $_user.enabled = $true + + # Validate roles provided are allowed. + if ($PSBoundParameters['Roles']) + { + foreach ($_role in $Roles) + { + + "[{0}] Processing role: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_role | Write-Verbose + + if (-not ((${Global:ConnectedSessions} | Where-Object Name -EQ $_appliance.Name).ApplianceSecurityRoles -contains $_role)) + { + + "[{0}] Invalid or unsupported" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + [void]$_unsupportedRoles.Add($_role) + + } + + else + { + + "[{0}] Supported" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_TempName = $_role.split(' ') + + $_NewPermission = NewObject -DirectoryGroupPermissions + + $_UpdatedName = [System.Text.StringBuilder]::new() + + for ($s = 0; $s -lt $_TempName.count; $s++) + { + + if ($s -eq 0) + { + + [void]$_UpdatedName.Append($_TempName[$s].Substring(0, 1).ToUpper() + $_TempName[$s].SubString(1, ($_TempName[$s].length - 1)).ToLower()) + + } + + else + { + + [void]$_UpdatedName.Append(" " + $_TempName[$s].ToLower()) + + } + + } + + $_NewPermission.roleName = $_UpdatedName.ToString() + + [void]$_user.permissions.Add($_NewPermission) + + } + + } + + if ($_unsupportedRoles.count -ge 1) + { + + $ErrorRecord = New-ErrorRecord ArgumentException UnsupportedRolesFound InvalidArgument $($MyInvocation.InvocationName.ToString().ToUpper()) -Message "The '$($_unsupportedRoles -join ", ")' role(s) is/are not supported or the correct names. Please validate the -roles Parameter contains one or more valid roles. Allowed roles are: $((${Global:ConnectedSessions} | ? Name -EQ $_appliance.Name).ApplianceSecurityRoles -join ", ")" + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + # Process scopes with permissions + if ($PSBoundParameters['ScopePermissions']) + { + + ForEach ($_ScopeToPermission in $ScopePermissions) + { + + "[{0}] Processing role: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_ScopeToPermission.Role | Write-Verbose + + if ((${Global:ConnectedSessions} | Where-Object Name -EQ $ApplianceConnection.Name).ApplianceSecurityRoles -notcontains $_ScopeToPermission.Role) + { + + "[{0}] Invalid or unsupported" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + [void]$_unsupportedRoles.Add($_ScopeToPermission.Role) + + } + + else + { + + "[{0}] Supported role." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if ([System.String]::IsNullOrWhiteSpace($_ScopeToPermission.Scope)) + { + + Throw "Scope property within ScopePermissions must contain at least 1 entry." + + } + + $_TempName = $_ScopeToPermission.Role.split(' ') + + "[{0}] Process scope." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + "[{0}] Scope object type: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_ScopeToPermission.Scope.GetType().Fullname | Write-Verbose + "[{0}] Scope object: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_ScopeToPermission.Scope | Write-Verbose + + if ($_ScopeToPermission.Scope -IsNot [HPEOneView.Appliance.ScopeCollection] -and $_ScopeToPermission.Scope -ne 'All') + { + + Throw ("Invalid scope resource {0}" -f $_ScopeToPermission.Name) + + } + + elseif ($_ScopeToPermission.Scope -eq 'All') + { + + "[{0}] Scope is not an HPEOneview.Appliance.ScopeCollection resource, but String 'All'. Will set uri to null." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + $_Scope = [PSCustomObject]@{uri = $null} + + } + + else + { + + $_Scope = $_ScopeToPermission.Scope + + } + + $_NewPermission = NewObject -DirectoryGroupPermissions + + $_UpdatedName = [System.Text.StringBuilder]::new() + + for ($s = 0; $s -lt $_tempname.count; $s++) + { + + if ($s -eq 0) + { + + [void]$_UpdatedName.Append($_TempName[$s].Substring(0, 1).ToUpper() + $_TempName[$s].SubString(1, ($_TempName[$s].length - 1)).ToLower()) + + } + + else + { + + [void]$_UpdatedName.Append(" " + $_TempName[$s].ToLower()) + + } + + } + + "[{0}] Adding Role '{1}' -> '{2}'." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_UpdatedName.ToString(), $_Scope.uri | Write-Verbose + + $_NewPermission.roleName = $_UpdatedName.ToString() + $_NewPermission.scopeUri = $_Scope.uri + + [void]$_user.permissions.Add($_NewPermission) + + } + + } + + } + + "[{0}] Sending request to create user: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_user.userName | Write-Verbose + + Try + { + + $_resp = Send-OVRequest -Uri $ApplianceUserAccountsUri -Method POST -Body $_user -Hostname $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $_resp.PSObject.TypeNames.Insert(0,'HPEOneview.Appliance.User') + + $_resp + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Set-OVUser +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = 'default')] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = 'Pipeline')] + [ValidateNotNullorEmpty()] + [Object]$UserObject, + + [Parameter (Mandatory, ParameterSetName = 'default')] + [ValidateNotNullorEmpty()] + [String]$UserName, + + [Parameter (Mandatory = $false, ParameterSetName = 'default')] + [Parameter (Mandatory = $false, ParameterSetName = 'Pipeline')] + [ValidateNotNullorEmpty()] + [String]$Password, + + [Parameter (Mandatory = $false, ParameterSetName = 'default')] + [Parameter (Mandatory = $false, ParameterSetName = 'Pipeline')] + [ValidateNotNullorEmpty()] + [String]$FullName, + + [Parameter (Mandatory = $false, ParameterSetName = 'default')] + [Parameter (Mandatory = $false, ParameterSetName = 'Pipeline')] + [ValidateNotNullorEmpty()] + [Array]$Roles, + + [Parameter (Mandatory = $false, ParameterSetName = 'default')] + [Parameter (Mandatory = $false, ParameterSetName = 'Pipeline')] + [Switch]$Append, + + [Parameter (Mandatory = $false, ParameterSetName = 'default')] + [Parameter (Mandatory = $false, ParameterSetName = 'Pipeline')] + [ValidateNotNullorEmpty()] + [Array]$ScopePermissions, + + [Parameter (Mandatory = $false, ParameterSetName = 'default')] + [Parameter (Mandatory = $false, ParameterSetName = 'Pipeline')] + [validatescript({$_ -as [Net.Mail.MailAddress]})] + [String]$EmailAddress, + + [Parameter (Mandatory = $false, ParameterSetName = 'default')] + [Parameter (Mandatory = $false, ParameterSetName = 'Pipeline')] + [ValidateNotNullorEmpty()] + [String]$OfficePhone, + + [Parameter (Mandatory = $false, ParameterSetName = 'default')] + [Parameter (Mandatory = $false, ParameterSetName = 'Pipeline')] + [ValidateNotNullorEmpty()] + [String]$MobilePhone, + + [Parameter (Mandatory = $false, ParameterSetName = 'default')] + [Parameter (Mandatory = $false, ParameterSetName = 'Pipeline')] + [Alias ('enable')] + [ValidateNotNullorEmpty()] + [Switch]$Enabled, + + [Parameter (Mandatory = $false, ParameterSetName = 'default')] + [Parameter (Mandatory = $false, ParameterSetName = 'Pipeline')] + [Alias ('disable')] + [ValidateNotNullorEmpty()] + [Switch]$Disabled, + + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = 'default')] + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = 'Pipeline')] + [Alias ('Appliance')] + [ValidateNotNullorEmpty()] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + # No need to validate ApplianceConnection, as object is passed via pipeline. + if ($PSCmdlet.ParameterSetName -eq 'Pipeline') + { + + "[{0}] Pipeline input." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $PipelineInput = $True + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command agian." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + $_UsersToUpdate = [System.Collections.ArrayList]::new() + $_UserStatus = [System.Collections.ArrayList]::new() + + } + + Process + { + + if ($PipelineInput) + { + + # Validate pipeline input is user object + if (-not($UserObject -is [PSCustomObject]) -and -not($UserObject.category -eq $ResourceCategoryEnum.User)) + { + + "[{0}] Invalid UserObject provided." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.UserResourceException InvalidUserObject InvalidArgument "UserObject" -TargetType 'PSObject' -Message "The UserObject Parameter value is not a valid User object resource. Object category provided '$($UserObject.category)', allowed object category value 'users'. Please verify the input object and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + "[{0}] Adding UserObject to Process collection: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $UserObject.Username | Write-Verbose + + [void]$_UsersToUpdate.Add($UserObject) + + } + + else + { + + ForEach ($_appliance in $ApplianceConnection) + { + + try + { + + $_UserObject = Get-OVUser -Name $userName -ApplianceConnection $_appliance + + } + + # If not found, throw error + catch [HPEOneView.Appliance.UserResourceException] + { + + # Generate terminating error + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.UserResourceException UserNotFound ObjectNotFound 'UserName' -Message "Username `'$userName`' was not found. Please check the spelling, or create the user and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + [void]$_UsersToUpdate.Add($_UserObject) + + } + + } + + } + + End + { + + ForEach ($_User in $_UsersToUpdate) + { + + $_NewUserRoles = [System.Collections.ArrayList]::new() + $_unsupportedRoles = [System.Collections.ArrayList]::new() + + "[{0}] Processing User: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_User.userName | Write-Verbose + + switch ($PSBoundParameters.keys) + { + + "Password" + { + + if ($_User.userName -eq (${Global:ConnectedSessions} | Where-Object Name -eq $_User.ApplianceConnection.Name).UserName) + { + + write-warning "This CMDLET will not modify the password for your account. Please use the Set-OVUserPassword CMDLET to update your user account password. Password update will not be Processed." + + } + + else + { + + $_User | Add-Member -NotePropertyName password -NotePropertyValue $Password -force + + } + + } + + "fullName" + { + + $_User.fullName = $FullName + + } + + "roles" + { + + if ($_User.userName -eq (${Global:ConnectedSessions} | Where-Object Name -eq $_User.ApplianceConnection.Name).UserName) + { + + write-warning "Unable to modify roles for your account, as you must be authenticated to the appliance with a different administrator account. Roles will not be Processed." + + } + + else + { + + $_User | add-member -NotePropertyName replaceRoles -NotePropertyValue $True -force + + # Validate roles provided are allowed. + foreach ($_role in $Roles) + { + + "[{0}] Processing role: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_role | Write-Verbose + + if (-not ((${Global:ConnectedSessions} | Where-Object Name -EQ $_User.ApplianceConnection.Name).ApplianceSecurityRoles -contains $_role)) + { + + "[{0}] Invalid or unsupported" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + [void]$_unsupportedRoles.Add($_role) + + } + + else + { + + "[{0}] Supported" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_TempName = $_role.split(' ') + + $_NewPermission = NewObject -DirectoryGroupPermissions + + $_UpdatedName = [System.Text.StringBuilder]::new() + + for ($s = 0; $s -lt $_TempName.count; $s++) + { + + if ($s -eq 0) + { + + [void]$_UpdatedName.Append($_TempName[$s].Substring(0, 1).ToUpper() + $_TempName[$s].SubString(1, ($_TempName[$s].length - 1)).ToLower()) + + } + + else + { + + [void]$_UpdatedName.Append(" " + $_TempName[$s].ToLower()) + + } + + } + + $_NewPermission.roleName = $_UpdatedName.ToString() + + [void]$_NewUserRoles.Add($_NewPermission) + + } + + } + + if ($_unsupportedRoles.count -ge 1) + { + + $ExceptionMessage = "The '{0}' role(s) is/are not supported or the correct names. Please validate the -roles Parameter contains one or more valid roles. Allowed roles are: {1}" -f [String]::Join(', ', $_unsupportedRoles.ToArray()), [String]::Join(', ', (${Global:ConnectedSessions} | Where-Object Name -EQ $_User.ApplianceConnection.Name).ApplianceSecurityRoles.ToArray()) + $ErrorRecord = New-ErrorRecord ArgumentException UnsupportedRolesFound InvalidArgument 'Roles' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + } + + # Process scopes with permissions + 'ScopePermissions' + { + + $_User | add-member -NotePropertyName replaceRoles -NotePropertyValue $True -force + + # Validate roles provided are allowed. + $_unsupportedRoles = [System.Collections.ArrayList]::new() + + + ForEach ($_ScopeToPermission in $ScopePermissions) + { + + "[{0}] Processing role: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_ScopeToPermission.Role | Write-Verbose + + if ((${Global:ConnectedSessions} | Where-Object Name -EQ $_user.ApplianceConnection.Name).ApplianceSecurityRoles -notcontains $_ScopeToPermission.Role) + { + + "[{0}] Invalid or unsupported" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + [void]$_unsupportedRoles.Add($_ScopeToPermission.Role) + + } + + else + { + + "[{0}] Supported role." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if ([System.String]::IsNullOrWhiteSpace($_ScopeToPermission.Scope)) + { + + Throw "Scope property within ScopePermissions must contain at least 1 entry." + + } + + $_TempName = $_ScopeToPermission.Role.split(' ') + + "[{0}] Process scope." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + "[{0}] Scope object type: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_ScopeToPermission.Scope.GetType().Fullname | Write-Verbose + "[{0}] Scope object: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_ScopeToPermission.Scope | Write-Verbose + + if ($_ScopeToPermission.Scope -IsNot [HPEOneView.Appliance.ScopeCollection] -and $_ScopeToPermission.Scope -ne 'All') + { + + Throw ("Invalid scope resource {0}" -f $_ScopeToPermission.Name) + + } + + elseif ($_ScopeToPermission.Scope -eq 'All') + { + + "[{0}] Scope is not an HPEOneview.Appliance.ScopeCollection resource, but String 'All'. Will set uri to null." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + $_Scope = [PSCustomObject]@{uri = $null} + + } + + else + { + + $_Scope = $_ScopeToPermission.Scope + + } + + $_NewPermission = NewObject -DirectoryGroupPermissions + + $_UpdatedName = [System.Text.StringBuilder]::new() + + for ($s = 0; $s -lt $_tempname.count; $s++) + { + + if ($s -eq 0) + { + + [void]$_UpdatedName.Append($_TempName[$s].Substring(0, 1).ToUpper() + $_TempName[$s].SubString(1, ($_TempName[$s].length - 1)).ToLower()) + + } + + else + { + + [void]$_UpdatedName.Append(" " + $_TempName[$s].ToLower()) + + } + + } + + "[{0}] Adding Role '{1}' -> '{2}'." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_UpdatedName.ToString(), $_Scope.uri | Write-Verbose + + $_NewPermission.roleName = $_UpdatedName.ToString() + $_NewPermission.scopeUri = $_Scope.uri + + [void]$_NewUserRoles.Add($_NewPermission) + + } + + } + + } + + "emailAddress" + { + + $_User.emailAddress = $EmailAddress + + } + + "officePhone" + { + + $_User.officePhone = $OfficePhone + + } + + "mobilePhone" + { + + $_User.mobilePhone = $MobilePhone + + } + + "enabled" + { + + if ($_User.userName -eq (${Global:ConnectedSessions} | Where-Object Name -eq $_User.ApplianceConnection.Name).UserName) + { + + write-warning "This CMDLET will not modify the state for your account. Please authenticate to the appliance with a different administrator account. Account state will not be Processed." + + } + + else + { + + $_User.enabled = $true + + } + + } + + "disabled" + { + + if ($_User.userName -eq (${Global:ConnectedSessions} | Where-Object Name -eq $_User.ApplianceConnection.Name).UserName) + { + + write-warning "This CMDLET will not modify the state for your account. Please authenticate to the appliance with a different administrator account. Account state will not be Processed." + + } + + else + { + + $_User.enabled = $false + + } + + } + + } + + if ($PSBoundParameters['Roles'] -or $PSBoundParameters['ScopePermissions']) + { + + if ($PSBoundParameters['Append']) + { + + "[{0}] Append operation." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + ForEach ($_originalpermission in $_user.permissions) + { + + $ScopeName = "AllResources" + + if (-not [String]::IsNullOrEmpty($_originalpermission.scopeUri)) + { + + Try + { + + $ScopeResource = Send-OVRequest -Uri $_originalpermission.scopeUri -Hostname $_User.ApplianceConnection + + $ScopeName = '{0} ({1})' -f $ScopeResource.name, $ScopeResource.uri + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + "[{0}] Original role - ROLENAME: '{1}' -> '{2}'" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_originalpermission.roleName, $ScopeName | Write-Verbose + + if (-not ($_NewUserRoles | ? { $_.roleName -eq $_originalpermission.roleName -and $_.scopeUri -eq $_originalpermission.scopeUri})) + { + + "[{0}] Appending '{1}' role to '{2}' user." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_originalpermission.roleName, $_user.userName | Write-Verbose + + [void]$_NewUserRoles.Add($_originalpermission) + + } + + } + + } + + $_user.permissions = $_NewUserRoles + + } + + "[{0}] Sending request to update '{1}' user at '{2}'" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_user.userName, $ApplianceUserAccountsUri | Write-Verbose + + Try + { + + $_resp = Send-OVRequest -Uri $ApplianceUserAccountsUri -Method PUT -Body $_User -Hostname $_User.ApplianceConnection.Name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $_resp.PSObject.TypeNames.Insert(0,'HPEOneview.Appliance.User') + + [void]$_UserStatus.Add($_resp) + + } + + Return $_UserStatus + + } + +} + +function Set-OVUserPassword +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding ()] + Param + ( + + [Parameter (Mandatory = $false)] + [ValidateNotNullorEmpty()] + [Alias ('CurrentPassword')] + [String]$Current, + + [Parameter (Mandatory = $false)] + [ValidateNotNullorEmpty()] + [Alias ('NewPassword')] + [String]$New, + + [Parameter (Mandatory = $false)] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command agian." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + # Prompt user for current password if not provided + if (-not($PSBoundParameters['Current'])) + { + + $Current = Read-Host -AsSecureString "Current" + $_decryptCurrentPassword = [Runtime.InteropServices.Marshal]::PtrToStringBSTR([Runtime.InteropServices.Marshal]::SecureStringToBSTR($Current)) + + } + + else + { + + $_decryptCurrentPassword = $Current + + } + + # Prompt user for new password if not provided + if (-not($PSBoundParameters['New'])) + { + + Do + { + + $New = Read-Host -AsSecureString "New" + $_CompareNewPassword = Read-Host -AsSecureString "Re-type New" + + # Compare provided password matches + $_decryptNewPassword = [Runtime.InteropServices.Marshal]::PtrToStringBSTR([Runtime.InteropServices.Marshal]::SecureStringToBSTR($New)) + $_decryptcompareNewPassword = [Runtime.InteropServices.Marshal]::PtrToStringBSTR([Runtime.InteropServices.Marshal]::SecureStringToBSTR($_CompareNewPassword)) + + if (-not ($_decryptNewPassword -eq $_decryptcompareNewPassword)) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.PasswordMismatchException NewPasswordsDoNotMatch InvalidResult 'New' -Message "The new password values do not match. Please check the value and try again." + $PSCmdlet.WriteError($ErrorRecord) + + } + + if (-not ($_decryptNewPassword.length -ge 8) -or -not ($_decryptcompareNewPassword -ge 8)) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.PasswordMismatchException NewPasswordLengthTooShort InvalidResult 'New' -Message "The new password value do not meet the minimum character length of 8 characters. Please try again." + $PSCmdlet.WriteError($ErrorRecord) + + } + + } Until ($_decryptNewPassword -eq $_decryptcompareNewPassword -and $_decryptNewPassword.length -ge 8) + + } + + else + { + + $_decryptNewPassword = $New + + } + + $_UserStatus = [System.Collections.ArrayList]::new() + + } + + Process + { + + ForEach ($_appliance in $ApplianceConnection) + { + + "[{0}] Processing '{1}' Appliance (of {2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name, $ApplianceConnection.Count | Write-Verbose + + if ($_appliance.AuthLoginDomain -ne 'LOCAL') + { + + $_message = "The user account Auth Provider, {0}, is not the local appliance. HPE OneView does not support updating an LDAP User Account password." -f $_appliance.AuthLoginDomain + $_errorrecord = New-ErrorRecord HPEOneview.Appliance.UserResourceException UserNotFound ObjectNotFound 'UserName' -Message $_message + $PSCmdlet.WriteError($_errorrecord) + + } + + else + { + + $_UpdatePassword = NewObject -UpdateUserPassword + $_UpdatePassword.currentPassword = $_decryptCurrentPassword + $_UpdatePassword.password = $_decryptNewPassword + $_UpdatePassword.userName = $_appliance.UserName + + Try + { + + $_resp = Send-OVRequest -Uri $ApplianceUserAccountsUri -Method PUT -Body $_UpdatePassword -Hostname $_appliance + + if ($_resp.category -eq $ResourceCategoryEnum.User) + { + + $_resp.PSObject.TypeNames.Insert(0,'HPEOneview.Appliance.User') + + } + + [void]$_UserStatus.Add($_resp) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + } + + End + { + + Return $_UserStatus + + } + +} + +function Remove-OVUser +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "default", SupportsShouldProcess, ConfirmImpact = 'High')] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = "default")] + [ValidateNotNullOrEmpty()] + [Alias ("u","user",'UserName', 'Name')] + [Object]$InputObject, + + [Parameter (Mandatory = $False, ValueFromPipelineByPropertyName, ParameterSetName = "default")] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not($PSBoundParameters['Name'])) + { + + $PipelineInput = $True + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command agian." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + $_TaskCollection = [System.Collections.ArrayList]::new() + $_UserCollection = [System.Collections.ArrayList]::new() + + } + + Process + { + + if ($PipelineInput -or $InputObject -is [PSCustomObject]) + { + + "[{0}] Processing Pipeline input" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + "[{0}] User Object provided: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), ($InputObject | Format-List * | Out-String) | Write-Verbose + + If ('users' -contains $InputObject.category) + { + + If (-not($InputObject.ApplianceConnection)) + { + + $ErrorRecord = New-ErrorRecord InvalidOperationException InvalidArgumentValue InvalidArgument "User:$($InputObject.Name)" -TargetType PSObject -Message "The User object resource provided is missing the source ApplianceConnection property. Please check the object provided and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + [void]$_UserCollection.Add($InputObject) + + } + + else + { + + $ErrorRecord = New-ErrorRecord InvalidOperationException InvalidArgumentValue InvalidArgument "User:$($InputObject.Name)" -TargetType PSObject -Message "The User object resource is not an expected category type [$($InputObject.category)]. The allowed resource category type is 'users'. Please check the object provided and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + else + { + + ForEach ($_appliance in $ApplianceConnection) + { + + "[{0}] Processing Appliance {1} (of {2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name, $ApplianceConnection.Count | Write-Verbose + + "[{0}] Processing User Name: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject| Write-Verbose + + Try + { + + $_User = Get-OVUser $InputObject -ApplianceConnection $_appliance + + $_User | ForEach-Object { + + [void]$_UserCollection.Add($_) + + } + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + } + + End + { + + "[{0}] Processing {1} User object resources to remove." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_UserCollection.count | Write-Verbose + + # Process User Resources + ForEach ($_user in $_UserCollection) + { + + if ($PSCmdlet.ShouldProcess($_user.ApplianceConnection, ("Remove User '{0}' from appliance") -f $_user.userName)) + { + + "[{0}] Removing User '{1}' from appliance '{2}'." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_user.userName, $_user.ApplianceConnection | Write-Verbose + + $_ETag = '*' + + if ($null -ne $_user.eTag) + { + + $_ETag = $_user.eTag + + } + + Try + { + + $_resp = Send-OVRequest -Uri $_user.Uri -Method DELETE -AddHeader @{'If-Match' = $_ETag} -Hostname $_user.ApplianceConnection.Name + + $_resp | Add-Member -NotePropertyName userName -NotePropertyValue $_user.userName + + $_resp + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + elseif ($PSBoundParameters['WhatIf']) + { + + "[{0}] WhatIf Parameter was passed." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + } + + } + +} + +function Show-OVUserSession +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "default")] + Param () + + Begin + { + + Write-Warning "This CMDLET has been deprecated. Please use the $ConnectedSessions Global variable for appliance session information." + + } + + Process { } + + End { } + +} + +function Get-OVRole +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "default")] + Param() + + Begin + { + + Write-Warning "This CMDLET is now deprecated. Please use the Get-OVUser CMDLET to retrieve the user account and associated Roles." + + } + +} + +function Set-OVUserRole +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding ()] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline)] + [ValidateNotNullOrEmpty()] + [Alias ("user",'userName')] + [Object]$Name, + + [Parameter (Mandatory)] + [ValidateNotNullOrEmpty()] + [Alias ('roleName')] + [Array]$Roles, + + [Parameter (ValueFromPipelineByPropertyName, Mandatory = $false)] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + Write-Warning "This CMDLET is now deprecated. Please use the Set-OVUser CMDLET to modify user accounts and associated roles/permissions." + + } + +} + +function Set-OVInitialPassword +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = 'Default')] + Param + ( + + [Parameter (Mandatory, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [Object]$OldPassword, + + [Parameter (Mandatory, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [Object]$NewPassword, + + [Parameter (Mandatory, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [Object]$Appliance + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + # Check to see if a connection to the appliance exists + if ($Appliance -is [String]) + { + + if (-not(${Global:ConnectedSessions}.Name -contains $Appliance) -and (-not(${Global:ConnectedSessions} | Where-Object Name -eq $Appliance).SessionID)) + { + + "[{0}] Appliance Session not found. Running FTS sequence?" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + "[{0}] Creating temporary Session object" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + [HPEOneView.Appliance.Connection]$Appliance = [HPEOneView.Appliance.Connection]::new(99, $Appliance) + + $Appliance.SessionID = 'TemporaryConnection' + + [void]${Global:ConnectedSessions}.Add($_Appliance) + + } + + elseif (${Global:ConnectedSessions}.Name -contains $Appliance) + { + + "[{0}] Appliance is a string value, lookup connection in global tracker." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + [HPEOneView.Appliance.Connection]$Appliance = ${Global:ConnectedSessions} | Where-Object Name -eq $Appliance + + "[{0}] Found connection in global tracker: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), ($Appliance | Out-String) | Write-Verbose + + } + + } + + elseif ($Appliance -is [HPEOneView.Appliance.Connection]) + { + + "[{0}] Appliance is a Connection: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), ($Appliance | Out-String) | Write-Verbose + + } + + else + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException UnknownCondition InvalidOperation "Appliance" -Message "An unknown condition has ocurred." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + if ($OldPassword -is [SecureString]) + { + + $OldPassword = [Runtime.InteropServices.Marshal]::PtrToStringBSTR([Runtime.InteropServices.Marshal]::SecureStringToBSTR($OldPassword)) + + } + + if ($NewPassword -is [SecureString]) + { + + $NewPassword = [Runtime.InteropServices.Marshal]::PtrToStringBSTR([Runtime.InteropServices.Marshal]::SecureStringToBSTR($NewPassword)) + + } + + } + + Process + { + + $body = [PSCustomObject]@{ + + userName = 'Administrator'; + oldPassword = $OldPassword; + newPassword = $NewPassword + + } + + $uri = $ApplianceUserAccountsUri + "/changePassword" + + Try + { + + $resp = Send-OVRequest -Uri $uri -Method POST -Body $body -Hostname $Appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + finally + { + + # Remove Temporary appliance connection + if ((${Global:ConnectedSessions} | Where-Object Name -eq $Appliance.Name).SessionID -eq 'TemporaryConnection') + { + + "[{0}] Removing temporary Session object" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $ConnectedSessions.RemoveConnection($Appliance) + + } + + } + + } + + End + { + + return $resp + + } + +} + +function Get-OVApplianceTrustedCertificate +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName='Default')] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = 'Resource')] + [Object]$InputObject, + + [Parameter (Mandatory = $False, ParameterSetName = 'Default')] + [String]$Name, + + [Parameter (Mandatory = $False, ParameterSetName = 'Default')] + [Alias ("CASOnly")] + [Switch]$CertificateAuthoritiesOnly, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = 'Resource')] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = ($ConnectedSessions | Where-Object Default) + + ) + + Begin + { + + "[{0}] Bound PS Parameters: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(),($PSBoundParameters | out-string) | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not($ConnectedSessions)) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command agian." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $_CertCollection = [System.Collections.ArrayList]::new() + + } + + Process + { + + $_uri = '{0}?category=certificates&count=10000&query=({1})' + + $_Query = [System.Collections.Generic.List[String]]::new() + + $_Query.Add("(NOT cert_type:STANDARD_ROOT)") + + $_Name = $null + + if ($PSBoundParameters['Name']) + { + + $_Query.Add('((cert_aliasName:/.*{0}.*/) OR (cert_altNames:/.*{0}.*/))' -f $Name) + + $_Name = $Name + + } + + if ($CertificateAuthoritiesOnly.IsPresent) + { + + $_Query.Add('(cert_type:INTERMEDIATE OR cert_type:CUSTOM_ROOT)') + + } + + if ($InputObject) + { + + switch ($InputObject.category) + { + + 'server-hardware' + { + + $_Query.Add(('((cert_aliasName:/.*{0}.*/) OR (cert_altNames:/.*{0}.*/) OR (cert_altNames:/.*{1}.*/))' -f $InputObject.uuid, $InputObject.name)) + + } + + 'enclosures' + { + + $_Query.Add(('((cert_aliasName:/.*{0}.*/) OR (cert_altNames:/.*{0}.*/) OR (cert_altNames:/.*{1}.*/))' -f $InputObject.serialNumber, $InputObject.name)) + + } + + default + { + + $ExceptionMessage = 'The provided resource "{0} ({1})" is unsupported with this Cmdlet. Please provide a Server or Enclosure resource.' -f $InputObject.name, $InputObject.category + $ErrorRecord = New-ErrorRecord InvalidOperationException InvalidInputObjectParameterValue InvalidArgument 'InputObject' -TargetType $InputObject.GetType().Name -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + $_Name = $InputObject.name + + } + + $_uri = $_uri -f $IndexUri, [String]::Join(' AND ', $_Query.ToArray()) + + ForEach ($_appliance in $ApplianceConnection) + { + + "[{0}] Processing '{1}' Appliance (of {2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name, $ApplianceConnection.Count | Write-Verbose + + Try + { + + $_CollectionResults = Send-OVRequest -Uri $_uri -Hostname $_appliance.Name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if ($_CollectionResults.members) + { + + Try + { + + ForEach ($_certMember in ($_CollectionResults.members | Sort-Object Type)) + { + + $_Cert = Send-OVRequest -Uri $_certMember.uri -Hostname $_appliance.Name + + "[{0}] Processing '{1}' ({2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_Cert.certificateDetails.aliasName, $_Cert.uri | Write-Verbose + + Switch ($_Cert.type) + { + + 'CertificateAuthorityInfo' + { + + if ($null -eq $_Cert.certRevocationConfInfo.crlExpiry -and + $null -eq $_Cert.certRevocationConfInfo.crlSize) + { + + $CertificateRevocationListInfo = [HPEOneView.Appliance.TrustedCertificateAuthority+CertificateRevocationListInfo]::new("1/1/1970", + "CrlNotFound", + $_Cert.certRevocationConfInfo.crlSize) + } + + else + { + + $CertificateRevocationListInfo = [HPEOneView.Appliance.TrustedCertificateAuthority+CertificateRevocationListInfo]::new($_Cert.certRevocationConfInfo.crlExpiry, + $_Cert.certRevocationConfInfo.crlConf.crlDpList, + $_Cert.certRevocationConfInfo.crlSize) + + } + + + + $_Certificate = [HPEOneView.Appliance.TrustedCertificateAuthority]::new($_Cert.certificateDetails.base64Data, + $_Cert.certificateDetails.aliasName, + $_Cert.certificateDetails.state, + $_Cert.created, + $_Cert.modified, + $_Cert.eTag, + $CertificateRevocationListInfo, + $_Cert.uri, + $_Cert.ApplianceConnection) + + } + + 'CertificateInfoV2' + { + + $_CertStatus = [HPEOneView.Appliance.CertificateStatus]::new($_Cert.certificateStatus.chainStatus, + $_Cert.certificateStatus.selfsigned, + $_Cert.certificateStatus.trusted) + + $_Certificate = [HPEOneView.Appliance.TrustedCertificate]::new($_Cert.certificateDetails.base64Data, + $_Cert.certificateDetails.aliasName, + $_Cert.certificateDetails.commonName, + $_Cert.created, + $_Cert.modified, + $_CertStatus, + $_Cert.eTag, + $_Cert.uri, + $_Cert.ApplianceConnection) + + } + + } + + [void]$_CertCollection.Add($_Certificate) + + } + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + elseif ($PSBoundParameters['Name']) + { + + $ExceptionMessage = "The specified '{0}' trusted SSL certificate resource not found on Appliance '{1}'. Please check the name and try again." -f $_Name, $_appliance.Name + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.TrustedCertificateResourceException TrustedCertificateResourceNotFound ObjectNotFound "Name" -Message $ExceptionMessage + $PSCmdlet.WriteError($ErrorRecord) + + } + + } + + } + + End + { + + $_CertCollection | Sort-Object type + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Add-OVApplianceTrustedCertificate +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = 'Default')] + Param + ( + + [Parameter (Mandatory = $false, ValueFromPipeline, ParameterSetName = 'Default')] + [Parameter (Mandatory = $false, ValueFromPipeline, ParameterSetName = 'CertChain')] + [ValidateNotNullOrEmpty()] + [System.IO.FileInfo]$Path, + + [Parameter (Mandatory = $false, ValueFromPipeline, ParameterSetName = 'Default')] + [Parameter (Mandatory = $false, ValueFromPipeline, ParameterSetName = 'CertChain')] + [ValidateNotNullOrEmpty()] + [Object]$CertObject, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [Parameter (Mandatory = $false, ParameterSetName = 'CertChain')] + [ValidateNotNullOrEmpty()] + [String]$ComputerName, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [Parameter (Mandatory = $false, ParameterSetName = 'CertChain')] + [ValidateNotNullOrEmpty()] + [Int]$Port, + + [Parameter (Mandatory = $false, ParameterSetName = 'CertChain')] + [switch]$TrustCertChain, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [String]$AliasName, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [Switch]$Force, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [Parameter (Mandatory = $false, ParameterSetName = 'CertChain')] + [Switch]$Async, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [Parameter (Mandatory = $false, ParameterSetName = 'CertChain')] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command agian." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + Process + { + + # Collection will have Base64 encoded certificate content + $_CertsToAdd = [System.Collections.Arraylist]::new() + + if (-not $Path -and $ComputerName) + { + + "[{0}] Attempting to retreive SSL certificate from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $ComputerName | Write-Verbose + + ForEach ($_appliance in $ApplianceConnection) + { + + "[{0}] Processing '{1}' Appliance (of {2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name, $ApplianceConnection.Count | Write-Verbose + + # Attempt to get the server cert using GET /rest/certificates/https/remote/$ComputerName + Try + { + + $_Uri = '{0}{1}' -f $RetrieveHttpsCertRemoteUri, $ComputerName + + if ($PSBoundParameters['Port']) + { + + $_Uri += ':{0}' -f $Port + + } + + $_RemoteHttpsServerCert = Send-OVRequest -Uri $_Uri -Hostname $_appliance + + # The first array item should be the certificate requested + [void]$_CertsToAdd.Add($_RemoteHttpsServerCert.certificateDetails[0].base64Data) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + elseif ($Path -or $CertObject) + { + + if ($Path) + { + + "[{0}] Processing path: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Path.Name | Write-Verbose + + # Validate cert is valid X509 object + Try + { + + $_x509CertObject = [Security.Cryptography.X509Certificates.X509Certificate2]::new($Path) + $sb = [System.Text.StringBuilder]::new() + [void]$sb.Append("-----BEGIN CERTIFICATE-----`n") + [void]$sb.Append([System.Convert]::ToBase64String($_x509CertObject.RawData, "InsertLineBreaks")) + [void]$sb.Append("`n-----END CERTIFICATE-----`n") + + [void]$_CertsToAdd.Add($sb.ToString().Clone()) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + elseif ($CertObject -is [System.Security.Cryptography.X509Certificates.X509Certificate2]) + { + + "[{0}] Processing certificate object: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $CertObject.ToString() | Write-Verbose + + # Validate cert is valid X509 object + Try + { + + $_x509CertObject = $CertObject + + $sb = [System.Text.StringBuilder]::new() + [void]$sb.Append("-----BEGIN CERTIFICATE-----`n") + [void]$sb.Append([System.Convert]::ToBase64String($CertObject.RawData, "InsertLineBreaks")) + [void]$sb.Append("`n-----END CERTIFICATE-----`n") + + [void]$_CertsToAdd.Add($sb.ToString().Clone()) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + else + { + + "[{0}] Base64 Cert object provided" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + # $base64string = $CertObject.Replace("-----BEGIN CERTIFICATE-----`n",$null).Replace("`n-----END CERTIFICATE-----",$null) + [void]$_CertsToAdd.Add($CertObject.Clone()) + # $_x509CertObject = [Security.Cryptography.X509Certificates.X509Certificate2]::new([System.Convert]::FromBase64String($base64string), $null) + + } + + } + + # Rebuild the list of certs by getting the cert chain + if ($PSBoundParameters['TrustCertChain']) + { + + # Collection will have X509Certificate2 objects + $_CertChainAuthoritiesToAdd = [System.Collections.Arraylist]::new() + + "[{0}] Requested to process certificate chain." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + ForEach ($_CertObject in $_CertsToAdd) + { + + # Cert is expected to be in Base64 encoded format + $_Base64Data = $_CertObject.Replace("-----BEGIN CERTIFICATE-----`n",$null).Replace("`n-----END CERTIFICATE-----",$null) + + $_Cert = [System.Security.Cryptography.X509Certificates.X509Certificate2]::new([System.Convert]::FromBase64String($_Base64Data)) + + Try + { + + $_CertsToAdd = ProcessCertChain -CertObject $_Cert + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + ForEach ($_CertChainElement in $_CertsToAdd) + { + + if (-not ($_CertChainAuthoritiesToAdd | ? Subject -eq $_CertChainElement.Subject)) + { + + "[{0}] Adding '{1}' cert authority within chain to collection" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_Cert.Subject | Write-Verbose + + [void]$_CertChainAuthoritiesToAdd.Add($_CertChainElement) + + } + + } + + $_CertsToAdd = $_CertChainAuthoritiesToAdd + + } + + ForEach ($_CertObject in $_CertsToAdd) + { + + if ($_CertObject -is [System.Security.Cryptography.X509Certificates.X509Certificate2]) + { + + $sb = [System.Text.StringBuilder]::new() + [void]$sb.Append("-----BEGIN CERTIFICATE-----`n") + [void]$sb.Append([System.Convert]::ToBase64String($_CertObject.RawData, "InsertLineBreaks")) + [void]$sb.Append("`n-----END CERTIFICATE-----`n") + + $_CertObject = $sb.ToString().Clone() + + } + + $_x509CertObject = [Security.Cryptography.X509Certificates.X509Certificate2]::new([System.Convert]::FromBase64String($_CertObject.Replace("-----BEGIN CERTIFICATE-----`n",$null).Replace("`n-----END CERTIFICATE-----",$null)), $null) + + # Look at .Extensions | ? { [RegEx]::Match($_.KeyUsages, 'KeyCertSign', $RegExInsensitiveFlag).Success } or EnhancedKeyUsage + # This is a CA or Issuing Cert Authority + if ($_x509CertObject.Extensions | Where-Object { [RegEx]::Match($_.KeyUsages, 'KeyCertSign', $RegExInsensitiveFlag).Success }) + { + + "[{0}] Cert is Issuing authority" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_Cert = NewObject -ApplianceTrustedCertAuthority + + if (-not $PSBoundParameters['AliasName']) + { + + $AliasName = $_x509CertObject.GetNameInfo([System.Security.Cryptography.X509Certificates.X509NameType]::SimpleName,$false) + + } + + $_Cert.certificateDetails.aliasName = $AliasName + $_Cert.certificateDetails.base64Data = $_CertObject + + $_CertToImportCollection = [PSCustomObject]@{ + + type = 'CertificateAuthorityInfoCollection'; + members = [System.Collections.ArrayList]::new() + + } + + [void]$_CertToImportCollection.members.Add($_Cert) + + $_Uri = $ApplianceCertificateAuthorityUri.Clone() + + } + + else + { + + # Add the SSL certificate to the appliance + $_CertObjectToAdd = NewObject -ApplianceTrustedSslCertificate + + if (-not $PSBoundParameters['AliasName']) + { + + $AliasName = $_x509CertObject.GetNameInfo([System.Security.Cryptography.X509Certificates.X509NameType]::SimpleName,$false) + + } + + $_CertObjectToAdd.base64Data = $_CertObject + + $_CertToImportCollection = [PSCustomObject]@{ + + type = 'CertificateInfoV2'; + certificateDetails = [System.Collections.ArrayList]::new() + + } + + [void]$_CertToImportCollection.certificateDetails.Add($_CertObjectToAdd) + + $_Uri = $ApplianceTrustedSslHostStoreUri.Clone() + + } + + ForEach ($_appliance in $ApplianceConnection) + { + + "[{0}] Processing '{1}' Appliance (of {2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name, $ApplianceConnection.Count | Write-Verbose + + # Validate the certificate hasn't been added to the appliance by first calculating the SHA384 hash of the appliance, then look for its thumbprint + Try + { + + $_CertSha384Thumbprint = CalculateSha384CertificateHash -CertObject $_x509CertObject + + $_Query = [System.Collections.Generic.List[String]]::new() + + $_Query.Add('(cert_thumbprint:{0})' -f $_CertSha384Thumbprint) + + $_indexuri = '{0}?category=certificates&count=10000&query=({1})' -f $IndexUri, [String]::Join(' AND ', $_Query.ToArray()) + + $_ExistingCertificate = Send-OVRequest -Uri $_indexuri -Hostname $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if ($_ExistingCertificate.count -gt 0) + { + + "[{0}] Cert already exists on the appliance. Generating non-terminating error" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $ExceptionMessage = "Cert '{0}' already exists on the appliance." -f $_x509CertObject.Subject + $ErrorRecord = New-ErrorRecord InvalidOperationException TrustedCertificateAlreadyExists ResourceExists -TargetObject 'Certificate' -Message $ExceptionMessage + $PSCmdlet.WriteError($ErrorRecord) + + } + + else + { + + $Params = @{ + Uri = $_Uri; + Method = 'POST'; + Body = $_CertToImportCollection; + Hostname = $_appliance.Name + } + + if ($PSBoundParameters['Force']) + { + + $Params.Add('AddHeader', @{Forcesaveleaf = $true}) + + } + + Try + { + + $_Resp = Send-OVRequest @Params + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if (-not $PSBoundParameters['Async']) + { + + $_Resp | Wait-OVTaskComplete + + } + + else + { + + $_Resp + + } + + } + + } + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +Function ProcessCertChain +{ + + [CmdletBinding (DefaultParameterSetName = 'Default')] + Param + ( + + [Parameter (Mandatory = $false, ValueFromPipeline, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [System.Security.Cryptography.X509Certificates.X509Certificate2]$CertObject + + ) + + Process + { + + # Build certchain first using [System.Security.Cryptography.X509Certificates.X509Chain]::new() + # Loop through the ChainElements property looking for SubjectName -ne $CertObject.SubjectName, and reverse add starting with outter most cert to root + + if ($CertObject.Subject -eq $CertObject.Issuer) + { + + "[{0}] Certificate provided is self-signed (Issuer matches Subject). Generating error." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + # Generate exception here that the certificate is self-signed and not supported to get cert chain. + + $ExceptionMessage = "The certificate provided is self-signed, and not supported." + $ErrorRecord = New-ErrorRecord HPEOneView.Library.CertificateChainException SelfSignedCertNotAllowed InvalidArgument "Certificate" -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Try + { + + $_CertChainObject = [System.Security.Cryptography.X509Certificates.X509Chain]::new() + + if ($_CertChainObject.Build($CertObject)) + { + + "[{0}] Cert chain built successfully." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_CertsToReturn = $_CertChainObject.ChainElements | ? { $_.Certificate.Subject -ne $CertObject.Subject } + + # Reverse order so root is added first, then children on the appliance + [Array]::Reverse($_CertsToReturn) + + ForEach ($_CertToReturn in $_CertsToReturn) + { + + "[{0}] Returning '{1}' cert in chain." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_CertToReturn.Certificate.Subject | Write-Verbose + + $_CertToReturn.Certificate + + } + + } + + else + { + + # Generate error that chain was unable to be built from provided certificate. User should validate the certificate was issued by a valid external authority + $ExceptionMessage = "Unable to build certificate chain. Check the certificate provided '{0]' was issued by a valid external certificate authority." -f $_CertToReturn.Certificate.Subject + $ErrorRecord = New-ErrorRecord HPEOneView.Library.CertificateChainException UnableToBuildCertChain InvalidArgument "Certificate" -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + +} + +function CalculateSha384CertificateHash +{ + + [CmdletBinding (DefaultParameterSetName = 'Default')] + Param + ( + + [Parameter (Mandatory = $false, ValueFromPipeline, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [System.Security.Cryptography.X509Certificates.X509Certificate2]$CertObject + + ) + + Process + { + + $sha384 = [System.Security.Cryptography.SHA384]::Create() + $data = $sha384.ComputeHash($CertObject.RawData) + + $sb = [System.Text.StringBuilder]::new() + + # // Loop through each byte of the hashed data + # // and format each one as a hexadecimal string. + for ($i = 0; $i -lt $data.Count; $i++) + { + + [void]$sb.Append($data[$i].ToString("x2")) + + } + + # // Return the hexadecimal string. + $sb.ToString() + + } + +} + +function Update-OVApplianceTrustedAuthorityCrl +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = 'Default')] + # [OutputType([System.Collections.Generic.List[HPEOneView.Appliance.SecurityProtocol]], ParameterSetName = "Default")] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = 'Default')] + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = 'FilePath')] + [ValidateNotNullOrEmpty()] + [HPEOneView.Appliance.TrustedCertificateAuthority[]]$InputObject, + + [Parameter (Mandatory, ParameterSetName = 'FilePath')] + [System.IO.FileInfo]$Path, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [Parameter (Mandatory = $false, ParameterSetName = 'FilePath')] + [Switch]$Async, + + [Parameter (Mandatory = $False, ValueFromPipelineByPropertyName, ParameterSetName = 'Default')] + [Parameter (Mandatory = $False, ValueFromPipelineByPropertyName, ParameterSetName = 'FilePath')] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command agian." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $_GlobalAuthDirectorySettings = [System.Collections.ArrayList]::new() + + } + + Process + { + + if (-not $PSBoundParameters['Path']) + { + + try + { + + "[{0}] Testing for Proxy settings" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + [Uri]$_ProxyUri = $null + + $_Options = @{Uri = $InputObject.CRLInfo.EndPointList[0]} + + $_filename = Split-Path $InputObject.CRLInfo.EndPointList[0] -Leaf + + $_Proxy = [System.Net.WebRequest]::GetSystemWebProxy() + + $_Proxy.Credentials = [System.Net.CredentialCache]::DefaultCredentials + + $_ProxyUri = $_Proxy.GetProxy($_Options.Uri) + + if ($_ProxyUri.OriginalString -ne $_Options.Uri) + { + + "[{0}] Using proxy settings" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_Options.Add('Proxy',$_proxyUri) + $_Options.Add('ProxyUseDefaultCredentials', $true) + + } + + "[{0}] Invoke-WebRequest Options: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), ($_Options | Out-String) | Write-Verbose + + Invoke-WebRequest @_Options -OutFile "$env:TEMP\$_filename" + + [System.IO.FileInfo]$Path = "$env:TEMP\$_filename" + + } + + catch + { + + $errorMessage = "$($_[0].exception.message). $($_[0].exception.InnerException.message)" + $ErrorRecord = New-ErrorRecord HPEOneView.Library.UpdateConnectionError InvalidResult ConnectionError 'CheckOnline' -TargetType 'Switch' -Message "$($_[0].exception.message)." -InnerException $_.exception.InnerException + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + Try + { + + $_Uri = '{0}/crl' -f $InputObject.Uri + + Upload-File -Uri $_Uri -Method PUT -File $Path | Wait-OVTaskComplete + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + End + { + + '[{0}] Done.' -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Remove-OVApplianceTrustedCertificate +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (SupportsShouldProcess, ConfirmImpact = 'High')] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline)] + [ValidateNotNullOrEmpty()] + [Object]$InputObject, + + [Parameter (Mandatory = $false)] + [Switch]$Async, + + [Parameter (Mandatory = $False, ValueFromPipelineByPropertyName)] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not($PSBoundParameters['InputObject'])) + { + + $PipelineInput = $True + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command agian." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + } + + Process + { + + "[{0}] Processing Pipeline input" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + "[{0}] Object provided: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject | Write-Verbose + + If ($InputObject -isnot [HPEOneView.Appliance.TrustedCertificate] -and $InputObject -isnot [HPEOneView.Appliance.TrustedCertificateAuthority]) + { + + $ExceptionMessage = 'The InputObject is not a valid appliance trusted certificate.' + $ErrorRecord = New-ErrorRecord HPEOneView.InputObjectResourceException InvalidResourceObject InvalidArgument "InputObject" -TargetType $InputObject.GetType().Name -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + $_RemoveMessage = "remove appliance trusted certificate '{0}'" -f $InputObject.Name + + if ($PSCmdlet.ShouldProcess($InputObject.ApplianceConnection.Name, $_RemoveMessage)) + { + + "[{0}] Removing appliance trusted certificate: {1} ({2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject.Name, $InputObject.Uri | Write-Verbose + + Try + { + + $_Resp = Send-OVRequest -Uri $InputObject.Uri -Method DELETE -AddHeader @{'If-Match' = $InputObject.eTag } -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if (-not $PSBoundParameters['Async']) + { + + $_Resp | Wait-OVTaskComplete + + } + + else + { + + $_Resp + + } + + } + + elseif ($PSBoundParameters['WhatIf']) + { + + "[{0}] WhatIf Parameter was passed." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Get-OVLdap +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName='Default')] + Param + ( + + [Parameter (Mandatory, ParameterSetName = 'Export')] + [Alias ('x')] + [Switch]$Export, + + [Parameter (Mandatory, ParameterSetName = 'Export')] + [Alias ('location')] + [ValidateScript ({split-path $_ | Test-Path})] + [String]$Save, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [Parameter (Mandatory = $false, ParameterSetName = 'Export')] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command agian." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $_GlobalAuthDirectorySettings = [System.Collections.ArrayList]::new() + + } + + Process + { + + ForEach ($_appliance in $ApplianceConnection) + { + + "[{0}] Processing '{1}' Appliance (of {2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name, $ApplianceConnection.Count | Write-Verbose + + Try + { + + $_AuthDirectoryGlobalSettings = Send-OVRequest $authnSettingsUri -Hostname $_appliance.Name + + $_AuthDirectoryGlobalSettings | ForEach-Object { $_.psobject.typenames.Insert(0,"HPEOneview.Appliance.AuthGlobalDirectoryConfiguration") } + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + [void]$_GlobalAuthDirectorySettings.Add($_AuthDirectoryGlobalSettings) + + } + + } + + End + { + + if ($PSBoundParameters['export']) + { + + "[{0}] Exporting Global Directory configuration." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + ForEach ($_Directory in $_GlobalAuthDirectorySettings) + { + + "[{0}] Saving to: $($save)\$($_Directory.ApplianceConnection.Name)_globalSettings.json" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + ConvertTo-Json $_Directory > $save\$($_Directory.ApplianceConnection.Name)_globalSettings.json + + } + + } + + else + { + + Return $_GlobalAuthDirectorySettings + + } + + } + +} + +function Get-OVLdapDirectory +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = 'Default')] + Param + ( + + [Parameter (Mandatory = $false, ParameterSetName='Default')] + [Alias ('directory','domain')] + [String]$Name, + + [Parameter (Mandatory, ParameterSetName = 'Export')] + [Alias ('x')] + [ValidateScript({split-path $_ | Test-Path})] + [String]$Export, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [Parameter (Mandatory = $false, ParameterSetName = 'Export')] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command agian." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $_AuthDirectorySettings = [System.Collections.ArrayList]::new() + + } + + Process + { + + ForEach ($_appliance in $ApplianceConnection) + { + + $Found = [System.Collections.ArrayList]::new() + + "[{0}] Processing '{1}' Appliance (of {2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name, $ApplianceConnection.Count | Write-Verbose + + Try + { + + $_AuthDirectories = Send-OVRequest -uri $AuthnProvidersUri -Hostname $_appliance.Name + + If ($PSBoundParameters['Name']) + { + + $_AuthDirectories.members = $_AuthDirectories.members | Where-Object name -like $Name + + } + + if ($_AuthDirectories.members) + { + + $_AuthDirectories.members | ForEach-Object { + + $_.PSObject.TypeNames.Insert(0,"HPEOneview.Appliance.AuthDirectory") + + [void]$Found.Add($_) + + } + + } + + if ($Found.Count -eq 0 -and $PSBoundParameters['Name']) + { + + $ExceptionMessage = "The specified '{0}' Authentication Directory resource not found on Appliance '{1}'. Please check the name and try again." -f $Name, $_appliance.Name + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.LdapDirectoryException AuthDirectoryResourceNotFound ObjectNotFound "Name" -Message $ExceptionMessage + $PSCmdlet.WriteError($ErrorRecord) + + } + + $Found | ForEach-Object { + + $_.PSObject.TypeNames.Insert(0,"HPEOneview.Appliance.AuthDirectory") + + [void]$_AuthDirectorySettings.Add($_) + + } + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + End + { + + # Export directory settings (raw JSON) to file + if ($PSboundParameters['export']) + { + + # Loop through each directory and get all configured settings + ForEach ($_directory in $_AuthDirectorySettings) + { + + "[{0}] Exporting Directory $($_directory.name) configuration." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_SaveLocation = $Export + "\" + $_directory.ApplianceConnection.Name + "_" + $_directory.name + ".json" + + "[{0}] Saving to: $_SaveLocation" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_directory | Select-Object * -ExcludeProperty credential,created,modified,eTag + $_directory.directoryServers | Select-Object * -ExcludeProperty directoryServerCertificateStatus,serverStatus,created,modified,eTag + $_directory | convertto-json > $_SaveLocation + + } + + } + + else + { + + Return $_AuthDirectorySettings + + } + + } + +} + +function New-OVLdapDirectory +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName='AD')] + Param + ( + + [Parameter (Mandatory, ParameterSetName = "AD")] + [Parameter (Mandatory, ParameterSetName = "LDAP")] + [ValidateNotNullOrEmpty()] + [String]$Name, + + [Parameter (Mandatory, ParameterSetName = "AD")] + [Switch]$AD, + + [Parameter (Mandatory, ParameterSetName = "LDAP")] + [Alias ('LDAP')] + [Switch]$OpenLDAP, + + [Parameter (Mandatory, ParameterSetName = "AD")] + [Parameter (Mandatory, ParameterSetName = "LDAP")] + [ValidateNotNullOrEmpty()] + [Alias ('root','rootdn')] + [String]$BaseDN, + + [Parameter (Mandatory = $false, ParameterSetName = "LDAP")] + [ValidateSet('CN', 'UID', IgnoreCase = $False)] + [String]$UserNamingAttribute = 'CN', + + [Parameter (Mandatory, ParameterSetName = "LDAP")] + [ValidateNotNullOrEmpty()] + [Array]$OrganizationalUnits, + + [Parameter (Mandatory, ParameterSetName = "AD")] + [Parameter (Mandatory, ParameterSetName = "LDAP")] + [ValidateNotNullOrEmpty()] + [Array]$Servers, + + [Parameter (Mandatory = $false, ParameterSetName = "AD")] + [Parameter (Mandatory = $false, ParameterSetName = "LDAP")] + [ValidateNotNullOrEmpty()] + [Alias ('u','user')] + [String]$Username, + + [Parameter (Mandatory = $false, ParameterSetName = "AD")] + [Parameter (Mandatory = $false, ParameterSetName = "LDAP")] + [ValidateNotNullOrEmpty()] + [Alias ('p','pass')] + [Object]$Password, + + [Parameter (ValueFromPipeline, Mandatory = $false, ParameterSetName = "AD")] + [Parameter (ValueFromPipeline, Mandatory = $false, ParameterSetName = "LDAP")] + [ValidateNotNullOrEmpty()] + [PSCredential]$Credential, + + [Parameter (Mandatory = $false, ParameterSetName = "AD")] + [Parameter (Mandatory = $false, ParameterSetName = "LDAP")] + [Switch]$ServiceAccount, + + [Parameter (Mandatory = $false, ParameterSetName = 'AD')] + [Parameter (Mandatory = $false, ParameterSetName = 'LDAP')] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + if ($PSBoundParameters['Username']) + { + + Write-Warning "The -Username parameter will be deprecated in a future release. Please transition to using the -Credental Parameter." + + } + + if ($PSBoundParameters['Password']) + { + + Write-Warning "The -Username parameter will be deprecated in a future release. Please transition to using the -Credental Parameter." + + } + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command agian." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + if (-not($PSBoundParameters['Password']) -and $PSBoundParameters['Username']) + { + + do + { + + $securepass = Read-Host 'Password' -AsSecureString + $securepass2 = Read-Host 'Confirm Password' -AsSecureString + $_DecryptPassword = [Runtime.InteropServices.Marshal]::PtrToStringBSTR([Runtime.InteropServices.Marshal]::SecureStringToBSTR($securepass)) + $_DecryptPassword2 = [Runtime.InteropServices.Marshal]::PtrToStringBSTR([Runtime.InteropServices.Marshal]::SecureStringToBSTR($securepass2)) + + if ($_DecryptPassword -ne $_DecryptPassword2) + { + + Write-Host "Passwords do not match!" -BackgroundColor Red + + } + + } until ($_DecryptPassword -eq $_DecryptPassword2) + + } + + elseif ($Password -is [SecureString]) + { + + $_DecryptPassword = [Runtime.InteropServices.Marshal]::PtrToStringBSTR([Runtime.InteropServices.Marshal]::SecureStringToBSTR($Password)) + + } + + elseif ($PSBoundParameters['Password']) + { + + $_DecryptPassword = $Password + + } + + elseif ($PSBoundParameters['Credential']) + { + + $Username = $Credential.Username + $_DecryptPassword = [Runtime.InteropServices.Marshal]::PtrToStringBSTR([Runtime.InteropServices.Marshal]::SecureStringToBSTR($Credential.Password)) + + } + + else + { + + $ExceptionMessage = 'Please provide valid credentials using either -Username/-Password or -Credential parameters.' + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.LdapAuthenticationException NoValidCredentialParameters AuthenticationError "ApplianceConnection" -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + $_AuthDirectorySettings = [System.Collections.ArrayList]::new() + + } + + Process + { + + ForEach ($_appliance in $ApplianceConnection) + { + + "[{0}] Processing '{1}' Appliance (of {2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name, $ApplianceConnection.Count | Write-Verbose + + $_NewAuthDirectoryObj = NewObject -AuthDirectory + + $_NewAuthDirectoryObj.name = $Name + $_NewAuthDirectoryObj.baseDN = $BaseDN + $_NewAuthDirectoryObj.credential.userName = $Username + $_NewAuthDirectoryObj.credential.password = $_DecryptPassword + + if ($ServiceAccount) + { + + "[{0}] Setting provided user credential as Service Account." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_NewAuthDirectoryObj.directoryBindingType = $LdapDirectoryAccountBindTypeEnum['SERVICEACCOUNT'] + + } + + "[{0}] Validating Server object values" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + ForEach ($_Server in $Servers) + { + + if ($_Server -is [PSCustomObject] -and $_Server.type -eq 'LoginDomainDirectoryServerInfoDto') + { + + $__Server = $_Server.PSObject.Copy() + + # Process the certificate if included, which means TrustLeafCertificate was used with New-OVLdapServer + if (-not [System.String]::IsNullOrWhiteSpace($_DirectoryServer.directoryServerCertificateBase64Data)) + { + + "[{0}] Adding directory server certificate to appliance trust store" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + # Add the SSL certificate to the appliance + $_CertObject = NewObject -ApplianceTrustedSslCertificate + $_CertObject.aliasName = '{0}_{1}' -f $Name, $__Server.directoryServerIpAddress + $_CertObject.base64Data = $__Server.directoryServerCertificateBase64Data + + $_CertToImportCollection = [PSCustomObject]@{ + + type = 'CertificateInfoV2'; + certificateDetails = [System.Collections.ArrayList]::new() + + } + + [void]$_CertToImportCollection.certificateDetails.Add($_CertObject) + + Try + { + + $Null = Send-OVRequest -Uri $ApplianceTrustedSslHostStoreUri -Method POST -Body $_CertToImportCollection -AddHeader @{Forcesaveleaf = $true} -Hostname $_appliance | Wait-OVTaskComplete + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingErro($_) + + } + + $__Server.directoryServerCertificateBase64Data = $null + + } + + [void]$_NewAuthDirectoryObj.directoryServers.Add($__Server) + + } + + else + { + + $ExceptionMessage = "The Servers Parameter contains an invalid Server object: {0}. Please correct this value and try again." -f $_Server.name + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.LdapDirectoryException InvalidDirectoryServer InvalidArgument 'Servers' -TargetType ($_Server.GetType().Name) -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + if ($PSBoundParameters['OpenLDAP']) + { + + $_NewAuthDirectoryObj.authProtocol = 'LDAP' + $_NewAuthDirectoryObj.userNamingAttribute = $UserNamingAttribute + + ForEach ($_ou in $OrganizationalUnits) + { + + if ($_ou.type -match $OrganizationalUnitPattern) + { + + [void]$_NewAuthDirectoryObj.orgUnits.Add($_ou) + + } + + else + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.LdapDirectoryException InvalidDirectoryServer InvalidArgument 'OrganizationalUnits' -Message "The OrganizationalUnits Parameter contains an invalid OU value: '$_ou'. Please correct this value and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + } + + Try + { + + # API is broken + # "[{0}] Validating authentication directory setting is valid" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + # $_validateresp = Send-OVRequest -Uri $authnProviderValidatorUri -Method POST -Body $_NewAuthDirectoryObj -Hostname $_appliance + + "[{0}] Submitting request to create new authentication directory" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_resp = Send-OVRequest -Uri $authnProvidersUri -Method POST -Body $_NewAuthDirectoryObj -Hostname $_appliance + + $_resp.PSObject.TypeNames.Insert(0,"HPEOneview.Appliance.AuthDirectory") + + [void]$_AuthDirectorySettings.Add($_resp) + + } + + Catch + { + + foreach ($NestedError in (${Global:ResponseErrorObject} | Where-Object Name -eq $_appliance.Name).ErrorResponse.nestedErrors) + { + + if ($NestedError.errorCode -eq "AUTHN_LOGINDOMAIN_SERVER_AUTHENTICATION_ERROR" ) + { + + $ErrorCategory = 'AuthenticationError' + + } + + elseif ($NestedError.errorCode -eq "AUTHN_LOGINDOMAIN_DUPLICATE_NAME" ) + { + + $ErrorCategory = 'ResourceExists' + + } + + else + { + + $ErrorCategory = 'InvalidOperation' + + } + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.LdapDirectoryException $NestedError.errorCode $ErrorCategory "New-OVLdapDirectory" -Message "$($NestedError.message) $($NestedError.details)" + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.LdapDirectoryException InvalidResult InvalidOperation 'New-OVLdapDirectory' -Message "$((${Global:ResponseErrorObject} | ? Name -eq $_appliance.Name).ErrorResponse.message) $((${Global:ResponseErrorObject} | ? Name -eq $_appliance.Name).ErrorResponse.details)" + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + } + + End + { + + Return $_AuthDirectorySettings + + } + +} + +function Remove-OVLdapDirectory +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "default", SupportsShouldProcess, ConfirmImpact = 'High')] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = "default")] + [ValidateNotNullOrEmpty()] + [Alias ("d",'Directory')] + [Object]$InputObject, + + [Parameter (Mandatory = $False, ValueFromPipelineByPropertyName, ParameterSetName = "default")] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default), + + [Parameter (Mandatory = $False, ParameterSetName = "default")] + [Switch]$Force + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not($PSBoundParameters['InputObject'])) + { + + $PipelineInput = $True + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command agian." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + $_TaskCollection = [System.Collections.ArrayList]::new() + $_DirectoryCollection = [System.Collections.ArrayList]::new() + + } + + Process + { + + if ($PipelineInput -or $InputObject -is [PSCustomObject]) + { + + "[{0}] Processing Pipeline input" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + # "[{0}] Directory Object provided: {1} ({2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject.name, $InputObject.uri | Write-Verbose + + If ($InputObject.category -eq $ResourceCategoryEnum.User) + { + + If (-not($InputObject.ApplianceConnection)) + { + + $ErrorRecord = New-ErrorRecord InvalidOperationException InvalidArgumentValue InvalidArgument "Directory:$($InputObject.Name)" -TargetType PSObject -Message "The Directory resource provided is missing the source ApplianceConnection property. Please check the object provided and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + [void]$_DirectoryCollection.Add($InputObject) + + } + + else + { + + $ErrorRecord = New-ErrorRecord InvalidOperationException InvalidArgumentValue InvalidArgument "Directory:$($InputObject.Name)" -TargetType PSObject -Message "The Directory resource is not an expected category type [$($InputObject.category)]. Allowed resource category type is 'users'. Please check the object provided and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + else + { + + ForEach ($_appliance in $ApplianceConnection) + { + + "[{0}] Processing Appliance $($_appliance.Name) (of $($ApplianceConnection.Count))" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + "[{0}] Processing Directory Name $($InputObject)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $_directory = Get-OVLdapDirectory $InputObject -ApplianceConnection $_appliance + + $_directory | ForEach-Object { + + [void]$_DirectoryCollection.Add($_) + + } + + } + + Catch + { + + if ([RegEx]::Match($_.FullyQualifiedErrorId, 'AuthDirectoryResourceNotFound', $RegExInsensitiveFlag).Success) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.LdapDirectoryException AuthDirectoryResourceNotFound ObjectNotFound 'InputObject' -Message "The Directory '$InputObject' was not found on Appliance '$($_appliance.Name)'." + $PSCmdlet.WriteError($ErrorRecord) + + } + + else + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + } + + } + + End + { + + "[{0}] Processing $($_DirectoryCollection.count) Authentication Directory resources to remove." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + # Process Directory Resources + ForEach ($_Directory in $_DirectoryCollection) + { + + if ($PSCmdlet.ShouldProcess($_Directory.ApplianceConnection.Name,"remove directory '$($_Directory.name)'")) + { + + "[{0}] Removing Directory '$($_Directory.name)' from appliance '$($_Directory.ApplianceConnection.Name)'." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $_resp = Send-OVRequest -Uri $_Directory.Uri -Method DELETE -Hostname $_Directory.ApplianceConnection.Name -AddHeader @{'If-Match' = $InputObject.eTag } + + $_resp | Add-Member -NotePropertyName name -NotePropertyValue $_Directory.name + + $_resp + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + elseif ($PSBoundParameters['WhatIf']) + { + + "[{0}] WhatIf Parameter was passed." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + } + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Set-OVLdapDefaultDirectory +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (SupportsShouldProcess, ConfirmImpact = 'High')] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = "Default")] + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = "EmergencyLocalLogin")] + [ValidateNotNullOrEmpty()] + [Alias('Directory')] + [Object]$InputObject, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Parameter (Mandatory, ParameterSetName = "EmergencyLocalLogin")] + [Bool]$DisableLocalLogin, + + [Parameter (Mandatory, ParameterSetName = "EmergencyLocalLogin")] + [bool]$EnableEmergencyLocalLogin, + + [Parameter (Mandatory = $false, ParameterSetName = "EmergencyLocalLogin")] + [ValidateSet ('ApplianceConsoleOnly', 'NetworkAndApplianceConsole')] + [String]$EmergencyLoginAllowType = "ApplianceConsoleOnly", + + [Parameter (Mandatory = $False, ValueFromPipelineByPropertyName, ParameterSetName = "Default")] + [Parameter (Mandatory = $False, ValueFromPipelineByPropertyName, ParameterSetName = "EmergencyLocalLogin")] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not($PSBoundParameters['InputObject'])) + { + + $PipelineInput = $True + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command agian." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + $_TaskCollection = [System.Collections.ArrayList]::new() + $_DirectoryCollection = [System.Collections.ArrayList]::new() + + } + + #Build collection of objects to Process + Process + { + + ForEach ($_appliance in $ApplianceConnection) + { + + "[{0}] Processing Appliance {1} (of {2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance, $ApplianceConnection.Count | Write-Verbose + + # Get current configuration, then set the settings + try + { + + $_CurrentAuthenticationSettings = Send-OVRequest -Uri $authnSettingsUri -Hostname $_appliance.Name + + } + + catch + { + + $PSCMdlet.ThrowTerminatingError($_) + + } + + Switch ($PSBoundParameters.Keys) + { + + 'InputObject' + { + + switch ($InputObject.Gettype().Name) + { + + "String" + { + + if ($InputObject -ne "Local") + { + + "[{0}] Authentication Directory Name provided: $InputObject" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $_InputObject = Get-OVLdapDirectory -Name $InputObject -Hostname $_appliance.Name -ErrorAction Stop + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + elseif ($InputObject -eq "Local") + { + + "[{0}] Setting authentication directory to LOCAL" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if ($DisableLocalLogin) + { + + $ExceptionMessage = "The authentication directory cannot be set to LOCAL when also disabling local logins. You must specify an authentication directory configured on the appliance." + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.LdapDirectoryException InvalidAuthDirectoryObject InvalidArgument "DisableLocalLogin" -TargetType "Bool" -Message $ExceptionMessage + + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + $_InputObject = [PSCustomObject] @{ + + type = 'LoginDomainConfigInfoDto'; + name = "LOCAL"; + uri = ""; + loginDomain = "0"; + + } + + "[{0}] Ensuring allowLocalLogin is enabled and emergancyLocalLoginEnabled disabled." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_CurrentAuthenticationSettings.allowLocalLogin = $true + $_CurrentAuthenticationSettings.emergencyLocalLoginEnabled = $false + + "[{0}] Removing emergencyLocalLoginType property." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_CurrentAuthenticationSettings = $_CurrentAuthenticationSettings | Select * -Exclude emergencyLocalLoginType + + } + + } + + "PSCustomObject" + { + + if ([RegEx]::Match($InputObject.type, 'LoginDomainConfig', $RegExInsensitiveFlag).Success) + { + + "[{0}] Authentication Directory Object provided: {1} ({2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject.name, $InputObject.uri | Write-Verbose + + $_Inputobject = $InputObject.PSObject.Copy() | Select-Object -Property type, uri, category, etag, created, modified, logindomain, name + + $_Inputobject.type = 'LoginDomainConfigInfoDto' + + } + + else + { + + $ExceptionMessage = "The authentication directory object type '$($InputObject.type)' provided is not correct. The type must be 'LoginDomainConfigVersion200'. Please correct the value and try again." + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.LdapDirectoryException InvalidAuthDirectoryObject InvalidArgument "InputObject" -TargetType "PSObject" -Message $ExceptionMessage + + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + } + + $_CurrentAuthenticationSettings.defaultLoginDomain = $_Inputobject + + } + + 'DisableLocalLogin' + { + + $_CurrentAuthenticationSettings.allowLocalLogin = (-not $PSBoundParameters['DisableLocalLogin']) + + if (-not $DisableLocalLogin) + { + + $_CurrentAuthenticationSettings | Select -Exclude emergencyLocalLoginType + + } + + } + + 'EnableEmergencyLocalLogin' + { + + # $_DefaultDirectoryConfig | Add-Member -NotePropertyName emergencyLocalLoginEnabled -NotePropertyValue $false + + if ($EnableEmergencyLocalLogin) + { + + "[{0}] Enable Emergency Local Login on the appliance." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_CurrentAuthenticationSettings.emergencyLocalLoginEnabled = $true + + } + + else + { + + "[{0}] Disable Emergency Local Login on the appliance." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_CurrentAuthenticationSettings.emergencyLocalLoginEnabled = $false + + } + + $_CurrentAuthenticationSettings | Add-Member -NotePropertyName emergencyLocalLoginType -NotePropertyValue "" -Force + + switch ($EmergencyLoginAllowType) + { + + 'APPLIANCECONSOLEONLY' + { + + "[{0}] Enable Emergency Local Login via console only on the appliance." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_CurrentAuthenticationSettings.emergencyLocalLoginType = $EmergencyLocalLoginTypeEnum['APPLIANCECONSOLEONLY'] + + } + + 'NETWORKANDAPPLIANCECONSOLE' + { + + "[{0}] Enable Emergency Local Login via console only on the appliance." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_CurrentAuthenticationSettings.emergencyLocalLoginType = $EmergencyLocalLoginTypeEnum['NETWORKANDAPPLIANCECONSOLE'] + + } + + } + + } + + } + + [void]$_DirectoryCollection.Add($_CurrentAuthenticationSettings.PSObject.Copy()) + + } + + } + + # Process objects here + End + { + + ForEach ($_DirectoryToProcess in $_DirectoryCollection) + { + + $ConfirmPromptMessage = "set appliance authentication directory '{0}' as default domain" -f $_DirectoryToProcess.defaultLoginDomain.name + + if ($PSBoundParameters.Keys -Contains 'EnableEmergencyLocalLogin') + { + + $ConfirmPromptMessage += " and {0} emergency local logins" + + if ($_DirectoryToProcess.emergencyLocalLoginEnabled) + { + + $ConfirmPromptMessage = $ConfirmPromptMessage -f 'enable' + + } + + else + { + + $ConfirmPromptMessage = $ConfirmPromptMessage -f 'disable' + + } + + } + + if ($PSCmdlet.ShouldProcess($_DirectoryToProcess.ApplianceConnection.Name, $ConfirmPromptMessage)) + { + + "[{0}] Setting default Authentication Directory to: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_DirectoryToProcess.defaultLoginDomain.name | Write-Verbose + + Try + { + + $_resp = Send-OVRequest -Uri $authnSettingsUri -Method PUT -Body $_DirectoryToProcess -Hostname $_DirectoryToProcess.ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if ($PSVersiontable.Platform -match 'win') + { + + "[{0}] Setting PowerShell library AuthProvider registry (HKCU:\Software\Hewlett-Packard\HPEOneView value to 'AuthProvider#{1}'" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_DirectoryToProcess.defaultLoginDomain.name | Write-Verbose + + Set-ItemProperty -Path HKCU:\Software\Hewlett-Packard\HPEOneView -Name ("AuthProvider#{0}" -f $_DirectoryToProcess.ApplianceConnection.Name) -Value $_DirectoryToProcess.defaultLoginDomain.name -Type STRING | Write-Verbose + + } + + } + + elseif ($PSBoundParameters['WhatIf']) + { + + "[{0}] WhatIf was passed." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_resp = $null + + } + + else + { + + "[{0}] User likely selected 'No' to prompt." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_resp = $null + + } + + $_resp + + } + + } + +} + +function Enable-OVLdapLocalLogin +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (SupportsShouldProcess, ConfirmImpact = 'High')] + Param + ( + + [Parameter (Mandatory = $False)] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command agian." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $_TaskCollection = [System.Collections.ArrayList]::new() + + } + + Process + { + + ForEach ($_appliance in $ApplianceConnection) + { + + "[{0}] Processing Appliance $($_appliance.Name) (of $($ApplianceConnection.Count)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + # Get current auth directory configuration + $_currentLocalLoginAllowedConfig = Send-OVRequest $AuthnLocalLoginsAllowedUri -Hostname $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + # $_currentLocalLoginAllowedConfig.allowLocalLogin = $True + + if ($_currentLocalLoginAllowedConfig.allowLocalLogin) + { + + $Message = "Local logins already enabled on {0}" -f $_appliance + + "[{0}] {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Message | Write-Verbose + + Write-Warning $Message + + } + + elseif ($PSCmdlet.ShouldProcess($_appliance.Name, "enable local logins")) + { + + Try + { + + # Update Configuration + $_resp = Send-OVRequest -Uri $AuthnLocalLoginsAllowedUri -Method POST -Body $true -Hostname $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + [void]$_TaskCollection.Add($_resp) + + } + + elseif ($PSBoundParameters['Whatif']) + { + + "[{0}] WhatIf Parameter was passed." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + } + + } + + End + { + + Return $_TaskCollection + + } + +} + +function Disable-OVLdapLocalLogin +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (SupportsShouldProcess, ConfirmImpact = 'High', DefaultParameterSetName = "Default")] + Param + ( + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [bool]$EnableEmergencyLocalLogin, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [ValidateSet ('ApplianceConsoleOnly', 'NetworkAndApplianceConsole')] + [String]$EmergencyLoginAllowType = "ApplianceConsoleOnly", + + [Parameter (Mandatory = $False, ParameterSetName = "Default")] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command agian." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $_TaskCollection = [System.Collections.ArrayList]::new() + + } + + Process + { + + ForEach ($_appliance in $ApplianceConnection) + { + + $ConfirmPromptMessage = "disable local logins" -f $_DirectoryToProcess.defaultLoginDomain.name + + "[{0}] Processing Appliance $($_appliance.Name) (of $($ApplianceConnection.Count)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if ($_appliance.AuthLoginDomain -eq 'LOCAL') + { + + $ExceptionMessage = 'To disable local login you must log in using another authentication service.' + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException InvalidLoginDomain InvalidOperation 'AuthLoginDomain' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Try + { + + # Get current auth directory configuration + $_DirectoryConfig = Send-OVRequest -Uri $authnSettingsUri -Hostname $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if ($_DirectoryConfig.defaultLoginDomain.name -eq 'LOCAL') + { + + $ExceptionMessage = 'The Default Login Domain must not be set to "LOCAL" before disabling Local Logins.' + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.LdapConfigurationException InvalidDefaultLoginDomain InvalidOperation 'DefaultLoginDomain' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + $_DirectoryConfig.allowLocalLogin = $false + + if ($PSBoundParameters.Keys -contains 'EnableEmergencyLocalLogin') + { + + if ($EnableEmergencyLocalLogin) + { + + "[{0}] Enable Emergency Local Login on the appliance." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_DirectoryConfig.emergencyLocalLoginEnabled = $true + + $ConfirmPromptMessage += " and enable emergency local logins" + + } + + else + { + + "[{0}] Disable Emergency Local Login on the appliance." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_DirectoryConfig.emergencyLocalLoginEnabled = $false + + $ConfirmPromptMessage += " and disable emergency local logins" + + } + + $_DirectoryConfig | Add-Member -NotePropertyName emergencyLocalLoginType -NotePropertyValue "" -Force + + switch ($EmergencyLoginAllowType) + { + + 'APPLIANCECONSOLEONLY' + { + + "[{0}] Enable Emergency Local Login via console only on the appliance." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_DirectoryConfig.emergencyLocalLoginType = $EmergencyLocalLoginTypeEnum['APPLIANCECONSOLEONLY'] + + } + + 'NETWORKANDAPPLIANCECONSOLE' + { + + "[{0}] Enable Emergency Local Login via console only on the appliance." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_DirectoryConfig.emergencyLocalLoginType = $EmergencyLocalLoginTypeEnum['NETWORKANDAPPLIANCECONSOLE'] + + } + + } + + } + + "[{0}] Current global authentication settings: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), ($_DirectoryConfig | ConvertTo-Json) | Write-Verbose + + if ($PSCmdlet.ShouldProcess($_appliance, $ConfirmPromptMessage)) + { + + Try + { + + # Update Configuration + $_resp = Send-OVRequest -Uri $AuthnSettingsUri -Method PUT -Body $_DirectoryConfig -Hostname $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + [void]$_TaskCollection.Add($_resp) + + } + + elseif ($PSBoundParameters['Whatif']) + { + + "[{0}] WhatIf Parameter was passed." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + } + + } + + End + { + + Return $_TaskCollection + + } + +} + +function New-OVLdapServer +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "default")] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = "default")] + [ValidateNotNullorEmpty()] + [Alias ('Name')] + [String]$Hostname, + + [Parameter (Mandatory = $false, ParameterSetName = "default")] + [Alias ('port')] + [ValidateRange (1,65535)] + [Int32]$SSLPort = 636, + + [Parameter (Mandatory = $false, ParameterSetName = "default")] + [Alias ('cert')] + [Object]$Certificate, + + [Parameter (Mandatory = $false, ParameterSetName = "default")] + [Switch]$TrustLeafCertificate + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + $_AuthDirectoryServer = [System.Collections.ArrayList]::new() + + } + + Process + { + + Try + { + + $Parameters = @{ + + Hostname = $Hostname; + + } + + if ($SSLPort) + { + + $Parameters.Add("SSLPort", $SSLPort) + + } + + if ($Certificate) + { + + $Parameters.Add("Certificate", $Certificate) + + } + + if ($TrustLeafCertificate) + { + + $Parameters.Add("TrustLeafCertificate", $TrustLeafCertificate.IsPresent) + + } + + $_LdapServer = BuildLdapServer @Parameters + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + # Add the directory server to the provided Auth Directory + if ($InputObject) + { + + "[{0}] Processing Auth Directory value" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if ($InputObject.category -ne 'users') + { + + $ExceptionMessage = "The Directory resource is not an expected category type [{0}]. Allowed resource category type is 'users'. Please check the object provided and try again." -f $InputObject.category + $ErrorRecord = New-ErrorRecord InvalidOperationException InvalidArgumentValue InvalidArgument $InputObject.Name -TargetType PSObject -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + if (-not($PSBoundParameters['Password'])) + { + + do + { + + $securepass = Read-Host 'Password' -AsSecureString + $securepass2 = Read-Host 'Confirm Password' -AsSecureString + $_DecryptPassword = [Runtime.InteropServices.Marshal]::PtrToStringBSTR([Runtime.InteropServices.Marshal]::SecureStringToBSTR($securepass)) + $_DecryptPassword2 = [Runtime.InteropServices.Marshal]::PtrToStringBSTR([Runtime.InteropServices.Marshal]::SecureStringToBSTR($securepass2)) + + if ($_DecryptPassword -ne $_DecryptPassword2) + { + + Write-Host "Passwords do not match!" -BackgroundColor Red + + } + + } until ($_DecryptPassword -eq $_DecryptPassword2) + + } + + elseif ($Password -is [SecureString]) + { + + $_DecryptPassword = [Runtime.InteropServices.Marshal]::PtrToStringBSTR([Runtime.InteropServices.Marshal]::SecureStringToBSTR($Password)) + + } + + else + { + + $_DecryptPassword = $Password + + } + + # Add credentials to object + $InputObject.credential = @{ userName = $Username; password = $_DecryptPassword } + + Try + { + + $_resp = Send-OVRequest -Uri $InputObject.Uri -Method PUT -Body $InputObject -Hostname $InputObject.ApplianceConnection.Name + + $_resp.PSObject.TypeNames.Insert(0,"HPEOneview.Appliance.AuthDirectory") + + $_resp + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + else + { + + "[{0}] Return directory server object" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_ldapServer + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Add-OVLdapServer +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "default")] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = "default")] + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = 'PSCredential')] + [ValidateNotNullorEmpty()] + [PSCustomObject]$InputObject, + + [Parameter (Mandatory, ParameterSetName = "default")] + [Parameter (Mandatory, ParameterSetName = "PSCredential")] + [ValidateNotNullorEmpty()] + [Alias ("Name")] + [String]$Hostname, + + [Parameter (Mandatory = $false, ParameterSetName = "default")] + [Parameter (Mandatory = $false, ParameterSetName = "PSCredential")] + [Alias ('port')] + [ValidateRange (1,65535)] + [Int32]$SSLPort = 636, + + [Parameter (Mandatory = $false, ParameterSetName = "default")] + [Parameter (Mandatory = $false, ParameterSetName = "PSCredential")] + [Alias ('cert')] + [Object]$Certificate, + + [Parameter (Mandatory, ParameterSetName = "default")] + [ValidateNotNullOrEmpty()] + [Alias ('u','user')] + [String]$Username, + + [Parameter (Mandatory = $false, ParameterSetName = "default")] + [ValidateNotNullOrEmpty()] + [Alias ('p','pass')] + [Object]$Password, + + [Parameter (Mandatory, ParameterSetName = "PSCredential")] + [ValidateNotNullOrEmpty()] + [PSCredential]$Credential, + + [Parameter (Mandatory = $false, ParameterSetName = "default")] + [Parameter (Mandatory = $false, ParameterSetName = "PSCredential")] + [Switch]$TrustLeafCertificate, + + [Parameter (Mandatory = $False, ValueFromPipelineByPropertyName, ParameterSetName = "default")] + [Parameter (Mandatory = $False, ValueFromPipelineByPropertyName, ParameterSetName = 'PSCredential')] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection + + ) + + Begin + { + + if ($PSBoundParameters['Username']) + { + + Write-Warning "The -Username parameter will be deprecated in a future release. Please transition to using the -Credental Parameter." + + } + + if ($PSBoundParameters['Password']) + { + + Write-Warning "The -Username parameter will be deprecated in a future release. Please transition to using the -Credental Parameter." + + } + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not $InputObject) + { + + $PipelineINput = $true + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command agian." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + if (-not($PSBoundParameters['Password']) -and $PSBoundParameters['Username']) + { + + do + { + + $securepass = Read-Host 'Password' -AsSecureString + $securepass2 = Read-Host 'Confirm Password' -AsSecureString + $_DecryptPassword = [Runtime.InteropServices.Marshal]::PtrToStringBSTR([Runtime.InteropServices.Marshal]::SecureStringToBSTR($securepass)) + $_DecryptPassword2 = [Runtime.InteropServices.Marshal]::PtrToStringBSTR([Runtime.InteropServices.Marshal]::SecureStringToBSTR($securepass2)) + + if ($_DecryptPassword -ne $_DecryptPassword2) + { + + Write-Host "Passwords do not match!" -BackgroundColor Red + + } + + } until ($_DecryptPassword -eq $_DecryptPassword2) + + } + + elseif ($Password -is [SecureString]) + { + + $_DecryptPassword = [Runtime.InteropServices.Marshal]::PtrToStringBSTR([Runtime.InteropServices.Marshal]::SecureStringToBSTR($Password)) + + } + + elseif ($PSBoundParameters['Password']) + { + + $_DecryptPassword = $Password + + } + + elseif ($PSBoundParameters['Credential']) + { + + $Username = $Credential.Username + $_DecryptPassword = [Runtime.InteropServices.Marshal]::PtrToStringBSTR([Runtime.InteropServices.Marshal]::SecureStringToBSTR($Credential.Password)) + + } + + else + { + + $ExceptionMessage = 'Please provide valid credentials using either -Username/-Password or -Credential parameters.' + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.LdapAuthenticationException NoValidCredentialParameters AuthenticationError "ApplianceConnection" -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + Process + { + + Try + { + + $Parameters = @{ + + Hostname = $Hostname; + + } + + if ($SSLPort) + { + + $Parameters.Add("SSLPort", $SSLPort) + + } + + if ($Certificate) + { + + $Parameters.Add("Certificate", $Certificate) + + } + + if ($TrustLeafCertificate) + { + + $Parameters.Add("TrustLeafCertificate", $TrustLeafCertificate.IsPresent) + + } + + $_LdapServer = BuildLdapServer @Parameters + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + # "[{0}] New Auth Directory Server Object: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $($_ldapServer | Format-List * ) | Write-Verbose + + "[{0}] Processing Auth Directory value" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if ($InputObject.category -ne 'users') + { + + $ExceptionMessage = "The Directory resource is not an expected category type [{0}]. Allowed resource category type is 'users'. Please check the object provided and try again." -f $InputObject.category + $ErrorRecord = New-ErrorRecord InvalidOperationException InvalidArgumentValue InvalidArgument $InputObject.Name -TargetType PSObject -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + # Add credentials to object + if ($InputObject.directoryBindingType -eq $LdapDirectoryAccountBindTypeEnum['USERACCOUNT']) + { + + $InputObject.credential = @{ userName = $Username; password = $_DecryptPassword } + + } + + else + { + + $InputObject.credential.userName = $Username + $InputObject.credential.password = $_DecryptPassword + + } + + # Rebuild directoryServers property + $_DirectoryServers = $InputObject.directoryServers.Clone() + + $InputObject.directoryServers = [System.Collections.ArrayList]::new() + + [Void]$InputObject.directoryServers.Add($_ldapServer) + + ForEach ($_Server in $_DirectoryServers) + { + + [Void]$InputObject.directoryServers.Add($_Server) + + } + + Try + { + + $_resp = Send-OVRequest -Uri $InputObject.Uri -Method PUT -Body $InputObject -Hostname $InputObject.ApplianceConnection.Name + + $_resp.PSObject.TypeNames.Insert(0,"HPEOneview.Appliance.AuthDirectory") + + $_resp + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function BuildLdapServer +{ + + [CmdletBinding (DefaultParameterSetName = "default")] + Param + ( + + [Parameter (Mandatory, ParameterSetName = "default")] + [ValidateNotNullorEmpty()] + [Alias ("Name")] + [String]$Hostname, + + [Parameter (Mandatory = $false, ParameterSetName = "default")] + [Alias ('port')] + [ValidateRange (1,65535)] + [Int32]$SSLPort = 636, + + [Parameter (Mandatory = $false, ParameterSetName = "default")] + [Alias ('cert')] + [Object]$Certificate, + + [Parameter (Mandatory = $false, ParameterSetName = "default")] + [Bool]$TrustLeafCertificate + + ) + + Process + { + + $Base64Certificate = "" + + if ($Certificate) + { + + if (Test-Path $Certificate) + { + + "[{0}] Certificate file found." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $readfile = [System.IO.File]::OpenText($Certificate) + $certificate = $readfile.ReadToEnd() + $readfile.Close() + $Base64Certificate = ($Certificate | Out-String) -join "`n" + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + else + { + + $ErrorRecord = New-ErrorRecord System.IO.FileNotFoundException CertificateNotFound ObjectNotFound 'Certificate' -TargetType 'PSObject' -Message "Autehntication Directory Server SSL certiciate not found. Please check the path of the public key, and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + elseif ($TrustLeafCertificate) + { + + "[{0}] Attempting to get SSL certificate from '{1}' on '{2}'" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Hostname, $Sslport | Write-Verbose + + try + { + + $Certificate = [HPEOneView.Utilities.Net]::DownloadSslCertificate($Hostname, $SslPort) + + } + + catch + { + + '[{0}] Caught exception' -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $sb = [System.Text.StringBuilder]::new() + + [void]$sb.Append("-----BEGIN CERTIFICATE-----`n") + [void]$sb.Append([System.Convert]::ToBase64String($Certificate.RawData, "InsertLineBreaks")) + [void]$sb.Append("`n-----END CERTIFICATE-----`n") + + $Base64Certificate = $sb.ToString() + + } + + $_LdapServer = NewObject -AuthDirectoryServer + + $_LdapServer.directoryServerIpAddress = $Hostname + $_LdapServer.directoryServerCertificateBase64Data = $Base64Certificate + + if ($PSBoundParameters['Sslport']) + { + + $_LdapServer.directoryServerSSLPortNumber = $Sslport.ToString() + + } + + $_LdapServer.PSObject.TypeNames.Insert(0,'HPEOneview.Appliance.AuthDirectoryServer') + + return $_LdapServer + + } + +} + +function Remove-OVLdapServer +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "Default", SupportsShouldProcess, ConfirmImpact = 'High')] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = 'Default')] + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = 'PSCredential')] + [Alias ('Directory')] + [ValidateNotNullorEmpty()] + [Object]$InputObject, + + [Parameter (Mandatory, ParameterSetName = 'Default')] + [Parameter (Mandatory, ParameterSetName = 'PSCredential')] + [ValidateNotNullorEmpty()] + [Alias ('Name')] + [String]$DirectoryServerName, + + [Parameter (Mandatory, ParameterSetName = "Default")] + [ValidateNotNullOrEmpty()] + [Alias ('u','user')] + [String]$Username, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [ValidateNotNullOrEmpty()] + [Alias ('p','pass')] + [Object]$Password, + + [Parameter (Mandatory, ParameterSetName = "PSCredential")] + [ValidateNotNullOrEmpty()] + [PSCredential]$Credential, + + [Parameter (Mandatory = $False, ValueFromPipelineByPropertyName, ParameterSetName = 'Default')] + [Parameter (Mandatory = $False, ValueFromPipelineByPropertyName, ParameterSetName = 'PSCredential')] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection + + ) + + Begin + { + + if ($PSBoundParameters['Username']) + { + + Write-Warning "The -Username parameter will be deprecated in a future release. Please transition to using the -Credental Parameter." + + } + + if ($PSBoundParameters['Password']) + { + + Write-Warning "The -Username parameter will be deprecated in a future release. Please transition to using the -Credental Parameter." + + } + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not $InputObject) + { + + $PipelineINput = $true + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command agian." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + if (-not($PSBoundParameters['Password']) -and $PSBoundParameters['Username']) + { + + do + { + + $securepass = Read-Host 'Password' -AsSecureString + $securepass2 = Read-Host 'Confirm Password' -AsSecureString + $_DecryptPassword = [Runtime.InteropServices.Marshal]::PtrToStringBSTR([Runtime.InteropServices.Marshal]::SecureStringToBSTR($securepass)) + $_DecryptPassword2 = [Runtime.InteropServices.Marshal]::PtrToStringBSTR([Runtime.InteropServices.Marshal]::SecureStringToBSTR($securepass2)) + + if ($_DecryptPassword -ne $_DecryptPassword2) + { + + Write-Host "Passwords do not match!" -BackgroundColor Red + + } + + } until ($_DecryptPassword -eq $_DecryptPassword2) + + } + + elseif ($Password -is [SecureString]) + { + + $_DecryptPassword = [Runtime.InteropServices.Marshal]::PtrToStringBSTR([Runtime.InteropServices.Marshal]::SecureStringToBSTR($Password)) + + } + + elseif ($PSBoundParameters['Password']) + { + + $_DecryptPassword = $Password + + } + + elseif ($PSBoundParameters['Credential']) + { + + $Username = $Credential.Username + $_DecryptPassword = [Runtime.InteropServices.Marshal]::PtrToStringBSTR([Runtime.InteropServices.Marshal]::SecureStringToBSTR($Credential.Password)) + + } + + else + { + + $ExceptionMessage = 'Please provide valid credentials using either -Username/-Password or -Credential parameters.' + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.LdapAuthenticationException NoValidCredentialParameters AuthenticationError "ApplianceConnection" -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + Process + { + + if ($PipelineInput -or $InputObject -is [PSCustomObject]) + { + + "[{0}] Processing Pipeline input" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + "[{0}] LdapDirectory Object provided: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), ($InputObject | Format-List *) | Write-Verbose + + If ('users' -contains $InputObject.category) + { + + If (-not($InputObject.ApplianceConnection)) + { + + $ExceptionMessage = "The InputObject parameter value resource provided is missing the source ApplianceConnection property. Please check the object provided and try again." + + $ErrorRecord = New-ErrorRecord InvalidOperationException InvalidArgumentValue InvalidArgument "InputObject" -TargetType PSObject -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + else + { + + $ExceptionMessage = "The Group object resource is not an expected category type [{0}]. The allowed resource category type is 'users'. Please check the object provided and try again." -f $InputObject.category + $ErrorRecord = New-ErrorRecord InvalidOperationException InvalidArgumentValue InvalidArgument "InputObject" -TargetType PSObject -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + # Add credentials to object + if ($InputObject.directoryBindingType -eq $LdapDirectoryAccountBindTypeEnum['USERACCOUNT']) + { + + $InputObject.credential = @{ userName = $Username; password = $_DecryptPassword } + + } + + else + { + + $InputObject.credential.userName = $Username + $InputObject.credential.password = $_DecryptPassword + + } + + $PromptMessage = "remove directory server '{0}'" -f $DirectoryServerName + + if ($PSCmdlet.ShouldProcess($InputObject.ApplianceConnection.Name,$PromptMessage)) + { + + "[{0}] Removing Directory Server '{1}' from LDAP Directory '{2}'." -f $MyInvocation.InvocationName.ToString().ToUpper(),$DirectoryServerName, $InputObject.name | Write-Verbose + + Try + { + + [Array]$InputObject.directoryServers = $InputObject.directoryServers | Where-Object directoryServerIpAddress -ne $DirectoryServerName + + $_resp = Send-OVRequest -Uri $InputObject.Uri -Method PUT -Body $InputObject -Hostname $InputObject.ApplianceConnection.Name + + $_resp.PSObject.TypeNames.Insert(0,"HPEOneview.Appliance.AuthDirectory") + + $_resp + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + elseif ($PSBoundParameters['WhatIf']) + { + + "[{0}] -WhatIf Parameter was passed." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Show-OVLdapGroups +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = 'Default')] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = 'Default')] + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = 'PSCredential')] + [ValidateNotNullOrEmpty()] + [Alias ("d","domain","AuthProvider")] + [Object]$Directory, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [Alias ("u")] + [String]$UserName, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [Alias ("p")] + [ValidateNotNullOrEmpty()] + [SecureString]$Password, + + [Parameter (Mandatory = $false, ParameterSetName = "PSCredential")] + [ValidateNotNullOrEmpty()] + [PSCredential]$Credential, + + [Parameter (Mandatory = $False, ParameterSetName = 'Default')] + [Parameter (Mandatory = $False, ParameterSetName = 'PSCredential')] + [ValidateNotNullOrEmpty()] + [String]$GroupName, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [Parameter (Mandatory = $false, ParameterSetName = 'PSCredential')] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + if ($PSBoundParameters['Username']) + { + + Write-Warning "The -Username parameter will be deprecated in a future release. Please transition to using the -Credental Parameter." + + } + + if ($PSBoundParameters['Password']) + { + + Write-Warning "The -Username parameter will be deprecated in a future release. Please transition to using the -Credental Parameter." + + } + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not $Directory) + { + + $PipelineINput = $true + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command agian." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + if (-not($PSBoundParameters['Password']) -and $PSBoundParameters['Username']) + { + + do + { + + $securepass = Read-Host 'Password' -AsSecureString + $securepass2 = Read-Host 'Confirm Password' -AsSecureString + $_DecryptPassword = [Runtime.InteropServices.Marshal]::PtrToStringBSTR([Runtime.InteropServices.Marshal]::SecureStringToBSTR($securepass)) + $_DecryptPassword2 = [Runtime.InteropServices.Marshal]::PtrToStringBSTR([Runtime.InteropServices.Marshal]::SecureStringToBSTR($securepass2)) + + if ($_DecryptPassword -ne $_DecryptPassword2) + { + + Write-Host "Passwords do not match!" -BackgroundColor Red + + } + + } until ($_DecryptPassword -eq $_DecryptPassword2) + + $Password = $securepass + + } + + elseif (-not $PSBoundParameters['Password'] -and -not $PSBoundParameters['Username'] -and -not $PSBoundParameters['Credential']) + { + + "[{0}] Credentials were not provided. Will validate directory object for 'directoryBindingType' in Process block." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + $_DirectoryGroupsCollection = [System.Collections.ArrayList]::new() + + } + + Process + { + + ForEach ($_appliance in $ApplianceConnection) + { + + "[{0}] Processing '{1}' Appliance (of {2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name, $ApplianceConnection.Count | Write-Verbose + + if ($PSBoundParameters['Directory']) + { + + "[{0}] Validating directory parameter." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + switch ($Directory.GetType().Name) + { + + 'String' + { + + "[{0}] Looking for directory by name." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $Directory = Get-OVLdapDirectory -Name $Directory -ApplianceConnection $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + 'PSCustomObject' + { + + "[{0}] Directory object provided." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if ($Directory.type -notmatch 'LoginDomainConfig') + { + + $ExceptionMessage = 'The provided -Directory Parameter value is not a support object type, {0}. Please verify the object.' -f $Directory.name + $ErrorRecord = New-ErrorRecord ArgumentException InvalidGroupCommonName InvalidArgument 'Group' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + } + + $_Search = $Directory.baseDN + + } + + if ($PSBoundParameters['GroupName']) + { + + $_Search = $GroupName + + } + + Try + { + + $_Params = @{ + + Search = $_Search; + Directory = $Directory.name; + Username = $null; + Password = $null; + ApplianceConnection = $_appliance + + } + + if ($Directory.directoryBindingType -eq $LdapDirectoryAccountBindTypeEnum['SERVICEACCOUNT']) + { + + "[{0}] Directory uses Service Account to bind." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_Params.Username = $Directory.credential.userName + + } + + elseif ($Directory.directoryBindingType -eq $LdapDirectoryAccountBindTypeEnum['USERACCOUNT']) + { + + if ($PSBoundParameters['Credential']) + { + + "[{0}] Using PSCredential object to provide directory auth credentials." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_Params.Username = $Credential.Username + $_Params.Password = $Credential.Password + + } + + elseif ($PSBoundParameters['Username']) + { + + "[{0}] Providing user crednetials for directory auth." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_Params.Username = $Username + $_Params.Password = $Password + + } + + # User did not provide required authentication for directory. Throw error. + else + { + + $ExceptionMessage = 'Please provide valid credentials using either -Username/-Password or -Credential parameters. The directory {0} is configured to require user authentication in order to bind to the authentication directory.' -f $Directory.name + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.LdapAuthenticationException NoValidCredentialParameters AuthenticationError "ApplianceConnection" -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + $_Groups = BuildGroupList @_Params + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + End + { + + return $_Groups + + } + +} + +function BuildGroupList +{ + + [CmdletBinding (DefaultParameterSetName = 'Default')] + Param + ( + + [Parameter (Position = 0, Mandatory, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [String]$Search, + + [Parameter (Position = 1, Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [String]$Username, + + [Parameter (Position = 2, Mandatory = $false, ParameterSetName = 'Default')] + [SecureString]$Password, + + [Parameter (Position = 3, Mandatory, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [String]$Directory, + + [Parameter (Position = 4, Mandatory, ParameterSetName = 'Default')] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection + + ) + + Begin + { + + "[{0}] Processing Search: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Search | Write-Verbose + + $_Collection = [System.Collections.ArrayList]::new() + + $_body = @{ + + type = 'Group2RoleSearchContext'; + directoryName = $Directory; + userName = $Username; + password = $Password; + searchContext = $Search + + } + + if ($PSBoundParameters['Password']) + { + + $_body.password = [Runtime.InteropServices.Marshal]::PtrToStringBSTR([Runtime.InteropServices.Marshal]::SecureStringToBSTR($Password)) + + } + + } + + Process + { + + $_uri = $AuthnDirectorySearchContextUri + + if ($Search.ToLower().StartsWith('ou=') -or $Search.ToLower().StartsWith('cn=') -or $Search.ToLower().StartsWith('dc=')) + { + + "[{0}] Navigating tree" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_body | Add-Member -NotePropertyName start -NotePropertyValue 0 -force + + } + + else + { + + "[{0}] Searching for group name" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_GroupSearch = $True + + $_uri += '/search' + + } + + Try + { + + $_Resp = Send-OVRequest -uri $_uri -Method POST -Body $_body -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if (-not($_GroupSearch)) + { + + ForEach ($_ChildOU in ($_Resp | Where-Object hasChildren)) + { + + "[{0}] Processing Child OU {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_ChildOU.distinguishedName | Write-Verbose + + $_Groups = BuildGroupList $_ChildOU.distinguishedName $Username $Password $Directory $ApplianceConnection + + ForEach ($_group in $_Groups) + { + + [void]$_Collection.Add($_group) + + } + + } + + } + + ForEach ($_DirGroup in ($_Resp | Where-Object groupType)) + { + + "[{0}] Processing Group {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_DirGroup.displayName.Replace('CN=',$null) | Write-Verbose + + $_entry = [HPEOneView.Appliance.LdapDirectoryGroup]::new($_DirGroup.displayName.Replace('CN=',$null), + $_DirGroup.distinguishedName, + $_DirGroup.distinguishedName.Replace($_DirGroup.displayName + ',',$null), + $Directory) + + [void]$_Collection.Add($_entry) + + } + + } + + End + { + + Return $_Collection + + } + +} + +function Get-OVLdapGroup +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = 'Default')] + Param + ( + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullorEmpty()] + [Alias ("group","GroupName")] + [String]$Name, + + [Parameter (Mandatory, ParameterSetName = 'Export')] + [Alias ('x')] + [ValidateScript({split-path $_ | Test-Path})] + [String]$Export, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [Parameter (Mandatory = $false, ParameterSetName = 'Export')] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command agian." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $_DirectoryGroupsCollection = [System.Collections.ArrayList]::new() + + } + + Process + { + + ForEach ($_appliance in $ApplianceConnection) + { + + "[{0}] Processing '{1}' Appliance (of {2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name, $ApplianceConnection.Count | Write-Verbose + + Try + { + + $_Groups = Send-OVRequest $AuthnEgroupRoleMappingUri -Hostname $_appliance.Name + + ForEach ($_Group in $_Groups.members) + { + + $_Group.PSObject.TypeNames.Insert(0,"HPEOneview.Appliance.AuthDirectoryGroupRoleMapping") + + [void]$_DirectoryGroupsCollection.Add($_Group) + + } + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + End + { + + if ($PSBoundParameters['Name']) + { + + $_DirectoryGroupsCollection = $_DirectoryGroupsCollection | Where-Object egroup -eq $Name + + if ($_DirectoryGroupsCollection.Count -eq 0) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.LdapDirectoryGroupException AuthDirectoryGroupResourceNotFound ObjectNotFound "Name" -Message "The specified '$name' Authentication Directory Group resource not found. Please check the name and try again." + + $PSCmdlet.WriteError($ErrorRecord) + + } + + } + + if ($PSBoundParameters['Export']) + { + + $_DirectoryGroupsCollection | convertto-json > $Export + + } + + else + { + + Return $_DirectoryGroupsCollection + + } + + } + +} + +function New-OVLdapGroup +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = 'Default')] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = 'Default')] + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = 'Scope')] + [ValidateNotNullOrEmpty()] + [Alias ("d","domain","authProvider")] + [Object]$Directory, + + [Parameter (Mandatory, ParameterSetName = 'Default')] + [Parameter (Mandatory, ParameterSetName = 'Scope')] + [ValidateNotNullOrEmpty()] + [Alias ("g","GroupName","name")] + [Object]$Group, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [Alias ("r","role")] + [Array]$Roles, + + [Parameter (Mandatory = $false, ParameterSetName = 'Scope')] + [ValidateNotNullOrEmpty()] + [Array]$ScopePermissions, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [Parameter (Mandatory = $false, ParameterSetName = 'Scope')] + [ValidateNotNullOrEmpty()] + [Alias ("u")] + [String]$Username, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [Parameter (Mandatory = $false, ParameterSetName = 'Scope')] + [Alias ("p")] + [ValidateNotNullOrEmpty()] + [Object]$Password, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [Parameter (Mandatory = $false, ParameterSetName = "Scope")] + [ValidateNotNullOrEmpty()] + [PSCredential]$Credential, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [Parameter (Mandatory = $false, ParameterSetName = 'Scope')] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + if ($PSBoundParameters['Username']) + { + + Write-Warning "The -Username parameter will be deprecated in a future release. Please transition to using the -Credental Parameter." + + } + + if ($PSBoundParameters['Password']) + { + + Write-Warning "The -Username parameter will be deprecated in a future release. Please transition to using the -Credental Parameter." + + } + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not($PSBoundParameters['Directory'])) + { + + $PipelineInput = $True + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command agian." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + $_DirectroyGroupStatus = [System.Collections.ArrayList]::new() + + if (-not $PipelineInput) + { + + if (-not($PSBoundParameters['Password']) -and $PSBoundParameters['Username']) + { + + do + { + + $securepass = Read-Host 'Password' -AsSecureString + $securepass2 = Read-Host 'Confirm Password' -AsSecureString + $_DecryptPassword = [Runtime.InteropServices.Marshal]::PtrToStringBSTR([Runtime.InteropServices.Marshal]::SecureStringToBSTR($securepass)) + $_DecryptPassword2 = [Runtime.InteropServices.Marshal]::PtrToStringBSTR([Runtime.InteropServices.Marshal]::SecureStringToBSTR($securepass2)) + + if ($_DecryptPassword -ne $_DecryptPassword2) + { + + Write-Host "Passwords do not match!" -BackgroundColor Red + + } + + } until ($_DecryptPassword -eq $_DecryptPassword2) + + } + + elseif ($Password -is [SecureString]) + { + + $_DecryptPassword = [Runtime.InteropServices.Marshal]::PtrToStringBSTR([Runtime.InteropServices.Marshal]::SecureStringToBSTR($Password)) + + } + + elseif ($PSBoundParameters['Password']) + { + + $_DecryptPassword = $Password + + } + + elseif ($PSBoundParameters['Credential']) + { + + $Username = $Credential.Username + $_DecryptPassword = [Runtime.InteropServices.Marshal]::PtrToStringBSTR([Runtime.InteropServices.Marshal]::SecureStringToBSTR($Credential.Password)) + + } + + else + { + + "[{0}] Credentials were not provided. Will validate directory object for 'directoryBindingType' in Process block." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + } + + } + + Process + { + + if ($PipelineInput) + { + + # Validate the auth directory is service account or user account + if ($Directory.directoryBindingType -ne $LdapDirectoryAccountBindTypeEnum['SERVICEACCOUNT']) + { + + if (-not($PSBoundParameters['Password']) -and $PSBoundParameters['Username']) + { + + do + { + + $securepass = Read-Host 'Password' -AsSecureString + $securepass2 = Read-Host 'Confirm Password' -AsSecureString + $_DecryptPassword = [Runtime.InteropServices.Marshal]::PtrToStringBSTR([Runtime.InteropServices.Marshal]::SecureStringToBSTR($securepass)) + $_DecryptPassword2 = [Runtime.InteropServices.Marshal]::PtrToStringBSTR([Runtime.InteropServices.Marshal]::SecureStringToBSTR($securepass2)) + + if ($_DecryptPassword -ne $_DecryptPassword2) + { + + Write-Host "Passwords do not match!" -BackgroundColor Red + + } + + } until ($_DecryptPassword -eq $_DecryptPassword2) + + } + + elseif ($Password -is [SecureString]) + { + + $_DecryptPassword = [Runtime.InteropServices.Marshal]::PtrToStringBSTR([Runtime.InteropServices.Marshal]::SecureStringToBSTR($Password)) + + } + + elseif ($PSBoundParameters['Password']) + { + + $_DecryptPassword = $Password + + } + + elseif ($PSBoundParameters['Credential']) + { + + $Username = $Credential.Username + $_DecryptPassword = [Runtime.InteropServices.Marshal]::PtrToStringBSTR([Runtime.InteropServices.Marshal]::SecureStringToBSTR($Credential.Password)) + + } + + else + { + + "[{0}] Credentials were not provided. Will validate directory object for 'directoryBindingType' in Process block." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + } + + } + + ForEach ($_appliance in $ApplianceConnection) + { + + "[{0}] Processing '{1}' Appliance (of {2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name, $ApplianceConnection.Count | Write-Verbose + + $_unsupportedRoles = [System.Collections.ArrayList]::new() + $_PremissionsCol = [System.Collections.ArrayList]::new() + + if ($PSBoundParameters['Roles']) + { + + "[{0}] Validating requested role values" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + # Validate roles provided are allowed. + foreach ($_role in $Roles) + { + + "[{0}] Processing role: $_role" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not ((${Global:ConnectedSessions} | Where-Object Name -EQ $_appliance.Name).ApplianceSecurityRoles -contains $_role)) + { + + "[{0}] Invalid or unsupported" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + [void]$_unsupportedRoles.Add($_role) + + } + + else + { + + "[{0}] Supported" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_TempName = $_role.split(' ') + + $_NewPermission = NewObject -DirectoryGroupPermissions + + $_UpdatedName = [System.Text.StringBuilder]::new() + + for ($s = 0; $s -lt $_TempName.count; $s++) + { + + if ($s -eq 0) + { + + [void]$_UpdatedName.Append($_TempName[$s].Substring(0, 1).ToUpper() + $_TempName[$s].SubString(1, ($_TempName[$s].length - 1)).ToLower()) + + } + + else + { + + [void]$_UpdatedName.Append(" " + $_TempName[$s].ToLower()) + + } + + } + + $_NewPermission.roleName = $_UpdatedName.ToString() + + [void]$_PremissionsCol.Add($_NewPermission) + + } + + } + + if ($_unsupportedRoles.count -ge 1) + { + + $ErrorRecord = New-ErrorRecord ArgumentException UnsupportedRolesFound InvalidArgument $($MyInvocation.InvocationName.ToString().ToUpper()) -Message "The '$($_unsupportedRoles -join ", ")' role(s) is/are not supported or the correct names. Please validate the -roles Parameter contains one or more valid roles. Allowed roles are: $((${Global:ConnectedSessions} | ? Name -EQ $_appliance.Name).ApplianceSecurityRoles -join ", ")" + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + # Process scopes with permissions + if ($PSBoundParameters['ScopePermissions']) + { + + # Rebuild the + + ForEach ($_ScopeToPermission in $ScopePermissions) + { + + "[{0}] Processing role: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_ScopeToPermission.Role | Write-Verbose + + if (-not ((${Global:ConnectedSessions} | Where-Object Name -EQ $_appliance.Name).ApplianceSecurityRoles -contains $_ScopeToPermission.Role)) + { + + "[{0}] Invalid or unsupported" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + [void]$_unsupportedRoles.Add($_ScopeToPermission.Role) + + } + + else + { + + "[{0}] Supported" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if ([System.String]::IsNullOrWhiteSpace($_ScopeToPermission.Scope)) + { + + Throw "Scope property within ScopePermissions must contain at least 1 entry." + + } + + $_TempName = $_ScopeToPermission.Role.split(' ') + + ForEach ($_Scope in $_ScopeToPermission.Scope) + { + + if ($_Scope -IsNot [HPEOneView.Appliance.ScopeCollection]) + { + + Throw ("Invalid scope resource {0}" -f $_Scope.name) + + } + + $_NewPermission = NewObject -DirectoryGroupPermissions + + $_UpdatedName = [System.Text.StringBuilder]::new() + + for ($s = 0; $s -lt $_tempname.count; $s++) + { + + if ($s -eq 0) + { + + [void]$_UpdatedName.Append($_TempName[$s].Substring(0, 1).ToUpper() + $_TempName[$s].SubString(1, ($_TempName[$s].length - 1)).ToLower()) + + } + + else + { + + [void]$_UpdatedName.Append(" " + $_TempName[$s].ToLower()) + + } + + } + + $_NewPermission.roleName = $_UpdatedName.ToString() + $_NewPermission.scopeUri = $_Scope.uri + + [void]$_PremissionsCol.Add($_NewPermission) + + } + + } + + } + + } + + switch ($Group.GetType().Name) + { + + 'String' + { + + if (-not [HPEOneView.Utilities.Security.X500DistinguishedName]::TryParse($Group)) + { + + $Message = 'The provided -Group Parameter value {0} is not a valid Distinguished Name (DN) value. Please verify the Group DN follows this format: CN=GroupName,OU=OrganizationalUnit,DC=Domain,DC=com' -f $Group + $ErrorRecord = New-ErrorRecord ArgumentException InvalidGroupCommonName InvalidArgument 'Group' -Message $Message + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + $Group = [PSCustomObject]@{ DN = $Group } + + } + + 'PSCustomObject' + { + + if (-not [HPEOneView.Utilities.Security.X500DistinguishedName]::TryParse($Group.DN)) + { + + $Message = 'The provided -Group Parameter value {0} does not contain a valid Distinguished Name (DN) value. Please verify the Group DN follows this format: CN=GroupName,OU=OrganizationalUnit,DC=Domain,DC=com' -f $Group.Name + $ErrorRecord = New-ErrorRecord ArgumentException InvalidGroupCommonName InvalidArgument 'Group' -TargetType 'PSObject' -Message $Message + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + } + + # Get new Directory Group object + $_NewGroup = NewObject -DirectoryGroup + + $_NewGroup.group2PermissionPerGroup.loginDomain = $Directory.name + $_NewGroup.group2PermissionPerGroup.egroup = $Group.DN + $_NewGroup.group2PermissionPerGroup.permissions = $_PremissionsCol + + if ($Directory.directoryBindingType -ne $LdapDirectoryAccountBindTypeEnum['SERVICEACCOUNT'] -and (-not $PSBoundParameters['Username'] -and -not $PSBoundParameters['Credential'])) + { + + $ExceptionMessage = 'Please provide valid credentials using either -Username/-Password or -Credential parameters.' + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.LdapAuthenticationException NoValidCredentialParameters AuthenticationError "ApplianceConnection" -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($Directory.directoryBindingType -eq $LdapDirectoryAccountBindTypeEnum['SERVICEACCOUNT']) + { + + $_NewGroup.credentials.userName = $Directory.credential.userName + + } + + elseif ($Directory.directoryBindingType -eq $LdapDirectoryAccountBindTypeEnum['USERACCOUNT']) + { + + # Add credentials to object + $_NewGroup.credentials.userName = $Username + $_NewGroup.credentials.password = $_decryptPassword + + } + + # "[{0}] Directory Group requested to create: $($_NewGroup | out-string )" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + "[{0}] Sending request to create $($_NewGroup.egroup) Directory Group" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $_resp = Send-OVRequest -Uri $AuthnEgroupRoleMappingUri -Method POST -Body $_NewGroup -Hostname $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $_resp.PSObject.TypeNames.Insert(0,'HPEOneview.Appliance.AuthDirectoryGroupRoleMapping') + + [void]$_DirectroyGroupStatus.Add($_resp) + + } + + } + + End + { + + Return $_DirectroyGroupStatus + + } + +} + +function Set-OVLdapGroupRole +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = 'Role')] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = 'Role')] + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = 'Scope')] + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = 'RoleAndScope')] + [ValidateNotNullOrEmpty()] + [Alias ("g","name",'GroupName', 'Group')] + [Object]$InputObject, + + [Parameter (Mandatory, ParameterSetName = 'Role')] + [Parameter (Mandatory, ParameterSetName = 'RoleAndScope')] + [ValidateNotNullOrEmpty()] + [Alias ("r","role")] + [Array]$Roles, + + [Parameter (Mandatory, ParameterSetName = 'Scope')] + [Parameter (Mandatory, ParameterSetName = 'RoleAndScope')] + [ValidateNotNullOrEmpty()] + [Array]$ScopePermissions, + + [Parameter (Mandatory = $false, ParameterSetName = 'Role')] + [Parameter (Mandatory = $false, ParameterSetName = 'Scope')] + [Parameter (Mandatory = $false, ParameterSetName = 'RoleAndScope')] + [Switch]$Append, + + [Parameter (Mandatory = $false, ParameterSetName = 'Role')] + [Parameter (Mandatory = $false, ParameterSetName = 'Scope')] + [Parameter (Mandatory = $false, ParameterSetName = 'RoleAndScope')] + [ValidateNotNullOrEmpty()] + [Alias ("u")] + [String]$UserName, + + [Parameter (Mandatory = $false, ParameterSetName = 'Role')] + [Parameter (Mandatory = $false, ParameterSetName = 'Scope')] + [Parameter (Mandatory = $false, ParameterSetName = 'RoleAndScope')] + [Alias ("p")] + [ValidateNotNullOrEmpty()] + [SecureString]$Password, + + [Parameter (Mandatory = $false, ParameterSetName = 'Role')] + [Parameter (Mandatory = $false, ParameterSetName = 'Scope')] + [Parameter (Mandatory = $false, ParameterSetName = 'RoleAndScope')] + [ValidateNotNullOrEmpty()] + [PSCredential]$Credential, + + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = 'Role')] + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = 'Scope')] + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = 'RoleAndScope')] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + if ($PSBoundParameters['Username']) + { + + Write-Warning "The -Username parameter will be deprecated in a future release. Please transition to using the -Credental Parameter." + + } + + if ($PSBoundParameters['Password']) + { + + Write-Warning "The -Username parameter will be deprecated in a future release. Please transition to using the -Credental Parameter." + + } + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + # No need to validate ApplianceConnection, as object is passed via pipeline. + if (-not $PSboundParameters['InputObject']) + { + + "[{0}] Pipeline input." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $PipelineInput = $True + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ExceptionMessage = "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command agian." + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + if ($InputObject.directoryBindingType -eq $LdapDirectoryAccountBindTypeEnum['USERACCOUNT']) + { + + # Decrypt the password + if (-not($PSBoundParameters['Password']) -and $PSBoundParameters['Username']) + { + + do + { + + $securepass = Read-Host 'Password' -AsSecureString + $securepass2 = Read-Host 'Confirm Password' -AsSecureString + $_DecryptPassword = [Runtime.InteropServices.Marshal]::PtrToStringBSTR([Runtime.InteropServices.Marshal]::SecureStringToBSTR($securepass)) + $_DecryptPassword2 = [Runtime.InteropServices.Marshal]::PtrToStringBSTR([Runtime.InteropServices.Marshal]::SecureStringToBSTR($securepass2)) + + if ($_DecryptPassword -ne $_DecryptPassword2) + { + + Write-Host "Passwords do not match!" -BackgroundColor Red + + } + + } until ($_DecryptPassword -eq $_DecryptPassword2) + + } + + elseif ($Password -is [SecureString]) + { + + $_DecryptPassword = [Runtime.InteropServices.Marshal]::PtrToStringBSTR([Runtime.InteropServices.Marshal]::SecureStringToBSTR($Password)) + + } + + elseif ($PSBoundParameters['Password']) + { + + $_DecryptPassword = $Password + + } + + elseif ($PSBoundParameters['Credential']) + { + + $Username = $Credential.Username + $_DecryptPassword = [Runtime.InteropServices.Marshal]::PtrToStringBSTR([Runtime.InteropServices.Marshal]::SecureStringToBSTR($Credential.Password)) + + } + + else + { + + "[{0}] Credentials were not provided. Will validate directory object for 'directoryBindingType' in Process block." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + } + + } + + $_DirectoryGroupsToUpdate = [System.Collections.ArrayList]::new() + $_DirectoryGroupStatus = [System.Collections.ArrayList]::new() + + } + + Process + { + + if ($PipelineInput) + { + + # Validate the auth directory is service account or user account + if ($Directory.directoryBindingType -ne $LdapDirectoryAccountBindTypeEnum['SERVICEACCOUNT']) + { + + if (-not($PSBoundParameters['Password']) -and $PSBoundParameters['Username']) + { + + do + { + + $securepass = Read-Host 'Password' -AsSecureString + $securepass2 = Read-Host 'Confirm Password' -AsSecureString + $_DecryptPassword = [Runtime.InteropServices.Marshal]::PtrToStringBSTR([Runtime.InteropServices.Marshal]::SecureStringToBSTR($securepass)) + $_DecryptPassword2 = [Runtime.InteropServices.Marshal]::PtrToStringBSTR([Runtime.InteropServices.Marshal]::SecureStringToBSTR($securepass2)) + + if ($_DecryptPassword -ne $_DecryptPassword2) + { + + Write-Host "Passwords do not match!" -BackgroundColor Red + + } + + } until ($_DecryptPassword -eq $_DecryptPassword2) + + } + + elseif ($Password -is [SecureString]) + { + + $_DecryptPassword = [Runtime.InteropServices.Marshal]::PtrToStringBSTR([Runtime.InteropServices.Marshal]::SecureStringToBSTR($Password)) + + } + + elseif ($PSBoundParameters['Password']) + { + + $_DecryptPassword = $Password + + } + + elseif ($PSBoundParameters['Credential']) + { + + $Username = $Credential.Username + $_DecryptPassword = [Runtime.InteropServices.Marshal]::PtrToStringBSTR([Runtime.InteropServices.Marshal]::SecureStringToBSTR($Credential.Password)) + + } + + else + { + + "[{0}] Credentials were not provided. Will validate directory object for 'directoryBindingType' in Process block." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + } + + } + + ForEach ($_Group in $InputObject) + { + + # Validate pipeline input is user object + if (-not $_Group.category -eq $ResourceCategoryEnum.User) + { + + "[{0}] Invalid Group provided: $($_Group )" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.LdapDirectoryGroupException InvalidDirectoryGroupObject InvalidArgument "Group" -TargetType 'PSObject' -Message "The Group Parameter value is not a valid Directory Group object resource. Object category provided '$($Group.category)', allowed object category value 'users'. Please verify the input object and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + "[{0}] Processing Group: $($_Group.egroup)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_UpdateDirectroyGroup = NewObject -DirectoryGroup + $_UpdateDirectroyGroup.group2PermissionPerGroup.egroup = $_Group.egroup + $_UpdateDirectroyGroup.group2PermissionPerGroup.loginDomain = $_Group.loginDomain + + "[{0}] Original Group object: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), ($_Group | ConvertTo-Json -Depth 99 | Out-String) | Write-Verbose + + # Get the auth directory associated with the group + Try + { + + $_Directory = Get-OVLdapDirectory -Name $_Group.loginDomain -ApplianceConnection $_Group.ApplianceConnection -ErrorAction Stop + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $_unsupportedRoles = [System.Collections.ArrayList]::new() + $_PremissionsCol = [System.Collections.ArrayList]::new() + + if ($PSBoundParameters['Roles']) + { + + "[{0}] Validating requested role values" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + # Validate roles provided are allowed. + foreach ($_role in $Roles) + { + + "[{0}] Processing role: $_role" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not ((${Global:ConnectedSessions} | Where-Object Name -EQ $ApplianceConnection.Name).ApplianceSecurityRoles -contains $_role)) + { + + "[{0}] Invalid or unsupported" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + [void]$_unsupportedRoles.Add($_role) + + } + + else + { + + "[{0}] Supported" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_TempName = $_role.split(' ') + + $_NewPermission = NewObject -DirectoryGroupPermissions + + $_UpdatedName = [System.Text.StringBuilder]::new() + + for ($s = 0; $s -lt $_TempName.count; $s++) + { + + if ($s -eq 0) + { + + [void]$_UpdatedName.Append($_TempName[$s].Substring(0, 1).ToUpper() + $_TempName[$s].SubString(1, ($_TempName[$s].length - 1)).ToLower()) + + } + + else + { + + [void]$_UpdatedName.Append(" " + $_TempName[$s].ToLower()) + + } + + } + + $_NewPermission.roleName = $_UpdatedName.ToString() + + "[{0}] Adding {1} role to {2} directory group." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_NewPermission.roleName, $_UpdateDirectroyGroup.group2PermissionPerGroup.egroup | Write-Verbose + + [void]$_UpdateDirectroyGroup.group2PermissionPerGroup.permissions.Add($_NewPermission) + + } + + } + + if ($_unsupportedRoles.count -ge 1) + { + + $ExceptionMessage = "The '{0}' role(s) is/are not supported or the correct names. Please validate the -roles Parameter contains one or more valid roles. Allowed roles are: {1}." -f [String]::Join(', ', $_unsupportedRoles.ToArray()), [String]::Join(', ', (${Global:ConnectedSessions} | Where-Object Name -EQ $ApplianceConnection.Name).ApplianceSecurityRoles) + $ErrorRecord = New-ErrorRecord ArgumentException UnsupportedRolesFound InvalidArgument $($MyInvocation.InvocationName.ToString().ToUpper()) -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + # Process scopes with permissions + if ($PSBoundParameters['ScopePermissions']) + { + + ForEach ($_ScopeToPermission in $ScopePermissions) + { + + "[{0}] Processing role: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_ScopeToPermission.Role | Write-Verbose + + if ((${Global:ConnectedSessions} | Where-Object Name -EQ $ApplianceConnection.Name).ApplianceSecurityRoles -notcontains $_ScopeToPermission.Role) + { + + "[{0}] Invalid or unsupported" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + [void]$_unsupportedRoles.Add($_ScopeToPermission.Role) + + } + + else + { + + "[{0}] Supported role." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if ([System.String]::IsNullOrWhiteSpace($_ScopeToPermission.Scope)) + { + + Throw "Scope property within ScopePermissions must contain at least 1 entry." + + } + + $_TempName = $_ScopeToPermission.Role.split(' ') + + "[{0}] Process scope." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + "[{0}] Scope object type: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_ScopeToPermission.Scope.GetType().Fullname | Write-Verbose + "[{0}] Scope object: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_ScopeToPermission.Scope | Write-Verbose + + if ($_ScopeToPermission.Scope -IsNot [HPEOneView.Appliance.ScopeCollection] -and $_ScopeToPermission.Scope -ne 'All') + { + + Throw ("Invalid scope resource {0}" -f $_ScopeToPermission.Name) + + } + + elseif ($_ScopeToPermission.Scope -eq 'All') + { + + "[{0}] Scope is not an HPEOneview.Appliance.ScopeCollection resource, but String 'All'. Will set uri to null." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + $_Scope = [PSCustomObject]@{uri = $null} + + } + + else + { + + $_Scope = $_ScopeToPermission.Scope + + } + + $_NewPermission = NewObject -DirectoryGroupPermissions + + $_UpdatedName = [System.Text.StringBuilder]::new() + + for ($s = 0; $s -lt $_tempname.count; $s++) + { + + if ($s -eq 0) + { + + [void]$_UpdatedName.Append($_TempName[$s].Substring(0, 1).ToUpper() + $_TempName[$s].SubString(1, ($_TempName[$s].length - 1)).ToLower()) + + } + + else + { + + [void]$_UpdatedName.Append(" " + $_TempName[$s].ToLower()) + + } + + } + + "[{0}] Adding Role '{1}' -> '{2}'." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_UpdatedName.ToString(), $_Scope.uri | Write-Verbose + + $_NewPermission.roleName = $_UpdatedName.ToString() + $_NewPermission.scopeUri = $_Scope.uri + + [void]$_UpdateDirectroyGroup.group2PermissionPerGroup.permissions.Add($_NewPermission) + + } + + } + + } + + "[{0}] Directory binding type: '{1}'" -f $MyInvocation.InvocationName.ToString().ToUpper(), $LdapDirectoryAccountBindTypeEnum[$_Directory.directoryBindingType] | Write-Verbose + + if ($_Directory.directoryBindingType -ne $LdapDirectoryAccountBindTypeEnum['SERVICEACCOUNT'] -and (-not $PSBoundParameters['Username'] -and -not $PSBoundParameters['Credential'])) + { + + $ExceptionMessage = 'Please provide valid credentials using either -Username/-Password or -Credential parameters.' + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.LdapAuthenticationException NoValidCredentialParameters AuthenticationError "ApplianceConnection" -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($_Directory.directoryBindingType -eq $LdapDirectoryAccountBindTypeEnum['SERVICEACCOUNT']) + { + + "[{0}] Adding username to object." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_UpdateDirectroyGroup.credentials.userName = $Directory.credential.userName + + } + + elseif ($_Directory.directoryBindingType -eq $LdapDirectoryAccountBindTypeEnum['USERACCOUNT']) + { + + "[{0}] Adding username and password to object." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + # Add credentials to object + $_UpdateDirectroyGroup.credentials.userName = $Username + $_UpdateDirectroyGroup.credentials.password = $_decryptPassword + + } + + if ($PSBoundParameters['Roles'] -or $PSBoundParameters['ScopePermissions']) + { + + if ($PSBoundParameters['Append']) + { + + "[{0}] Append operation." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + ForEach ($_originalpermission in $_Group.permissions) + { + + if (-not ($_UpdateDirectroyGroup.group2PermissionPerGroup.permissions | ? { $_.roleName -eq $_originalpermission.roleName -and $_.scopeUri -eq $_originalpermission.scopeUri})) + { + + "[{0}] Appending {1} role with {2} scope to {3} directory group." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_originalpermission.roleName, $_Scope.name, $_UpdateDirectroyGroup.group2PermissionPerGroup.egroup | Write-Verbose + + [void]$_UpdateDirectroyGroup.group2PermissionPerGroup.permissions.Add($_originalpermission) + + } + + } + + } + + } + + "[{0}] Sending request to update '$($_Group.egroup)' group." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $_resp = Send-OVRequest -Uri $AuthnEgroupRoleMappingUri -Method PUT -Body $_UpdateDirectroyGroup -Hostname $_Group.ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $_resp.PSObject.TypeNames.Insert(0,'HPEOneview.Appliance.AuthDirectoryGroupRoleMapping') + + $_resp + + } + + } + + End + { + + '[{0}] Done.' -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Remove-OVLdapGroup +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "default", SupportsShouldProcess, ConfirmImpact = 'High')] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = "default")] + [ValidateNotNullOrEmpty()] + [Alias ('g','Group','Name')] + [Object]$InputObject, + + [Parameter (Mandatory = $False, ValueFromPipelineByPropertyName, ParameterSetName = "default")] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not($PSBoundParameters['InputObject'])) + { + + $PipelineInput = $True + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command agian." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + $_TaskCollection = [System.Collections.ArrayList]::new() + $_GroupCollection = [System.Collections.ArrayList]::new() + + } + + Process + { + + if ($PipelineInput -or $InputObject -is [PSCustomObject]) + { + + "[{0}] Processing Pipeline input" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + "[{0}] Group Object provided: {2}\{1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject.egroup, $InputObject.logindomain | Write-Verbose + + If ('users' -contains $InputObject.category) + { + + If (-not($InputObject.ApplianceConnection)) + { + + $ErrorRecord = New-ErrorRecord InvalidOperationException InvalidArgumentValue InvalidArgument "Group:$($InputObject.Name)" -TargetType PSObject -Message "The Group object resource provided is missing the source ApplianceConnection property. Please check the object provided and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + [void]$_GroupCollection.Add($InputObject) + + } + + else + { + + $ErrorRecord = New-ErrorRecord InvalidOperationException InvalidArgumentValue InvalidArgument "InputObject" -TargetType PSObject -Message "The Group object resource is not an expected category type [$($Name.category)]. The allowed resource category type is 'users'. Please check the object provided and try again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + else + { + + ForEach ($_appliance in $ApplianceConnection) + { + + "[{0}] Processing Appliance $($_appliance.Name) (of $($ApplianceConnection.Count))" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + "[{0}] Processing Group Name $($InputObject)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $_Group = Get-OVLdapGroup -Name $InputObject -ApplianceConnection $_appliance + + $_Group | ForEach-Object { + + [void]$_GroupCollection.Add($_) + + } + + } + + Catch + { + + if ([RegEx]::Match($_.FullyQualifiedErrorId, 'AuthDirectoryGroupResourceNotFound', $RegExInsensitiveFlag).Success) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.LdapDirectoryGroupException AuthDirectoryGroupResourceNotFound ObjectNotFound 'InputObject' -Message "The Directory Group '$InputObject' was not found on Appliance '$($_appliance.Name)'." + $PSCmdlet.WriteError($ErrorRecord) + + } + + else + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + } + + } + + End + { + + "[{0}] Processing $($_GroupCollection.count) Directory Group resources to remove." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + # Process Network Resources + ForEach ($_Group in $_GroupCollection) + { + + if ($PSCmdlet.ShouldProcess($_Group.ApplianceConnection.Name,"remove directory group '$($_Group.egroup)'")) + { + + "[{0}] Removing Directory Group '$($_Group.egroup)' from appliance '$($_Group.ApplianceConnection.Name)'." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $_resp = Send-OVRequest -Uri $_Group.Uri -Method DELETE -AddHeader @{'If-Match' = $_Group.eTag } -Hostname $_Group.ApplianceConnection + + $_resp | Add-Member -NotePropertyName name -NotePropertyValue $_Group.egroup + + [void]$_TaskCollection.Add($_resp) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + elseif ($PSBoundParameters['WhatIf']) + { + + "[{0}] WhatIf Parameter was passed." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + } + + Return $_TaskCollection + + } + +} + +function Get-OVAuditLog +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "default")] + Param + ( + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [ValidateNotNullOrEmpty()] + [Int]$Count = 0, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [ValidateNotNullOrEmpty()] + [TimeSpan]$TimeSpan, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [ValidateNotNullOrEmpty()] + [DateTime]$Start, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [ValidateNotNullOrEmpty()] + [DateTime]$End = [DateTime]::Now, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command agian." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $_AllAuditLogs = [System.Collections.ArrayList]::new() + + } + + Process + { + + ForEach ($_appliance in $ApplianceConnection) + { + + "[{0}] Processing '{1}' Appliance (of {2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name, $ApplianceConnection.Count | Write-Verbose + + $uri = $applAuditLogsUri + "?sort:asc" + + if ($PSBoundParameters['Count']) + { + + $uri = "{0}&count={1}" -f $uri, $Count + + } + + $Filter = [System.Collections.ArrayList]::new() + + if ($TimeSpan) + { + + [Void]$Filter.Add(("DATE<='{0}/P{1}D'" -f [DateTime]::Now.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ss.fffZ"),$TimeSpan.Days)) + + } + + elseif ($Start) + { + + [Void]$Filter.Add(("DATE>='{0}' and DATE<='{1}'" -f $Start.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssZ"), $End.ToUniversalTime().ToString("yyyy-MM-ddT23:59:59Z"))) + + } + + if ($Filter.count -gt 0) + { + + $uri = '{0}&filter="{1}"' -f $uri, [String]::Join(' and ',$Filter.ToArray()) + + } + + Try + { + + # Send the request + $_AuditLogs = Send-OVRequest -Uri $uri -Hostname $_appliance + + $_AuditLogs.members | ForEach-Object { + + $_.PSObject.TypeNames.Insert(0,'HPEOneview.Appliance.AuditLogEntry') + + [void]$_AllAuditLogs.Add($_) + + } + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + End + { + + Return $_AllAuditLogs + + } + +} + +Function Get-OVAuditLogArchive +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "default")] + Param + ( + + [Parameter (Mandatory = $false, ParameterSetName = "default")] + [ValidateNotNullorEmpty()] + [Alias ("save")] + [System.IO.DirectoryInfo]$Location = (get-location).Path, + + [Parameter (Mandatory = $false, ParameterSetName = 'default')] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + # Validate the path exists. If not, create it. + if (-not(Test-Path $Location)) + { + + "[{0}] Directory does not exist. Creating directory..." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + New-Item $Location -itemtype directory + + } + + } + + Process + { + + ForEach ($_appliance in $ApplianceConnection) + { + + "[{0}] Processing '{1}' Appliance (of {2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name, $ApplianceConnection.Count | Write-Verbose + + Try + { + + # Now that the Support Dump has been requested, download the file + "[{0}] Downloading audit log to $($Location)" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Download-File $applAuditLogDownloadUri $_appliance $Location + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + +} + +function Get-OVApplianceServiceConsoleAccess +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "Default")] + [OutputType([HPEOneView.Appliance.ServiceConsoleAccess])] + Param + ( + + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = "Default")] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command agian." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + Process + { + + $_uri = $ApplianceServiceAccessUri + + ForEach ($_appliance in $ApplianceConnection) + { + + "[{0}] Processing '{1}' Appliance (of {2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name, $ApplianceConnection.Count | Write-Verbose + + Try + { + + $_serviceConsoleStatus = Send-OVRequest -Uri $_uri -Hostname $_appliance + + [HPEOneView.Appliance.ServiceConsoleAccess]::new([bool]$_serviceConsoleStatus, ([HPEOneView.Library.ApplianceConnection]::new($_appliance.Name, $_appliance.ConnectionID))) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Enable-OVApplianceServiceConsoleAccess +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "Default")] + Param + ( + + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = "Default")] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command agian." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + Process + { + + $_uri = $ApplianceEnableServiceAccessUri.Clone() + + ForEach ($_appliance in $ApplianceConnection) + { + + "[{0}] Processing '{1}' Appliance (of {2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name, $ApplianceConnection.Count | Write-Verbose + + Try + { + + Send-OVRequest -Uri $_uri -Method PUT -Body 'true' -Hostname $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Disable-OVApplianceServiceConsoleAccess +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "Default", SupportsShouldProcess, ConfirmImpact = 'High')] + Param + ( + + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = "Default")] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command agian." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + Process + { + + $_uri = $ApplianceEnableServiceAccessUri.Clone() + + Write-Warning "Disabling support access means that an authorized support representative cannot diagnose your system in the event of a system failure." + + ForEach ($_appliance in $ApplianceConnection) + { + + "[{0}] Processing '{1}' Appliance (of {2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name, $ApplianceConnection.Count | Write-Verbose + + if ($PSCmdlet.ShouldProcess($_appliance.Name, "disable appliance console access")) + { + + "[{0}] Disabling appliance console access on appliance '{1}'." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name | Write-Verbose + + Try + { + + Send-OVRequest -Uri $_uri -Method PUT -Body 'false' -Hostname $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + elseif ($PSBoundParameters['WhatIf']) + { + + "[{0}] WhatIf Parameter was passed." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Enable-OVApplianceComplexPasswords +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "Default")] + Param + ( + + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = "Default")] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command agian." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + Process + { + + $_uri = $AuthnSettingsUri.Clone() + + ForEach ($_appliance in $ApplianceConnection) + { + + "[{0}] Processing '{1}' Appliance (of {2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name, $ApplianceConnection.Count | Write-Verbose + + # Get global settings from appliance + Try + { + + $_CurrentApplianceLoginDomainGlobalSettings = Send-OVRequest -Uri $_uri -Hostname $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $_CurrentApplianceLoginDomainGlobalSettings.enforceComplexPasswordEnabled = $true + + Try + { + + Send-OVRequest -Uri $_uri -Method PUT -Body $_CurrentApplianceLoginDomainGlobalSettings -Hostname $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Disable-OVApplianceComplexPasswords +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "Default", SupportsShouldProcess, ConfirmImpact = 'High')] + Param + ( + + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = "Default")] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command agian." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + Process + { + + $_uri = $AuthnSettingsUri.Clone() + + ForEach ($_appliance in $ApplianceConnection) + { + + "[{0}] Processing '{1}' Appliance (of {2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name, $ApplianceConnection.Count | Write-Verbose + + # Get global settings from appliance + Try + { + + $_CurrentApplianceLoginDomainGlobalSettings = Send-OVRequest -Uri $_uri -Hostname $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $_CurrentApplianceLoginDomainGlobalSettings.enforceComplexPasswordEnabled = $false + + Try + { + + Send-OVRequest -Uri $_uri -Method PUT -Body $_CurrentApplianceLoginDomainGlobalSettings -Hostname $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Get-OVApplianceSshAccess +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "Default")] + [OutputType([HPEOneView.Appliance.SshAccess])] + Param + ( + + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = "Default")] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command agian." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + Process + { + + $_uri = $ApplianceSshAccessUri.Clone() + + ForEach ($_appliance in $ApplianceConnection) + { + + "[{0}] Processing '{1}' Appliance (of {2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name, $ApplianceConnection.Count | Write-Verbose + + Try + { + + $_sshAccessStatus = Send-OVRequest -Uri $_uri -Hostname $_appliance + + [HPEOneView.Appliance.SshAccess]::new($_sshAccessStatus.allowSshAccess, $_sshAccessStatus.ApplianceConnection) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Enable-OVApplianceSshAccess +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "Default")] + [OutputType([HPEOneView.Appliance.TaskResource])] + Param + ( + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Switch]$Async, + + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = "Default")] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command agian." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + Process + { + + $_uri = $ApplianceSshAccessUri.Clone() + + $_body = @{ + type = "SshAccess"; + allowSshAccess = $True + } + + ForEach ($_appliance in $ApplianceConnection) + { + + "[{0}] Processing '{1}' Appliance (of {2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name, $ApplianceConnection.Count | Write-Verbose + + Try + { + + $_Resp = Send-OVRequest -Uri $_uri -Method PUT -Body $_body -Hostname $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if (-not $PSBoundParameters['Async']) + { + + $_Resp | Wait-OVTaskComplete + + } + + else + { + + $_Resp + + } + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Disable-OVApplianceSshAccess +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "Default", SupportsShouldProcess, ConfirmImpact = 'High')] + [OutputType([HPEOneView.Appliance.TaskResource])] + Param + ( + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Switch]$Async, + + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = "Default")] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command agian." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + Process + { + + $_uri = $ApplianceSshAccessUri.Clone() + + $_body = @{ + type = "SshAccess"; + allowSshAccess = $False + } + + Write-Warning "Disabling SSH access prevents remote access to the maintenance console. The maintenance console is still accessible from the virtual machine system console." + + ForEach ($_appliance in $ApplianceConnection) + { + + "[{0}] Processing '{1}' Appliance (of {2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name, $ApplianceConnection.Count | Write-Verbose + + if ($PSCmdlet.ShouldProcess($_appliance.Name, "disable appliance ssh access")) + { + + "[{0}] Disabling appliance SSH access on appliance '{1}'." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name | Write-Verbose + + Try + { + + $_Resp = Send-OVRequest -Uri $_uri -Method PUT -Body $_body -Hostname $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + elseif ($PSBoundParameters['WhatIf']) + { + + "[{0}] WhatIf Parameter was passed." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + if (-not $PSBoundParameters['Async']) + { + + $_Resp | Wait-OVTaskComplete + + } + + else + { + + $_Resp + + } + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Enable-OVCertificateValidation +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "Default", SupportsShouldProcess, ConfirmImpact = 'High')] + Param + ( + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Bool]$CheckForSelfSignedExpiry, + + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = "Default")] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command agian." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + Process + { + + $_uri = $ApplianceCertificateValidatorUri.Clone() + + $_Action = 'enable certificate validation' + + if ($PSBoundParameters['CheckForSelfSignedExpiry']) + { + + Write-Warning 'If you enable expiry checking, while establishing a connection to external devices or servers associated with self-signed certificates, certificate expiry check will be performed and communication with any device that has an expired self-signed certificate will fail.' + + $_Action += ' and check for expiration of self-signed certificates' + + } + + Write-Warning "Enabling certificate validation will require a reboot of the appliance. Please ensure that other users are not in the middle of operations before continuing." + + ForEach ($_appliance in $ApplianceConnection) + { + + "[{0}] Processing '{1}' Appliance (of {2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name, $ApplianceConnection.Count | Write-Verbose + + if ($PSCmdlet.ShouldProcess($_appliance.Name, $_Action)) + { + + "[{0}] {1} on appliance '{2}'." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_Action, $_appliance.Name | Write-Verbose + + # Get current configuration from appliance + Try + { + + $_CurrentCertValidationConfig = Send-OVRequest -Uri $_uri -Hostname $_appliance.name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $_CurrentCertValidationConfig.certValidationConfig.'global.validateCertificate' = $true + $_CurrentCertValidationConfig.okToReboot = $true + + if ($PSBoundParameters['CheckForSelfSignedExpiry']) + { + + $_CurrentCertValidationConfig.certValidationConfig.'global.enableExpiryCheckForSelfSignedLeafAtConnect' = $true + + } + + # Remove global.daysBeofeToTriggerCRLDownload if global.autoDownloadCRL is false, as the API will reject the PUT call is autoDownloadCRL is false + if (-not [bool]::Parse($_CurrentCertValidationConfig.certValidationConfig."global.autoDownloadCRL")) + { + + $_CurrentCertValidationConfig.certValidationConfig.PSObject.Properties.Remove('global.daysBeforeToTriggerCRLDownload') + + } + + Try + { + + $_Resp = Send-OVRequest -Uri $_uri -Method PUT -Body $_CurrentCertValidationConfig -Hostname $_appliance + + } + + Catch + { + + if ($_.Exception.Message -notmatch "timed out") + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + Write-Warning ('Appliance {0} is now rebooting.' -f $_appliance.Name) + + } + + elseif ($PSBoundParameters['WhatIf']) + { + + "[{0}] WhatIf Parameter was passed." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Disable-OVCertificateValidation +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "Default", SupportsShouldProcess, ConfirmImpact = 'High')] + Param + ( + + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = "Default")] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command agian." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + Process + { + + $_uri = $ApplianceCertificateValidatorUri.Clone() + + $_Action = 'disable certificate validation' + + Write-Warning 'Communication to devices and servers whose certificates are not validated is insecure and is subject to man-in-the-middle (MITM) attacks. Disabling certificate validation is discouraged.' + + Write-Warning "Diabling certificate validation will require a reboot of the appliance. Please ensure that other users are not in the middle of operations before continuing." + + ForEach ($_appliance in $ApplianceConnection) + { + + "[{0}] Processing '{1}' Appliance (of {2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name, $ApplianceConnection.Count | Write-Verbose + + # Need to validate if two-factor authentication is enabled, as certificate validation cannot be disabled + Try + { + + "[{0}] Getting current appliance global authentication configuration to check for two-factor auth setting." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + $_ApplianceTwoFactorConfiguration = Send-OVRequest -Uri $AuthnSettingsUri -Hostname $_appliance.Name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if ($_ApplianceTwoFactorConfiguration.twoFactorAuthenticationEnabled) + { + + "[{0}] Two-factor auth is configured. Building ErrorRecord." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $ExceptionMessage = 'Certificate validation or revocation cannot be disabled as two-factor authentication is enabled. Turn off two-factor authentication to disable certificate validation or revocation.' + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthGlobalSettingException InvalidCertValidationSetting InvalidOperation 'DisableCertVerification' -Message $ExceptionMessage + $PSCmdlet.WriteError($ErrorRecord) + + } + + elseif ($PSCmdlet.ShouldProcess($_appliance.Name, $_Action)) + { + + "[{0}] Two-factor auth is not configured." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + "[{0}] {1} on appliance '{2}'." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_Action, $_appliance.Name | Write-Verbose + + # Get current configuration from appliance + Try + { + + $_CurrentCertValidationConfig = Send-OVRequest -Uri $_uri -Hostname $_appliance.name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $_CurrentCertValidationConfig.certValidationConfig.'global.validateCertificate' = $false + $_CurrentCertValidationConfig.okToReboot = $true + + Try + { + + $_Resp = Send-OVRequest -Uri $_uri -Method PUT -Body $_CurrentCertValidationConfig -Hostname $_appliance + + } + + Catch + { + + if ($_.Exception.Message -notmatch "timed out") + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + Write-Warning ('Appliance {0} is now rebooting.' -f $_appliance.Name) + + } + + elseif ($PSBoundParameters['WhatIf']) + { + + "[{0}] WhatIf Parameter was passed." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Enable-OVCertificateRevocationChecking +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "Default", SupportsShouldProcess, ConfirmImpact = 'High')] + Param + ( + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Bool]$SkipRevocationCheck, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Bool]$AllowExpiredCRLs, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Bool]$NotifyExpiredMissingCRLs, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Bool]$EnableAutoCRLDownload, + + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = "Default")] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command agian." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + Process + { + + $_uri = $ApplianceCertificateValidatorUri.Clone() + + $_Action = 'enable certificate revocation checking' + + if ($PSBoundParameters['SkipRevocationCheck']) + { + + Write-Warning 'SkipRevocationCheck: If you have existing CA certificates associated with expired certificate revocation lists (CRL), any communication with devices or remote servers that have certificates authorized by those CAs will fail until new CRLs are uploaded for all of those CA certificates.' + $_SkipAction = if ($SkipRevocationCheck) { 'enable' } else { 'disable' } + $_Action += ', {0} skip CRL revocation check' -f $_SkipAction + + } + + if ($PSBoundParameters['AllowExpiredCRLs']) + { + + Write-Warning 'AllowExpiredCRLs: If you have existing CA certificates associated with expired certificate revocation lists (CRL), any communication with devices or remote servers that have certificates authorized by those CAs will fail until new CRLs are uploaded for all of those CA certificates.' + + $_AllowExpiredCRLsAction = if ($AllowExpiredCRLs) { 'enable' } else { 'disable' } + $_Action += ', {0} skip CRL revocation check' -f $_AllowExpiredCRLsAction + + } + + if ($PSBoundParameters['NotifyExpiredMissingCRLs']) + { + + Write-Warning 'NotifyExpiredMissingCRLs: Changing notify missing or expired CRLs security setting require rebooting the appliance.' + + $_AllowNotifyExpiredCRLsAction = if ($NotifyExpiredMissingCRLs) { 'enable' } else { 'disable' } + $_Action += ', {0} notify missing or expired CRLs' -f $_AllowNotifyExpiredCRLsAction + + } + + if ($PSBoundParameters['EnableAutoCRLDownload']) + { + + $_EnableAutoCRLDownloadAction = if ($EnableAutoCRLDownload) { + + Write-Warning 'EnableCRLAutomaticDownload: Enabling the automatic CRL download setting downloads the CRLs issued by the Certificate Authorities that are trusted in the appliance. You may need to configure the proxy settings in the appliance so that the CRL distribution points (DPs) are reachable. These DPs can be located by viewing each certificate shown in the manage certificates UI.' + + 'enable' + + } else { 'disable' } + + $_Action += ', {0} automatic CRL download' -f $_EnableAutoCRLDownloadAction + + } + + Write-Warning "Enabling certificate revocation checking will require a reboot of the appliance. Please ensure that other users are not in the middle of operations before continuing." + + ForEach ($_appliance in $ApplianceConnection) + { + + "[{0}] Processing '{1}' Appliance (of {2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name, $ApplianceConnection.Count | Write-Verbose + + if ($PSCmdlet.ShouldProcess($_appliance.Name, $_Action)) + { + + "[{0}] {1} on appliance '{2}'." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_Action, $_appliance.Name | Write-Verbose + + # Get current configuration from appliance + Try + { + + $_CurrentCertValidationConfig = Send-OVRequest -Uri $_uri -Hostname $_appliance.name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + # Need to process enabling CRL Auto Download first due to API enforcing it to be set before you can change the daily interval + if ($_EnableAutoCRLDownloadAction -eq 'enable') + { + + Write-Warning "If auto CRL was previously enabled, the interval is reeset back to 3 days. Use Set-OVCertificateRevocationInterval to modify the number of days between CRL check." + $_CurrentCertValidationConfig.certValidationConfig.'global.autoDownloadCRL' = $EnableAutoCRLDownload + $_CurrentCertValidationConfig.certValidationConfig.PSObject.Properties.Remove('global.daysBeforeToTriggerCRLDownload') + + } + + else + { + + $_CurrentCertValidationConfig.certValidationConfig.PSObject.Properties.Remove('global.daysBeforeToTriggerCRLDownload') + + } + + $_CurrentCertValidationConfig.certValidationConfig.'global.checkCertificateRevocation' = $true + + if ($PSBoundParameters['SkipRevocationCheck']) + { + + $_CurrentCertValidationConfig.certValidationConfig.'global.checkCertificateRevocation' = $SkipRevocationCheck + + } + + if ($PSBoundParameters['AllowExpiredCRLs']) + { + + $_CurrentCertValidationConfig.certValidationConfig.'global.allow.noCRL' = $AllowExpiredCRLs + + } + + if ($PSBoundParameters['NotifyExpiredMissingCRLs']) + { + + $_CurrentCertValidationConfig.certValidationConfig.'global.allow.invalidCRL' = $NotifyExpiredMissingCRLs + + } + + Try + { + + Send-OVRequest -Uri $_uri -Method PUT -Body $_CurrentCertValidationConfig -Hostname $_appliance + + } + + Catch + { + + if ($_.Exception.Message -notmatch "timed out") + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + Write-Warning ('Appliance {0} is now rebooting.' -f $_appliance.Name) + + } + + elseif ($PSBoundParameters['WhatIf']) + { + + "[{0}] WhatIf Parameter was passed." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Set-OVCertificateRevocationInterval +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "Default", SupportsShouldProcess, ConfirmImpact = 'High')] + Param + ( + + [Parameter (Mandatory, ParameterSetName = "Default")] + [ValidateRange(2,365)] + [Int]$AutoCRLDownloadInterval, + + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = "Default")] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneView.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command agian." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneView.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneView.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + Process + { + + $_uri = $ApplianceCertificateValidatorUri.Clone() + + $_Action = 'change certificate revocation interval to {0}' -f $AutoCRLDownloadInterval + + Write-Warning "Changing certificate revocation internval checking will require a reboot of the appliance. Please ensure that other users are not in the middle of operations before continuing." + + ForEach ($_appliance in $ApplianceConnection) + { + + "[{0}] Processing '{1}' Appliance (of {2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name, $ApplianceConnection.Count | Write-Verbose + + # Get current configuration from appliance + Try + { + + $_CurrentCertValidationConfig = Send-OVRequest -Uri $_uri -Hostname $_appliance.name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if (-not $_CurrentCertValidationConfig.certValidationConfig.'global.autoDownloadCRL') + { + + "[{0}] autoDownloadCRL is false. Building ErrorRecord." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $ExceptionMessage = 'Setting the CRL auto download interval requires certificate revocation list download to be enabled. Use Enable-OVCertificateRevocationChecking Cmdlet first to enable automatic CRL download.' + $ErrorRecord = New-ErrorRecord HPEOneView.Appliance.AuthGlobalSettingException InvalidCertValidationSetting InvalidOperation 'AutoCRLDownloadInterval' -Message $ExceptionMessage + $PSCmdlet.WriteError($ErrorRecord) + + } + + else + { + + if ($PSCmdlet.ShouldProcess($_appliance.Name, $_Action)) + { + + "[{0}] {1} on appliance '{2}'." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_Action, $_appliance.Name | Write-Verbose + + $_CurrentCertValidationConfig.certValidationConfig.'global.daysBeforeToTriggerCRLDownload' = $AutoCRLDownloadInterval + + Try + { + + Send-OVRequest -Uri $_uri -Method PUT -Body $_CurrentCertValidationConfig -Hostname $_appliance + + } + + Catch + { + + if ($_.Exception.Message -notmatch "timed out") + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + Write-Warning ('Appliance {0} is now rebooting.' -f $_appliance.Name) + + } + + elseif ($PSBoundParameters['WhatIf']) + { + + "[{0}] WhatIf Parameter was passed." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + } + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Disable-OVCertificateRevocationChecking +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "Default", SupportsShouldProcess, ConfirmImpact = 'High')] + Param + ( + + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = "Default")] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command agian." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + Process + { + + $_uri = $ApplianceCertificateValidatorUri.Clone() + + $_Action = 'disable certificate revocation checking' + + Write-Warning 'Communication to devices and servers whose certificates are not checked for revocation is insecure and is subject to man-in-the-middle (MITM) attack. It is strongly recommended that certificate revocation check is not turned off as it poses a serious security risk to the environment.' + + Write-Warning "Diabling certificate revocation checking will require a reboot of the appliance. Please ensure that other users are not in the middle of operations before continuing." + + ForEach ($_appliance in $ApplianceConnection) + { + + "[{0}] Processing '{1}' Appliance (of {2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name, $ApplianceConnection.Count | Write-Verbose + + # Need to validate if two-factor authentication is enabled, as certificate validation cannot be disabled + Try + { + + "[{0}] Getting current appliance global authentication configuration to check for two-factor auth setting." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + $_ApplianceTwoFactorConfiguration = Send-OVRequest -Uri $AuthnSettingsUri -Hostname $_appliance.Name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if ($_ApplianceTwoFactorConfiguration.twoFactorAuthenticationEnabled) + { + + "[{0}] Two-factor auth is configured. Building ErrorRecord." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $ExceptionMessage = 'Certificate validation or revocation cannot be disabled as two-factor authentication is enabled. Turn off two-factor authentication to disable certificate validation or revocation.' + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthGlobalSettingException InvalidCertValidationSetting InvalidOperation 'DisableCertVerification' -Message $ExceptionMessage + $PSCmdlet.WriteError($ErrorRecord) + + } + + elseif ($PSCmdlet.ShouldProcess($_appliance.Name, $_Action)) + { + + "[{0}] Two-factor auth is not configured." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + "[{0}] {1} on appliance '{2}'." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_Action, $_appliance.Name | Write-Verbose + + # Get current configuration from appliance + Try + { + + $_CurrentCertValidationConfig = Send-OVRequest -Uri $_uri -Hostname $_appliance.name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $_CurrentCertValidationConfig.certValidationConfig.'global.validateCertificate' = $false + $_CurrentCertValidationConfig.okToReboot = $true + + # Remove global.daysBeofeToTriggerCRLDownload if global.autoDownloadCRL is false, as the API will reject the PUT call is autoDownloadCRL is false + if (-not [bool]::Parse($_CurrentCertValidationConfig.certValidationConfig."global.autoDownloadCRL")) + { + + $_CurrentCertValidationConfig.certValidationConfig.PSObject.Properties.Remove('global.daysBeforeToTriggerCRLDownload') + + } + + Try + { + + Send-OVRequest -Uri $_uri -Method PUT -Body $_CurrentCertValidationConfig -Hostname $_appliance + + } + + Catch + { + + if ($_.Exception.Message -notmatch "timed out") + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + Write-Warning ('Appliance {0} is now rebooting.' -f $_appliance.Name) + + } + + elseif ($PSBoundParameters['WhatIf']) + { + + "[{0}] WhatIf Parameter was passed." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Get-OVApplianceTwoFactorAuthentication +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "Default")] + Param + ( + + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = "Default")] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command agian." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + Process + { + + ForEach ($_appliance in $ApplianceConnection) + { + + "[{0}] Processing '{1}' Appliance (of {2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name, $ApplianceConnection.Count | Write-Verbose + + Try + { + + $_Current2FAConfig = Send-OVRequest -Uri $AuthnSettingsUri -Hostname $_appliance.Name + + if (-not $_Current2FAConfig.emergencyLocalLoginEnabled) + { + + [HPEOneView.Appliance.Security.TwoFactorAuthConfiguration]::new($_Current2FAConfig.twoFactorAuthenticationEnabled, + $_Current2FAConfig.strictTwoFactorAuthentication, + $_Current2FAConfig.allowLocalLogin, + $_Current2FAConfig.emergencyLocalLoginEnabled, + 'EmergencyLocalLoginDisabled', + $_Current2FAConfig.ApplianceConnection + ) + + } + + else + { + + [HPEOneView.Appliance.Security.TwoFactorAuthConfiguration]::new($_Current2FAConfig.twoFactorAuthenticationEnabled, + $_Current2FAConfig.strictTwoFactorAuthentication, + $_Current2FAConfig.allowLocalLogin, + $_Current2FAConfig.emergencyLocalLoginEnabled, + $EmergencyLocalLoginTypeEnum[$_Current2FAConfig.emergencyLocalLoginType], + $_Current2FAConfig.ApplianceConnection + ) + + } + + + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Disable-OVApplianceTwoFactorAuthentication +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "Default", SupportsShouldProcess, ConfirmImpact = 'High')] + Param + ( + + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = "Default")] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command agian." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + Process + { + + ForEach ($_appliance in $ApplianceConnection) + { + + "[{0}] Processing '{1}' Appliance (of {2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name, $ApplianceConnection.Count | Write-Verbose + + Try + { + + "[{0}] Getting Global Auth settings from appliance." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_CurrentAuthn2FAConfig = Send-OVRequest -Uri $AuthnSettingsUri -Hostname $_appliance.Name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if ($PSCmdlet.ShouldProcess($_appliance.Name, 'disable two factor authentication')) + { + + "[{0}] Will disable 2FA on the appliance." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_CurrentAuthn2FAConfig.twoFactorAuthenticationEnabled = $false + + Try + { + + Send-OVRequest -Uri $AuthnSettingsUri -Method PUT -Body $_CurrentAuthn2FAConfig -Hostname $_appliance.Name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Set-OVApplianceTwoFactorAuthentication +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "Default", SupportsShouldProcess, ConfirmImpact = 'High')] + Param + ( + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Bool]$SmartCardLoginOnly, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Obsolete()] + [Bool]$EnableEmergencyLocalLogin, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Obsolete()] + [ValidateSet ('ApplianceConsoleOnly', 'NetworkAndApplianceConsole')] + [String]$EmergencyLoginAllowType, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [ValidateNotNullOrEmpty()] + [Array]$SubjectAlternativeNamePatterns, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [ValidateNotNullOrEmpty()] + [String]$SubjectPatterns, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [ValidateNotNullOrEmpty()] + [Array]$ValidationOids = @(@{"1.3.6.1.4.1.311.20.2.2" = "Smart Card Logon"; "1.3.6.1.5.5.7.3.2" = "Client Authentication"}), + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [ValidateSet ('Subject', 'SubjectAlternativeName', 'Issuer', 'Manual')] + [String]$DirectoryDomainType = 'Subject', + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [ValidateNotNullOrEmpty()] + [String]$DirectoryDomain = 'DC=(.*)', + + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = "Default")] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command agian." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + if ($PSBoundParameters.Keys -contains 'EnableEmergencyLocalLogin') + { + + Write-Warning "The -EnableEmergencyLocalLogin has moved to both Disable-OVLdapLocalLogin and Set-OVLdapDefaultDirectory Cmdlets. Please update your scripts." + + } + + if ($PSBoundParameters.Keys -contains 'EmergencyLoginAllowType') + { + + Write-Warning "The -EmergencyLoginAllowType has moved to both Disable-OVLdapLocalLogin and Set-OVLdapDefaultDirectory Cmdlets. Please update your scripts." + + } + + } + + Process + { + + ForEach ($_appliance in $ApplianceConnection) + { + + "[{0}] Processing '{1}' Appliance (of {2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name, $ApplianceConnection.Count | Write-Verbose + + Try + { + + "[{0}] Getting Global Auth settings from appliance." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_CurrentAuthn2FAConfig = Send-OVRequest -Uri $AuthnSettingsUri -Hostname $_appliance.Name + + $_Current2FALoginCertConfig = Send-OVRequest -Uri $Authn2FALoginCertificateConfigUri -Hostname $_appliance.Name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + "[{0}] 2FA is enabled on the appliance: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_CurrentAuthn2FAConfig.twoFactorAuthenticationEnabled.ToString() | Write-Verbose + + if (-not $_CurrentAuthn2FAConfig.twoFactorAuthenticationEnabled) + { + + "[{0}] Will enable 2FA on the appliance." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_CurrentAuthn2FAConfig.twoFactorAuthenticationEnabled = $true + + } + + switch ($PSBoundParameters.Keys) + { + + 'SmartCardLoginOnly' + { + + if ($SmartCardLoginOnly) + { + + if ($PSCmdlet.ShouldProcess($_appliance.Name, 'enforce two factor authentication only')) + { + + "[{0}] Will enable 2FA on the appliance." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_CurrentAuthn2FAConfig.twoFactorAuthenticationEnabled = $true + $_CurrentAuthn2FAConfig.allowLocalLogin = $false + + } + + } + + else + { + + "[{0}] Disabling strict 2FA on the appliance." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_CurrentAuthn2FAConfig.twoFactorAuthenticationEnabled = $false + + } + + } + + 'SubjectAlternativeNamePatterns' + { + + "[{0}] Setting SAN pattern values on the appliance to {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), [String]::Join(', ', $SubjectAlternativeNamePatterns.ToArray()) | Write-Verbose + + $_Current2FALoginCertConfig.subjectAlternateNamePatterns = [String]::Join(', ', $SubjectAlternativeNamePatterns.ToArray()) + + } + + 'SubjectPatterns' + { + + "[{0}] Setting SAN pattern values on the appliance to {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), [String]::Join(', ', $SubjectPatterns.ToArray()) | Write-Verbose + + $_Current2FALoginCertConfig.subjectPatterns = [String]::Join(', ', $SubjectPatterns.ToArray()) + + } + + 'DirectoryDomainType' + { + + "[{0}] Setting DirectoryDomainType on the appliance to {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $DirectoryDomainType | Write-Verbose + + $_Current2FALoginCertConfig.certificateDomainIdentifier = $DirectoryDomainType + + } + + 'ValidationOids' + { + + $_ValidationOids = [System.Collections.ArrayList]::new() + + ForEach ($e in $ValidationOids) + { + + [void]$_ValidationOids.Add($e) + + } + + "[{0}] Setting ValidationOids on the appliance to {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), [String]::Join(', ', $_ValidationOids.ToArray()) | Write-Verbose + + $_Current2FALoginCertConfig.validationOids = $_ValidationOids + + } + + 'DirectoryDomain' + { + + "[{0}] Setting Directory Domain Identifier Pattern on the appliance to {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $DirectoryDomain | Write-Verbose + + $_Current2FALoginCertConfig.certificateDomainIdentifierPattern = $DirectoryDomain + + } + + } + + # Update Appliance Authn Glboal Settings + + Try + { + + Send-OVRequest -Uri $AuthnSettingsUri -Method PUT -Body $_CurrentAuthn2FAConfig -Hostname $_appliance.Name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + # Update LoginCertificateConfigDto + + Try + { + + Send-OVRequest -Uri $Authn2FALoginCertificateConfigUri -Method PUT -Body $_Current2FALoginCertConfig -Hostname $_appliance.Name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Get-OVApplianceAvailableSecurityMode +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = 'Default')] + param + ( + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateSet ('Legacy', 'FIPS', 'CNSA')] + [String[]]$ModeName, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = ($ConnectedSessions | Where-Object Default) + + ) + + Begin + { + + "[{0}] Bound PS Parameters: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(),($PSBoundParameters | out-string) | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not($ConnectedSessions)) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command agian." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -gt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + if (-not $PSBoundParameters['ModeName']) + { + + $ModeName = 'Legacy', 'FIPS', 'CNSA' + + } + + } + + Process + { + + ForEach ($_appliance in $ApplianceConnection) + { + + "[{0}] Processing appliance {1} (of {2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name, $ApplianceConnection.Count | Write-Verbose + + ForEach ($_modeName in $ModeName) + { + + $_uri = '{0}/{1}' -f $ApplianceSecurityModesUri, $_modeName + + Try + { + + $_SecurityMode = Send-OVRequest -Uri $_uri -ApplianceConnection $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + [HPEOneView.Appliance.SecurityMode]::new($_SecurityMode.modeName, + $_SecurityMode.currentMode, + $_SecurityMode.ApplianceConnection) + + } + + } + + } + + end + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Get-OVApplianceCurrentSecurityMode +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = 'Default')] + param + ( + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = ($ConnectedSessions | Where-Object Default) + + ) + + Begin + { + + "[{0}] Bound PS Parameters: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(),($PSBoundParameters | out-string) | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not($ConnectedSessions)) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command agian." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -gt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $_CollectionName = [System.Collections.ArrayList]::new() + + } + + Process + { + + ForEach ($_appliance in $ApplianceConnection) + { + + "[{0}] Processing appliance {1} (of {2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name, $ApplianceConnection.Count | Write-Verbose + + $_uri = '{0}' -f $ApplianceCurrentSecurityModeUri + + Try + { + + $_SecurityMode = Send-OVRequest -Uri $_uri -ApplianceConnection $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + [HPEOneView.Appliance.SecurityMode]::new($_SecurityMode.modeName, + $_SecurityMode.currentMode, + $_SecurityMode.ApplianceConnection) + + } + + } + + end + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Set-OVApplianceCurrentSecurityMode +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = 'Default', SupportsShouldProcess, ConfirmImpact = 'High' )] + param + ( + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = 'Default')] + [HPEOneView.Appliance.SecurityMode]$SecurityMode, + + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = ($ConnectedSessions | Where-Object Default) + + ) + + Begin + { + + "[{0}] Bound PS Parameters: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(),($PSBoundParameters | out-string) | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not($ConnectedSessions)) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command agian." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -gt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $_CollectionName = [System.Collections.ArrayList]::new() + + } + + Process + { + + ForEach ($_appliance in $ApplianceConnection) + { + + "[{0}] Processing appliance {1} (of {2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name, $ApplianceConnection.Count | Write-Verbose + + Switch ($SecurityMode.ModeName) + { + + 'FIPS' + { + + Write-Warning 'While in FIPS cryptography mode, the appliance uses strong cryptographic protocols and ciphers for all internal and external configuration and communications as defined by the FIPS standard.' + + } + + 'CNSA' + { + + Write-Warning 'While in CNSA cryptography mode, the appliance uses strong cryptographic protocols and ciphers for all internal and external configuration and communications as defined by the CNSA standard.' + + } + + } + + Write-Host "" + Write-Warning "Changing the cryptography mode will generate new appliance certificates if the current certificates are self-signed and are not compatible with the new cryptography mode. Any externally signed appliance certificates will need to be re-imported by the user before changing the mode.`r`n`r`nIt is extremely important to create and review the compatibility report for the new cryptography mode before proceeding. Not doing so could result in disruptions to the normal operation of the appliance. Cancel this operation and review the report if you have not already done so." + + $_uri = '{0}' -f $ApplianceCurrentSecurityModeUri + + $_Body = @{ + modeName = $SecurityMode.ModeName + } + + $_Message = 'change appliance active security mode to "{0}"' -f $SecurityMode.ModeName + + if ($PSCmdlet.ShouldProcess($_appliance, $_Message)) + { + + Try + { + + Send-OVRequest -Uri $_uri -Method PUT -Body $_Body -ApplianceConnection $_appliance | Wait-OVTaskComplete -ApplianceWillReboot + + } + + Catch + { + + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + } + + end + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Get-OVApplianceSecurityProtocol +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = 'Default')] + [OutputType([System.Collections.Generic.List[HPEOneView.Appliance.SecurityProtocol]], ParameterSetName = "Default")] + param + ( + + [Parameter (ParameterSetName = 'Default', Mandatory = $false)] + [ValidateSet ('TLSv1', 'TLSv1.1', 'TLSv1.2')] + [String[]]$TlsVersion, + + [Parameter (ParameterSetName = 'Default', Mandatory = $false)] + [ValidateSet ('Legacy', 'FIPS', 'CNSA')] + [String[]]$SecurityMode, + + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = ($ConnectedSessions | Where-Object Default) + + ) + + Begin + { + + "[{0}] Bound PS Parameters: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(),($PSBoundParameters | out-string) | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not($PSBoundParameters['InputObject'])) + { + + $Pipelineinput = $True + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not($ConnectedSessions)) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command agian." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -gt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + if (-not $PSBoundParameters['TlsVersion']) + { + + $TlsVersion = 'TLSv1', 'TLSv1.1', 'TLSv1.2' + + } + + $_ApplianceProtocolsCollection = [System.Collections.Generic.List[HPEOneView.Appliance.SecurityProtocol]]::new() + + } + + Process + { + + ForEach ($_appliance in $ApplianceConnection) + { + + "[{0}] Processing appliance {1} (of {2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name, $ApplianceConnection.Count | Write-Verbose + + # need to get the current security mode + try + { + + $_CurrentSecurityMode = Send-OVRequest -Uri $ApplianceCurrentSecurityModeUri -Hostname $_appliance + + } + + catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + ForEach ($_TlsVersion in $TlsVersion) + { + + $_uri = '{0}/{1}' -f $ApplianceSecurityProtocolsUri, $_TlsVersion.Replace('tls','TLS') + + if ($PSBoundParameters['SecurityMode']) + { + + ForEach ($_SecurityMode in $SecurityMode) + { + + $_CipherSuitesCol = [System.Collections.Generic.List[HPEOneView.Appliance.SecurityProtocol+CipherSuite]]::new() + + $__uri = '{0}?mode={1}' -f $_uri, $_SecurityMode + + try + { + + $_SecurityProtocolWithMode = Send-OVRequest -Uri $__uri -Hostname $_appliance + + } + + catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + ForEach ($_cipherSuite in $_SecurityProtocolWithMode.cipherSuites) + { + + $_CipherSuite = [HPEOneView.Appliance.SecurityProtocol+CipherSuite]::new($_cipherSuite.cipherSuiteName, $_cipherSuite.enabled) + $_CipherSuitesCol.Add($_CipherSuite) + + } + + $_Protocol = [HPEOneView.Appliance.SecurityProtocol]::new($_SecurityProtocolWithMode.protocolName, + $_CipherSuitesCol, + $_SecurityProtocolWithMode.category, + $_SecurityMode, + ($_CurrentSecurityMode.ModeName -eq $_SecurityMode), + $_SecurityProtocolWithMode.enabled, + $_SecurityProtocolWithMode.ApplianceConnection) + + $_ApplianceProtocolsCollection.Add($_Protocol) + + } + + } + + else + { + + $_CipherSuitesCol = [System.Collections.Generic.List[HPEOneView.Appliance.SecurityProtocol+CipherSuite]]::new() + + try + { + + $_ApplianceSecurityProtocols = Send-OVRequest -Uri ($_uri + "?mode=$($_CurrentSecurityMode.modeName)") -Hostname $_appliance + + } + + catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + ForEach ($_SecurityProtocol in $_ApplianceSecurityProtocols) + { + + ForEach ($_cipherSuite in $_SecurityProtocol.cipherSuites) + { + + $_CipherSuite = [HPEOneView.Appliance.SecurityProtocol+CipherSuite]::new($_cipherSuite.cipherSuiteName, $_cipherSuite.enabled) + $_CipherSuitesCol.Add($_CipherSuite) + + } + + $_Protocol = [HPEOneView.Appliance.SecurityProtocol]::new($_SecurityProtocol.protocolName, + $_CipherSuitesCol, + $_SecurityProtocol.category, + $_CurrentSecurityMode.modeName, + $True, + $_SecurityProtocol.enabled, + $_SecurityProtocol.ApplianceConnection) + + $_ApplianceProtocolsCollection.Add($_Protocol) + + } + + } + + } + + } + + } + + end + { + + $_ApplianceProtocolsCollection | Sort-Object Mode + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Set-OVApplianceSecurityProtocol +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = 'Default', SupportsShouldProcess, ConfirmImpact = 'High')] + [OutputType([System.Collections.Generic.List[HPEOneView.Appliance.SecurityProtocol]], ParameterSetName = "Default")] + param + ( + + [Parameter (ParameterSetName = 'Default', Mandatory)] + [ValidateSet ('TLSv1', 'TLSv1.1', 'TLSv1.2')] + [String[]]$EnableTlsVersion, + + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = ($ConnectedSessions | Where-Object Default) + + ) + + Begin + { + + "[{0}] Bound PS Parameters: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(),($PSBoundParameters | out-string) | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not($ConnectedSessions)) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command agian." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -gt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $_SecurityProtocolsToSet = NewObject -ApplianceSecurityProtocols + + ForEach ($_Protocol in $EnableTlsVersion) + { + + "[{0}] Will enable '{1}' security protocol." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_Protocol | Write-Verbose + + ($_SecurityProtocolsToSet | Where-Object protocolName -eq $_Protocol).enabled = $true + + } + + $_ApplianceProtocolsCollection = [System.Collections.Generic.List[HPEOneView.Appliance.SecurityProtocol]]::new() + + } + + Process + { + + ForEach ($_appliance in $ApplianceConnection) + { + + $_WaitedFoReboot = $false + + "[{0}] Processing appliance {1} (of {2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name, $ApplianceConnection.Count | Write-Verbose + + Write-Warning "Changing the appliance security protocol(s) will immediately reboot the appliance." + + $_ShouldProcessMessage = "enable only '{0}' security protocol(s)" -f [String]::Join("','", $EnableTlsVersion) + + if ($PSCmdlet.ShouldProcess($_appliance, $_ShouldProcessMessage)) + { + + try + { + + $_CurrentSecurityMode = Send-OVRequest -Uri $ApplianceSecurityProtocolsUri -Method PUT -Body $_SecurityProtocolsToSet -Hostname $_appliance + + } + + catch + { + + # Appliance has likely rebooted. + if ([RegEx]::Match($_.Exception.Message, 'The operation has timed out|An unexpected error occurred on a receive', $RegExInsensitiveFlag).Success) + { + + Write-Warning "Appliance has now started to reboot." + + # Lets wait 10 minutes for appliance to reboot. Waiting less time may cause excessive timeout issues waiting for heavily loaded appliance from rebooting in time. + Wait-Reboot + + $_WaitedFoReboot = $true + + } + + else + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + try + { + + # In case the appliance didn't reboot in time and cause the operation timed out exception + if (-not $_WaitedFoReboot) + { + + Wait-Reboot + + } + + Get-OVApplianceSecurityProtocol -ApplianceConnection $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + } + + end + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Show-OVApplianceSecurityModeCompatibilityReport +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = 'Default')] + [OutputType([HPEOneView.Appliance.SecurityModeCompatibilityReport], ParameterSetName="Default")] + param + ( + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [HPEOneView.Appliance.SecurityMode]$TargetSecurityMode, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [Switch]$UpdateReport, + + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = ($ConnectedSessions | Where-Object Default) + + ) + + Begin + { + + "[{0}] Bound PS Parameters: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(),($PSBoundParameters | out-string) | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not $PSBoundParameters['TargetSecurityMode']) + { + + $Pipelineinput = $True + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not($ConnectedSessions)) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command agian." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -gt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + function GenerateCompatabilityReport + { + + [CmdletBinding (DefaultParameterSetName = 'Default')] + param + ( + + [Parameter (Mandatory, ParameterSetName = 'Default', Position = 0)] + [ValidateNotNullOrEmpty()] + [HPEOneView.Appliance.SecurityMode]$_CurrentMode, + + [Parameter (Mandatory, ParameterSetName = 'Default', Position = 1)] + [ValidateNotNullOrEmpty()] + [HPEOneView.Appliance.SecurityMode]$_TargetMode, + + [Parameter (Mandatory, ParameterSetName = 'Default', Position = 2)] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [HPEOneView.Appliance.Connection]$_ApplianceConnection, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default', Position = 3)] + [Switch]$UpdateReport + + ) + + Try + { + + $_GenerateCompatabilityReport = NewObject -SecurityModeCompatabilityReport + $_GenerateCompatabilityReport.currentMode = $_CurrentMode.ModeName + $_GenerateCompatabilityReport.targetMode = $_TargetMode.ModeName + + $_Uri = $ApplianceSecurityModeCompatibiltyReportUri.Clone() + + if ($UpdateReport.IsPresent) + { + + $_Uri += "?force=true" + + } + + Send-OVRequest -Uri $_Uri -Method POST -Body $_GenerateCompatabilityReport -Hostname $_ApplianceConnection | Wait-OVTaskComplete | Out-Null + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + Process + { + + # Get current security mode + '[{0}] Getting current appliance security mode.' -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $_CurrentApplianceSecurityMode = Get-OVApplianceCurrentSecurityMode -ApplianceConnection $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + # If current matches target, generate error saying mode already set + if ($_CurrentApplianceSecurityMode.ModeName -eq $TargetSecurityMode.ModeName) + { + + '[{0}] Appliance is already at the requested appliance security mode: {1}' -f $MyInvocation.InvocationName.ToString().ToUpper(), $TargetSecurityMode.ModeName | Write-Verbose + + $ExceptionMessage = "The appliance is already at the requested '{0}' security mode." -f $TargetSecurityMode.ModeName + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.ApplianceSecurityModeException ApplianceAlreadySetToSecurityMode ResourceExists "ApplianceConnection" -Message $ExceptionMessage + $PSCmdlet.WriteError($ErrorRecord) + + } + + else + { + + # Regenerate report + if ($UpdateReport.IsPresent) + { + + '[{0}] Refreshing the security mode compatability report.' -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + GenerateCompatabilityReport $_CurrentApplianceSecurityMode $TargetSecurityMode $ApplianceConnection $UpdateReport.IsPresent + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + # Get supported security protocols for security mode + Try + { + + $_SupportedSecurityProtocolsFromMode = Get-OVApplianceSecurityProtocol -SecurityMode $TargetSecurityMode.ModeName -ApplianceConnection $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + # Check to see if a report exists, if not, generate it + Try + { + + $_Report = Send-OVRequest -Uri $ApplianceSecurityModeCompatibiltyReportUri -Hostname $ApplianceConnection + + '[{0}] Report exists on appliance. Generating the security mode compatability report.' -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + Catch [HPEOneView.ResourceNotFoundException] + { + + '[{0}] Report does not exist. Creating the security mode compatability report.' -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + GenerateCompatabilityReport $_CurrentApplianceSecurityMode $TargetSecurityMode $ApplianceConnection + + '[{0}] Report created. Retrieving details.' -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_Report = Send-OVRequest -Uri $ApplianceSecurityModeCompatibiltyReportUri -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + # Build report + Try + { + + '[{0}] Building compatibility report object(s).' -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_externalServers = [System.Collections.Generic.List[HPEOneView.Appliance.SecurityModeCompatibilityReport+ExternalServer]]::new() + + ForEach ($_ExternalCert in ($_Report.members | Where-Object { $_.reportSection.sectionKey -eq 'EXTERNALCERTIFICATE'})) + { + + $_ExternalCompatbilityDetails = [System.Collections.Generic.List[HPEOneView.Appliance.SecurityModeCompatibilityReport+CompapatibilityDetail]]::new() + + ForEach ($_CompatDetail in $_ExternalCert.nonCompatibilityDetails) + { + + $_CompapatibilityDetail = [HPEOneView.Appliance.SecurityModeCompatibilityReport+CompapatibilityDetail]::new($_CompatDetail.nonCompatibilityKey, $_CompatDetail.nonCompatibilityAction) + $_ExternalCompatbilityDetails.Add($_CompapatibilityDetail) + + } + + $_externalServer = [HPEOneView.Appliance.SecurityModeCompatibilityReport+ExternalServer]::new($_ExternalCert.deviceName, + $_ExternalCert.deviceType, + $_ExternalCert.deviceUri, + $_ExternalCompatbilityDetails, + $_ExternalCert.ApplianceConnection) + + $_externalServers.Add($_externalServer) + + } + + $_managedDevices = [System.Collections.Generic.List[HPEOneView.Appliance.SecurityModeCompatibilityReport+ManagedDevice]]::new() + + ForEach ($_managedDevice in ($_Report.members | Where-Object { $_.reportSection.sectionKey -eq 'MANAGEDDEVICE'})) + { + + $_ManagedDeviceCompatbilityDetails = [System.Collections.Generic.List[HPEOneView.Appliance.SecurityModeCompatibilityReport+CompapatibilityDetail]]::new() + + ForEach ($_CompatDetail in $_managedDevice.nonCompatibilityDetails) + { + + $_CompapatibilityDetail = [HPEOneView.Appliance.SecurityModeCompatibilityReport+CompapatibilityDetail]::new($_CompatDetail.nonCompatibilityKey, $_CompatDetail.nonCompatibilityAction) + $_ManagedDeviceCompatbilityDetails.Add($_CompapatibilityDetail) + + } + + $_externalServer = [HPEOneView.Appliance.SecurityModeCompatibilityReport+ManagedDevice]::new($_managedDevice.deviceName, + $_managedDevice.deviceType, + $_managedDevice.deviceUri, + $_ManagedDeviceCompatbilityDetails, + $_managedDevice.ApplianceConnection) + + $_managedDevices.Add($_externalServer) + + } + + $_applianceCerificates = [System.Collections.Generic.List[HPEOneView.Appliance.SecurityModeCompatibilityReport+ApplianceCerificate]]::new() + + ForEach ($_ApplianceCert in ($_Report.members | Where-Object { $_.reportSection.sectionKey -eq 'APPLIANCECERTIFICATE'})) + { + + $_ApplianceCertCompatbilityDetails = [System.Collections.Generic.List[HPEOneView.Appliance.SecurityModeCompatibilityReport+CompapatibilityDetail]]::new() + + ForEach ($_CompatDetail in $_ApplianceCert.nonCompatibilityDetails) + { + + $_CompapatibilityDetail = [HPEOneView.Appliance.SecurityModeCompatibilityReport+CompapatibilityDetail]::new($_CompatDetail.nonCompatibilityKey, $_CompatDetail.nonCompatibilityAction) + $_ApplianceCertCompatbilityDetails.Add($_CompapatibilityDetail) + + } + + $_applianceCerificate = [HPEOneView.Appliance.SecurityModeCompatibilityReport+ApplianceCerificate]::new($_ApplianceCert.deviceName, + $_ApplianceCert.deviceType, + $_ApplianceCert.deviceUri, + $_ApplianceCertCompatbilityDetails, + $_ApplianceCert.ApplianceConnection) + + $_applianceCerificates.Add($_applianceCerificate) + + } + + [HPEOneView.Appliance.SecurityModeCompatibilityReport]::new($TargetSecurityMode.ModeName, + $_Report.created, + $_SupportedSecurityProtocolsFromMode, + $_applianceCerificates, + $_externalServers, + $_managedDevices, + $_Report.ApplianceConnection) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + End + { + + '[{0}] Done.' -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Enable-OVApplianceStrictSecurityCipherSuite +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "Default", SupportsShouldProcess, ConfirmImpact = 'High')] + Param + ( + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ExceptionMessage = "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command agian." + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + Process + { + + $_uri = "{0}" -f $ApplianceGlobalSecuritySettingsUri + + "[{0}] Processing '{1}' appliance" -f $MyInvocation.InvocationName.ToString().ToUpper(), $ApplianceConnection | Write-Verbose + + $Request = @( + @{ + name = 'EnforceGCMCipherSuites'; + value = $true + } + ) + + Write-Warning "Performing this operation will cause the appliance to rebot immediately." + + $_Action = "enable strict GCM security ciphers" + + if ($PSCmdlet.ShouldProcess($ApplianceConnection.Name, $_Action)) + { + + "[{0}] Processing '{1}' appliance" -f $MyInvocation.InvocationName.ToString().ToUpper(), $ApplianceConnection | Write-Verbose + + # Get current configuration from appliance + Try + { + + Send-OVRequest -Uri $_uri -Method PUT -Body $Request -Hostname $ApplianceConnection | Wait-OVTaskComplete + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + Write-Warning ('Appliance {0} should now be rebooting.' -f $ApplianceConnection) + + } + + elseif ($PSBoundParameters['WhatIf']) + { + + "[{0}] WhatIf Parameter was passed." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Disable-OVApplianceStrictSecurityCipherSuite +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "Default", SupportsShouldProcess, ConfirmImpact = 'High')] + Param + ( + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ExceptionMessage = "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command agian." + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + Process + { + + $_uri = "{0}" -f $ApplianceGlobalSecuritySettingsUri + + "[{0}] Processing '{1}' appliance" -f $MyInvocation.InvocationName.ToString().ToUpper(), $ApplianceConnection | Write-Verbose + + $Request = @( + @{ + name = 'EnforceGCMCipherSuites'; + value = $false + } + ) + + Write-Warning "Performing this operation will cause the appliance to rebot immediately." + + $_Action = "disable strict GCM security ciphers" + + if ($PSCmdlet.ShouldProcess($ApplianceConnection.Name, $_Action)) + { + + "[{0}] Processing '{1}' appliance" -f $MyInvocation.InvocationName.ToString().ToUpper(), $ApplianceConnection | Write-Verbose + + # Get current configuration from appliance + Try + { + + Send-OVRequest -Uri $_uri -Method PUT -Body $Request -Hostname $ApplianceConnection | Wait-OVTaskComplete + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + Write-Warning ('Appliance {0} should now be rebooting.' -f $ApplianceConnection) + + } + + elseif ($PSBoundParameters['WhatIf']) + { + + "[{0}] WhatIf Parameter was passed." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +####################################################### +# Alerts & Events: +# + +function Get-OVAlert +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "Default")] + Param + ( + + [Parameter (Mandatory = $False, ValueFromPipeline, ParameterSetName = "Default")] + [ValidateNotNullOrEmpty()] + [Alias ('resourceUri','Resource')] + [Object]$InputObject, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [ValidateNotNullOrEmpty()] + [ValidateSet ('OK', 'Critical', 'Disabled', 'Warning', 'Unknown')] + [String]$Severity, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [ValidateNotNullOrEmpty()] + [AlertHealthCategoryEnum]$HealthCategory, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [ValidateNotNullOrEmpty()] + [String]$AssignedToUser, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Alias ('State')] + [ValidateNotNullOrEmpty()] + [String]$AlertState, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Int]$Count = 0, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [ValidateNotNullOrEmpty()] + [TimeSpan]$TimeSpan, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [ValidateNotNullOrEmpty()] + [DateTime]$Start, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [ValidateNotNullOrEmpty()] + [DateTime]$End = [DateTime]::Now, + + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = "Default")] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if ($PSCmdlet.ParameterSetName -eq 'ResourcePipeline') + { + + $Pipelineinput = $True + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command agian." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + $_AlertResources = [System.Collections.ArrayList]::new() + + if (-not $Count) + { + + $Count = -1 + + } + + } + + Process + { + + $_uri = "{0}?sort=created:desc&category=alerts" -f $IndexUri + + $_Query = [System.Collections.ArrayList]::new() + + [void]$_Query.Add("_category:'alerts' AND parentTaskUri:'null' AND NOT taskType:'Background' AND (NOT state:'New' AND NOT state:'Starting') AND NOT stateReason:'ValidationError' AND NOT hidden:'true'") + + If ($Pipelineinput -or $InputObject -is [PSCustomObject]) + { + + "[{0}] Processing InputObject from pipeline: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Pipelineinput | Write-Verbose + + # Check what type of resource is being provided + switch ($InputObject.category) + { + + { $ResourceCategoryEnum.ServerHardware, + $ResourceCategoryEnum.Enclosure, + $ResourceCategoryEnum.LogicalEnclosure, + $ResourceCategoryEnum.ServerProfile, + $ResourceCategoryEnum.Interconnect, + $ResourceCategoryEnum.LogicalInterconnect, + $ResourceCategoryEnum.Baseline -contains $_ } + { + + "[{0}] Processing '{1}' resource." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_ | Write-Verbose + + [void]$_Query.Add(("resourceUri:'{0}'" -f $InputObject.uri)) + + } + + default + { + + $ExceptionMessage = 'The provided object {0} is not supported. Only Server Hardware, Server Profile and Enclosure are supported resources.' -f $InputObject.name + $ErrorRecord = New-ErrorRecord HPEOneView.InputObjectResourceException InvalidInputObjectResource InvalidArgument "InputObject" -TargetType 'PSObject' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + # Generate error if ApplianceConnection properties do not match + if ($InputObject -and $InputObject.ApplianceConnection.Name -ne $ApplianceConnection.Name) + { + + $ExceptionMessage = "The provided input object '{0}' 'ApplianceConnection' NoteProperty ({1}) does notmatch the Appliance Connection." -f $InputObject.ApplianceConnection, $ApplianceConnection + $ErrorRecord = New-ErrorRecord HPEOneView.InputObjectResourceException ApplianceConnetionDoesNotMatchObject InvalidArgument 'InputObject' -TargetType 'PSObject' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + if ($PSBoundParameters['Count']) + { + + $_uri = "{0}&count={1}" -f $_uri, $Count + + } + + # Needs to be a filter statement in URI. NEED TO ADD TO GET-OVALERT FOR ITS TIMESPAN PARAMETER + if ($TimeSpan) + { + + $_uri = '{0}&filter="created > {1}"' -f $_uri, ([DateTime]::Now - $timespan).ToString("yyyy-MM-ddTHH:mm:ff.fffZ") + + } + + elseif ($Start) + { + + $_uri = '{0}&filter="created > {1}"&filter="created < {2}"' -f $_uri, $End.ToString("yyyy-MM-ddTHH:mm:ff.fffZ"), $Start.ToString("yyyy-MM-ddTHH:mm:ff.fffZ") + + } + + if ($PSBoundParameters['Severity']) + { + + [Void]$_Query.Add(("severity='{0}'" -f $Severity)) + + } + + if ($PSBoundParameters['HealthCategory']) + { + + [Void]$_Query.Add(("healthCategory:'{0}'" -f $HealthCategory)) + + } + + if ($PSBoundParameters['AssignedToUser']) + { + + [Void]$_Query.Add(("Owner:'{0}'" -f $AssignedToUser)) + + } + + if ($PSBoundParameters['AlertState']) + { + + [Void]$_Query.Add(("state='{0}'" -f ($AlertState.SubString(0,1).ToUpper() + $AlertState.SubString(1).tolower()))) + + } + + $_uri = '{0}&query="{1}"' -f $_uri, [String]::Join(' AND ',$_Query.ToArray()) + + "[{0}] URI: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_uri | Write-Verbose + + ForEach ($_appliance in $ApplianceConnection) + { + + "[{0}] Processing '{1}' Appliance (of {2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name, $ApplianceConnection.Count | Write-Verbose + + Try + { + + [Array]$_ResourceAlerts = Get-AllIndexResources -Uri $_uri -ApplianceConnection $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + ForEach ($_alert in $_ResourceAlerts) + { + + if ($null -ne $_alert) + { + + $_alert.PSObject.TypeNames.Insert(0, "HPEOneView.Alert") + + [void]$_AlertResources.Add($_alert) + + } + + } + + } + + } + + End + { + + Return $_AlertResources + + } + +} + +function Get-OVServiceAlert +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "Default")] + Param + ( + + [Parameter (Mandatory = $False, ValueFromPipeline, ParameterSetName = "Default")] + [ValidateNotNullOrEmpty()] + [Object]$InputObject, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [ValidateNotNullOrEmpty()] + [ValidateSet ('Open', 'Closed', 'Pending', 'Received', 'Submitted', 'Error')] + [String]$State, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Int]$Count = 0, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [ValidateNotNullOrEmpty()] + [TimeSpan]$TimeSpan, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [ValidateNotNullOrEmpty()] + [DateTime]$Start, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [ValidateNotNullOrEmpty()] + [DateTime]$End = [DateTime]::Now, + + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = "Default")] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if ($PSCmdlet.ParameterSetName -eq 'ResourcePipeline') + { + + $Pipelineinput = $True + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command agian." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + $_AlertResources = [System.Collections.ArrayList]::new() + + if (-not $Count) + { + + $Count = -1 + + } + + } + + Process + { + + $_uri = "{0}?sort:asc" -f $IndexUri + + $_Query = [System.Collections.ArrayList]::new() + [void]$_Query.Add("category:alerts AND healthCategory:RemoteSupport AND ServiceEventSource:True AND NOT description:'Service Test Event'") + + If ($Pipelineinput -or $InputObject -is [PSCustomObject]) + { + + "[{0}] Processing InputObject from pipeline: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Pipelineinput | Write-Verbose + + # Check what type of resource is being provided + switch ($InputObject.category) + { + + { $ResourceCategoryEnum.ServerHardware, $ResourceCategoryEnum.Enclosure -contains $_ } + { + + "[{0}] Processing '{1}' resource." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_ | Write-Verbose + + if (-not (ValidateRemoteSupport -InputObject $InputObject)) + { + + $ExceptionMessage = "The resource {0} is not configured for Remote Support or does not support Remote Support." -f $InputObject.Name + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.RemoteSupportResourceException InvalidResourceObject InvalidArgument "InputObject" -TargetType 'PSObject' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + else + { + + "[{0}] Remote Support is enabled." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_ | Write-Verbose + + } + + [void]$_Query.Add(("resourceUri:'{0}'" -f $InputObject.uri)) + + } + + $ResourceCategoryEnum.ServerProfile + { + + "[{0}] Processing '{1}' resource." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_ | Write-Verbose + + if (-not (ValidateRemoteSupport -InputObject $InputObject)) + { + + $ExceptionMessage = "The resource {0} is not configured for Remote Support or does not support Remote Support." -f $InputObject.Name + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.RemoteSupportResourceException InvalidResourceObject InvalidArgument "InputObject" -TargetType 'PSObject' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + else + { + + "[{0}] Remote Support is enabled." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_ | Write-Verbose + + } + + if ($null -eq $InputObject.serverHardwareUri) + { + + $ExceptionMessage = 'The provided server profile object {0} is not assigned to a server hardware resource.' -f $InputObject.name + $ErrorRecord = New-ErrorRecord HPEOneView.InputObjectResourceException InvalidInputObjectResource InvalidArgument "InputObject" -TargetType 'PSObject' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + [void]$_Query.Add(("resourceUri:'{0}'" -f $InputObject.serverHardwareUri)) + + } + + default + { + + $ExceptionMessage = 'The provided object {0} is not supported. Only Server Hardware, Server Profile and Enclosure are supported resources.' -f $InputObject.name + $ErrorRecord = New-ErrorRecord HPEOneView.InputObjectResourceException InvalidInputObjectResource InvalidArgument "InputObject" -TargetType 'PSObject' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + # Generate error if ApplianceConnection properties do not match + if ($InputObject -and $InputObject.ApplianceConnection.Name -ne $ApplianceConnection.Name) + { + + $ExceptionMessage = "The provided input object '{0}' 'ApplianceConnection' NoteProperty ({1}) does notmatch the Appliance Connection." -f $InputObject.ApplianceConnection, $ApplianceConnection + $ErrorRecord = New-ErrorRecord HPEOneView.InputObjectResourceException ApplianceConnetionDoesNotMatchObject InvalidArgument 'InputObject' -TargetType 'PSObject' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + if ($PSBoundParameters['Count']) + { + + $_uri = "{0}&count={1}" -f $_uri, $Count + + } + + # Needs to be a filter statement in URI. NEED TO ADD TO GET-OVALERT FOR ITS TIMESPAN PARAMETER + if ($TimeSpan) + { + + $_uri = '{0}&filter="created > {1}"' -f $_uri, ([DateTime]::Now - $timespan).ToString("yyyy-MM-ddTHH:mm:ss:ff.fffZ") + + } + + elseif ($Start) + { + + $_uri = '{0}&filter="created > {1}"&filter="created < {2}"' -f $_uri, $Start.ToString("yyyy-MM-ddTHH:mm:ss:ff.fffZ"), $End.ToString("yyyy-MM-ddTHH:mm:ss:ff.fffZ") + + } + + if ($PSBoundParameters['State']) + { + + [void]$_Query.Add(("remoteSupportState:{0}" -f $State)) + + } + + $_uri = '{0}&query="{1}"' -f $_uri, [String]::Join(' AND ',$_Query.ToArray()) + + "[{0}] URI: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_uri | Write-Verbose + + ForEach ($_appliance in $ApplianceConnection) + { + + "[{0}] Processing '{1}' Appliance (of {2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name, $ApplianceConnection.Count | Write-Verbose + + # Check if the appliance has remote support enabled. Exception if not. + $_RemoteSupportStatus = $null + + "[{0}] Validate Remote Support is configured on the appliance." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $_RemoteSupportStatus = Send-OVRequest -Uri $RemoteSupportConfigUri -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if (-not $_RemoteSupportStatus.enableRemoteSupport) + { + + "[{0}] Remote Support is not enabled and configured on the appliance. Generate non-terminating error." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $ExceptionMessage = 'Remote Support is not configured on the appliance, {0}. In order to set the Remote Support location for the DataCenter, Remote SUpport must be enabledon the appliance. Either enable Remote Support or do not attempt to set the Data Center location until Remote Support has been anabled on the appliance.' -f $ApplianceConnection.Name + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.RemoteSupportException RemoteSupportNotEnabled InvalidOperation 'ApplianceConnect' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Try + { + + $_ResourceAlerts = Get-AllIndexResources -Uri $_uri -ApplianceConnection $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + ForEach ($_alert in $_ResourceAlerts) + { + + # Get resource serial number to add to object + Try + { + + $_associatedresource = Send-OVRequest -Uri $_alert.associatedResource.resourceUri -Hostname $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + [HPEOneView.Appliance.ServiceAlert]::new($_alert.serviceEventDetails.caseID, + $_alert.associatedResource.resourceName, + $_associatedresource.serialNumber, + $_alert.serviceEventDetails.remoteSupportState, + $_alert.description, + $_alert.correctiveAction, + $_alert.created, + $_alert.modified, + $_alert.resourceUri, + $_alert.uri, + $_alert.ApplianceConnection) + + } + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function ValidateRemoteSupport +{ + + [CmdletBinding (DefaultParameterSetName = "Default")] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = "Default")] + [ValidateNotNullOrEmpty()] + [Object]$InputObject, + + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = "Default")] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = $InputObject.ApplianceConnection + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + } + + Process + { + + "[{0}] Resource name: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject.name | Write-Verbose + "[{0}] Resource uri: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject.uri | Write-Verbose + "[{0}] Resource supportState: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject.supportState | Write-Verbose + + if ($InputObject.supportState -eq 'Enabled') + { + + return $true + + } + + else + { + + return $false + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + } +} + +Function Get-OVServerProfileMessage +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "Default")] + [Obsolete()] + Param + ( + + [Parameter (Mandatory = $False, ValueFromPipeline, ParameterSetName = "Default")] + [ValidateNotNullOrEmpty()] + [Alias ('ServerProfile')] + [Object]$InputObject, + + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = "Default")] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Throw "This Cmdlet is no longer supported and implemented. Please use Get-OVTask to get server profile tasks and associated messages." + +} + +function Set-OVAlert +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = 'Default')] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = 'Default')] + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = 'Cleared')] + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = 'Active')] + [ValidateNotNullOrEmpty()] + [Alias ('alertUri','Alert')] + [Object]$InputObject, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [String]$AssignToUser, + + [Parameter (Mandatory = $false, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [String]$Notes, + + [Parameter (Mandatory, ParameterSetName = 'Cleared')] + [Switch]$Cleared, + + [Parameter (Mandatory, ParameterSetName = 'Active')] + [Switch]$Active, + + [Parameter (Mandatory = $False, ValueFromPipelineByPropertyName, ParameterSetName = 'Default')] + [Parameter (Mandatory = $False, ValueFromPipelineByPropertyName, ParameterSetName = 'Cleared')] + [Parameter (Mandatory = $False, ValueFromPipelineByPropertyName, ParameterSetName = 'Active')] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not($PSBoundParameters['InputObject'])) + { + + "[{0}] Alert Object via pipeline" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $Pipelineinput = $True + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command agian." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + } + + Process + { + + # Validate input object is correct + if ($InputObject.category -ne $ResourceCategoryEnum.Alert) + { + + $ErrorRecord = New-ErrorRecord InvalidOperationException InvalidAlertObject InvalidArgument 'InputObject' -TargetType $InputObject.GetType().Name -Message 'The Alert Parameter value is not a PSCustomObject or contains a valid resource category. Please check the value and try again.' + $PSCmdlet.WriteError($ErrorRecord) + + } + + else + { + + $_AlertUpdateObject = NewObject -UpdateAlert + + if (-not $PSBoundParameters['Notes']) + { + + $_AlertUpdateObject.notes = 'Updated alert with: {0}' -f (($PSBoundParameters.Keys | Where-Object { 'Cleared','Active','AssignToUser' -contains $_ } | ForEach-Object { "{0} ({1})" -f $_,$PSBoundParameters[$_] } )-Join ", ") + + } + + switch ($PSBoundParameters.keys) + { + + 'Cleared' + { + + $_AlertUpdateObject.alertState = 'Cleared' + + } + + 'Active' + { + + $_AlertUpdateObject.alertState = 'Active' + + } + + 'AssignToUser' + { + + $_AlertUpdateObject.assignedToUser = $AssignToUser + + } + + 'Notes' + { + + $_AlertUpdateObject.notes = $Notes + + } + + } + + if ((-not $PSboundParameters['Cleared']) -and (-not $PSboundParameters['Active'])) + { + + $_AlertUpdateObject.alertState = $InputObject.alertState + + } + + if (-not($InputObject.ApplianceConnection.Name) -and -not($ApplianceConnection)) + { + + $ErrorRecord = New-ErrorRecord InvalidOperationException InvalidAlertObject InvalidArgument 'InputObject' -TargetType $InputObject.GetType().Name -Message 'The Alert Parameter value does not contain a valid ApplianceConnection property. Please check the value and try again.' + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + $_Uri = $InputObject.Uri.ToString() + + if ($InputObject.alertState -eq 'Locked' -and ($PSboundParameters['Cleared'] -or $PSboundParameters['Active'])) + { + + "[{0}] Locked alert state being changed." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_Uri += "?force=true" + + } + + Try + { + + if ($InputObject.eTag) + { + + $_AlertUpdateObject.eTag = $InputObject.eTag + + } + + $_resp = Send-OVRequest -Uri $_Uri -Method PUT -Body $_AlertUpdateObject -Hostname $ApplianceConnection.Name + + $_resp.PSObject.TypeNames.Insert(0,"HPEOneView.Alert") + + $_resp + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Clear-OVAlert +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding ()] + Param + () + + Write-Warning 'This CMDLET is deprecated. Please use Set-OVAlert.' + +} + +function Remove-OVAlert +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "Default", SupportsShouldProcess, ConfirmImpact = 'High')] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [Object]$InputObject, + + [Parameter (Mandatory = $False, ParameterSetName = 'Default')] + [Switch]$Force, + [Parameter (Mandatory = $False, ValueFromPipelineByPropertyName, ParameterSetName = 'Default')] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not($PSBoundParameters['InputObject'])) + { + + + $Pipelineinput = $True + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command agian." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + + } + + Process + { + + # Validate input object is correct + if ($InputObject.category -ne $ResourceCategoryEnum.Alert) + { + + $ErrorRecord = New-ErrorRecord InvalidOperationException InvalidAlertObject InvalidArgument 'InputObject' -TargetType $InputObject.GetType().Name -Message 'The Alert Parameter value is not a PSCustomObject or contains a valid resource category. Please check the value and try again.' + $PSCmdlet.WriteError($ErrorRecord) + + } + + else + { + + $RemoveMessage = "remove '{0}' alert" -f $InputObject.description + + if ($PSCmdlet.ShouldProcess($InputObject.ApplianceConnection.Name, $RemoveMessage)) + { + + "[{0}] Removing alert: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), ($InputObject | Out-String) | Write-Verbose + "[{0}] URI: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject.uri | Write-Verbose + + $_Uri = '{0}' -f $InputObject.uri + + if ($Force) + { + + $_Uri += '?force=true' + + } + + try + { + + Send-OVRequest -Uri $_Uri -Method DELETE -Hostname $InputObject.ApplianceConnection -AddHeader @{'If-Match' = $InputObject.eTag } + + } + + catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + elseif ($PSBoundParameters['whatif']) + { + + "[{0}] -WhatIf was passed" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Get-OVLicense +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "Default")] + Param + ( + + [Parameter (Mandatory = $False, ParameterSetName = "Default")] + [ValidateSet ("OneViewAdvanced", "OneView", "OneViewAdvancedNoiLO", "OneViewNoiLO","all")] + [String]$Type, + + [Parameter (Mandatory = $False, ParameterSetName = "Default")] + [ValidateSet ("Unlicensed", "Permanent",$null)] + [String]$State, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Switch]$Summary, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Switch]$Report, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command agian." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $_LicenseResources = [System.Collections.ArrayList]::new() + + [String]$filter = $null + + If ($PSboundParameters['Type']) + { + + "[{0}] License Type: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Type | Write-Verbose + + switch ($Type) + { + + # User wants the HPE OneView License report + {[RegEx]::Match($_, "OneView","OneViewAdvanced", $RegExInsensitiveFlag).Success} + { + + $filter += "?filter=`"product='HP OneView Advanced'`"" + + } + + # User wants the HPE OneView without iLO License Report + {[RegEx]::Match($_, "OneViewNoiLO","OneViewAdvancedNoiLO", $RegExInsensitiveFlag).Success} + { + + $filter += "?filter=`"product='HP OneView Advanced w/o iLO'`"" + + } + + } + + } + + If ($PSboundParameters['State']) + { + + "[{0}] License State: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $State | Write-Verbose + + # Check to see if the license type/product was specified, as we would have an existing filter value + If ($filter) + { + + $filter += "&filter=`"licenseType='$State'`"" + + } + ElseIf (-not($filter)) + { + + $filter += "?filter=`"licenseType='$State'`"" + + } + + } + + ElseIf (-not($PSboundParameters['State'])) + { + + "[{0}] No license state provided ({1})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $State | Write-Verbose + + } + + If ($PSboundParameters['Report']) + { + + "[{0}] Parameter is being deprecated." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Write-Warning "The -Report parameter is being deprecated. Node information is contained within the .Nodes property of the returned object." + + } + + elseif ($PSboundParameters['Summary']) + { + + "[{0}] Generating Summary Report" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + # Check to see if the license type/product was specified, as we would have an existing filter value + If ($filter) + { + + $disSummary = "&view=summary" + + } + ElseIf (-not($filter)) + { + + $disSummary = "?view=summary" + + } + + } + + } + + Process + { + + ForEach ($_appliance in $ApplianceConnection) + { + + "[{0}] Processing '{1}' Appliance (of {2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name, $ApplianceConnection.Count | Write-Verbose + + Try + { + + # Send the request + $_Uri = "{0}{1}{2}" -f $ApplianceLicensePoolUri, $Filter, $disSummary + $_LicenseCol = Send-OVRequest -Uri $_Uri -Hostname $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + ForEach ($_license in $_LicenseCol.members) + { + + $_Nodes = [System.Collections.Generic.List[HPEOneView.Appliance.LicensedNode]]::new() + # $_UnlicensedNodes = [System.Collections.Generic.List[HPEOneView.Appliance.UnlicensedNode]]::new() + $_AdditionalKeys = [System.Collections.Generic.List[String]]::new() + + ForEach ($_node in $_license.nodes) + { + + "[{0}] Adding '{1}' to '{2}' license pool collection." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_node.nodeName, $_license.product | Write-Verbose + + $_LicensedNode = [HPEOneView.Appliance.LicensedNode]::new($_node.nodeName, + $_node.nodeId, + $_node.appliedDate, + $_node.nodeUri) + + [void]$_Nodes.Add($_LicensedNode) + + } + + if ($_license.additionalKeys.Count -gt 0) + { + + $_license.additionalKeys | ForEach-Object { [void]$_AdditionalKeys.Add($_) } + + } + + "[{0}] Creating '{1} ({2})' license pool object." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_license.product, $_license.licenseType | Write-Verbose + + [HPEOneView.Appliance.License]::new($_license.product, + $_license.licenseType, + $_license.productDescription, + $_license.eon, + $_license.salesOrder, + $_license.availableCapacity, + $_license.totalCapacity, + $_license.key, + $_license.uri, + $_Nodes, + $_AdditionalKeys, + $_license.created, + $_license.ApplianceConnection) + + } + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function New-OVLicense +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "licenseKey")] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = "licenseKey")] + [ValidateNotNullOrEmpty()] + [String]$LicenseKey, + + [Parameter (Mandatory, ParameterSetName = "InputFile")] + [ValidateScript({Test-Path $_})] + [String]$File, + + [Parameter (Mandatory = $false, ParameterSetName = "licenseKey")] + [Parameter (Mandatory = $false, ParameterSetName = "InputFile")] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command agian." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $_LicenseResponseCollection = [System.Collections.ArrayList]::new() + + if ($file) + { + + [Array]$LicenseKey = Get-Content $file + + } + + } + + Process + { + + # Loop through all keys, and add one by one. + foreach ($_lk in ($LicenseKey | Where-Object { -not $_.startswith("#") })) + { + + "[{0}] Processing LicenseKey: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_lk | Write-Verbose + + $_FilterDelegate = [Func[object,bool]]{ param ($l) return $_lk.Contains($l) } + + if ($_FoundFioSku = [Linq.Enumerable]::ToArray([System.Linq.Enumerable]::Where($OneViewFIOLicenseSKUs, $_FilterDelegate))) + { + + $ExcpetionMessage = "The provided license key SKU {0}, starting with '{1}', is an FIO (Factory Integrated Option). This key is not supported being added directly to an HPE OneView appliance. Please add the server hardware that contains the embedded FIO license key to the appliance for automatic processing of the key." -f $_FoundFioSku, $_lk.Substring(0, 20) + $ErrorRecord = New-ErrorRecord HPEOneView.Appliance.LicenseKeyException UnsupportedForAPILicenseKeySku InvalidOperation 'LicenseKey' -Message $ExcpetionMessage + $PSCmdlet.WriteError($ErrorRecord) + + } + + else + { + + $_key = NewObject -LicenseKey + $_key.key = '{0}' -f $_lk + + Try + { + + $_ret = Send-OVRequest -Uri $ApplianceLicensePoolUri -Method POST -Body $_key -Hostname $ApplianceConnection + + } + + Catch + { + + $_Exception = $_ + + Switch ($_.FullyQualifiedErrorId) + { + + "LICENSE_ALREADY_EXISTS" + { + + $ErrorRecord = New-ErrorRecord HPEOneView.Appliance.LicenseKeyException LicenseKeyAlreadyExists ResourceExists 'LicenseKey' -Message "The license key provided already exists on the appliance. Please correct the value, and try again." + + } + + "ADD_LICENSE_FAILED" + { + + $ErrorRecord = New-ErrorRecord HPEOneView.Appliance.LicenseKeyException InstallLicenseFailure InvalidResult 'LicenseKey' -Message $_Exception.Message + + } + + default + { + + $ErrorRecord = New-ErrorRecord HPEOneView.Appliance.LicenseKeyException InvalidResult InvalidResult 'LicenseKey' -Message $_Exception.Exception.Message + + } + + } + + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + $_AdditionalKeys = [System.Collections.Generic.List[String]]::new() + + if ($_ret.additionalKeys.Count -gt 0) + { + + $_ret.additionalKeys | ForEach-Object { [void]$_AdditionalKeys.Add($_) } + + } + + [HPEOneView.Appliance.License]::new($_ret.product, + $_ret.licenseType, + $_ret.productDescription, + $_ret.eon, + $_ret.salesOrder, + $_ret.availableCapacity, + $_ret.totalCapacity, + $_ret.key, + $_ret.uri, + $null, + $_AdditionalKeys, + $_ret.created, + $_ret.ApplianceConnection) + + } + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Remove-OVLicense +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "Default", SupportsShouldProcess, ConfirmImpact = 'High')] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = "Default")] + [ValidateNotNullOrEmpty()] + [Alias ('uri', 'name', 'license','Resource')] + [HPEOneView.Appliance.License]$InputObject, + + [Parameter (Mandatory, ValueFromPipelineByPropertyName, ParameterSetName = "Default")] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not($PSBoundParameters['Resource'])) + { + + $PipelineInput = $True + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command agian." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + $_ResponseCollection = [System.Collections.ArrayList]::new() + $_LicenseCollection = [System.Collections.ArrayList]::new() + + } + + Process + { + + if ($PipelineInput) + { + + "[{0}] Processing Pipeline input" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + if ($null -ne $InputObject) + { + + if ($InputObject -is [HPEOneView.Appliance.License]) + { + + if (-not $InputObject.ApplianceConnection) + { + + $ExceptionMessage = "The License resource provided is missing the source ApplianceConnection property. Please check the object provided and try again." + $ErrorRecord = New-ErrorRecord InvalidOperationException InvalidArgumentValue InvalidArgument "InputObject" -TargetType PSObject -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + if ($PSCmdlet.ShouldProcess($InputObject.product, ("remove license from appliance {0}" -f $InputObject.ApplianceConnection))) + { + + "[{0}] Removing License '{1}' [{2}]; URI: {3}." -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject.Product, $InputObject.Description, $InputObject.Uri | Write-Verbose + + try + { + + Send-OVRequest -Uri $InputObject.uri -Method DELETE -Hostname $InputObject.ApplianceConnection -AddHeader @{'If-Match' = $InputObject.eTag } + + } + + catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + elseif ($PSBoundParameters['whatif']) + { + + "[{0}] User provided -WhatIf parameter." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + else + { + + "[{0}] User cancelled." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + } + + else + { + + $ExceptionMessage = "The License resource is not an expected category type [{0}]. Allowed resource category types is '[HPEOneView.Library.License'. Please check the object provided and try again." -f $InputObject.Getype().FullName + $ErrorRecord = New-ErrorRecord InvalidOperationException InvalidArgumentValue InvalidArgument "InputObject" -TargetType PSObject -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Set-OVSmtpConfig +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "Default")] + Param + ( + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [ValidateNotNullOrEmpty()] + [validatescript({if ($_ -as [Net.Mail.MailAddress]) {$true} else { Throw "The Parameter value is not an email address. Please correct the value and try again." }})] + [System.String]$SenderEmailAddress, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Alias ('SmtpServer')] + [ValidateNotNullOrEmpty()] + [System.String]$Server, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Alias ('SmtpPort')] + [ValidateNotNull()] + [System.Int32]$Port, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [ValidateSet ('None', 'TLS', 'StartTls')] + [String]$ConnectionSecurity = 'None', + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [ValidateNotNullOrEmpty()] + [Object]$Password, + + [Parameter (Mandatory, ParameterSetName = "Disabled")] + [Switch]$AlertEmailDisabled, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Switch]$AlertEmailEnabled, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Switch]$UseMXRecordLookup, + + [Parameter (Mandatory = $False, ParameterSetName = "Default")] + [Parameter (Mandatory = $False, ParameterSetName = "Disabled")] + [Switch]$Async, + + [Parameter (Mandatory = $False, ParameterSetName = "Default")] + [Parameter (Mandatory = $False, ParameterSetName = "Disabled")] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneView.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command agian." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneView.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneView.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $_ResponseCollection = [System.Collections.ArrayList]::new() + + } + + Process + { + + ForEach ($_appliance in $ApplianceConnection) + { + + "[{0}] Processing '{1}' Appliance (of {2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name, $ApplianceConnection.Count | Write-Verbose + + # Get email alert configuration from the appliance + Try + { + + $_SmtpConfig = Send-OVRequest -Uri $SmtpConfigUri -Hostname $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + # Change the authentication password + if ($PSBoundParameters['Password']) + { + + if ($Password -is [SecureString]) + { + + $_DecryptPassword = [Runtime.InteropServices.Marshal]::PtrToStringBSTR([Runtime.InteropServices.Marshal]::SecureStringToBSTR($Password)) + + } + + else + { + + $_DecryptPassword = $Password + + } + + $_SmtpConfig.password = $_DecryptPassword + + } + + if (-not $UseMXRecordLookup.IsPresent) + { + + # Change the server address + if ($PSBoundParameters['Server']) + { + + "[{0}] Configuring SMTP Server: {1}." -f $MyInvocation.InvocationName.ToString().ToUpper(), $Server | Write-Verbose + + $_SmtpConfig.smtpServer = $Server + + } + + # Change the server TCP port + if ($PSBoundParameters['Port']) + { + + "[{0}] Configuring SMTP TCP Port: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Port | Write-Verbose + + $_SmtpConfig.smtpPort = $Port + + if (-not $PSBoundParameters['Server'] -and [String]::IsNullOrEmpty($_SmtpConfig.smtpServer) -and -not $PSBoundParameters['SenderEmailAddress']) + { + + $ExceptionMessage = "When specifying an SMTP Server Port value, the -Server parameter or an existing SMTP Server value must be present on the appliance." + + $ErrorRecord = New-ErrorRecord HPEOneView.Appliance.EmailAlertResourceException InvalidSmtpServer InvalidArgument "Port" -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + elseif (-not $PSBoundParameters['Port'] -and ([String]::IsNullOrEmpty($_SmtpConfig.smtpPort) -or $_SmtpConfig.smtpPort -eq 0)) + { + + "[{0}] SMTP port not provided, defaulting to '25'" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_SmtpConfig.smtpPort = 25 + + } + + } + + else + { + + "[{0}] Will set email alert configuration to use MX DNS record lookup based on the appliance sender email address." -f $MyInvocation.InvocationName.ToString().ToUpper(), $Port | Write-Verbose + $_SmtpConfig.smtpServer = $null + $_SmtpConfig.smtpPort = $null + + } + + # Change connection security + if ($PSBoundParameters['ConnectionSecurity']) + { + + $_SmtpConfig.smtpProtocol = $SmtpConnectionSecurityEnum[$ConnectionSecurity] + + } + + # Enable or disable email alert filtering + $_SmtpConfig.alertEmailDisabled = if ($alertEmailDisabled.IsPresent) { $True } + elseif ($alertEmailEnabled.IsPresent) { $False } + else { $False } + + if ($PSBoundParameters['AlertEmailEnabled'] -and -not $PSBoundParameters['SenderEmailAddress'] -and [String]::IsNullOrEmpty($_SmtpConfig.senderEmailAddress)) + { + + $ExceptionMessage = 'The -AlertEmailEnabled Parameter requires the -SenderEmailAddress Parameter to be provided when the appliance is first configured.' + $ErrorRecord = New-ErrorRecord HPEOneView.Appliance.EmailAlertResourceException InvalidArgumentValue InvalidArgument 'AlertEmailEnabled' -TargetType 'SwitchParameter' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif (-not $PSBoundParameters['Server'] -and -not $PSBoundParameters['SenderEmailAddress'] -and [String]::IsNullOrEmpty($_SmtpConfig.senderEmailAddress)) + { + + $ExceptionMessage = 'The -SenderEmailAddress parameter must be provided when not including the -Server parameter.' + $ErrorRecord = New-ErrorRecord HPEOneView.Appliance.EmailAlertResourceException InvalidArgumentValue InvalidArgument 'Server' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($PSBoundParameters['SenderEmailAddress']) + { + + $_SmtpConfig.senderEmailAddress = $SenderEmailAddress + + } + + $_SmtpConfig = $_SmtpConfig | Select * -Exclude uri, eTag, created, modified + + if ($_smtpconfig.alertEmailFilters.Count -eq 0) + { + + $_SmtpConfig = $_SmtpConfig | Select * -Exclude alertEmailFilters + + } + + Try + { + + $_resp = Send-OVRequest -Uri $SmtpConfigUri -Method POST -Body $_SmtpConfig -Hostname $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if ($PSBoundParameters['Async']) + { + + $_resp + + } + + else + { + + $_resp | Wait-OVTaskComplete + + } + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Test-OVEmailAlert +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding ()] + Param + ( + + [Parameter (Mandatory)] + [ValidateNotNullOrEmpty()] + [Array]$Recipients, + + [Parameter (Mandatory = $false)] + [ValidateNotNullOrEmpty()] + [String]$Subject = 'This is a test message.', + + [Parameter (Mandatory = $false)] + [ValidateNotNullOrEmpty()] + [String]$Body = 'Test email message from HPE OneView appliance.', + + [Parameter (Mandatory = $false)] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command agian." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $_SMTPConfigCollection = [System.Collections.ArrayList]::new() + + } + + Process + { + + $_EmailTest = NewObject -TestSmtpConfig + + # Add recipients to property + ForEach ($_recipient in $Recipients) + { + + # Validate recipient is a valid Email Address + if (-not $_recipient -as [Net.Mail.MailAddress]) + { + + $ExceptionMessage = 'The provided recipient email address {0} is invalid.' -f $_recipient + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.EmailAlertResourceException InvalidEmailAddress InvalidArgument "Recipients" -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + [void]$_EmailTest.toAddress.Add($_recipient) + + } + + if ([Regex]::Match($Body,$HtmlPattern).Success) + { + + $_EmailTest.htmlMessageBody = $Body + + } + + else + { + + $_EmailTest.textMessageBody = $Body + + } + + $_EmailTest.subject = $Subject + + ForEach ($_appliance in $ApplianceConnection) + { + + "[{0}] Processing '{1}' Appliance (of {2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name, $ApplianceConnection.Count | Write-Verbose + + Try + { + + $null = Send-OVRequest -Uri $TestNotificationUri -Method POST -Body $_EmailTest -Hostname $_appliance + + } + + catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + # Add properties + $_EmailTest | Add-Member -NotePropertyName category -NotePropertyValue appliance + $_EmailTest | Add-Member -NotePropertyName uri -NotePropertyValue $TestNotificationUri + $_EmailTest | Add-Member -NotePropertyName ccAddress -NotePropertyValue @() + $_EmailTest | Add-Member -NotePropertyName bccAddress -NotePropertyValue @() + $_EmailTest | Add-Member -NotePropertyName eTag -NotePropertyValue $null + $_EmailTest | Add-Member -NotePropertyName created -NotePropertyValue $null + $_EmailTest | Add-Member -NotePropertyName modified -NotePropertyValue $null + $_EmailTest | Add-Member -NotePropertyName ApplianceConnection -NotePropertyValue ([HPEOneView.Library.ApplianceConnection]::new($_appliance.Name, $_appliance.ID)) + $_EmailTest + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Get-OVSMTPConfig +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding ()] + Param + ( + + [Parameter (Mandatory = $false)] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command agian." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $_SMTPConfigCollection = [System.Collections.ArrayList]::new() + + } + + Process + { + + ForEach ($_appliance in $ApplianceConnection) + { + + "[{0}] Processing '{1}' Appliance (of {2})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name, $ApplianceConnection.Count | Write-Verbose + + Try + { + + $currentSmtpConfig = Send-OVRequest -Uri $SmtpConfigUri -Hostname $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $currentSmtpConfig | ForEach-Object { + + $_.PSObject.TypeNames.Insert(0,"HPEOneview.Appliance.SmtpConfiguration") + + [void]$_SMTPConfigCollection.Add($_) + + } + + } + + } + + End + { + + Return $_SMTPConfigCollection + + } + +} + +function Add-OVSmtpAlertEmailFilter +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "Default")] + Param + ( + + [Parameter (Mandatory, ParameterSetName = "RemoteSupportFilter")] + [Switch]$RemoteSupportFilter, + + [Parameter (Mandatory, ParameterSetName = "Default")] + [ValidateNotNullOrEmpty()] + [System.String]$Name, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Alias ('query')] + [ValidateNotNullOrEmpty()] + [System.String]$Filter, + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = "Default")] + [Alias ('recipients')] + [validatescript({$_ | ForEach-Object { if ($_ -as [Net.Mail.MailAddress]) {$true} else { Throw "The Parameter value '$_' is not an email address. Please correct the value and try again." }}})] + [Net.Mail.MailAddress[]]$Emails, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [validatescript({if ($_ -as [Net.Mail.MailAddress]) {$true} else { Throw "The Parameter value '$_' is not an email address. Please correct the value and try again." }})] + [Net.Mail.MailAddress]$SenderEmail, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [ValidateNotNullOrEmpty()] + [SecureString]$SenderEmailPassword, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [HPEOneView.Appliance.ScopeCollection[]]$Scope, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [ValidateSet ('AND','OR')] + [System.String]$ScopeMatchPreference = 'OR', + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Parameter (Mandatory = $false, ParameterSetName = "RemoteSupportFilter")] + [Switch]$Async, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Parameter (Mandatory = $false, ParameterSetName = "RemoteSupportFilter")] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command agian." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $colStatus = [System.Collections.ArrayList]::new() + + if (-not($PSBoundParameters['Filter'])) + { + + Write-Warning 'The Filter provided is Null or Empty. This will return all resources and severities, which will cause performance issues in a large environment.' + + } + + # This is needed as the scopeQuery property cannot be null + if (-not $PSBoundParameters['Scope']) + { + + [String]$Scope = "" + + } + + else + { + + $_ScopeEntries = [System.Collections.ArrayList]::new() + + ForEach ($_entry in $Scope) + { + + if (-not $_entry.StartsWith("scope:'")) + { + + $_entry = "scope:'{0}'" -f $_entry + + } + + [void]$_ScopeEntries.Add($_entry) + + } + + [String]$Scope = [System.String]::Join(" $ScopeMatchPreference ",$_ScopeEntries.ToArray()) + + } + + } + + Process + { + + ForEach ($_appliance in $ApplianceConnection) + { + + $_resp = $null + + if ($PSBoundParameters['RemoteSupportFilter']) + { + + "[{0}] Getting current remote support configuration from '{1}'." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance | Write-Verbose + + Try + { + + $_remoteSupportConfig = Send-OVRequest -Uri $RemoteSupportConfigUri -Hostname $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if (-not $_remoteSupportConfig.enableEmailNotification) + { + + $_remoteSupportConfig.enableEmailNotification = $true + + "[{0}] Enabling remote support email filter." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $_resp = Send-OVRequest -Uri $RemoteSupportConfigUri -Method PUT -Body $_remoteSupportConfig -Hostname $_appliance.Name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + else + { + + "[{0}] Remote support email filter already configured." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + } + + else + { + + "[{0}] Getting current SMTP Configuration from '$($_appliance.Name)'." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $_smtpFilterConfiguration = Send-OVRequest $SmtpConfigUri -Hostname $_appliance.Name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $_OriginalFilterConfig = $_smtpFilterConfiguration.alertEmailFilters + + # Rebuild property as ArrayList + $_smtpFilterConfiguration.alertEmailFilters = [System.Collections.ArrayList]::new() + + $_OriginalFilterConfig | ForEach-Object { + + [void]$_smtpFilterConfiguration.alertEmailFilters.Add($_) + + } + + # Create new alert filter object + $_alertFilter = NewObject -AlertFilter + + $_alertFilter.filter = $filter + $_alertFilter.displayFilter = $filter + $_alertFilter.userQueryFilter = $filter + + ForEach ($_email in $Emails) + { + + [void]$_alertFilter.emails.Add($_email.ToString()) + + } + + $_alertFilter.scopeQuery = $Scope + $_alertFilter.filterName = $Name + + if ($PSBoundParameters['SenderEmail']) + { + + $_alertFilter.customEmailSenderEnabled = $true + $_alertFilter.customSenderEmailAddress = $SenderEmail + + if ($PSBoundParameters['SenderEmailPassword']) + { + + $_alertFilter.customSenderPassword = [Runtime.InteropServices.Marshal]::PtrToStringBSTR([Runtime.InteropServices.Marshal]::SecureStringToBSTR($SenderEmailPassword)) + + } + + } + + "[{0}] Processing SMTP Alert Configuration for '$($_appliance.Name)'." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + [void]$_smtpFilterConfiguration.alertEmailFilters.Add($_alertFilter) + + Try + { + + $_resp = Send-OVRequest -Uri $SmtpConfigUri -Method POST -Body $_smtpFilterConfiguration -Hostname $_appliance.Name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + if ($null -ne $_resp) + { + + if ($PSBoundParameters['Async']) + { + + $_resp + + } + + else + { + + $_resp | Wait-OVTaskComplete + + } + + } + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Get-OVSmtpAlertEmailFilter +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "Default")] + # [OutputType ([HPEOneView.Appliance.AlertEmailFilter])] + Param + ( + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [ValidateNotNullOrEmpty()] + [String]$Name, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $_ColStatus = [System.Collections.ArrayList]::new() + + } + + Process + { + ForEach ($_appliance in $ApplianceConnection) + { + + # Get Smtp config from appliance, then filter alertEmailFilters for filterName if -Name is provided + Try + { + + $_CurrentSmtpConfig = Send-OVRequest -Uri $SmtpConfigUri -Hostname $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $_EmailFilters = $_CurrentSmtpConfig.alertEmailFilters + + # Need to get the current status of OVRS email filter config + Try + { + + $_OVRSConfig = Send-OVRequest -Uri $RemoteSupportConfigUri -Hostname $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if ($_OVRSConfig.enableRemoteSupport) + { + + $_OVRSEmailFilterStatus = [PSCustomObject]@{ + emails = @(); + filter = @(); + userQueryFilter = $null; + displayFilter = $null; + limit = 0; + limitDuration = $null; + disabled = -not $_OVRSConfig.enableEmailNotification; + scopeQuery = $null; + filterName = "Remote Support" + } + + $_EmailFilters += $_OVRSEmailFilterStatus + + } + + if ($PSBoundParameters['Name']) + { + + $_EmailFilters = $_EmailFilters | Where-Object { $_.filterName -eq $Name } + + } + + ForEach ($_filter in $_EmailFilters) + { + + $_filter.PSObject.TypeNames.Insert(0, 'HPEOneView.Appliance.AlertEmailFilter') + + $_filter | Add-Member -NotePropertyName ApplianceConnection -NotePropertyValue ([HPEOneView.Library.ApplianceConnection]::new($_appliance.name, $_appliance.ConnectionId)) + + } + + $_EmailFilters + + } + + } + + End + { + + "[{0}] Done. " -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Set-OVSmtpAlertEmailFilter +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "Default")] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = "Default")] + [ValidateNotNullOrEmpty()] + [Object]$InputObject, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [ValidateNotNullOrEmpty()] + [System.String]$Name, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Bool]$Disable, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Alias ('query')] + [System.String]$Filter, + + [Parameter (Mandatory = $false, ValueFromPipeline, ParameterSetName = "Default")] + [Alias ('recipients')] + [ValidateScript({$_ | ForEach-Object { if ($_ -as [Net.Mail.MailAddress]) {$true} else { Throw "The Parameter value '$_' is not an email address. Please correct the value and try again." }}})] + [Net.Mail.MailAddress[]]$Emails, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Bool]$EnableSenderEmailAddress, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [validatescript({if ($_ -as [Net.Mail.MailAddress]) {$true} else { Throw "The Parameter value '$_' is not an email address. Please correct the value and try again." }})] + [Net.Mail.MailAddress]$SenderEmail, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [ValidateNotNullOrEmpty()] + [SecureString]$SenderEmailPassword, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [HPEOneView.Appliance.ScopeCollection[]]$Scope, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [ValidateSet ('AND','OR')] + [System.String]$ScopeMatchPreference = 'OR', + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Switch]$Async, + + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = "Default")] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command agian." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + Process + { + + $_resp = $null + + if ($InputObject.PSObject.TypeNames -notcontains "HPEOneView.Appliance.AlertEmailFilter") + { + + $ExceptionMessage = 'The "{0}" provided InputObject is not an alert email filter resource.' -$InputObject.name + $ErrorRecord = New-ErrorRecord HPEOneView.InputObjectResourceException InvalidInputObjectResource InvalidArgument "InputObject" -TargetType $InputObject.GetType().Name -Message $ExceptionMessage + + $PSCmdlet.WriteError($ErrorRecord) + + } + + elseif ($InputObject.filterName -eq 'Remote Support') + { + + $ExceptionMessage = 'The provided alert filter applies to Remote Support and cannot be changed. If you wish to disable the email filter, you need to use Remove-OVSmtpAlertEmailFilter Cmdlet.' + $ErrorRecord = New-ErrorRecord HPEOneView.InputObjectResourceException InvalidInputObjectResource InvalidArgument "InputObject" -TargetType $InputObject.GetType().Name -Message $ExceptionMessage + + $PSCmdlet.WriteError($ErrorRecord) + + } + + else + { + + $_AlertFilterToUpdate = $InputObject.PSObject.Copy() + + switch ($PSBoundParameters.Keys) + { + + 'EnableSenderEmailAddress' + { + + if ($EnableSenderEmailAddress -and -not $PSBoundParameters['SenderEmail']) + { + + "[{0}] Enable custom sender email address, but -SenderEmail parameter not provided." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $ExceptionMessage = "Enabling a custom sender email address requires the SenderEmail parameter." + $ErrorRecord = New-ErrorRecord HPEOneView.Library.ParameterValidationException InvalidParameter InvalidOperation 'EnableSenderEmailAddress' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + + } + + # Ensble custom sender email address + elseif ($EnableSenderEmailAddress -and $PSBoundParameters['SenderEmail']) + { + + "[{0}] Enable custom sender email address." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_AlertFilterToUpdate.customEmailSenderEnabled = $true + $_AlertFilterToUpdate.customSenderEmailAddress = $SenderEmail + + if ($PSBoundParameters['SenderEmailPassword']) + { + + "[{0}] Setting custom sender email password." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_AlertFilterToUpdate.customSenderPassword = [Runtime.InteropServices.Marshal]::PtrToStringBSTR([Runtime.InteropServices.Marshal]::SecureStringToBSTR($SenderEmailPassword)) + + } + + } + + # Diasble custom sender email address + else + { + + "[{0}] Disable custom sender email address." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_AlertFilterToUpdate.customEmailSenderEnabled = $false + + } + + } + + 'Disable' + { + + "[{0}] Disable filter." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_AlertFilterToUpdate.disabled = $Disable + + } + + 'Name' + { + + "[{0}] Update filter name to: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Name | Write-Verbose + + $_AlertFilterToUpdate.filterName = $Name + + } + + 'Filter' + { + + "[{0}] Update filter to: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Filter | Write-Verbose + + if ($PSBoundParameters['Filter'] -and [String]::IsNullOrEmpty($Filter)) + { + + Write-Warning 'The Filter provided is Null or Empty. This will return all resources and severities, which will cause performance issues in a large environment.' + + } + + $_AlertFilterToUpdate.filter = $Filter + $_AlertFilterToUpdate.displayFilter = $Filter + + } + + 'Scope' + { + + $_ScopeEntries = [System.Collections.ArrayList]::new() + + ForEach ($_entry in $Scope) + { + + if (-not $_entry.StartsWith("scope:'")) + { + + $_entry = "scope:'{0}'" -f $_entry + + } + + [void]$_ScopeEntries.Add($_entry) + + } + + [String]$_Scope = [System.String]::Join(" $ScopeMatchPreference ",$_ScopeEntries.ToArray()) + + "[{0}] Update scope target(s) to: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_Scope | Write-Verbose + + $_AlertFilterToUpdate.scopeQuery = $_Scope + + } + + 'Emails' + { + + $_e = 1 + + $_AlertFilterToUpdate.emails = [System.Collections.ArrayList]::new() + + ForEach ($_email in $Emails) + { + + "[{0}] Replacing email recipients with [{1}/{2}]: {3}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_e, $Emails.Count, $_email.ToString() | Write-Verbose + + [void]$_AlertFilterToUpdate.emails.Add($_email.ToString()) + + } + + } + + } + + "[{0}] Getting current SMTP Configuration from '{1}'." -f $MyInvocation.InvocationName.ToString().ToUpper(), $ApplianceConnection | Write-Verbose + + Try + { + + $_CurrentSmtpFilterConfiguration = Send-OVRequest -Uri $SmtpConfigUri -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + # Keep all but the original filter + $_OriginalFilterConfig = $_CurrentSmtpFilterConfiguration.alertEmailFilters | Where-Object { $_.filterName -ne $InputObject.filterName } + + # Rebuild property as ArrayList + $_CurrentSmtpFilterConfiguration.alertEmailFilters = [System.Collections.ArrayList]::new() + + ForEach ($_Filter in $_OriginalFilterConfig) + { + + [void]$_CurrentSmtpFilterConfiguration.alertEmailFilters.Add($_Filter) + + } + + # Add the udpated filter to the collection + [void]$_CurrentSmtpFilterConfiguration.alertEmailFilters.Add($_AlertFilterToUpdate) + + Try + { + + $_resp = Send-OVRequest -Uri $SmtpConfigUri -Method POST -Body $_CurrentSmtpFilterConfiguration -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if ($null -ne $_resp) + { + + if ($PSBoundParameters['Async']) + { + + $_resp + + } + + else + { + + $_resp | Wait-OVTaskComplete + + } + + } + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Remove-OVSmtpAlertEmailFilter +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "Default", SupportsShouldProcess, ConfirmImpact = 'High')] + Param + ( + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = "Default")] + [ValidateNotNullOrEmpty()] + [Object]$InputObject, + + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = "Default")] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not($PSBoundParameters['InputObject'])) + { + + $PipelineInput = $True + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command agian." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $_connection -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + } + + Process + { + + ForEach ($_Filter in $InputObject) + { + + Try + { + + $_CurrentSmtpAlertConfig = Send-OVRequest -Uri $SmtpConfigUri -Hostname $_Filter.ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $_ConfirmMessage = "Remove '{0}' email filter from appliance" -f $_Filter.filterName + + if ($PSCmdlet.ShouldProcess($_Filter.ApplianceConnection, $_ConfirmMessage)) + { + + "[{0}] Removing email filter '{1}' from appliance '{2}'." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_Filter.filterName, $_Filter.ApplianceConnection | Write-Verbose + + if ($InputObject.filterName -eq 'Remote Support') + { + + Try + { + + $_OVRSConfig = Send-OVRequest -Uri $RemoteSupportConfigUri -Hostname $_Filter.ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + $_OVRSConfig.enableEmailNotification = $false + + Send-OVRequest -Uri $RemoteSupportConfigUri -Method PUT $_OVRSConfig -Hostname $_Filter.ApplianceConnection | Wait-OVTaskComplete + + } + + else + { + + [Array]$_CurrentSmtpAlertConfig.alertEmailFilters = $_CurrentSmtpAlertConfig.alertEmailFilters | Where-Object { $_.filterName -ne $_Filter.filterName } + + $_CurrentSmtpAlertConfig = $_CurrentSmtpAlertConfig | Select * -Exclude uri, eTag, created, modified + + if ($_CurrentSmtpAlertConfig.alertEmailFilters.Count -eq 0) + { + + $_CurrentSmtpAlertConfig = $_CurrentSmtpAlertConfig | Select * -Exclude alertEmailFilters + + } + + Try + { + + # Update the SMTP email configuration with the new filter settings. + Send-OVRequest -Uri $SmtpConfigUri -Method POST -Body $_CurrentSmtpAlertConfig -Hostname $_Filter.ApplianceConnection | Wait-OVTaskComplete + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + elseif ($PSBoundParameters['WhatIf']) + { + + "[{0}] WhatIf Parameter was passed." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + } + + } + + End + { + + "[{0}] Done. " -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Get-OVLoginMessage +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "Default")] + Param + ( + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $_ColStatus = [System.Collections.ArrayList]::new() + + } + + Process + { + + ForEach ($_appliance in $ApplianceConnection) + { + + "[{0}] Getting current Login Message Configuration from '$($_appliance.Name)'." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $_LoginDomainGlobalSettings = Send-OVRequest -Uri $authnSettingsUri -Hostname $_appliance + + $_LoginMessageObject = [HPEOneView.Appliance.LoginMessage]::new($_LoginDomainGlobalSettings.loginMessage.message, + $_LoginDomainGlobalSettings.loginMessage.acknowledgment, + [HPEOneView.Library.ApplianceConnection]::new($_appliance.name, $_appliance.ConnectionId)) + + $_LoginMessageObject + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + End + { + + "[{0}] Done. " -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Set-OVLoginMessage +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "Default")] + Param + ( + + [Parameter (Mandatory, ParameterSetName = "Default")] + [String]$Message, + + [Parameter (Mandatory = $False, ParameterSetName = "Default")] + [Parameter (Mandatory = $False, ParameterSetName = "ChangeEnablement")] + [Bool]$Acknowledgment = $False, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Parameter (Mandatory = $false, ParameterSetName = "ChangeEnablement")] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command again." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $_ColStatus = [System.Collections.ArrayList]::new() + + } + + Process + { + + ForEach ($_appliance in $ApplianceConnection) + { + + "[{0}] Getting current Login Message Configuration from '$($_appliance.Name)'." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + $_LoginDomainGlobalSettings = Send-OVRequest -Uri $authnSettingsUri -Hostname $_appliance.Name + + if ($PSBoundParameters['Message']) + { + + $_LoginDomainGlobalSettings.loginMessage.message = $Message + + } + + $_LoginDomainGlobalSettings.loginMessage.acknowledgment = [Bool]$Acknowledgment + + "[{0}] Updating Login Message Configuration." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_NewLoginDomainGlobalSettings = Send-OVRequest -Uri $authnSettingsUri -Method PUT -Body $_LoginDomainGlobalSettings -Hostname $_appliance + + $_LoginMessageObject = [HPEOneView.Appliance.LoginMessage]::new($_NewLoginDomainGlobalSettings.loginMessage.message, + $_NewLoginDomainGlobalSettings.loginMessage.acknowledgment, + [HPEOneView.Library.ApplianceConnection]::new($_appliance.name, $_appliance.ConnectionId)) + + $_LoginMessageObject + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + End + { + + "[{0}] Done. " -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Get-OVRemoteSyslog +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "Default")] + Param + ( + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [ValidateNotNullOrEmpty()] + [Alias ('Appliance')] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command agian." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $_ColStatus = [System.Collections.ArrayList]::new() + + } + + Process + { + + ForEach ($_appliance in $ApplianceConnection) + { + + "[{0}] Processing {1} appliance connection." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name | Write-Verbose + + Try + { + + $_RemoteSyslogSettings = Send-OVRequest $RemoteSyslogUri -Hostname $_appliance.Name + + $_RemoteSyslogSettings.PSObject.TypeNames.Insert(0,'HPEOneView.RemoteSyslog') + + [void]$_ColStatus.Add($_RemoteSyslogSettings) + + } + + Catch + { + + $_ColStatus + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + End + { + + Return $_ColStatus + + } + +} + +function Set-OVRemoteSyslog +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "Default")] + Param + ( + + [Parameter (Mandatory, ParameterSetName = "Default")] + [ValidateNotNullorEmpty()] + [Net.IPAddress]$Destination, + + [Parameter (Mandatory = $False, ParameterSetName = "Default")] + [ValidateRange(1,65535)] + [Int]$Port = 514, + + [Parameter (Mandatory = $False, ParameterSetName = "Default")] + [Switch]$SendTestMessage, + + [Parameter (Mandatory = $False, ParameterSetName = "Default")] + [Switch]$Async, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Alias ('Appliance')] + [ValidateNotNullOrEmpty()] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command agian." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $_ColStatus = [System.Collections.ArrayList]::new() + + } + + Process + { + + ForEach ($_appliance in $ApplianceConnection) + { + + "[{0}] Processing {1} appliance connection." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name | Write-Verbose + + $_RemoteSyslogConfig = NewObject -RemoteSyslog + $_RemoteSyslogConfig.enabled = $true + + switch ($PSBoundParameters.Keys) + { + + 'Destination' + { + + "[{0}] Setting RemoteSyslog destination to: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $PSBoundParameters['Destination'] | Write-Verbose + + $_RemoteSyslogConfig.remoteSyslogDestination = $Destination.ToString() + + } + + 'Port' + { + + "[{0}] Setting RemoteSyslog destination TCP Port to: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $PSBoundParameters['Port'] | Write-Verbose + + $_RemoteSyslogConfig.remoteSyslogPort = $Port.ToString() + + } + + 'SendTestMessage' + { + + "[{0}] Will generate a test SysLog entry." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_RemoteSyslogConfig.sendTestLog = $true + + } + + } + + Try + { + + "[{0}] Sending API POST request." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_results = Send-OVRequest $RemoteSyslogUri PUT $_RemoteSyslogConfig -Hostname $_appliance.Name + + } + + Catch + { + + $_ColStatus + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if ($PSBoundParameters['Async']) + { + + $_results + + } + + else + { + + $_results | Wait-OVTaskComplete + + } + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Enable-OVRemoteSyslog +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "Default")] + Param + ( + + [Parameter (Mandatory = $False, ParameterSetName = "Default")] + [Switch]$Async, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Alias ('Appliance')] + [ValidateNotNullOrEmpty()] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command agian." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $_ColStatus = [System.Collections.ArrayList]::new() + + } + + Process + { + + ForEach ($_appliance in $ApplianceConnection) + { + + "[{0}] Processing {1} appliance connection." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name | Write-Verbose + + Try + { + + "[{0}] Getting current settings from the appliance." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_RemoteSyslogSettings = Get-OVRemoteSyslog -ApplianceConnection $_appliance.Name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if ($_RemoteSyslogSettings.enabled) + { + + "[{0}] SysLog already enabled." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + else + { + + $_RemoteSyslogSettings.enabled = $true + + Try + { + + $_results = Send-OVRequest -Uri $RemoteSyslogUri -Method PUT -Body $_RemoteSyslogSettings -Hostname $_appliance.Name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + if ($PSBoundParameters['Async']) + { + + $_results + + } + + else + { + + $_results | Wait-OVTaskComplete + + } + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Disable-OVRemoteSyslog +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "Default")] + Param + ( + + [Parameter (Mandatory = $False, ParameterSetName = "Default")] + [Switch]$Async, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Alias ('Appliance')] + [ValidateNotNullOrEmpty()] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command agian." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $_ColStatus = [System.Collections.ArrayList]::new() + + } + + Process + { + + ForEach ($_appliance in $ApplianceConnection) + { + + "[{0}] Processing {1} appliance connection." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name | Write-Verbose + + Try + { + + "[{0}] Getting current settings from the appliance." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + $_RemoteSyslogSettings = Get-OVRemoteSyslog -ApplianceConnection $_appliance.Name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if (-not($_RemoteSyslogSettings.enabled)) + { + + "[{0}] SysLog is already disabled." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name | Write-Verbose + + } + + else + { + + $_RemoteSyslogSettings.enabled = $false + + Try + { + + $_results = Send-OVRequest -Uri $RemoteSyslogUri -Method PUT -Body $_RemoteSyslogSettings -Hostname $_appliance.Name + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if ($PSBoundParameters['Async']) + { + + $_results + + } + + else + { + + $_results | Wait-OVTaskComplete + + } + + } + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Get-OVScope +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "Default")] + Param + ( + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [ValidateNotNullorEmpty()] + [SupportsWildcards()] + [String]$Name, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Alias ('Appliance')] + [ValidateNotNullOrEmpty()] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command agian." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + Process + { + + $_uri = $ScopesUri + + if ($PSBoundParameters['Name']) + { + + if ($Name.Contains('*')) + { + + $_uri = "{0}?query=name matches '{1}'" -f $_uri, $Name.Replace('*','%25') + + } + + else + { + + $_uri = "{0}?query=name eq '{1}'" -f $_uri, $Name + + } + + } + + ForEach ($_appliance in $ApplianceConnection) + { + + "[{0}] Processing {1} appliance connection." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name | Write-Verbose + + # Get Scope resource + Try + { + + $_Scopes = Send-OVRequest $_uri -Hostname $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if ($PSBoundParameters['Name'] -and $_Scopes.count -eq 0) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.ScopeResourceException ScopeResourceNotFound ObjectNotFound -TargetObject 'Name' -Message ('{0} was not found on {1} appliance. Check the Name Parameter value.' -f $Name, $_appliance.Name) + $PSCmdlet.WriteError($ErrorRecord) + + } + + # Process Scopes Collection from API + ForEach ($_scopemember in $_Scopes.members) + { + + $_Scope = [HPEOneView.Appliance.ScopeCollection]::new($_scopemember.name, + $_scopemember.description, + $_scopemember.uri, + $_scopemember.eTag, + $_scopemember.ApplianceConnection) + + # Lookup Scope resource associations, and add to [ScopeCollectionMembers] Members property + Try + { + + $_IndexAssocationUri = '{0}?filter=scopeuris:{1}' -f $IndexUri, $_scopemember.uri + + $_AssociatedResources = Send-OVRequest -Uri $_IndexAssocationUri -Hostname $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + ForEach ($_Member in ($_AssociatedResources.members | Sort-Object name)) + { + + $_ScopeMember = [HPEOneView.Appliance.ScopeCollectionMemberEntry]::new($_Member.name, $ScopeCategoryEnum[$_Member.category], $_Member.uri) + + [void]$_Scope.Members.Add($_ScopeMember) + + } + + $_Scope + + } + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function New-OVScope +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "Default")] + Param + ( + + [Parameter (Mandatory, ParameterSetName = "Default")] + [ValidateNotNullorEmpty()] + [String]$Name, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [ValidateNotNullorEmpty()] + [String]$Description, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [Alias ('Appliance')] + [ValidateNotNullOrEmpty()] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command agian." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + Process + { + + ForEach ($_appliance in $ApplianceConnection) + { + + "[{0}] Processing {1} appliance connection." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name | Write-Verbose + + $_Scope = [HPEOneView.Appliance.Scope]::new($Name, $Description) + + # Get Scope resource + Try + { + + $_ScopeTask = Send-OVRequest -Uri $ScopesUri -Method POST -Body $_Scope -Hostname $_appliance | Wait-OVTaskComplete + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if ($_ScopeTask.taskState -eq 'Completed') + { + + try + { + + $_scoperesource = Send-OVRequest -Uri $_ScopeTask.associatedResource.resourceUri -Hostname $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + # Return Strongly typed object + [HPEOneView.Appliance.ScopeCollection]::new($_Scope.name, + $_Scope.description, + $_Scope.uri, + $_Scope.eTag, + ([HPEOneView.Library.ApplianceConnection]::new($_appliance.Name, $_appliance.ConnectionId))) + + } + + else + { + + $ExceptionMessage = [String]::Join(' ', $_ScopeTask.taskErrors.message) + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.ScopeResourceException InvalidResult InvalidResult 'ApplianceConnection' -Message $ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Add-OVResourceToScope +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "Default")] + Param + ( + + [Parameter (Mandatory, ParameterSetName = "Default", ValueFromPipeline)] + [ValidateNotNullorEmpty()] + [HPEOneView.Appliance.ScopeCollection[]]$Scope, + + [Parameter (Mandatory, ParameterSetName = "Default")] + [Alias('Resource')] + [ValidateNotNullorEmpty()] + [Object]$InputObject, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [ValidateNotNullorEmpty()] + [Switch]$Async, + + [Parameter (Mandatory = $false, ParameterSetName = "Default", ValueFromPipelineByPropertyName)] + [Alias ('Appliance')] + [ValidateNotNullOrEmpty()] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not($PSBoundParameters['Scope'])) + { + + $PipelineInput = $True + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command agian." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $_connection -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + } + + Process + { + + #$_UpdateScopeMembers = NewObject -ScopeMemberUpdate + $_UpdateScopeMembers = NewObject -PatchOperation + $_UpdateScopeMembers.op = 'add' + $_UpdateScopeMembers.path = '/addedResourceUris' + $_UpdateScopeMembers.value = [System.Collections.ArrayList]::new() + + ForEach ($_resource in $InputObject) + { + + # Validate Resource is allowed + if ($ScopeCategoryEnum[$_resource.category]) + { + + # Generate error that Resource already contains the Scope Uri + if ($_resource.scopeUris -contains $Scope.Uri) + { + + $_ExceptionMessage = '{0} is already a member of {1} scope.' -f $_resource.name, $Scope.Name + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.ScopeResourceException ResourceAlreadyWithinScope ResourceExists -TargetObject 'InputObject' -TargetType 'PSObject' -Message $_ExceptionMessage + $PSCmdlet.WriteError($ErrorRecord) + + } + + # Add resource URI to collection + else + { + + "[{0}] {1} Resource is not a member of {2} Scope, adding to collection." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_resource.name, $Scope.Name | Write-Verbose + + [void]$_UpdateScopeMembers.value.Add($_resource.uri) + + } + + } + + # Throw error + else + { + + $_ExceptionMessage = 'The provided InputObject argument value is not supported. Only the following resources are supported: "{0}"' -f (($ScopeCategoryEnum.GetEnumerator() | % { $_.Value }) -Join '", "') + $ErrorRecord = New-ErrorRecord InvalidOperationException InvalidInputObjectParameterValue InvalidArgument 'InputObject' -TargetType "$($InputObject.GetType().Name)" -Message $_ExceptionMessage + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + Try + { + + $_Resp = Send-OVRequest -Uri $Scope.Uri -Method PATCH -Body $_UpdateScopeMembers -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if ($PSboundParameters['Async']) + { + + $_Resp + + } + + else + { + + $_resp | Wait-OVTaskComplete + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Remove-OVResourceFromScope +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "Default")] + Param + ( + + [Parameter (Mandatory, ParameterSetName = "Default", ValueFromPipeline)] + [ValidateNotNullorEmpty()] + [HPEOneView.Appliance.ScopeCollection[]]$Scope, + + [Parameter (Mandatory, ParameterSetName = "Default")] + [Alias('Resource')] + [ValidateNotNullorEmpty()] + [Object]$InputObject, + + [Parameter (Mandatory = $false, ParameterSetName = "Default")] + [ValidateNotNullorEmpty()] + [Switch]$Async, + + [Parameter (Mandatory = $false, ParameterSetName = "Default", ValueFromPipelineByPropertyName)] + [Alias ('Appliance')] + [ValidateNotNullOrEmpty()] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not($PSBoundParameters['Scope'])) + { + + $PipelineInput = $True + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command agian." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $_connection -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + } + + Process + { + + $_UpdateScopeMembers = NewObject -PatchOperation + $_UpdateScopeMembers.op = 'replace' + $_UpdateScopeMembers.path = '/removedResourceUris' + $_UpdateScopeMembers.value = [System.Collections.ArrayList]::new() + + ForEach ($_resource in $InputObject) + { + + # Validate Resource is allowed + if ($ScopeCategoryEnum[$_resource.category]) + { + + # Generate error that Resource already contains the Scope Uri + if ($Scope.Members.Uri -notcontains $_resource.uri) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.ScopeResourceException ResourceDoesNotExistWithinScope ObjectNotFound -TargetObject 'InputObject' -TargetType 'PSObject' -Message ('{0} is not found to be a member of {1} scope.' -f $_resource.name, $Scope.Name) + $PSCmdlet.WriteError($ErrorRecord) + + } + + # Add resource URI to collection + else + { + + "[{0}] {1} Resource is a member of {2} Scope. Removing." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_resource.name, $Scope.Name | Write-Verbose + + [void]$_UpdateScopeMembers.value.Add($_resource.uri) + + } + + } + + } + + Try + { + + $_Resp = Send-OVRequest -Uri $Scope.Uri -Method PATCH -Body $_UpdateScopeMembers -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if ($PSboundParameters['Async']) + { + + $_Resp + + } + + else + { + + $_resp | Wait-OVTaskComplete + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Remove-OVScope +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "Default", SupportsShouldProcess, ConfirmImpact = 'High')] + Param + ( + + [Parameter (Mandatory, ParameterSetName = "Default", ValueFromPipeline)] + [ValidateNotNullorEmpty()] + [HPEOneView.Appliance.ScopeCollection[]]$Scope, + + [Parameter (Mandatory = $false, ParameterSetName = "Default", ValueFromPipelineByPropertyName)] + [Alias ('Appliance')] + [ValidateNotNullOrEmpty()] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not($PSBoundParameters['Scope'])) + { + + $PipelineInput = $True + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command agian." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $_connection -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + $_ScopeCollection = [System.Collections.ArrayList]::new() + + } + + Process + { + + "[{0}] Processing Scope: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Scope.Name | Write-Verbose + + [void]$_ScopeCollection.Add($Scope) + + } + + End + { + + "[{0}] Processing $($_ScopeCollection.count) Scope object resources to remove." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + # Process Storage Resources + ForEach ($_Scope in $_ScopeCollection) + { + + if ($PSCmdlet.ShouldProcess($_Scope.ApplianceConnection.Name,"Remove Scope '$($_Scope.Name)' from appliance")) + { + + "[{0}] Removing Scope '$($_Scope.name)' from appliance '$($_Scope.ApplianceConnection.Name)'." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Try + { + + Send-OVRequest -Uri $_Scope.Uri -Method DELETE -Hostname $_Scope.ApplianceConnection.Name -addHeader @{'If-Match' = $_Scope.eTag} + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + elseif ($PSBoundParameters['WhatIf']) + { + + "[{0}] WhatIf Parameter was passed." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + } + + } + +} + +function Get-OVLabel +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding ()] + Param + ( + + [Parameter (Mandatory = $false)] + [ValidateNotNullorEmpty()] + [Object]$Name, + + [Parameter (Mandatory = $false)] + [Alias ('Appliance')] + [ValidateNotNullOrEmpty()] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command agian." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $ApplianceConnection[$c].Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + Process + { + + ForEach ($_appliance in $ApplianceConnection) + { + + "[{0}] Processing {1} appliance connection." -f $MyInvocation.InvocationName.ToString().ToUpper(), $_appliance.Name | Write-Verbose + + # Get label resources + Try + { + + $_Labels = Send-OVRequest -Uri $LabelsUri -Hostname $_appliance + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + if ($PSBoundParameters['Name']) + { + + [Array]$_Labels.members = $_Labels.members | Where-Object name -match $Name + + if ($_Labels.members.count -eq 0) + { + + $ExceptionMessage = '{0} was not found on {1} appliance. Check the Name Parameter value.' -f $Name, $_appliance.Name + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.LabelResourceException LabelResourceNotFound ObjectNotFound -TargetObject 'Name' -Message $ExceptionMessage + $PSCmdlet.WriteError($ErrorRecord) + + } + + } + + # Process Scopes Collection from API + ForEach ($_label in $_Labels.members) + { + + [HPEOneView.Appliance.Label]::new($_label.name, $_label.eTag, $_label.uri, $_label.ApplianceConnection) + + } + + } + + } + + End + { + + "[{0}] Done." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Add-OVResourceToLabel +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding ()] + Param + ( + + [Parameter (Mandatory)] + [ValidateNotNullorEmpty()] + [String]$Name, + + [Parameter (Mandatory, ValueFromPipeline)] + [ValidateNotNullorEmpty()] + [Object]$InputObject, + + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName)] + [Alias ('Appliance')] + [ValidateNotNullOrEmpty()] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not($PSBoundParameters['InputObject'])) + { + + $PipelineInput = $True + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command agian." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $_connection -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + } + + Process + { + + ForEach ($_Resource in $InputObject) + { + + "[{0}] Processing Label: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Name | Write-Verbose + + Try + { + + $_Uri = '{0}{1}' -f $LabelsResourcesBaseUri, $_Resource.uri + $ExistingLabels = Send-OVRequest -Uri $_Uri -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + # Label already exists. Generate non-terminating error? + if ($Name -contains $ExistingLabels.labels) + { + + "[{0}] Resource {1} is already associated with {2} label ({3})" -f $MyInvocation.InvocationName.ToString().ToUpper(), $_Resource.name, $Name, [String]::Join($ExistingLabels.labels, ', ') | Write-Verbose + + Write-Warning "Resource is already associated with label." + + } + + else + { + + if ($ExistingLabels.labels.count -gt 0) + { + + "[{0}] Appending {1} label to resource {2} association." -f $MyInvocation.InvocationName.ToString().ToUpper(), $Name, $_Resource.name | Write-Verbose + + [Array]$ExistingLabels.labels += $Name + + } + + else + { + + "[{0}] Associating {1} label to resource {2}." -f $MyInvocation.InvocationName.ToString().ToUpper(), $Name, $_Resource.name | Write-Verbose + + [Array]$ExistingLabels.labels = $Name + + } + + Try + { + + Send-OVRequest -Uri $ExistingLabels.uri -Method PUT -Body $ExistingLabels -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + } + + End + { + + '[{0}] Done.' | Write-Verbose + + } + +} + +function Remove-OVResourceFromLabel +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = 'Default', SupportsShouldProcess, ConfirmImpact = 'High')] + Param + ( + + [Parameter (Mandatory, ParameterSetName = 'Default')] + [ValidateNotNullorEmpty()] + [String]$Name, + + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = 'Default')] + [Parameter (Mandatory, ValueFromPipeline, ParameterSetName = 'RemoveAll')] + [ValidateNotNullorEmpty()] + [Object]$InputObject, + + [Parameter (Mandatory = $false, ParameterSetName = 'RemoveAll')] + [Switch]$RemoveAllLabelsFromResource, + + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = 'Default')] + [Parameter (Mandatory = $false, ValueFromPipelineByPropertyName, ParameterSetName = 'RemoveAll')] + [Alias ('Appliance')] + [ValidateNotNullOrEmpty()] + [Object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + if (-not($PSBoundParameters['InputObject'])) + { + + $PipelineInput = $True + + } + + else + { + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection) -and -not(${Global:ConnectedSessions})) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError "ApplianceConnection" -Message "No Appliance connection session found. Please use Connect-OVMgmt to establish a connection, then try your command agian." + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection -is [System.Collections.IEnumerable] -and $ApplianceConnection -isnot [System.String]) + { + + For ([Int]$c = 0; $c -lt $ApplianceConnection.Count; $c++) + { + + Try + { + + $ApplianceConnection[$c] = Test-OVAuth $ApplianceConnection[$c] + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError $_connection -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + } + + Process + { + + if ($InputObject -isnot [HPEOneView.Appliance.Label]) + { + + "[{0}] Processing Label {1} for {2} resource." -f $MyInvocation.InvocationName.ToString().ToUpper(), $Name, $InputObject.name | Write-Verbose + + if ($PSCmdlet.ParameterSetName -eq 'RemoveAll') + { + + if ($PSCmdlet.ShouldProcess($InputObject.name, 'remove resource from all associated labels')) + { + + "[{0}] Removing {1} resource from all labels." -f $MyInvocation.InvocationName.ToString().ToUpper(), $InputObject.name | Write-Verbose + + Try + { + + $_Uri = '{0}{1}' -f $LabelsResourcesBaseUri, $InputObject.uri + Send-OVRequest -Uri $_Uri -Method DELETE -AddHeader @{'If-Match' = '*'} -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + elseif ($PSBoundParameters['WhatIf']) + { + + "[{0}] User specified -WhatIf" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + + } + + else + { + + Try + { + + $_Uri = '{0}{1}' -f $LabelsResourcesBaseUri, $InputObject.uri + $ExistingLabels = Send-OVRequest -Uri $_Uri -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + "[{0}] Removing {1} label from resource {2} association." -f $MyInvocation.InvocationName.ToString().ToUpper(), $Name, $InputObject.name | Write-Verbose + + [Array]$ExistingLabels.labels = $ExistingLabels.labels | Where-Object name -ne $Name + + Try + { + + Send-OVRequest -Uri $ExistingLabels.uri -Method PUT -Body $ExistingLabels -Hostname $ApplianceConnection + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + else + { + + $_Message = "An invalid InputObject argument value type was provided, {0}. Labels cannot be removed via the appliance API. Labels are automatically removed when the last association to a resource is removed. Please provide a resource object to remove the label association." -f $InputObject.name + $ErrorRecord = New-ErrorRecord InvalidOperationException InvalidInputObjectParameterValue InvalidArgument 'InputObject' -TargetType "$($InputObject.GetType().Name)" -Message $_Message + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + } + + End + { + + '[{0}] Done.' -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +######################################################## +# HPE Support CMDLETs + +function Enable-OVDebug +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "default")] + Param + ( + + [Parameter (Mandatory, ParameterSetName = "default",HelpMessage = "Provide the debug Scope.")] + [ValidateNotNullOrEmpty()] + [String]$Scope, + + [Parameter (Mandatory, ParameterSetName = "default",HelpMessage = "Provide the component Logger Name.")] + [ValidateNotNullOrEmpty()] + [String]$LoggerName, + + [Parameter (Mandatory, ParameterSetName = "default",HelpMessage = "Specify the verbose log level (ERROR, WARN, DEBUG or TRACE are allowed).")] + [ValidateNotNullOrEmpty()] + [ValidateSet ('ERROR','WARN','DEBUG','TRACE', IgnoreCase = $False)] + [String]$Level, + + [Parameter (Mandatory = $false, ParameterSetName = "default", ValueFromPipelineByPropertyName)] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + [console]::WriteLine() + Write-Warning "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" + Write-Warning "!!! FOR HPE SUPPORT USE ONLY. DO NOT USE UNLESS OTHERWISE INSTRUCTED TO BY HPE SUPPORT !!!" + Write-Warning "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" + [console]::WriteLine() + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection -is [HPEOneView.Appliance.Connection]) -and (-not($ApplianceConnection -is [System.String]))) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException InvalidApplianceConnectionDataType InvalidArgument 'ApplianceConnection' -Message 'The specified ApplianceConnection Parameter is not type [HPEOneView.Appliance.Connection] or [System.String]. Please correct this value and try again.' + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection.Count -gt 1) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException MultipleApplianceConnections InvalidArgument 'ApplianceConnection' -Message 'The specified ApplianceConnection Parameter contains multiple Appliance Connections. This CMDLET only supports 1 Appliance Connection in the ApplianceConnect Parameter value. Please correct this and try again.' + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -TargetType $ApplianceConnection.GetType().Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + $colStatus = [System.Collections.ArrayList]::new() + + } + + Process + { + + $_debug = NewObject -ApplianceDebug + + $_debug.scope = $Scope + $_debug.loggerName = $LoggerName + $_debug.level = $Level + + "[{0}] Setting '{1}' at '{2}:{3}'" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Level, $Scope, $LoggerName | Write-Verbose + + Try + { + + $resp = Send-OVRequest $script:applianceDebugLogSetting POST $_debug -Hostname $ApplianceConnection + + } + + Catch + { + + "Unable to set '{0}:{1}' to '{2}' logging level. Error '{3}'" -f $Scope, $LoggerName, $Level, $_.Exception.Message + + $PSCmdlet.ThrowTerminatingError($_) + + } + + "'{0}:{1}' successfully set to '{2}' on Appliance {3}" -f $Scope, $LoggerName, $Level, $ApplianceConnection + + } + + End + { + + '[{0}] Done.' -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + Write-Warning "Remember to set '$Scope`:$LoggerName' back to 'INFO' with 'Disable-OVDebug $Scope $LoggerName'" + + } + +} + +function Disable-OVDebug +{ + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "default")] + Param + ( + + [Parameter (Mandatory, ParameterSetName = "default")] + [ValidateNotNullOrEmpty()] + [String]$Scope, + + [Parameter (Mandatory, ParameterSetName = "default")] + [ValidateNotNullOrEmpty()] + [String]$LoggerName, + + [Parameter (Mandatory = $false, ParameterSetName = "default", ValueFromPipelineByPropertyName)] + [ValidateNotNullorEmpty()] + [object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + [console]::WriteLine() + Write-Warning "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" + Write-Warning "!!! FOR HPE SUPPORT USE ONLY. DO NOT USE UNLESS OTHERWISE INSTRUCTED TO BY HPE SUPPORT !!!" + Write-Warning "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" + [console]::WriteLine() + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection -is [HPEOneView.Appliance.Connection]) -and (-not($ApplianceConnection -is [System.String]))) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException InvalidApplianceConnectionDataType InvalidArgument 'ApplianceConnection' -Message 'The specified ApplianceConnection Parameter is not type [HPEOneView.Appliance.Connection] or [System.String]. Please correct this value and try again.' + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection.Count -gt 1) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException MultipleApplianceConnections InvalidArgument 'ApplianceConnection' -Message 'The specified ApplianceConnection Parameter contains multiple Appliance Connections. This CMDLET only supports 1 Appliance Connection in the ApplianceConnect Parameter value. Please correct this and try again.' + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -TargetType $ApplianceConnection.GetType().Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + Process + { + + $_debug = NewObject -ApplianceDebug + + $_debug.scope = $Scope + $_debug.loggerName = $LoggerName + $_debug.level = 'INFO' + + "[{0}] Setting '{1}' at '{2}:{3}'" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Level, $Scope, $LoggerName | Write-Verbose + + Try + { + + $resp = Send-OVRequest $script:applianceDebugLogSetting POST $_debug -Hostname $ApplianceConnection + + } + + Catch + { + + "Unable to set '{0}:{1}' to '{2}' logging level. Error '{3}'" -f $Scope, $LoggerName, $Level, $_.Exception.Message + + $PSCmdlet.ThrowTerminatingError($_) + + } + + "'{0}:{1}' successfully set to '{2}' on Appliance {3}" -f $Scope, $LoggerName, $Level, $ApplianceConnection.Name + + } + + End + { + + '[{0}] Done.' -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +function Get-OVFixMeInstallationLog +{ + + + # .ExternalHelp HPEOneView.900.psm1-help.xml + + [CmdletBinding (DefaultParameterSetName = "default")] + Param + ( + + [Parameter (Mandatory = $false, ParameterSetName = "default", ValueFromPipeline)] + [ValidateNotNullorEmpty()] + [System.IO.DirectoryInfo]$Location = [Environment]::CurrentDirectory, + + [Parameter (Mandatory = $false, ParameterSetName = "default")] + [ValidateNotNullorEmpty()] + [Alias ('Appliance')] + [object]$ApplianceConnection = (${Global:ConnectedSessions} | Where-Object Default) + + ) + + Begin + { + + RedactPassword -BoundParameters $PSBoundParameters | Write-Verbose + + $Caller = (Get-PSCallStack)[1].Command + + "[{0}] Called from: {1}" -f $MyInvocation.InvocationName.ToString().ToUpper(), $Caller | Write-Verbose + + "[{0}] Verify auth" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + if (-not($ApplianceConnection -is [HPEOneView.Appliance.Connection]) -and (-not($ApplianceConnection -is [System.String]))) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException InvalidApplianceConnectionDataType InvalidArgument 'ApplianceConnection' -Message 'The specified ApplianceConnection Parameter is not type [HPEOneView.Appliance.Connection] or [System.String]. Please correct this value and try again.' + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + elseif ($ApplianceConnection.Count -gt 1) + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException MultipleApplianceConnections InvalidArgument 'ApplianceConnection' -Message 'The specified ApplianceConnection Parameter contains multiple Appliance Connections. This CMDLET only supports 1 Appliance Connection in the ApplianceConnect Parameter value. Please correct this and try again.' + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + else + { + + Try + { + + $ApplianceConnection = Test-OVAuth $ApplianceConnection + + } + + Catch [HPEOneView.Appliance.AuthSessionException] + { + + $ErrorRecord = New-ErrorRecord HPEOneview.Appliance.AuthSessionException NoApplianceConnections AuthenticationError 'ApplianceConnection' -TargetType $ApplianceConnection.GetType().Name -Message $_.Exception.Message -InnerException $_.Exception + $PSCmdlet.ThrowTerminatingError($ErrorRecord) + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + Process + { + + $_uri = $ApplianceFixmeLogsDownloadUri + + ForEach ($_appliance in $ApplianceConnection) + { + + Try + { + + Download-File -Uri $_uri -ApplianceConnection $_appliance -SaveLocation $Location + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + } + + End + { + + '[{0}] Done.' -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + + } + +} + +######################################################## +# PowerShell Filters + +filter ColorPattern( [String]$Pattern, [hashtable]$Color) +{ + + $split = $_ -split $Pattern + + $found = [regex]::Matches( $_, $Pattern, 'IgnoreCase' ) + + for( $i = 0; $i -lt $split.Count; ++$i ) + { + + [ConsoleColor]$displayColor = $Color.keys | ForEach-Object { if ($_ -ieq $found[$i]) { $color[$_]} } + Write-Host $split[$i] -NoNewline + Write-Host $found[$i] -NoNewline -ForegroundColor $displayColor + + } + + [console]::WriteLine() + +} + +filter Convert-IP2Decimal +{ + + ([Net.IPAddress][String]([Net.IPAddress]$_)).Address + +} + + +filter Convert-Decimal2IP +{ + + ([System.Net.IPAddress]$_).IPAddressToString + +} + +####################################################### +# CMDLET Aliases +set-Alias New-OVEnclosure Add-OVEnclosure +set-Alias New-OVServer Add-OVServer +set-Alias Wait-OVTaskAccepted Wait-OVTaskStart +set-Alias Get-OVServerHardwareTypes Get-OVServerHardwareType +set-Alias New-OVStorageSystem Add-OVStorageSystem +set-Alias New-OVSanManager Add-OVSanManager +set-Alias New-OVStoragePool Add-OVStoragePool +# Set-Alias New-OVPowerDevice Add-OVPowerDevice +set-Alias Set-OVRole Set-OVUserRole +set-Alias Get-OVSppFile Get-OVBaseline +set-Alias Add-OVSppFile Add-OVBaseline +set-Alias New-OVLdap New-OVLdapDirectory +set-Alias Remove-OVLdap Remove-OVLdapDirectory +set-Alias Get-OVProfile Get-OVServerProfile +set-Alias New-OVAddressRange New-OVAddressPoolRange +set-Alias New-OVProfile New-OVServerProfile +set-Alias Get-OVProfileAssign New-OVServerProfileAssign +set-Alias Copy-OVProfile Copy-OVServerProfile +set-Alias Remove-OVProfile Remove-OVServerProfile +set-Alias Get-OVProfileConnectionList Get-OVServerProfileConnectionList +set-Alias New-OVProfileConnection New-OVServerProfileConnection +set-Alias New-OVProfileAttachVolume New-OVServerProfileAttachVolume +set-Alias sr Send-OVRequest +Set-Alias Show-OVBaselineRepositorySize Get-OVBaselineRepository +Set-Alias Get-OVHypervisorManager Get-OVClusterManager +Set-Alias Add-OVHypervisorManager Add-OVClusterManager +Set-Alias Set-OVHypervisorManager Set-OVClusterManager +Set-Alias Remove-OVHypervisorManager Remove-OVClusterManager + +####################################################### +# Export the public functions from this module +# Generic suport functions: +Export-ModuleMember -function Send-OVRequest -Alias sr +Export-ModuleMember -function Connect-OVMgmt +Export-ModuleMember -function Push-OVAppliancePermission +Export-ModuleMember -function Pop-OVAppliancePermission +Export-ModuleMember -function Disconnect-OVMgmt +Export-ModuleMember -function Set-OVApplianceDefaultConnection +Export-ModuleMember -function Ping-OVAddress +Export-ModuleMember -function New-OVResource +Export-ModuleMember -function Set-OVResource +Export-ModuleMember -function Remove-OVResource +Export-ModuleMember -function Wait-OVApplianceStart +Export-ModuleMember -function Enable-OVDebug +Export-ModuleMember -function Disable-OVDebug +Export-ModuleMember -function Get-OVFixMeInstallationLog +Export-ModuleMember -function Get-OVRemoteSyslog +Export-ModuleMember -function Set-OVRemoteSyslog +Export-ModuleMember -function Enable-OVMSDSC +Export-ModuleMember -function Disable-OVMSDSC +Export-ModuleMember -function Start-OVLibraryTrace +Export-ModuleMember -function Stop-OVLibraryTrace +Export-ModuleMember -function Get-OVCommandTrace +Export-ModuleMember -function Get-OVRemoteSyslog +Export-ModuleMember -function Set-OVRemoteSyslog +Export-ModuleMember -function Enable-OVRemoteSyslog +Export-ModuleMember -function Disable-OVRemoteSyslog +Export-ModuleMember -function Get-OVApplianceProxy +Export-ModuleMember -function Set-OVApplianceProxy +Export-ModuleMember -function Remove-OVApplianceProxy +Export-ModuleMember -function Invoke-OVWebBrowser +Export-ModuleMember -function Show-OVActiveUser +Export-ModuleMember -Function ConvertTo-OVPowerShellScript +Export-ModuleMember -Function Update-OVUserScript +Export-ModuleMember -Function Get-OVRotateMPPasswordPolicy +Export-ModuleMember -Function Set-OVRotateMPPasswordPolicy +Export-ModuleMember -Function Get-OVRotateMPPasswordPolicyReport + +# Remote Support: +Export-ModuleMember -function Get-OVRemoteSupport +Export-ModuleMember -function Set-OVRemoteSupport +Export-ModuleMember -function Get-OVRemoteSupportContact +Export-ModuleMember -function New-OVRemoteSupportContact +Export-ModuleMember -function Set-OVRemoteSupportPrimaryContact +Export-ModuleMember -function Set-OVRemoteSupportSecondaryContact +Export-ModuleMember -function Remove-OVRemoteSupportContact +Export-ModuleMember -function Get-OVRemoteSupportDefaultSite +Export-ModuleMember -function Set-OVRemoteSupportDefaultSite +Export-ModuleMember -function Test-OVRemoteSupportEvent +Export-ModuleMember -function Get-OVRemoteSupportSetting +Export-ModuleMember -function Set-OVRemoteSupportSetting +Export-ModuleMember -function Start-OVRemoteSupportCollection +Export-ModuleMember -function Get-OVRemoteSupportPartner +Export-ModuleMember -function New-OVRemoteSupportPartner +Export-ModuleMember -function Remove-OVRemoteSupportPartner +Export-ModuleMember -function Set-OVRemoteSupportDataCollectionSchedule +Export-ModuleMember -function Get-OVRemoteSupportDataCollectionSchedule +Export-ModuleMember -function Get-OVRemoteSupportEntitlementStatus +Export-ModuleMember -function Enable-OVRemoteSupport +Export-ModuleMember -function Disable-OVRemoteSupport +Export-ModuleMember -function Update-OVRemoteSupportEntitlement +Export-ModuleMember -function Get-OVRemoteSupportPortalConnectionStatus +Export-ModuleMember -function Register-OVRemoteSupportPortalConnection +Export-ModuleMember -function Unregister-OVRemoteSupportPortalConnection + +# Appliance Configuration: +Export-ModuleMember -function Get-OVComputeOpsManagement +Export-ModuleMember -function Set-OVComputeOpsManagement +Export-ModuleMember -function Connect-OVComputeOpsManagement +Export-ModuleMember -function Enable-OVComputeOpsManagement +Export-ModuleMember -function Disable-OVComputeOpsManagement +Export-ModuleMember -function Get-OVApplianceStaticRoute +Export-ModuleMember -function New-OVApplianceStaticRoute +Export-ModuleMember -function Set-OVApplianceStaticRoute +Export-ModuleMember -function Remove-OVApplianceStaticRoute +Export-ModuleMember -function Get-OVApplianceAuditLogForwarding +Export-ModuleMember -function Set-OVApplianceAuditLogForwarding +Export-ModuleMember -function Test-OVApplianceAuditLogForwarding +Export-ModuleMember -function Get-OVApplianceCertificateStatus +Export-ModuleMember -function Get-OVApplianceDateTime +Export-ModuleMember -function Set-OVApplianceDateTime +Export-ModuleMember -function New-OVApplianceSelfSignedCertificate +Export-ModuleMember -function New-OVApplianceCsr +Export-ModuleMember -function Install-OVApplianceCertificate +Export-ModuleMember -function Get-OVApplianceTrustedCertificate +Export-ModuleMember -function Add-OVApplianceTrustedCertificate +Export-ModuleMember -function Remove-OVApplianceTrustedCertificate +Export-ModuleMember -function Update-OVApplianceTrustedAuthorityCrl +Export-ModuleMember -function Get-OVVersion +Export-ModuleMember -function Get-OVHealthStatus +Export-ModuleMember -function Get-OVXApiVersion +Export-ModuleMember -function Get-OVEulaStatus +Export-ModuleMember -function Set-OVEulaStatus +Export-ModuleMember -function Get-OVApplianceIPAddress +Export-ModuleMember -function Get-OVApplianceNetworkConfig +Export-ModuleMember -function Set-OVApplianceNetworkConfig +Export-ModuleMember -function Get-OVSnmpReadCommunity +Export-ModuleMember -function Set-OVSnmpReadCommunity +Export-ModuleMember -function Get-OVApplianceTrapDestination +Export-ModuleMember -function New-OVApplianceTrapDestination +Export-ModuleMember -function Remove-OVApplianceTrapDestination +Export-ModuleMember -function Get-OVApplianceSnmpV3EngineId +Export-ModuleMember -function Set-OVApplianceSnmpV3EngineId +Export-ModuleMember -function New-OVSnmpV3User +Export-ModuleMember -function Get-OVSnmpV3User +Export-ModuleMember -function Remove-OVSnmpV3User +Export-ModuleMember -function Get-OVApplianceGlobalSetting +Export-ModuleMember -function Set-OVApplianceGlobalSetting +Export-ModuleMember -function Get-OVBaseline -Alias Get-OVSppFile +Export-ModuleMember -function Add-OVBaseline -Alias Add-OVSppFile +Export-ModuleMember -function New-OVCustomBaseline +Export-ModuleMember -function Restore-OVCustomBaseline +Export-ModuleMember -function Remove-OVBaseline +Export-ModuleMember -function Get-OVBaselineRepository -Alias Show-OVBaselineRepositorySize +Export-ModuleMember -function New-OVExternalRepository +Export-ModuleMember -function Set-OVExternalRepository +Export-ModuleMember -function Update-OVExternalRepository +Export-ModuleMember -function Remove-OVExternalRepository +Export-ModuleMember -function New-OVSupportDump +Export-ModuleMember -function New-OVBackup +Export-ModuleMember -function Get-OVBackup +Export-ModuleMember -function Save-OVBackup +Export-ModuleMember -function New-OVRestore +Export-ModuleMember -function New-OVApplianceDataAtRestEncryptionKey +Export-ModuleMember -function Save-OVApplianceDataAtRestEncryptionKey +Export-ModuleMember -function Get-OVApplianceDataAtRestEncryption +Export-ModuleMember -function Enable-OVApplianceDataAtRestEncryption +Export-ModuleMember -function Disable-OVApplianceDataAtRestEncryption +Export-ModuleMember -function Get-OVFirmwareBundleUpdateSchedule -alias Get-OVApplianceUpdateSchedule +Export-ModuleMember -function Get-OVFirmwareBundleUpdate -alias Get-OVApplianceUpdate +Export-ModuleMember -function Set-OVFirmwareBundleUpdateSchedule -alias Set-OVApplianceUpdateSchedule +Export-ModuleMember -function Get-OVAutomaticBackupConfig +Export-ModuleMember -function Set-OVAutomaticBackupConfig +Export-ModuleMember -function Get-OVScmbCertificates +Export-ModuleMember -function Remove-OVScmbCertificate +Export-ModuleMember -function Install-OVUpdate +Export-ModuleMember -function Get-OVPEndingUpdate +Export-ModuleMember -function Remove-OVPEndingUpdate +Export-ModuleMember -function Import-OVSSLCertificate +Export-ModuleMember -function Restart-OVAppliance +Export-ModuleMember -function Stop-OVAppliance +Export-ModuleMember -function Get-OVApplianceStatus +Export-ModuleMember -function Get-OVComposerNode +Export-ModuleMember -function Enable-OVComposerHANode +Export-ModuleMember -function Remove-OVStandbyComposerNode +Export-ModuleMember -function Get-OVLabel +Export-ModuleMember -function Add-OVResourceToLabel +Export-ModuleMember -function Remove-OVResourceFromLabel +Export-ModuleMember -function Enable-OVComposerIlo +Export-ModuleMember -function Disable-OVComposerIlo +Export-ModuleMember -function Set-OVComposerIlo +Export-ModuleMember -function Get-OVComposerIloStatus + +# Server hardware and enclosures: +Export-ModuleMember -function Get-OVServer +Export-ModuleMember -function Add-OVServer -Alias New-OVServer +Export-ModuleMember -function Set-OVServerPower +Export-ModuleMember -function Get-OVServerOneTimeBoot +Export-ModuleMember -function Set-OVServerOneTimeBoot +Export-ModuleMember -function Start-OVServer +Export-ModuleMember -function Stop-OVServer +Export-ModuleMember -function Restart-OVServer +Export-ModuleMember -function Remove-OVServer +Export-ModuleMember -function Update-OVServer +Export-ModuleMember -function Update-OVServerHardwareLicenseIntent +Export-ModuleMember -function Get-OVMigratableServer +Export-ModuleMember -function Invoke-OVMigrateServer +Export-ModuleMember -function Update-OVServerFirmware +Export-ModuleMember -function Get-OVRackManager +Export-ModuleMember -function Add-OVRackManager +Export-ModuleMember -function Update-OVRackManager +Export-ModuleMember -function Remove-OVRackManager +Export-ModuleMember -function Get-OVEnclosure +Export-ModuleMember -function Set-OVEnclosure +Export-ModuleMember -function Start-OVEnclosureAppliance +Export-ModuleMember -function Update-OVEnclosure +Export-ModuleMember -function Add-OVEnclosure -Alias New-OVEnclosure +Export-ModuleMember -function Add-OVRemoteFrame +Export-ModuleMember -function New-OVLogicalEnclosure +Export-ModuleMember -function Get-OVLogicalEnclosure +Export-ModuleMember -function Set-OVLogicalEnclosure +Export-ModuleMember -function Update-OVLogicalEnclosure +Export-ModuleMember -function Update-OVLogicalEnclosureFirmware +Export-ModuleMember -function Remove-OVLogicalEnclosure +Export-ModuleMember -function Remove-OVEnclosure +Export-ModuleMember -function Get-OVEnclosureGroup +Export-ModuleMember -function New-OVEnclosureGroup +Export-ModuleMember -function Set-OVEnclosureGroup +Export-ModuleMember -function Remove-OVEnclosureGroup +Export-ModuleMember -function Get-OVServerHardwareType -Alias Get-OVServerHardwareTypes +Export-ModuleMember -function Set-OVServerHardwareType +Export-ModuleMember -function Show-OVFirmwareReport +Export-ModuleMember -function Invoke-OVVcmMigration +Export-ModuleMember -function Enable-OVDeviceUid +Export-ModuleMember -function Disable-OVDeviceUid +Export-ModuleMember -function Set-OVEnclosureActiveFLM +Export-ModuleMember -function Reset-OVEnclosureDevice +Export-ModuleMember -function Get-OVIloSso +Export-ModuleMember -function ConvertTo-OVImageStreamerConfiguration +Export-ModuleMember -function Enable-OVMaintenanceMode +Export-ModuleMember -function Disable-OVMaintenanceMode +Export-ModuleMember -function Show-OVUtilization +Export-ModuleMember -function Get-OVServerNTPConfiguration +Export-ModuleMember -function Set-OVServerNTPConfiguration + +# Storage +Export-ModuleMember -function Get-OVStorageSystem +Export-ModuleMember -function Update-OVStorageSystem +Export-ModuleMember -function Add-OVStorageSystem -Alias New-OVStorageSystem +Export-ModuleMember -function Remove-OVStorageSystem +Export-ModuleMember -function Show-OVStorageSystemPerformancePolicy +Export-ModuleMember -function Get-OVStoragePool +Export-ModuleMember -function Add-OVStoragePool -Alias New-OVStoragePool +Export-ModuleMember -function Set-OVStoragePool +Export-ModuleMember -function Update-OVStoragePool +Export-ModuleMember -function Remove-OVStoragePool +Export-ModuleMember -function Get-OVStorageVolumeSet +Export-ModuleMember -function Get-OVStorageVolumeTemplate +Export-ModuleMember -function New-OVStorageVolumeTemplate +Export-ModuleMember -function Set-OVStorageVolumeTemplate +Export-ModuleMember -function Remove-OVStorageVolumeTemplate +Export-ModuleMember -function Get-OVStorageVolumeTemplatePolicy +Export-ModuleMember -function Set-OVStorageVolumeTemplatePolicy +Export-ModuleMember -function Get-OVStorageVolume +Export-ModuleMember -function New-OVStorageVolume +Export-ModuleMember -function Add-OVStorageVolume +Export-ModuleMember -function Set-OVStorageVolume +Export-ModuleMember -function Remove-OVStorageVolume +Export-ModuleMember -function Get-OVStorageVolumeSnapshot +Export-ModuleMember -function New-OVStorageVolumeSnapShot +Export-ModuleMember -function Remove-OVStorageVolumeSnapShot +Export-ModuleMember -function ConvertTo-OVStorageVolume +Export-ModuleMember -function Get-OVSanManager +Export-ModuleMember -function Add-OVSanManager -Alias New-OVSanManager +Export-ModuleMember -function Set-OVSanManager +Export-ModuleMember -function Update-OVSanManager +Export-ModuleMember -function Remove-OVSanManager +Export-ModuleMember -function Get-OVManagedSan +Export-ModuleMember -function Set-OVManagedSan +Export-ModuleMember -function Get-OVSanZone +Export-ModuleMember -function Show-OVSanEndpoint +Export-ModuleMember -function Get-OVDriveEnclosure +Export-ModuleMember -function Get-OVAvailableDriveType +Export-ModuleMember -function Get-OVDriveEnclosureInventory +Export-ModuleMember -function Get-OVLogicalJBOD +Export-ModuleMember -function New-OVLogicalJBOD +Export-ModuleMember -function Remove-OVLogicalJBOD +Export-ModuleMember -function Set-OVLogicalJBOD +Export-ModuleMember -function Get-OVSasInterconnectType + +# Unmanaged Devices +Export-ModuleMember -function Get-OVUnmanagedDevice +Export-ModuleMember -function New-OVUnmanagedDevice +Export-ModuleMember -function Remove-OVUnmanagedDevice + +# Power Devices (iPDUs): +Export-ModuleMember -function Get-OVPowerDevice +Export-ModuleMember -function Add-OVPowerDevice +Export-ModuleMember -function Remove-OVPowerDevice +Export-ModuleMember -function Get-OVPowerPotentialDeviceConnection +Export-ModuleMember -function Get-OVPowerPotentialDeviceConnection +# Export-ModuleMember -function New-OVPowerDevice +# Export-ModuleMember -function Add-OVPowerDeviceConnection + +# Networking and Connections: +Export-ModuleMember -function New-OVNetwork +Export-ModuleMember -function Get-OVNetwork +Export-ModuleMember -function Set-OVNetwork +Export-ModuleMember -function Remove-OVNetwork +Export-ModuleMember -function New-OVNetworkSet +Export-ModuleMember -function Get-OVNetworkSet +Export-ModuleMember -function Set-OVNetworkSet +Export-ModuleMember -function Remove-OVNetworkSet +Export-ModuleMember -function Get-OVInterconnect +Export-ModuleMember -function Set-OVInterconnectName +Export-ModuleMember -function Get-OVInterconnectType +Export-ModuleMember -function Get-OVLogicalInterconnect +Export-ModuleMember -function Get-OVSasLogicalInterconnect +Export-ModuleMember -function Update-OVLogicalInterconnect +Export-ModuleMember -function Install-OVLogicalInterconnectFirmware +Export-ModuleMember -function Show-OVLogicalInterconnectMacTable +Export-ModuleMember -function Show-OVPortStatistics +Export-ModuleMember -function Reset-OVInterconnectNetOpPassword +Export-ModuleMember -function Get-OVLogicalInterconnectGroup +Export-ModuleMember -function New-OVLogicalInterconnectGroup +Export-ModuleMember -function Remove-OVLogicalInterconnectGroup +Export-ModuleMember -function New-OVQosConfig +Export-ModuleMember -function New-OVQosTrafficClass +Export-ModuleMember -function Get-OVUplinkSet +Export-ModuleMember -function New-OVUplinkSet +Export-ModuleMember -function Set-OVUplinkSet +Export-ModuleMember -function Get-OVAddressPool +Export-ModuleMember -function Get-OVAddressPoolRange +Export-ModuleMember -function New-OVAddressPoolRange -Alias New-OVAddressRange +Export-ModuleMember -function Get-OVAddressPoolSubnet +Export-ModuleMember -function New-OVAddressPoolSubnet +Export-ModuleMember -function Set-OVAddressPoolSubnet +Export-ModuleMember -function Remove-OVAddressPoolSubnet +Export-ModuleMember -function Remove-OVAddressPoolRange +Export-ModuleMember -function Get-OVReservedVlanRange +Export-ModuleMember -function Set-OVReservedVlanRange +Export-ModuleMember -function New-OVSnmpTrapDestination +Export-ModuleMember -function New-OVSnmpConfiguration +Export-ModuleMember -function Get-OVSwitchType +Export-ModuleMember -function Get-OVLogicalSwitchGroup +Export-ModuleMember -function New-OVLogicalSwitchGroup +Export-ModuleMember -function Remove-OVLogicalSwitchGroup +Export-ModuleMember -function Get-OVLogicalSwitch +Export-ModuleMember -function New-OVLogicalSwitch +Export-ModuleMember -function Remove-OVLogicalSwitch +Export-ModuleMember -function Update-OVLogicalSwitch +Export-ModuleMember -function Get-OVSwitch +Export-ModuleMember -function Get-OVLogicalInterconnectPortMonitoring +Export-ModuleMember -function Enable-OVLogicalInterconnectPortMonitoring +Export-ModuleMember -function Disable-OVLogicalInterconnectPortMonitoring +Export-ModuleMember -function Get-OVFabricManager +Export-ModuleMember -function Add-OVFabricManager +Export-ModuleMember -function Remove-OVFabricManager +Export-ModuleMember -function Get-OVInterconnectNTPConfiguration +Export-ModuleMember -function Set-OVInterconnectNTPConfiguration + +# I3S (Image Streamer) Support +Export-ModuleMember -function Get-OVImageStreamerAppliance +Export-ModuleMember -function Get-OVOSDeploymentServer +Export-ModuleMember -function New-OVOSDeploymentServer +Export-ModuleMember -function Remove-OVOSDeploymentServer +Export-ModuleMember -function Get-OVOSDeploymentPlan +Export-ModuleMember -function Get-OVOSDeploymentPlanAttribute + +# Server Profiles and Server Profile Templates: +Export-ModuleMember -function Get-OVServerProfile -Alias Get-OVProfile +Export-ModuleMember -function New-OVServerProfile -Alias New-OVProfile +# Export-ModuleMember -function Set-OVServerProfilefunction Set-OVServerProfile +Export-ModuleMember -function New-OVServerProfileAssign -Alias Get-OVProfileAssign +Export-ModuleMember -function Copy-OVServerProfile -Alias Copy-OVProfile +Export-ModuleMember -function Remove-OVServerProfile -Alias Remove-OVProfile +Export-ModuleMember -function Update-OVServerProfile +Export-ModuleMember -function Convert-OVServerProfile +Export-ModuleMember -function Get-OVServerProfileConnectionList -Alias Get-OVProfileConnectionList +Export-ModuleMember -function Get-OVAvailableServerConnections +Export-ModuleMember -function New-OVServerProfileConnection -Alias New-OVProfileConnection +Export-ModuleMember -function New-OVServerProfileAttachVolume -Alias New-OVProfileAttachVolume +Export-ModuleMember -function New-OVServerProfileIloPolicy +Export-ModuleMember -function New-OVIloLocalUserAccount +Export-ModuleMember -function New-OVIloDirectoryGroup +Export-ModuleMember -function New-OVServerProfileTemplate +# Export-ModuleMember -function Set-OVServerProfileTemplate +Export-ModuleMember -function Get-OVServerProfileTemplate +Export-ModuleMember -function Join-OVServerProfileToTemplate +Export-ModuleMember -function ConvertTo-OVServerProfileTemplate +Export-ModuleMember -function Remove-OVServerProfileTemplate +Export-ModuleMember -function New-OVServerProfileLogicalDisk +Export-ModuleMember -function New-OVServerProfileLogicalDiskController +Export-ModuleMember -function Get-OVServerHardwareAvailableController +Export-ModuleMember -function Save-OVServerProfile +Export-ModuleMember -function Save-OVServerProfileTemplate +Export-ModuleMember -function Convert-OVServerProfileTemplate + +# Hypervisor Cluster Profiles +Export-ModuleMember -function Get-OVClusterManager -Alias Get-OVHypervisorManager +Export-ModuleMember -function Add-OVClusterManager -Alias Add-OVHypervisorManager +Export-ModuleMember -function Set-OVClusterManager -Alias Set-OVHypervisorManager +Export-ModuleMember -function Remove-OVClusterManager -Alias Remove-OVHypervisorManager +Export-ModuleMember -function Get-OVClusterProfile +Export-ModuleMember -function Get-OVClusterNode +Export-ModuleMember -function New-OVClusterProfile +Export-ModuleMember -function New-OVClusterProfileMember +# Not sure this is needed. A Cmdlet does not exist. +# Export-ModuleMember -function New-OVClusterProfileVirtualSwitchConf +Export-ModuleMember -function Import-OVCluster +Export-ModuleMember -function Add-OVClusterNode +Export-ModuleMember -function Show-OVHypervisorCluster +Export-ModuleMember -function Remove-OVClusterProfile +Export-ModuleMember -function Remove-OVClusterNode +Export-ModuleMember -function Update-OVClusterProfile +Export-ModuleMember -function Update-OVClusterNode +Export-ModuleMember -function Enter-OVClusterNodeMaintenanceMode +Export-ModuleMember -function Exit-OVClusterNodeMaintenanceMode + +# Facilities +Export-ModuleMember -function Get-OVRack +Export-ModuleMember -function New-OVRack +Export-ModuleMember -function Set-OVRack +Export-ModuleMember -function Add-OVResourceToRack +Export-ModuleMember -function Set-OVRackMemberLocation +Export-ModuleMember -function Get-OVRackMember +Export-ModuleMember -function Remove-OVRackMember +Export-ModuleMember -function Remove-OVRack +Export-ModuleMember -function Get-OVDatacenter +Export-ModuleMember -function New-OVDatacenter +Export-ModuleMember -function Add-OVRackToDataCenter +Export-ModuleMember -function Set-OVDataCenterRemoteSupport +Export-ModuleMember -function Set-OVDatacenter +Export-ModuleMember -function Remove-OVDatacenter + +# Index: +Export-ModuleMember -function Search-OVIndex +Export-ModuleMember -function Search-OVAssociations + +# Tasks: +Export-ModuleMember -function Get-OVTask +Export-ModuleMember -function Wait-OVTaskStart -Alias Wait-OVTaskAccepted +Export-ModuleMember -function Wait-OVTaskComplete + +# Security: +Export-ModuleMember -function Get-OVUser +Export-ModuleMember -function New-OVUser +Export-ModuleMember -function Set-OVUser +Export-ModuleMember -function Set-OVUserPassword +Export-ModuleMember -function Remove-OVUser +Export-ModuleMember -function Show-OVUserSession +Export-ModuleMember -function Get-OVRole +Export-ModuleMember -function Set-OVUserRole -Alias Set-OVRole +Export-ModuleMember -function Set-OVInitialPassword +Export-ModuleMember -function Get-OVLdap +Export-ModuleMember -function Get-OVLdapDirectory +Export-ModuleMember -function New-OVLdapDirectory -Alias New-OVLdap +Export-ModuleMember -function Set-OVLdapDefaultDirectory +Export-ModuleMember -function Enable-OVLdapLocalLogin +Export-ModuleMember -function Disable-OVLdapLocalLogin +Export-ModuleMember -function New-OVLdapServer +Export-ModuleMember -function Add-OVLdapServer +Export-ModuleMember -function Remove-OVLdapServer +Export-ModuleMember -function Set-OVLdapGroupRole +Export-ModuleMember -function Remove-OVLdapDirectory -Alias Remove-OVLdap +Export-ModuleMember -function Show-OVLdapGroups +Export-ModuleMember -function Get-OVLdapGroup +Export-ModuleMember -function New-OVLdapGroup +Export-ModuleMember -function Set-OVLdapGroup +Export-ModuleMember -function Remove-OVLdapGroup +Export-ModuleMember -function Get-OVAuditLog +Export-ModuleMember -function Get-OVAuditLogArchive +Export-ModuleMember -function Get-OVLoginMessage +Export-ModuleMember -function Set-OVLoginMessage +Export-ModuleMember -function Get-OVScope +Export-ModuleMember -function New-OVScope +Export-ModuleMember -function Remove-OVScope +Export-ModuleMember -function Add-OVResourceToScope +Export-ModuleMember -function Remove-OVResourceFromScope +Export-ModuleMember -function Get-OVApplianceServiceConsoleAccess +Export-ModuleMember -function Enable-OVApplianceServiceConsoleAccess +Export-ModuleMember -function Disable-OVApplianceServiceConsoleAccess +Export-ModuleMember -function Enable-OVApplianceComplexPasswords +Export-ModuleMember -function Disable-OVApplianceComplexPasswords +Export-ModuleMember -function Get-OVApplianceSshAccess +Export-ModuleMember -function Enable-OVApplianceSshAccess +Export-ModuleMember -function Disable-OVApplianceSshAccess +Export-ModuleMember -function Enable-OVCertificateValidation +Export-ModuleMember -function Disable-OVCertificateValidation +Export-ModuleMember -function Enable-OVCertificateRevocationChecking +Export-ModuleMember -function Set-OVCertificateRevocationInterval +Export-ModuleMember -function Disable-OVCertificateRevocationChecking +Export-ModuleMember -function Get-OVApplianceTwoFactorAuthentication +Export-ModuleMember -function Disable-OVApplianceTwoFactorAuthentication +Export-ModuleMember -function Set-OVApplianceTwoFactorAuthentication +Export-ModuleMember -function Get-OVApplianceAvailableSecurityMode +Export-ModuleMember -function Get-OVApplianceCurrentSecurityMode +Export-ModuleMember -function Set-OVApplianceCurrentSecurityMode +Export-ModuleMember -function Get-OVApplianceSecurityProtocol +Export-ModuleMember -function Set-OVApplianceSecurityProtocol +Export-ModuleMember -function Show-OVApplianceSecurityModeCompatibilityReport +Export-ModuleMember -function Enable-OVApplianceStrictSecurityCipherSuite +Export-ModuleMember -function Disable-OVApplianceStrictSecurityCipherSuite + +# Alerts: +Export-ModuleMember -function Get-OVAlert +Export-ModuleMember -function Get-OVServiceAlert +Export-ModuleMember -function Set-OVAlert +Export-ModuleMember -function Set-OVAlertAssignToUser +Export-ModuleMember -function Clear-OVAlert +Export-ModuleMember -function Remove-OVAlert +Export-ModuleMember -function Set-OVSmtpConfig +Export-ModuleMember -function Get-OVSmtpConfig +Export-ModuleMember -function Add-OVSmtpAlertEmailFilter +Export-ModuleMember -function Get-OVSmtpAlertEmailFilter +Export-ModuleMember -function Set-OVSmtpAlertEmailFilter +Export-ModuleMember -function Remove-OVSmtpAlertEmailFilter +Export-ModuleMember -function Get-OVServerProfileMessage +Export-ModuleMember -function Test-OVEmailAlert + +# Licensing: +Export-ModuleMember -function Get-OVLicense +Export-ModuleMember -function New-OVLicense +Export-ModuleMember -function Remove-OVLicense + +####################################################### +# Library Global Settings Init +# + +# Needed to support non-Windows PowerShell environments +$private:IsWindows = if (-not (Get-Variable -Name IsWindows -ErrorAction SilentlyContinue)) { $True } else { $IsWindows } + +if ($private:IsWindows) +{ + + If (-not(Test-Path "HKCU:\Software\Hewlett-Packard\HPEOneView" -ErrorAction SilentlyContinue)) + { + + New-Item "HKCU:\Software\Hewlett-Packard\HPEOneView" -force | Out-Null + + } + + # Check to see if Global Policy is set first. + $regkeyGlobal = "HKLM:\Software\Hewlett-Packard\HPEOneView" + $regkeyUser = "HKCU:\Software\Hewlett-Packard\HPEOneView" + $UserUseMSDSC = [Bool](Get-ItemProperty -LiteralPath $regkeyUser -ea SilentlyContinue).'UseMSDSC' + $PesterRun = Get-Variable -Name PesterTest -Scope Global -ErrorAction SilentlyContinue + + Write-Verbose "$regkeyUser exists: $(Test-Path $regkeyUser)" -verbose:$script:ModuleVerbose + Write-Verbose "UseMSDSC Enabled: $($UserUseMSDSC)" -verbose:$script:ModuleVerbose + + # Override Write-Host for MSDSC + if ((Test-Path $regkeyUser) -and ($UserUseMSDSC)) + { + + function Write-Host + { + + [CmdletBinding ()] + Param + ( + + [Parameter (Mandatory = $false, ValueFromPipeline)] + [Object]$Object, + + [Parameter (Mandatory = $false)] + [Object]$Object2, + + [Parameter (Mandatory = $false)] + [Object]$Object3, + + [Switch]$NoNewLine, + + [ConsoleColor]$ForegroundColor, + + [ConsoleColor]$BackgroundColor + + ) + + # Override default Write-Host... + Write-Verbose $Object -verbose:$script:ModuleVerbose + + } + + function Get-Host + { + + [CmdletBinding ()] + Param() + + Return [PSCustomObject]$Width = @{ UI = @{ RawUI = @{ MaxWindowSize = @{ width = 120 } } } } + + } + + } + +} + +if ($PesterRun) +{ + + function Write-Host + { + + [CmdletBinding ()] + Param + ( + + [Parameter (Mandatory = $false, ValueFromPipeline)] + [Object]$Object, + + [Parameter (Mandatory = $false)] + [Object]$Object2, + + [Parameter (Mandatory = $false)] + [Object]$Object3, + + [Switch]$NoNewLine, + + [ConsoleColor]$ForegroundColor, + + [ConsoleColor]$BackgroundColor + + ) + + # Override default Write-Host... + Out-Null + + } + +} + +####################################################### +# Remove-Module Processing +# + +$ExecutionContext.SessionState.Module.OnRemove = { + + "[{0}] Cleaning up" -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose -verbose:$script:ModuleVerbose + + 'PesterTest','CallStack', 'ConnectedSessions','FCNetworkFabricTypeEnum','GetUplinkSetPortSpeeds','SetUplinkSetPortSpeeds','LogicalInterconnectConsistencyStatusEnum','UplinkSetNetworkTypeEnum','UplinkSetEthNetworkTypeEnum','LogicalInterconnectGroupRedundancyEnum','IgnoreCertPolicy','ResponseErrorObject' | ForEach-Object { Remove-Variable -Name $_ -Scope Global -ErrorAction SilentlyContinue } + +} + + + + + + + diff --git a/HPEOneView.900_93487b26-37bd-4c1a-bbe9-596baa795520_HelpInfo.xml b/HPEOneView.900_93487b26-37bd-4c1a-bbe9-596baa795520_HelpInfo.xml new file mode 100644 index 0000000..bf01358 --- /dev/null +++ b/HPEOneView.900_93487b26-37bd-4c1a-bbe9-596baa795520_HelpInfo.xml @@ -0,0 +1,10 @@ + + + http://hewlettpackard.github.io/POSH-HPEOneView/UpdateHelp + + + en-US + 9.0.4010.1836 + + + \ No newline at end of file diff --git a/HPEOneView.900_93487b26-37bd-4c1a-bbe9-596baa795520_ModuleInfo.xml b/HPEOneView.900_93487b26-37bd-4c1a-bbe9-596baa795520_ModuleInfo.xml new file mode 100644 index 0000000..b1b2e3a --- /dev/null +++ b/HPEOneView.900_93487b26-37bd-4c1a-bbe9-596baa795520_ModuleInfo.xml @@ -0,0 +1,5 @@ + + + http://hewlettpackard.github.io/POSH-HPEOneView/UpdateHelp + 9.0.4010.1835 + \ No newline at end of file diff --git a/Networking.format.ps1xml b/Networking.format.ps1xml new file mode 100644 index 0000000..6aa5414 --- /dev/null +++ b/Networking.format.ps1xml @@ -0,0 +1,3508 @@ + + + + + NetworkResources + + HPEOneView.Networking.EthernetNetwork + HPEOneView.Networking.FibreChannelNetwork + HPEOneView.Networking.FCoENetwork + HPEOneView.Networking.RoCENetwork + + + + LIGResources + + HPEOneView.Networking.LogicalInterconnectGroup + HPEOneView.Networking.SasLogicalInterconnectGroup + + + + InterconnectResources + + HPEOneView.Networking.Interconnect + HPEOneView.Networking.SasInterconnect + + + + + + + NetworkResources-GroupingFormat + + + + + + 4 + + Type: + + + Switch ($_.category) { + + 'ethernet-networks' { "Ethernet" } + 'fc-networks' { "Fibre Channel" } + 'roce-networks' { "RoCE" } + 'fcoe-networks' { "FCoE" } + 'iscsi-networks' { "iSCSI" } + + } + + + + + + + + + + + + + InterconnectPortResources-GroupingFormat + + + + + + 4 + + Interconnect: + + "'{0}' {1} Ports" -f $_.interconnectName,$_.portType + + + + + + + + + + + + PortStatistics-GroupingFormat + + + + + + 4 + + Port Type: + + "{0}" -f $_.portConfigType + + + + + + + + + + + + LIGResources-GroupingFormat + + + + + + 4 + + Type: + + + Switch ($_.category) + { + + 'sas-logical-interconnect-groups' { "SAS-LogicalInterconnectGroup" } + default { "LogicalInterconnectGroup" } + + } + + + + + + + + + + + + + InterconnectResources-GroupingFormat + + + + + + 4 + + Type: + + + Switch ($_.category) + { + + 'sas-interconnects' { "SAS Interconnect" } + default { "Interconnect" } + + } + + + + + + + + + + + + + + + EthernetNetwork + + HPEOneView.Networking.EthernetNetwork + + + + type + NetworkResources-GroupingFormat + + + + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + + + + name + + + status + + + purpose + + + ethernetNetworkType + + + vlanId + + + + + if (-not [System.String]::IsNullOrWhiteSpace($_.subnetUri)) { '{0}' -f (Send-OVRequest -Uri $_.subnetUri -Hostname $_.ApplianceConnection.Name).networkId } + else { 'None' } + + + + + smartLink + + + privateNetwork + + + defaultTypicalBandwidth + + + defaultMaximumBandwidth + + + + + + + + + EthernetNetwork + + HPEOneView.Networking.EthernetNetwork + + + + type + NetworkResources-GroupingFormat + + + + + + + + name + + + + status + + + + ethernetNetworkType + + + + vlanId + + + + + + if (-not [System.String]::IsNullOrWhiteSpace($_.subnetUri)) { '{0}' -f (Send-OVRequest -Uri $_.subnetUri -Hostname $_.ApplianceConnection.Name).networkId } + else { 'None' } + + + + + + purpose + + + + smartLink + + + + privateNetwork + + + + defaultTypicalBandwidth + + + + defaultMaximumBandwidth + + + + + + $indexResponse = Send-OVRequest -uri "/rest/index/trees$($_.uri)?childDepth=1&parentDepth=2" -Hostname $_.ApplianceConnection.Name + if ($indexResponse.parents.UPLINK_SET_TO_NETWORK.resource) { $indexResponse.parents.UPLINK_SET_TO_NETWORK.resource.name } + else { "None" } + + + + + + + + $indexResponse = Send-OVRequest -uri "/rest/index/trees$($_.uri)?childDepth=1&parentDepth=2" -Hostname $_.ApplianceConnection.Name + if ($indexResponse.parents.server_profiles_to_networks.resource) { $indexResponse.parents.server_profiles_to_networks.resource.name } + else { "None" } + + + + + + + + $indexResponse = Send-OVRequest -uri "/rest/index/trees$($_.uri)?childDepth=1&parentDepth=2" -Hostname $_.ApplianceConnection.Name + if ($indexResponse.parents.NETWORKSET_TO_NETWORK.resource) { $indexResponse.parents.NETWORKSET_TO_NETWORK.resource.name } + else { "None" } + + + + + + + + + + + RoCENetwork + + HPEOneView.Networking.RoCENetwork + + + type + NetworkResources-GroupingFormat + + + + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + + + + name + + + status + + + ethernetNetworkType + + + vlanId + + + privateNetwork + + + defaultTypicalBandwidth + + + defaultMaximumBandwidth + + + + + + + + + RoCENetwork + + HPEOneView.Networking.RoCENetwork + + + type + NetworkResources-GroupingFormat + + + + + + + + name + + + + status + + + + ethernetNetworkType + + + + vlanId + + + + smartLink + + + + privateNetwork + + + + defaultTypicalBandwidth + + + + defaultMaximumBandwidth + + + + + + $indexResponse = Send-OVRequest -uri "/rest/index/trees$($_.uri)?childDepth=1&parentDepth=2" -Hostname $_.ApplianceConnection.Name + if ($indexResponse.parents.UPLINK_SET_TO_NETWORK.resource) { $indexResponse.parents.UPLINK_SET_TO_NETWORK.resource.name } + else { "None" } + + + + + + + + $indexResponse = Send-OVRequest -uri "/rest/index/trees$($_.uri)?childDepth=1&parentDepth=2" -Hostname $_.ApplianceConnection.Name + if ($indexResponse.parents.server_profiles_to_networks.resource) { $indexResponse.parents.server_profiles_to_networks.resource.name } + else { "None" } + + + + + + + + $indexResponse = Send-OVRequest -uri "/rest/index/trees$($_.uri)?childDepth=1&parentDepth=2" -Hostname $_.ApplianceConnection.Name + if ($indexResponse.parents.NETWORKSET_TO_NETWORK.resource) { $indexResponse.parents.NETWORKSET_TO_NETWORK.resource.name } + else { "None" } + + + + + + + + + + + FibreChannelNetwork + + HPEOneView.Networking.FibreChannelNetwork + + + + type + NetworkResources-GroupingFormat + + + + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + + + + name + + + status + + + fabricType + + + defaultTypicalBandwidth + + + defaultMaximumBandwidth + + + autoLoginRedistribution + + + linkStabilityTime + + + + if ($_.managedSanUri) { (Send-OVRequest -uri $_.managedSanUri -Hostname $_.ApplianceConnection.Name).name } + else { $Null } + + + + + + + + + + FibreChannelNetwork + + HPEOneView.Networking.FibreChannelNetwork + + + + type + NetworkResources-GroupingFormat + + + + + + + + name + + + + status + + + + fabricType + + + + + + if ($_.managedSanUri) { (Send-OVRequest -uri $_.managedSanUri -Hostname $_.ApplianceConnection.Name).name } + else { $Null } + + + + + + + + $indexResponse = Send-OVRequest "/rest/index/trees$($_.uri)?childDepth=1&parentDepth=2" -Hostname $_.ApplianceConnection.Name + if ($indexResponse.parents.MANAGED_SAN_TO_FC_NETWORK.parents.SAN_MANAGER_TO_MANAGED_SAN.resource) { $indexResponse.parents.MANAGED_SAN_TO_FC_NETWORK.parents.SAN_MANAGER_TO_MANAGED_SAN.resource.name } + else { "None" } + + + + + + defaultMaximumBandwidth + + + + defaultMaximumBandwidth + + + + + + $indexResponse = Send-OVRequest "/rest/index/trees$($_.uri)?childDepth=1&parentDepth=2" -Hostname $_.ApplianceConnection.Name + if ($indexResponse.parents.UPLINK_SET_TO_NETWORK.resource) { $indexResponse.parents.UPLINK_SET_TO_NETWORK.resource.name } + else { "None" } + + + + + + + + $indexResponse = Send-OVRequest "/rest/index/trees$($_.uri)?childDepth=1&parentDepth=2" -Hostname $_.ApplianceConnection.Name + if ($indexResponse.parents.server_profiles_to_fc_networks.resource) { $indexResponse.parents.server_profiles_to_fc_networks.resource.name } + else { "None" } + + + + + + + + $indexResponse = Send-OVRequest "/rest/index/trees$($_.uri)?childDepth=1&parentDepth=2" -Hostname $_.ApplianceConnection.Name + if ($indexResponse.parents.FC_NETWORK_TO_STORAGE_SYSTEM.resource) { $indexResponse.parents.FC_NETWORK_TO_STORAGE_SYSTEM.resource.name } + else { "None" } + + + + + + + + + + + FCoENetwork + + HPEOneView.Networking.FCoENetwork + + + type + NetworkResources-GroupingFormat + + + + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + + + + name + + + status + + + vlanId + + + defaultTypicalBandwidth + + + defaultMaximumBandwidth + + + + if ($_.managedSanUri) { (Send-OVRequest -uri $_.managedSanUri -Hostname $_.ApplianceConnection.Name).name } + else { $Null } + + + + + + + + + + FCoENetwork + + HPEOneView.Networking.FCoENetwork + + + + type + NetworkResources-GroupingFormat + + + + + + + + name + + + + status + + + + vlanId + + + + defaultMaximumBandwidth + + + + defaultMaximumBandwidth + + + + + if ($_.managedSanUri) { (Send-OVRequest -uri $_.managedSanUri -Hostname $_.ApplianceConnection.Name).name } + else { $Null } + + + + + + + $indexResponse = Send-OVRequest "/rest/index/trees$($_.uri)?childDepth=1&parentDepth=2" -Hostname $_.ApplianceConnection.Name + if ($indexResponse.parents.MANAGED_SAN_TO_FC_NETWORK.parents.SAN_MANAGER_TO_MANAGED_SAN.resource) { $indexResponse.parents.MANAGED_SAN_TO_FC_NETWORK.parents.SAN_MANAGER_TO_MANAGED_SAN.resource.name } + else { $Null } + + + + + + + + $indexResponse = Send-OVRequest "/rest/index/trees$($_.uri)?childDepth=1&parentDepth=2" -Hostname $_.ApplianceConnection.Name + if ($indexResponse.parents.UPLINK_SET_TO_NETWORK.resource) { $indexResponse.parents.UPLINK_SET_TO_NETWORK.resource.name } + else { $Null } + + + + + + + + $indexResponse = Send-OVRequest "/rest/index/trees$($_.uri)?childDepth=1&parentDepth=2" -Hostname $_.ApplianceConnection.Name + if ($indexResponse.parents.server_profiles_to_fc_networks.resource) { $indexResponse.parents.server_profiles_to_fc_networks.resource.name } + else { $Null } + + + + + + + + + + + NetworkSet + + HPEOneView.Networking.NetworkSet + + + + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + + + + + name + + + typicalBandwidth + + + maximumBandwidth + + + + $ApplianceConnection = $_.ApplianceConnection.Name + $_.networkUris | % { + + (Send-OVRequest $_ -Hostname $ApplianceConnection).name + + } + + + + + + $indexResponse = Send-OVRequest "/rest/index/trees$($_.uri)?childDepth=1&parentDepth=2" -hostname $_.ApplianceConnection.Name + if ($indexResponse.parents.server_profiles_to_networks.resource) { $indexResponse.parents.server_profiles_to_networks.resource.name } + else { "None" } + + + + + + + $indexResponse = Send-OVRequest "/rest/index/trees$($_.uri)?childDepth=1&parentDepth=2" -hostname $_.ApplianceConnection.Name + if ($indexResponse.parents.SERVER_PROFILE_TEMPLATE_TO_NETWORK.resource) { $indexResponse.parents.SERVER_PROFILE_TEMPLATE_TO_NETWORK.resource.name } + else { "None" } + + + + + + + + + + + NetworkSet + + HPEOneView.Networking.NetworkSet + + + + + + + + name + + + + typicalBandwidth + + + + maximumBandwidth + + + + + $ApplianceConnection = $_.ApplianceConnection.Name + $_.networkUris | % { + + (Send-OVRequest $_ -Hostname $ApplianceConnection).name + + } + + + + + + (Send-OVRequest $_.nativeNetworkUri -Hostname $_.ApplianceConnection.Name).name + + + + + + + $indexResponse = Send-OVRequest "/rest/index/trees$($_.uri)?childDepth=1&parentDepth=2" -hostname $_.ApplianceConnection.Name + if ($indexResponse.parents.server_profiles_to_networks.resource) { $indexResponse.parents.server_profiles_to_networks.resource.name } + else { "None" } + + + + + + + + $indexResponse = Send-OVRequest "/rest/index/trees$($_.uri)?childDepth=1&parentDepth=2" -hostname $_.ApplianceConnection.Name + if ($indexResponse.parents.SERVER_PROFILE_TEMPLATE_TO_NETWORK.resource) { $indexResponse.parents.SERVER_PROFILE_TEMPLATE_TO_NETWORK.resource.name } + else { "None" } + + + + + + + + + + + LogicalInterconnectGroup + + HPEOneView.Networking.LogicalInterconnectGroup + + + category + LIGResources-GroupingFormat + + + + + + + Left + + + + Left + + + + + + + name + + + + $indexResults = Send-OVRequest "/rest/index/associations?childUri=$($_.uri)&name=ENCLOSURE_GROUP_TO_LOGICAL_INTERCONNECT_GROUP" -hostname $_.ApplianceConnection.Name + ($indexResults.members | % { Send-OVRequest $_.parentUri -hostname $_.ApplianceConnection.Name}).name + + + + + + + + + + LogicalInterconnectGroup + + HPEOneView.Networking.LogicalInterconnectGroup + + + category + LIGResources-GroupingFormat + + + + + + + + name + + + + + $indexResults = Send-OVRequest "/rest/index/associations?childUri=$($_.uri)&name=ENCLOSURE_GROUP_TO_LOGICAL_INTERCONNECT_GROUP" -hostname $_.ApplianceConnection.Name + ($indexResults.members | % { Send-OVRequest $_.parentUri -hostname $_.ApplianceConnection.Name}).name + + + + + ethernetSettings + + + + telemetryConfiguration + + + + snmpConfiguration + + + + portMonitor + + + + + + + + + LogicalInterconnect + + HPEOneView.Networking.LogicalInterconnect + + + + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + + + + name + + + status + + + stackingHealth + + + $LogicalInterconnectConsistencyStatusEnum[$_.consistencyStatus] + + + + $hostname = $_.ApplianceConnection.Name + "{0}" -f ($_.enclosureUris | % { (send-OVrequest $_ -hostname $hostname).name } ) + + + + "{0}" -f (send-OVrequest $_.logicalInterconnectGroupUri -hostname $_.ApplianceConnection.Name).name + + + + $baseline = Send-OVRequest "$($_.uri)/firmware" -Hostname $_.ApplianceConnection.Name + if ($baseline.fwBaseline -eq 'UnDefined' -and $baseline.name -eq 'UnKnown') { $baseline.sppName = "Managed Manually" } + "{0}" -f $baseline.sppName + + + + + + + + + + LogicalInterconnect + + HPEOneView.Networking.LogicalInterconnect + + + + + + + + name + + + + status + + + + stackingHealth + + + + $global:logicalInterconnectConsistencyStatusEnum[$_.consistencyStatus] + + + + + $hostname = $_.ApplianceConnection.Name + "{0}" -f ($_.enclosureUris | % { (send-OVrequest $_ -hostname $hostname).name } ) + + + + + "{0}" -f (Send-OVRequest $_.logicalInterconnectGroupUri -Hostname $_.ApplianceConnection.Name).name + + + + + $baseline = Send-OVRequest "$($_.uri)/firmware" -Hostname $_.ApplianceConnection.Name + if ($baseline.fwBaseline -eq 'UnDefined' -and $baseline.name -eq 'UnKnown') { $baseline.sppName = "Managed Manually" } + "{0}" -f $baseline.sppName + + + + + ethernetSettings + + + + telemetryConfiguration + + + + snmpConfiguration + + + + portMonitor + + + + + + + + + snmpConfiguration + + HPEOneView.Networking.LogicalInterconnect.SnmpConfiguration + + + + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + + + + enabled + + + systemContact + + + readCommunity + + + $_.trapDestinations | % { $_.trapDestination } + + + snmpAccess + + + + + + + + + snmpConfiguration + + HPEOneView.Networking.LogicalInterconnect.snmpConfiguration + + + + + + + + enabled + + + + systemContact + + + + readCommunity + + + + $_.trapDestinations | % { $_.trapDestination } + + + + snmpAccess + + + + + + + + + SnmpConfigurationDestinations + + HPEOneView.Networking.LogicalInterconnect.SnmpConfiguration.Destinations + + + + + + + + trapDestination + + + + communityString + + + + trapFormat + + + + trapSeverities + + + + vcmTrapCategories + + + + enetTrapCategories + + + + fcTrapCategories + + + + + + + + + SnmpConfigurationDestinations + + HPEOneView.Networking.LogicalInterconnect.SnmpConfiguration.Destinations + + + + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + + + + trapDestination + + + communityString + + + trapFormat + + + trapSeverities + + + vcmTrapCategories + + + enetTrapCategories + + + fcTrapCategories + + + + + + + + + QosTrafficClassifier + + HPEOneView.Networking.QosTrafficClassifier + + + + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + + + + + $_.qosTrafficClass.className + + + $_.qosTrafficClass.enabled + + + $_.qosTrafficClass.bandwidthShare + + + $_.qosTrafficClass.maxBandwidth + + + $_.qosTrafficClass.realTime + + + $_.qosTrafficClass.egressDot1pValue + + + $_.qosClassificationMapping.dot1pClassMapping + + + $_.qosClassificationMapping.dscpClassMapping + + + + + + + + + QosTrafficClassifier + + HPEOneView.Networking.QosTrafficClassifier + + + + + + + + $_.qosTrafficClass.className + + + + $_.qosTrafficClass.enabled + + + + $_.qosTrafficClass.bandwidthShare + + + + $_.qosTrafficClass.maxBandwidth + + + + $_.qosTrafficClass.realTime + + + + $_.qosTrafficClass.egressDot1pValue + + + + $_.qosClassificationMapping.dot1pClassMapping + + + + $_.qosClassificationMapping.dscpClassMapping + + + + + + + + + InterconnectSettings + + HPEOneView.Networking.LogicalInterconnect.InterconnectSettings + + + + + + + + trapDestination + + + + communityString + + + + trapFormat + + + + trapSeverities + + + + vcmTrapCategories + + + + enetTrapCategories + + + + fcTrapCategories + + + + + + + + + InterconnectSettings + + HPEOneView.Networking.LogicalInterconnect.InterconnectSettings + + + + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + + + + trapDestination + + + communityString + + + trapFormat + + + trapSeverities + + + vcmTrapCategories + + + enetTrapCategories + + + fcTrapCategories + + + + + + + + + Interconnect + + HPEOneView.Networking.Interconnect + + + type + InterconnectResources-GroupingFormat + + + + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + + + + name + + + status + + + + if ($_.state -ne 'Inventory' -and $_.state -ne 'Monitored') + { + (Send-OVRequest $_.logicalInterconnectUri -Hostname $_.ApplianceConnection.Name).name + } + + else + { + 'N/A (Unmanaged)' + } + + + + state + + + powerState + + + serialNumber + + + firmwareVersion + + + model + + + + + + + + + Interconnect + + HPEOneView.Networking.Interconnect + + + type + InterconnectResources-GroupingFormat + + + + + + + + name + + + + status + + + + + if ($_.state -ne 'Inventory' -and $_.state -ne 'Monitored') + { + (Send-OVRequest $_.logicalInterconnectUri -Hostname $_.ApplianceConnection.Name).name + } + + else + { + 'N/A (Unmanaged)' + } + + + + + state + + + + powerState + + + + serialNumber + + + + $_.ipAddressList.ipAddress + + + + firmwareVersion + + + + model + + + + + + + + + InterconnectType + + HPEOneView.Networking.InterconnectType + + + + + + + Left + + + + Left + + + + + + + name + + + partNumber + + + + + + + + + InterconnectType + + HPEOneView.Networking.InterconnectType + + + + + + + + name + + + + partNumber + + + + + + + + + InterconnectUplinkPort + + HPEOneView.Networking.Interconnect.UplinkPort + + + interconnectName + + + + + + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + + + + + portName + + + + + switch ($_.configPortTypes) { + + "FibreChannel" { "FC" } + "Ethernet" { "Ethernet" } + "EnetFcoe" { "FCoE" } + + } + + + + enabled + + + "{0} [{1}]" -f $_.portStatus,$_.portStatusReason + + + (Send-OVRequest $_.associatedUplinkSetUri -Hostname $_.ApplianceConnection.Name).name + + + connectorType + + + $script:getUplinkSetPortSpeeds[$_.operationalSpeed] + + + lagId + + + + + if ($_.configPortTypes -contains "FibreChannel" -and $_.portStatus -ne "Unlinked") { "{0}" -f $_.neighbor.remoteChassisId } + elseif ($_.configPortTypes -contains "Ethernet" -and $_.portStatus -ne "Unlinked") { "{0} ({1})" -f $_.neighbor.remoteMgmtAddress,$_.neighbor.remotePortId } + elseif ($_.portStatus -eq "Unlinked") { "" } + + + + + + + + + + + InterconnectDownlinkPort + + HPEOneView.Networking.Interconnect.DownlinkPort + + + interconnectName + + + + + + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + + + + portName + + + enabled + + + "{0} [{1}]" -f $_.portStatus,$_.portStatusReason + + + + + $interconnectUri = $Null + $ApplianceConnection = $_.ApplianceConnection.Name + $portUri = $_.uri -split "/" + + #rebuild Interconnect URI + for ($i = 1; $i -le 3; $i++) { $interconnectUri += "/$($portUri[$i])" } + + #Get associated Server Hardware to Interconnect resources + $interconnectIndexCollection = Send-OVRequest "/rest/index/associations?childUri=$interconnectUri&name=BLADE_TO_INTERCONNECT" -Hostname $ApplianceConnection + + #Get Server Hardware resoruce URIs + $sh = $interconnectIndexCollection.members.parentUri | % { Send-OVRequest $_ -Hostname $ApplianceConnection } + + $downlinkPort = $_.portName -replace "d","" + $server = $sh | ? { $_.portMap.deviceSlots.physicalPorts.interconnectPort -eq $downlinkPort } + + "{0}" -f $server.name + + + + + + + $interconnectUri = $Null + $ApplianceConnection = $_.ApplianceConnection.Name + $downlinkPort = $_.portName -replace "d","" + + $portUri = $_.uri -split "/" + + #rebuild Interconnect URI + for ($i = 1; $i -le 3; $i++) { $interconnectUri += "/$($portUri[$i])" } + + $interconnectIndexCollection = Send-OVRequest "/rest/index/associations?childUri=$interconnectUri&name=BLADE_TO_INTERCONNECT" -Hostname $_.ApplianceConnection.Name + + $sh = ($interconnectIndexCollection.members.parentUri | % { Send-OVRequest $_ -Hostname $ApplianceConnection }) + + $deviceSlotDisplayHash = @{ + + "lom" = "LOM"; + "flb" = "FlexibleLOM" + "mezz" = "Mezzanine" + + } + + $sh | % { + + $_.portMap.deviceSlots | % { + + #$_.physicalPorts #-eq $Null + + if ($_.physicalPorts) { + + $port = $_ | ? { $_.physicalPorts.interconnectUri -eq $interconnectUri -and $_.physicalPorts.interconnectPort -eq $downlinkPort } + $subPort = $_.physicalPorts | ? { $_.interconnectUri -eq $interconnectUri -and $_.interconnectPort -eq $downlinkPort } + if ($port) { "{0} {1}:{2}" -f $deviceSlotDisplayHash[$port.location],$port.slotNumber,$subPort.portNumber } + + } + + } + + } + + + + + + + $interconnectUri = $Null + $ApplianceConnection = $_.ApplianceConnection.Name + $downlinkPort = $_.portName -replace "d","" + + $portUri = $_.uri -split "/" + + #rebuild Interconnect URI + for ($i = 1; $i -le 3; $i++) { $interconnectUri += "/$($portUri[$i])" } + + $interconnectIndexCollection = Send-OVRequest "/rest/index/associations?childUri=$interconnectUri&name=BLADE_TO_INTERCONNECT" -Hostname $ApplianceConnection + + #Get Server Hardware resoruce URIs + $sh = ($interconnectIndexCollection.members.parentUri | % { Send-OVRequest $_ -Hostname $ApplianceConnection }) + + #($_.ports | ? { $_.portType -eq "Downlink" }) | % { + + #$downlinkPort = $_.portName -replace "d","" + $server = $sh | ? { $_.portMap.deviceSlots.physicalPorts.interconnectPort -eq $downlinkPort } + + if ($server.serverProfileUri) { $serverProfileName = (Send-OVRequest $server.serverProfileUri -Hostname $ApplianceConnection).name } + else { $serverProfileName = $Null } + + "{0}" -f $serverProfileName + + + + + + + + + + + InterconnectUplinkPort + + HPEOneView.Networking.LogicalInterconnect.UplinkSet.Ethernet + + + networkType + + + + + + + + + + name + + + + + (Send-OVRequest $_.logicalInterconnectUri -Hostname $_.ApplianceConnection.Name).name + + + + + "{0} ({1})" -f $_.status,$_.state + + + + reachability + + + + connectionMode + + + + + + switch ($_.lacpTimer) { + + "Short" { "Short (1s)" } + "Long" { "Long (30s)" } + + } + + + + + + + + $networkNames = New-Object System.Collections.ArrayList + ForEach ($uri in $_.networkUris) { + + $net = Send-OVRequest $uri -Hostname $_.ApplianceConnection.Name + + if ($uri -eq $_.nativeNetworkUri) { $net.name += " ($($net.vlanId)) [Untagged]" } + else { $net.name += " ($($net.vlanId))" } + [void]$networkNames.Add($net.name) + + } + + $networknames + + + + + + + + + + ForEach ($port in $_.portCOnfigInfos) { + + $port = Send-OVRequest $port.portUri -Hostname $_.ApplianceConnection.Name + + "{0}:{1} ({2}/{3})" -f $port.interconnectName,$port.portName,$port.portStatus,$port.portStatusReason + + } + + + + + + + + + + + InterconnectUplinkPort + + HPEOneView.Networking.LogicalInterconnect.UplinkSet.FibreChannel + + + networkType + + + + + + + + + + name + + + + + (Send-OVRequest $_.logicalInterconnectUri -Hostname $_.ApplianceConnection.Name).name + + + + + "{0} ({1})" -f $_.status,$_.state + + + + reachability + + + + + + Switch ([String](Send-OVRequest $_.fcNetworkUris[0] -Hostname $_.ApplianceConnection.Name).autoLoginRedistribution) { + + "True" { "Auto" } + "False" { "Manual" } + + } + + + + + + + $FcNetwork = Send-OVRequest $_.fcNetworkUris[0] -Hostname $_.ApplianceConnection.Name + "{0} [{1}]" -f $FcNetwork.name,$FcNetwork.fabricType + + + + + + + + + + ForEach ($port in $_.portCOnfigInfos) { + + $port = Send-OVRequest $port.portUri -Hostname $_.ApplianceConnection.Name + + "{0}:{1} ({2}/{3})" -f $port.interconnectName,$port.portName,$port.portStatus,$port.portStatusReason + + } + + + + + + + + + + + UplinkSetEthernetUplinkPort + + HPEOneView.Networking.LogicalInterconnect.UplinkSet.Ethernet.UplinkPort + + + + + + + + + $global:_tempPortReport = Send-OVRequest $_.portUri -Hostname $_.ApplianceConnection.Name + "{0}, {1}" -f $global:_tempPortReport.interconnectName, $global:_tempPortReport.portName + + + + + + "{0}\{1}" -f $global:_tempPortReport.portStatusReason, $global:_tempPortReport.status + + + + + desiredSpeed + + + + + "{0}" -f $global:getUplinkSetPortSpeeds["$($global:_tempPortReport.operationalSpeed)"] + + + + + + "{0}" -f $global:_tempPortReport.lagId + + + + + + "{0} [{1}], {2} {3}" -f $global:_tempPortReport.neighbor.remoteSystemName,$(if (-not $global:_tempPortReport.neighbor.remoteMgmtAddress) { $global:_tempPortReport.neighbor.remoteChassisId } else {$global:_tempPortReport.neighbor.remoteMgmtAddress}),$global:_tempPortReport.neighbor.remotePortDescription, $global:_tempPortReport.neighbor.remotePortId + + + + + + + + + + UplinkSetFibreChannelUplinkPort + + HPEOneView.Networking.LogicalInterconnect.UplinkSet.FibreChannel.UplinkPort + + + + + + + + + $global:_tempPortReport = Send-OVRequest $_.portUri -Hostname $_.ApplianceConnection.Name + "{0}, {1}" -f $global:_tempPortReport.interconnectName, $global:_tempPortReport.portName + + + + + + "{0}\{1}" -f $global:_tempPortReport.portStatusReason, $global:_tempPortReport.status + + + + + desiredSpeed + + + + + "{0}" -f $global:getUplinkSetPortSpeeds["$($global:_tempPortReport.operationalSpeed)"] + + + + + + "{0}" -f $global:_tempPortReport.fcPortProperties.opOnlineReason + + + + + + "{0}" -f $global:_tempPortReport.fcPortProperties.wwpn + + + + + + + + + + PortStatisticsEthernet + + HPEOneView.Networking.PortStatistics.Ethernet + + + portConfigType + + + + + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + + + + portName + + + "{0}Kbps ({1}min)" -f ($_.advancedStatistics.receiveKilobitsPerSec -split ":")[0],($_.sampleInterval / 60) + + + "{0}Kbps ({1}min)" -f ($_.advancedStatistics.transmitKilobitsPerSec -split ":")[0],($_.sampleInterval / 60) + + + "{0}pps ({1}min)" -f ($_.advancedStatistics.receivePacketsPerSec -split ":")[0],($_.sampleInterval / 60) + + + "{0}pps ({1}min)" -f ($_.advancedStatistics.transmitPacketsPerSec -split ":")[0],($_.sampleInterval / 60) + + + "{0}pps ({1}min)" -f ($_.advancedStatistics.receiveNonunicastPacketsPerSec -split ":")[0],($_.sampleInterval / 60) + + + "{0}pps ({1}min)" -f ($_.advancedStatistics.transmitNonunicastPacketsPerSec -split ":")[0],($_.sampleInterval / 60) + + + + + + + + + PortStatisticsEthernetFL + + HPEOneView.Networking.PortStatistics.Ethernet + + + portConfigType + + + + + + + + + portName + + + + "{0}Kbps ({1}min)" -f ($_.advancedStatistics.receiveKilobitsPerSec -split ":")[0],($_.sampleInterval / 60) + + + + "{0}Kbps ({1}min)" -f ($_.advancedStatistics.transmitKilobitsPerSec -split ":")[0],($_.sampleInterval / 60) + + + + $_.commonStatistics.rfc1213IfInDiscards + + + + $_.commonStatistics.rfc1213IfOutDiscards + + + + $_.commonStatistics.rfc1213IfInErrors + + + + $_.commonStatistics.rfc1213IfOutErrors + + + + $_.commonStatistics.rfc1757StatsCRCAlignErrors + + + + $_.commonStatistics.rfc1493Dot1DBasePortMtuExceededDiscards + + + + $_.commonStatistics.rfc2665Dot3StatsFrameTooLongs + + + + + + + + + PortStatisticsFibreChannel + + HPEOneView.Networking.PortStatistics.FibreChannel + + + portConfigType + + + + + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + + + + portName + + + "{0:0.##} MB/s" -f ($_.fcStatistics.fcRxByteRate / 1MB) + + + "{0:0.##} MB/s" -f ($_.fcStatistics.fcTxByteRate / 1MB) + + + "{0}" -f $_.fcStatistics.fcTotalRxFrames + + + "{0}" -f $_.fcStatistics.fcTotalTxFrames + + + "{0}" -f $_.fcStatistics.fcTotalRxBytes + + + "{0}" -f $_.fcStatistics.fcTotalTxBytes + + + + + + + + + PortStatisticsFibreChannelFL + + HPEOneView.Networking.PortStatistics.FibreChannel + + + portConfigType + + + + + + + + + portName + + + + "{0:0.##} MB/s" -f ($_.fcStatistics.fcRxByteRate / 1MB) + + + + "{0:0.##} MB/s" -f ($_.fcStatistics.fcTxByteRate / 1MB) + + + + "{0}" -f $_.fcStatistics.fcTotalRxFrames + + + + "{0}" -f $_.fcStatistics.fcTotalRxFrames + + + + "{0}" -f $_.fcStatistics.fcInvalidCRC + + + + "{0}" -f $_.fcStatistics.fcLinkFailures + + + + "{0}" -f $_.fcStatistics.fcNumberLinkResets + + + + "{0}" -f $_.fcStatistics.fcLossOfSynchronization + + + + "{0}" -f $_.fcStatistics.fcBBCreditFrameFailures + + + + + + + + + PortStatisticsFibreChannel + + HPEOneView.Networking.MacAddressEntry + + + portConfigType + + + + + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + + + + portName + + + "{0:0.##} MB/s" -f ($_.fcStatistics.fcRxByteRate / 1MB) + + + "{0:0.##} MB/s" -f ($_.fcStatistics.fcTxByteRate / 1MB) + + + "{0}" -f $_.fcStatistics.fcTotalRxFrames + + + "{0}" -f $_.fcStatistics.fcTotalTxFrames + + + "{0}" -f $_.fcStatistics.fcTotalRxBytes + + + "{0}" -f $_.fcStatistics.fcTotalTxBytes + + + + + + + + + PortStatisticsFibreChannelFL + + HPEOneView.Networking.PortStatistics.FibreChannel + + + portConfigType + + + + + + + + + portName + + + + "{0:0.##} MB/s" -f ($_.fcStatistics.fcRxByteRate / 1MB) + + + + "{0:0.##} MB/s" -f ($_.fcStatistics.fcTxByteRate / 1MB) + + + + "{0}" -f $_.fcStatistics.fcTotalRxFrames + + + + "{0}" -f $_.fcStatistics.fcTotalRxFrames + + + + "{0}" -f $_.fcStatistics.fcInvalidCRC + + + + "{0}" -f $_.fcStatistics.fcLinkFailures + + + + "{0}" -f $_.fcStatistics.fcNumberLinkResets + + + + "{0}" -f $_.fcStatistics.fcLossOfSynchronization + + + + "{0}" -f $_.fcStatistics.fcBBCreditFrameFailures + + + + + + + + + SasLogicalInterconnectGroup + + HPEOneView.Networking.SasLogicalInterconnectGroup + + + category + LIGResources-GroupingFormat + + + + + + + Left + + + + Left + + + + Left + + + + + + + name + + + + switch ($_.type) + { + + 'sas-logical-interconnect-group' + { + + 'SAS' + + } + + default + { + + 'VC' + + } + + } + + + + + $indexResults = Send-OVRequest "/rest/index/associations?childUri=$($_.uri)&name=ENCLOSURE_GROUP_TO_LOGICAL_INTERCONNECT_GROUP" -hostname $_.ApplianceConnection.Name + ($indexResults.members | % { Send-OVRequest $_.parentUri -hostname $_.ApplianceConnection.Name}).name + + + + + + + + + + SasLogicalInterconnectGroup + + HPEOneView.Networking.SasLogicalInterconnectGroup + + + category + LIGResources-GroupingFormat + + + + + + + + name + + + + + switch ($_.type) + { + + 'sas-logical-interconnect-group' + { + + 'SAS' + + } + + default + { + + 'LIG' + + } + + } + + + + + + $indexResults = Send-OVRequest "/rest/index/associations?childUri=$($_.uri)&name=ENCLOSURE_GROUP_TO_LOGICAL_INTERCONNECT_GROUP" -hostname $_.ApplianceConnection.Name + ($indexResults.members | % { Send-OVRequest $_.parentUri -hostname $_.ApplianceConnection.Name}).name + + + + + + + + + + SasInterconnectType + + HPEOneView.Networking.SasInterconnectType + + + + + + + Left + + + + Left + + + + + + + name + + + partNumber + + + + + + + + + SasInterconnectType + + HPEOneView.Networking.SasInterconnectType + + + + + + + + name + + + + partNumber + + + + + + + + + SasInterconnect + + HPEOneView.Networking.SasInterconnect + + + category + InterconnectResources-GroupingFormat + + + + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + + + + name + + + status + + + + if ($_.state -ne 'Inventory' -or $_.state -ne 'Monitored') + { + (Send-OVRequest $_.logicalSasInterconnectUri -Hostname $_.ApplianceConnection.Name).name + } + + else + { + 'N/A (Unmanaged)' + } + + + + state + + + powerState + + + firmwareVersion + + + model + + + serialNumber + + + + + + + + + SasInterconnect + + HPEOneView.Networking.SasInterconnect + + + category + InterconnectResources-GroupingFormat + + + + + + + + name + + + + status + + + + + if ($_.state -ne 'Inventory' -or $_.state -ne 'Monitored') + { + (Send-OVRequest $_.logicalSasInterconnectUri -Hostname $_.ApplianceConnection.Name).name + } + + else + { + 'N/A (Unmanaged)' + } + + + + + state + + + + powerState + + + + interconnectIP + + + + firmwareVersion + + + + model + + + + serialNumber + + + + + + + + + SwitchType + + HPEOneView.Networking.SwitchType + + + + + + + Left + + + + Left + + + + + + + name + + + partNumber + + + + + + + + + SwitchType + + HPEOneView.Networking.SwitchType + + + + + + + + name + + + + partNumber + + + + minimumFirmwareVersion + + + + maximumFirmwareVersion + + + + + + + + + + LogicalSwitchGroup + + HPEOneView.Networking.LogicalSwitchGroup + + + + + + + Left + + + + Left + + + + Left + + + + + + + name + + + + (Send-OVRequest $_.switchMapTemplate.switchMapEntryTemplates[0].permittedSwitchTypeUri -Hostname $_.ApplianceConnection.Name).name + + + + + $_.switchMapTemplate.switchMapEntryTemplates.count + + + + + + + + + + LogicalSwitchGroup + + HPEOneView.Networking.LogicalSwitchGroup + + + + + + + + name + + + + + (Send-OVRequest $_.switchMapTemplate.switchMapEntryTemplates[0].permittedSwitchTypeUri -Hostname $_.ApplianceConnection.Name).name + + + + + $_.switchMapTemplate.switchMapEntryTemplates.count + + + + + + + + + LogicalSwitch + + HPEOneView.Networking.LogicalSwitch + + + + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + + + + name + + + managementLevel + + + status + + + $logicalInterconnectConsistencyStatusEnum[$_.consistencyStatus] + + + '{0}' -f (Send-OVRequest $_.logicalSwitchGroupUri -Hostname $_.ApplianceConnection.Name).name + + + '{0}' -f $_.logicalSwitchDomainInfo.domainId + + + "{0}" -f ($_.logicalSwitchDomainInfo.perSwitchDomain | ? vpcRole -eq 'primary').ipAddress + + + + + + + + + LogicalSwitch + + HPEOneView.Networking.LogicalSwitch + + + + + + + + name + + + + managementLevel + + + + status + + + + stackingHealth + + + + '{0}' -f (Send-OVRequest $_.logicalSwitchGroupUri -Hostname $_.ApplianceConnection.Name).name + + + + $logicalInterconnectConsistencyStatusEnum[$_.consistencyStatus] + + + + '{0}' -f $_.logicalSwitchDomainInfo.domainId + + + + "{0}" -f ($_.logicalSwitchDomainInfo.perSwitchDomain | ? vpcRole -eq 'primary').ipAddress + + + + "{0}" -f ($_.logicalSwitchDomainInfo.perSwitchDomain | ? vpcRole -eq 'secondary').ipAddress + + + + + + + + + Switch + + HPEOneView.Networking.Switch + + + + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + + + + name + + + status + + + state + + + modelName + + + firmwareVersion + + + + if ($_.logicalSwitchVPC.ipAddress) { '{0}' -f $_.logicalSwitchVPC.ipAddress } + else { '{0}' -f $_.switchManagementConnection.connectionProperties[0].value } + + + + '{0}' -f (Send-OVRequest $_.logicalSwitchUri -Hostname $_.ApplianceConnection.Name).name + + + + + + + + + Switch + + HPEOneView.Networking.Switch + + + + + + + + name + + + + status + + + + state + + + + modelName + + + + firmwareVersion + + + + '{0}' -f $_.logicalSwitchVPC.role + + + + '{0}' -f $_.logicalSwitchVPC.peer.name + + + + '{0}' -f (Send-OVRequest $_.logicalSwitchUri -Hostname $_.ApplianceConnection.Name).name + + + + + + + + + RemotePortMonitor + + HPEOneView.Networking.RemotePortMonitor + + + + + + + Left + + + + Left + + + + Left + + + + + + + + NetworkName + + + AnalyzerPort + + + MonitoredPorts + + + + + + + + + RemotePortMonitor + + HPEOneView.Networking.RemotePortMonitor + + + + + + + + NetworkName + + + + AnalyzerPort + + + + MonitoredPorts + + + + + + + + \ No newline at end of file diff --git a/PSScriptAnalyzerSettings.psd1 b/PSScriptAnalyzerSettings.psd1 new file mode 100644 index 0000000..d7440cf --- /dev/null +++ b/PSScriptAnalyzerSettings.psd1 @@ -0,0 +1,46 @@ +## The PowerShell Script Analyzer will generate a warning +## diagnostic record for this file due to a bug - +## https://github.com/PowerShell/PSScriptAnalyzer/issues/472 +#@{ +# # Only diagnostic records of the specified severity will be generated. +# # Uncomment the following line if you only want Errors and Warnings but +# # not Information diagnostic records. +Severity = @('Error','Warning') +# +# # Analyze **only** the following rules. Use IncludeRules when you want +# # to invoke only a small subset of the defualt rules. +# #IncludeRules = @('PSAvoidDefaultValueSwitchParameter', +# # 'PSMisleadingBacktick', +# # 'PSMissingModuleManifestField', +# # 'PSReservedCmdletChar', +# # 'PSReservedParams', +# # 'PSShouldProcess', +# # 'PSUseApprovedVerbs', +# # 'PSAvoidUsingAliases', +# # 'PSUseDeclaredVarsMoreThanAssigments') +# +# # Do not analyze the following rules. Use ExcludeRules when you have +# # commented out the IncludeRules settings above and want to include all +# # the default rules except for those you exclude below. +# # Note: if a rule is in both IncludeRules and ExcludeRules, the rule +# # will be excluded. +# ExcludeRules = @('PSAvoidUsingCmdletAliases') +#} +@{ + ExcludeRules = @( + 'PSUseDeclaredVarsMoreThanAssignments', + 'PSUseApprovedVerbs', + 'PSUsePSCredentialType', + 'PSAvoidUsingPlainTextForPassword', + 'PSAvoidUsingUsernameAndPasswordParams', + 'PSAvoidUsingConvertToSecureStringWithPlainText', + 'PSAvoidGlobalVars', + 'PSAvoidUsingCmdletAliases', + 'PSUseDeclaredVarsMoreThanAssignments', + 'PSAvoidDefaultValueForMandatoryParameter', + 'PSUseLiteralInitializerForHashtable', + 'PSAvoidUsingWriteHost', + 'PSUseShouldProcessForStateChangingFunctions', + 'PSUseOutputTypeCorrectly' + ) +} diff --git a/Samples/AddServers_Monitored_Sample.ps1 b/Samples/AddServers_Monitored_Sample.ps1 new file mode 100644 index 0000000..40c1d38 --- /dev/null +++ b/Samples/AddServers_Monitored_Sample.ps1 @@ -0,0 +1,118 @@ +############################################################################## +# AddServers_Monitored_Sample.ps1 +# - Example script for importing multiple servers to be monitored. +# +# VERSION 1.2 +# (C) Copyright 2013-2024 Hewlett Packard Enterprise Development LP +############################################################################## +<# +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +#> +############################################################################## + +[CmdletBinding()] +param +( + + [Parameter(Position = 0, Mandatory, HelpMessage = "Please provide the path and filename of the CSV file containing the server iLO's and crednetials.")] + [ValidateNotNullorEmpty()] + [string]$CSV, + + [Parameter(Position = 1, Mandatory, HelpMessage = "Provide the appliance FQDN or Hostname to connect to.")] + [String]$Hostname = "hpov.domain.local" + +) + +if (-not(Test-Path $CSV -PathType Leaf)) +{ + + Write-Error ("The CSV parameter value {0} does not resolve to a file. Please check the value and try again." -f $CSV) -ErrorAction Stop + +} + +if (-not (get-module HPEOneView.700)) +{ + + Import-Module HPEOneView.700 + +} + +# First connect to the HP OneView appliance +if (-not($ConnectedSessions)) +{ + + $ApplianceConnection = Connect-OVMgmt -hostname $Hostname -Credential (Get-Credential -Username Administrator -Message Password) + +} + +#Read CSV of server iLO Addresses, with account credentials +# CSV File should contain the following headers: +# +# hostname,account,password +[Array]$ServersList = Import-Csv $CSV + +$counter = 1 + +#Used to store the async task object for varification later +$AsyncTaskCollection = New-Object System.Collections.ArrayList + +Write-Progress -ID 1 -Activity ("Adding Servers to {0}" -f $ApplianceConnection.Name) -Status "Starting" -PercentComplete 0 + +$i = 1 + +$ServersList | % { + + #Pauase the processing, as only 64 concurrent async tasks are supported by the appliance + if ($counter -eq 64) + { + + Write-Host 'Sleeping for 120 seconds.' + + 1..120 | % { + + Write-Progress -id 2 -parentid 1 -Activity 'Sleeping for 2 minutes' -Status ("{0:mm\:ss}"-f (New-TimeSpan -Seconds $_ ))-PercentComplete (($_ / 120) * 100) + + Start-Sleep -Seconds 1 + + } + + Write-Progress -Activity 'Sleeping for 2 minutes' -Completed + + #Reset counter here + $counter = 1 + + } + + Write-Progress -ID 1 -Activity ("Adding Servers to {0}" -f $ApplianceConnection.Name) -Status ("Processing {0}" -f $_.hostname) -PercentComplete ($i / $ServersList.Count * 100) + + $Credential = [System.Management.Automation.PSCredential]::new($_.account, (ConvertTo-SecureString $_.password -AsPlainText -Force)) + + $Resp = Add-OVServer -hostname $_.hostname -Credential $Credential -Monitored -Async + + [void]$AsyncTaskCollection.Add($Resp) + + $counter++ + +} + +Write-Host 'We are all done.' +Write-Host ("{0} async tasks were created." -f $AsyncTaskCollection.Count) +Write-Host 'Displaying status of tasks.' + +$AsyncTaskCollection | % { Send-OVRequest $_.uri } | Sort status -Descending | Format-Table diff --git a/Samples/AddStorageSystem_Sample.ps1 b/Samples/AddStorageSystem_Sample.ps1 new file mode 100644 index 0000000..d3a9794 --- /dev/null +++ b/Samples/AddStorageSystem_Sample.ps1 @@ -0,0 +1,224 @@ +############################################################################## +# AddStorageSystem_Sample.ps1 +# - Example script for adding a supported Primera Storage System, creating Storage Pools +# and Storage Volumes +# +# VERSION 3.0 +# +# (C) Copyright 2013-2024 Hewlett Packard Enterprise Development LP +############################################################################## +<# +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +#> +############################################################################## + +if (-not (get-module HPEOneView.700)) +{ + + Import-Module HPEOneView.700 + +} + +if (-not $ConnectedSessions) +{ + + $Appliance = Read-Host 'ApplianceName' + $Credential = Get-Credential -UserName Administrator -Message Password + + $ApplianceConnection = Connect-OVMgmt -Hostname $Appliance -Credential $Credential + +} + +#Connect a Storage System using OneView Expected Connectivity +$myStorageSystem = "HPEStoreServ_1-array.contoso.com" +$myStorageSystemCreds = Get-Credential -Username 3paradm -Message "3Paradm password" + + +#Add Storage System specifying the Virtual Domain and Storage Host Ports +$params = @{ + + hostname = $myStorageSystem; + credential = $myStorageSystemCreds; + domain = "NODOMAIN" + Ports = @{ + + "0:1:1" = "3PAR SAN DA A"; + "0:1:2" = "3PAR SAN Fabric A"; + "1:1:1" = "3PAR SAN Fabric B"; + "1:1:2" = "3PAR SAN DA B" + + }; + PortGroups = @{ + + "0:1:1" = "PG_1"; + "0:1:2" = "PG_2"; + "1:1:1" = "PG_1"; + "1:1:2" = "PG_2" + + } + +} + +"Importing POD storage array: {0}" -f $params.hostname | Write-Host + +Try +{ + + Add-OVStorageSystem @params | Wait-OVTaskComplete + + Add-OVStoragePool HP-P7400-1 -poolName R1_FC_CPG | Wait-OVTaskComplete + +} + +Catch +{ + + $PSCMdlet.ThrowTerminatingError($_) + +} + +#Add a second Storage System specifying the Virtual Domain and Storage Host Ports +$myStorageSystem = "HP3Par_2-array.contoso.com" +$myStorageSystemAdmin = "3paradm" +$myStorageSystemPass = "3pardata" +$myStorageSystemDomain = "VirtualDomain1" #NOTE: The value is case sensitive. +$myStorageSystemPorts = @{ + + "1:1:1" = "Fabric A"; + "2:1:1" = "FabricA"; + "1:1:2" = "Fabric B"; + "2:1:2" = "Fabric B" +} + +$myStorageSystemPG = @{ + + "0:1:1" = "PG_1"; + "0:1:2" = "PG_2"; + "1:1:1" = "PG_1"; + "1:1:2" = "PG_2" + +} + +$params = @{ + + hostname = $myStorageSystem; + username = $myStorageSystemAdmin; + password = $myStorageSystemPass; + domain = $myStorageSystemDomain; + Ports = $myStorageSystemPorts; + PortGroups = $myStorageSystemPG + +} + +"Importing POD storage array: {0}" -f $params.hostname | Write-Host + +Try +{ + + Add-OVStorageSystem @params | Wait-OVTaskComplete + + Add-OVStoragePool -StorageSystem $myStorageSystem -PoolName R1_FC_CPG | Wait-OVTaskComplete + +} + +Catch +{ + + $PSCMdlet.ThrowTerminatingError($_) + +} + +Get-OVStorageSystem + +#Get Storage System Details +$myStorageSystem1 = Get-OVStorageSystem -Name HP3Par_1 +$myStorageSystem2 = Get-OVStorageSystem -Name HP3Par_2 + + +#Add Storage Pools in order to provision Storage Volumes +#HP3Par_1 + +Try +{ + + $myStorageSystem1 | New-OVStoragePool -PoolName "FST_CPG1" + $myStorageSystem1 | New-OVStoragePool -PoolName "FST_CPG2" + +} + +Catch +{ + + Write-Error -ErrorRecord $_ + +} + + +#HP3Par_2 + +Try +{ + + $myPools = @("FST_CPG3","FST_CPG4") + $myStorageSystem2 | New-OVStoragePool -PoolName $myPools + +} + +Catch +{ + + Write-Error -ErrorRecord $_ + +} + +Get-OVStoragePool + +$StroagePool1 = Get-OVStoragePool -Name FST_CPG1 + +#Create some volumes + +Try +{ + + 1..10 | % { New-OVStorageVolume -name Vol$_ -Pool $StroagePool1 -Size 60 } + +} + +Catch +{ + + Write-Error -ErrorRecord $_ + +} + +Try +{ + + 1..5 | % { New-OVStorageVolume -name SharedVol$_ -StoragePool FST_CPG2 -Size 250 -shared } + +} + +Catch +{ + + Write-Error -ErrorRecord $_ + +} + +Get-OVStorageVolume \ No newline at end of file diff --git a/Samples/Alerts_Sample.ps1 b/Samples/Alerts_Sample.ps1 new file mode 100644 index 0000000..e5ddeec --- /dev/null +++ b/Samples/Alerts_Sample.ps1 @@ -0,0 +1,168 @@ +############################################################################## +# Alerts_Sample.ps1 +# - Example scripts for creating a user account, and retrieving alerts specific +# to the new user. +# +# VERSION 3.1 +# +# (C) Copyright 2013-2024 Hewlett Packard Enterprise Development LP +############################################################################## +<# +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + +#> +############################################################################## +if (-not (get-module HPEOneView.630)) +{ + + Import-Module HPEOneView.700 + +} + +# First connect to the HP OneView appliance. +if (-not $ConnectedSessions) +{ + + $Appliance = Read-Host 'ApplianceName' + $Credential = Get-Credential -UserName Administrator -Message Password + + $ApplianceConnection = Connect-OVMgmt -Hostname $Appliance -Credential $Credential + +} + +# Make sure we have a local user 'Sally' +$sally = Get-OVUser -Name Sally -ErrorAction SilentlyContinue + +If (-not $sally) +{ + + Write-Host 'User Sally does not exist. Creating user account.' + + Try + { + + New-OVUser -Username Sally -fullName "Sally Test User" -password SallyPassword -Roles "Network administrator" + + } + + Catch + { + + Write-Error -ErrorRecord $_ -EA Stop + + } + +} + +Catch +{ + + Write-Error -ErrorRecord $_ -EA Stop + +} + +# Now view the list of alerts +# Note: If there is a large set of alerts on the appliance, calling Get-OVAlert (without any filters) +# can take a VERY long time! This query really needs to be filtered by category, state, etc. +Try +{ + + Get-OVAlert + +} + +Catch +{ + + Write-Error -ErrorRecord $_ -EA Stop + +} + +# Let's assign any Interconnect Bay alerts to Administrator + +Try +{ + + $alerts = Get-OVAlert -healthCategory Logical-Interconnect -alertState Active + +} + +Catch +{ + + Write-Error -ErrorRecord $_ -EA Stop + +} + +foreach ($alert in $alerts) +{ + + Try + { + + $updatedAlert = Set-OVAlert -InputObject $alert -AssignToUser Sally + + "Assigned to Sally: {0}" -f $updatedAlert.description | Write-Host + + } + + Catch + { + + Write-Error -ErrorRecord $_ -EA Stop + + } + +} + +# Clear any alerts older than one week +$alerts = Get-OVAlert -AlertState Active + +foreach ($alert in $alerts) +{ + + $created = Get-Date $alert.created + + if ((Get-Date) -gt $created.AddDays(7)) + { + + Try + { + + $updatedAlert = Clear-OVAlert $alert + + "Cleared from {0} : {1}" -f $created,$updatedAlert.description | Write-Host + + } + + Catch + { + + Write-Error -ErrorRecord $_ -EA Stop + + } + + } + +} + +#Display the active alerts for Sally, most recent first +Write-Host "Sally's active alerts:" + +Get-OVAlert -AssignedToUser Sally -AlertState Active diff --git a/Samples/ApplianceConfig_Sample.ps1 b/Samples/ApplianceConfig_Sample.ps1 new file mode 100644 index 0000000..fe79901 --- /dev/null +++ b/Samples/ApplianceConfig_Sample.ps1 @@ -0,0 +1,599 @@ +############################################################################## +# ApplianceConfig_Sample.ps1 +# - Example scripts for configuring an HPE OneView appliance (networking, NTP, +# etc.). +# +# VERSION 3.0 +# +# (C) Copyright 2013-2024 Hewlett Packard Enterprise Development LP +############################################################################## +<# +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +#> +############################################################################## + +[CmdletBinding()] +param +( + + [Parameter (Mandatory, HelpMessage = "Please provide the Appliances DHCP Address.")] + [ValidateNotNullorEmpty()] + [IPAddress]$vm_ipaddr, + + [Parameter (Mandatory, HelpMessage = "Please provide the Appliances NEW Hostname or FQDN.")] + [String]$Hostname, + + [Parameter (Mandatory, HelpMessage = "Provide a [SecureString] pr [String] object representing the new appliance Administrator password.")] + [ValidateNotNullorEmpty()] + [Object]$NewPassword, + + [Parameter (Mandatory, HelpMessage = "Please provide the Appliances NEW Static IPv4 Address.")] + [ValidateNotNullorEmpty()] + [IPAddress]$IPv4Address, + + [Parameter (Mandatory, HelpMessage = "Please provide the Appliances NEW IPv4 Subnet.")] + [ValidateNotNullorEmpty()] + [String]$IPv4SubnetMask, + + [Parameter (Mandatory, HelpMessage = "Please provide the Appliances NEW IPv4 Default Gateway.")] + [ValidateNotNullorEmpty()] + [IPAddress]$IPv4Gateway, + + [Parameter (Mandatory, HelpMessage = "Please provide the Appliances NEW IPv4 DNS Servers.")] + [ValidateNotNullorEmpty()] + [Array]$IPv4DnsServers, + + [Parameter (Mandatory, HelpMessage = "Please provide the Appliances NEW DNS Domain Name.")] + [ValidateNotNullorEmpty()] + [String]$DnsDomainName, + + [Parameter (Mandatory = $false, HelpMessage = "Please provide the Appliances NEW IPv4 NTP Servers.")] + [ValidateNotNullorEmpty()] + [Array]$IPv4NtpServers, + + [Parameter (Mandatory = $False, HelpMessage = "Please provide the Appliances NEW IPv6 Static Address.")] + [ValidateNotNullorEmpty()] + [IPAddress]$IPv6Address, + + [Parameter (Mandatory = $False, HelpMessage = "Please provide the Appliances NEW IPv6 Static Address CIDR Subnet Mask.")] + [ValidateNotNullorEmpty()] + [Int]$IPv6CidrMask + +) + +if (-not (get-module HPEOneView.700)) +{ + + Import-Module HPEOneView.700 + +} + +#region + + Write-Host 'Waiting for appliance to respond to network test.' -NoNewline + + While (-not (Test-Connection -ComputerName $vm_ipaddr.IPAddressToString -Quiet)) + { + + Write-Host '.' -NoNewline + + } + + Write-Host "" + + #Core Appliance Setup + + # Accept the EULA + if (-not (Get-OVEulaStatus -Appliance $vm_ipaddr.IPAddressToString).Accepted ) + { + + Write-Host "Accepting EULA..." + + Try + { + + $ret = Set-OVEulaStatus -SupportAccess "yes" -Appliance $vm_ipaddr.IPAddressToString + + } + + Catch + { + + $PSCMdlet.ThrowTerminatingError($_) + } + + } + + # For initial setup, connect first using "default" Administrator credentials: + Try + { + + Connect-OVMgmt -appliance $vm_ipaddr.IPAddressToString -user "Administrator" -password "admin" + + } + + catch [HPEOneView.Appliance.PasswordChangeRequired] + { + + Write-Host "Set initial password" + + Try + { + + Set-OVInitialPassword -OldPassword "admin" -NewPassword $NewPassword -Appliance $vm_ipaddr.IPAddressToString + + } + + Catch + { + + $PSCMdlet.ThrowTerminatingError($_) + + } + + } + + Catch + { + + $PSCMdlet.ThrowTerminatingError($_) + + } + + Write-Host "Reconnect with new password" + + Try + { + + $ApplianceConnection = Connect-OVMgmt -appliance $vm_ipaddr.IPAddressToString -user Administrator -password $NewPassword + + } + + Catch + { + + $PSCMdlet.ThrowTerminatingError($_) + + } + + Write-Host "Set appliance networking configuration" + + $params = @{ + + Hostname = $Hostname; + IPv4Addr = $IPv4Address.IPAddressToString; + IPv4Subnet = $IPv4SubnetMask; + IPv4Gateway = $IPv4Gateway.IPAddressToString; + DomainName = $DnsDomainName; + IPv4NameServers = $IPv4DnsServers + + } + + if ($IPv6Address) + { + + $params.Add('IPv6Type','STATIC') + $params.Add('IPv6Addr', $IPv6Address) + $params.Add('IPv6Subnet', $IPv6CidrMask) + + } + + Try + { + + $task = Set-OVApplianceNetworkConfig @params + + } + + Catch + { + + $PSCMdlet.ThrowTerminatingError($_) + + } + + if (-not($Global:ConnectedSessions | ? Name -EQ $Hostname)) + { + + Try + { + + $ApplianceConnection = Connect-OVMgmt -appliance $Hostname -user Administrator -password $NewPassword + + } + + Catch + { + + $PSCMdlet.ThrowTerminatingError($_) + + } + + } + + try + { + + Write-Host 'Setting Appliance NTP Servers' + + $Results = Set-OVApplianceDateTime -NtpServers $IPv4NtpServers + + } + + catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + Write-Host "Completed appliance networking configuration" + + $template = "WebServer" # must always use concatenated name format + $CA = "MyCA.domain.local\domain-MyCA-CA" + $csrdir = "C:\Certs\Requests" + + if (-not(Test-Path $csrdir)) + { + + New-Item -Path $csrdir -ItemType directory | Out-Null + + } + + #Process appliance certificate + $CSR = @{ + + Country = "US"; + State = "California"; + City = "Palo Alto"; + Organization = "Hewlett-Packard"; + CommonName = $Hostname; + AlternativeName = "$Hostname,hpov,$IPv4Address" + + } + + Try + { + + $request = New-OVApplianceCsr @CSR -ApplianceConnection $ApplianceConnection + + } + + Catch + { + + $PSCMdlet.ThrowTerminatingError($_) + + } + + $baseName = $Hostname + $csrFileName = "$Hostname.csr" + $cerFileName = "$Hostname.cer" + + Set-Content -path (Join-Path $csrdir -ChildPath $csrFileName) -value $request.base64Data -Force + + $csr = Get-ChildItem $csrdir | ? name -eq $csrFileName + + $parameters = "-config {0} -submit -attrib CertificateTemplate:{1} {2}\{3}.csr {2}\{3}.cer {2}\{3}.p7b" -f $CA, $template, $csrdir, $baseName + + $request = [System.Diagnostics.Process]::Start("certreq", $parameters) + + $request.WaitForExit() + + $Task = gc $csrdir\$cerFileName | Install-OVApplianceCertificate -ApplianceConnection $ApplianceConnection | Wait-OVTaskComplete + + #Configuring appliance LDAP/AD Security + $dc1 = New-OVLdapServer -Name dc1.domain.local + $dc2 = New-OVLdapServer -Name dc2.domain.local + + $AuthParams = @{ + + UserName = "ftoomey@domain.local" + Password = convertto-securestring -asplaintext "HPinv3nt" -force + + } + + Try + { + + $LdapAuthDirectory = New-OVLdapDirectory -Name 'domain.local' -AD -BaseDN 'dc=domain,dc=local' -servers $dc1,$dc2 @AuthParams + $LdapGroups = $LdapAuthDirectory | Show-OVLdapGroups @AuthParams + $InfrastructureAdminGroup = $LdapGroups | ? Name -match 'CI Manager Full' + $ServerAdminGroup = $LdapGroups | ? Name -match 'CI Manager Server' + $StorageAdminGroup = $LdapGroups | ? Name -match 'CI Manager Storage' + $NetworkAdminGroup = $LdapGroups | ? Name -match 'CI Manager Network' + New-OVLdapGroup -d $LdapAuthDirectory -GroupName $InfrastructureAdminGroup -Roles "Infrastructure administrator" @AuthParams + New-OVLdapGroup -d $LdapAuthDirectory -GroupName $NetworkAdminGroup -Roles "Network administrator" @AuthParams + New-OVLdapGroup -d $LdapAuthDirectory -GroupName $ServerAdminGroup -Roles "Server administrator" @AuthParams + New-OVLdapGroup -d $LdapAuthDirectory -GroupName $StorageAdminGroup -Roles "Storage administrator" @AuthParams + + } + + Catch + { + + $PSCMdlet.ThrowTerminatingError($_) + + } + + Try + { + + #Upload custom SPP Baseline + gci \\Server\SPP\bp-Default-Baseline-0-1.iso | Add-OVBaseline + + } + + Catch + { + + $PSCMdlet.ThrowTerminatingError($_) + + } + + Try + { + + write-host "Adding OneView license." + New-OVLicense -License '9CDC D9MA H9P9 KHVY V7B5 HWWB Y9JL KMPL FE2H 5BP4 DXAU 2CSM GHTG L762 EG4Z X3VJ KJVT D5KM EFVW DW5J G4QM M6SW 9K2P 3E82 AJYM LURN TZZP AB6X 82Z5 WHEF D9ED 3RUX BJS2 XFXC T84U R42A 58S5 XA2D WXAP GMTQ 4YLB MM2S CZU7 2E4X E8EW BGB5 BWPD CAAR YT9J 4NUG 2NJN J9UF "424710048 HPOV-NFR1 HP_OneView_16_Seat_NFR 64HTAYJH92EY"_3KB73-R2JV9-V9HS6-LYGTN-6RLYW' + + } + + Catch + { + + $PSCMdlet.ThrowTerminatingError($_) + + } + + # Create the new users + New-OVUser Nat -fullName "Nat Network Admin" -password hpinvent -roles "Network administrator" + New-OVUser Sally -fullName "Sally Server Admin" -password hpinvent -roles "Server administrator" + New-OVUser Sandy -fullName "Sandy SAN Admin" -password hpinvent -roles "Storage administrator" + New-OVUser Rheid -fullName "Rheid Read-Only" -password hpinvent -roles "Read only" + New-OVUser Bob -fullName "Bob Backup" -password hpinvent -roles "Backup administrator" + New-OVUser admin -fullName "admin" -password hpinvent -roles "Infrastructure administrator" + +#endregion + +#region + + #Resource Configuration + + $params = @{ + + hostname = "172.18.15.1"; + type = "BNA"; + username = "administrator"; + password = "password"; + UseSsl = $True + + } + + write-host "Importing BNA SAN Manager" + + Try + { + + Add-OVSanManager @params | Wait-OVTaskComplete + + } + + Catch + { + + $PSCMdlet.ThrowTerminatingError($_) + + } + + Write-Host "Creating network resources" + + # Management networks + Try + { + + New-OVNetwork -Name "VLAN 1-A" -type "Ethernet" -vlanId 1 -smartlink $true -purpose Management + New-OVNetwork -Name "VLAN 1-B" -type "Ethernet" -vlanId 1 -smartlink $true -purpose Management + + # Internal Networks + New-OVNetwork -Name "Live Migration" -type "Ethernet" -vlanId 100 -smartlink $true -purpose VMMigration + New-OVNetwork -Name "Heartbeat" -type "Ethernet" -vlanId 101 -smartlink $true -purpose Management + New-OVNetwork -Name "iSCSI Network" -type "Ethernet" -vlanId 3000 -smartlink $true -purpose ISCSI + + # VM Networks + 10,20,30,40,50 | % { New-OVNetwork -Name "VLAN $_-A" -type "Ethernet" -vlanId $_ -smartlink $true -purpose General } + 10,20,30,40,50 | % { New-OVNetwork -Name "VLAN $_-B" -type "Ethernet" -vlanId $_ -smartlink $true -purpose General } + 101,102,103,104,105 | % { New-OVNetwork -Name "Dev VLAN $_-A" -type "Ethernet" -vlanId $_ -smartlink $true -purpose General } + 101,102,103,104,105 | % { New-OVNetwork -Name "Dev VLAN $_-B" -type "Ethernet" -vlanId $_ -smartlink $true -purpose General } + + #Misc networks + New-OVNetwork -Name "My Vlan 501" -type "Ethernet" -vlanId 3000 -smartlink $true -purpose General + + $ProdNetsA = Get-OVNetwork -Name "VLAN *0-A" -ErrorAction Stop + $ProdNetsB = Get-OVNetwork -Name "VLAN *0-B" -ErrorAction Stop + $DevNetsA = Get-OVNetwork -Name "Dev VLAN *-A" -ErrorAction Stop + $DevNetsB = Get-OVNetwork -Name "Dev VLAN *-B" -ErrorAction Stop + $InternalNetworks = 'Live Migration','Heartbeat' | % { Get-OVNetwork -Name $_ -ErrorAction Stop } + + # Create the network sets + New-OVNetworkSet -Name "Prod NetSet1 A" -networks $ProdNetsA -untaggedNetwork $ProdNetsA[0] -typicalBandwidth 2500 -maximumBandwidth 10000 + New-OVNetworkSet -Name "Prod NetSet1 B" -networks $ProdNetsB -untaggedNetwork $ProdNetsB[0] -typicalBandwidth 2500 -maximumBandwidth 10000 + New-OVNetworkSet -Name "Dev Networks A" -networks $DevNetsA -untaggedNetwork $DevNetsA[0] -typicalBandwidth 2500 -maximumBandwidth 10000 + New-OVNetworkSet -Name "Dev Networks B" -networks $DevNetsB -untaggedNetwork $DevNetsB[0] -typicalBandwidth 2500 -maximumBandwidth 10000 + + # Create the FC networks: + New-OVNetwork -Name "Fabric A" -type "FibreChannel" -typicalBandwidth 4000 -autoLoginRedistribution $true -managedSan "SAN1_0" + New-OVNetwork -Name "Fabric B" -type "FibreChannel" -typicalBandwidth 4000 -autoLoginRedistribution $true -managedSan "SAN1_1" + New-OVNetwork -Name "DirectAttach A" -type "FibreChannel" -typicalBandwidth 4000 -autoLoginRedistribution $true -fabricType DirectAttach + New-OVNetwork -Name "DirectAttach B" -type "FibreChannel" -typicalBandwidth 4000 -autoLoginRedistribution $true -fabricType DirectAttach + + } + + Catch + { + + $PSCMdlet.ThrowTerminatingError($_) + + } + + Try + { + + $LigName = "Default VC FF LIG" + $Bays = @{ 1 = 'Flex2040f8'; 2 = 'Flex2040f8'} + + $SnmpDest1 = New-OVSnmpTrapDestination -Destination mysnmpserver.domain.local -Community MyR3adcommun1ty -SnmpFormat SNMPv1 -TrapSeverities critical,warning + $SnmpDest2 = New-OVSnmpTrapDestination -Destination 10.44.120.9 -Community MyR3adcommun1ty -SnmpFormat SNMPv1 -TrapSeverities critical,warning -VCMTrapCategories legacy -EnetTrapCategories Other,PortStatus,PortThresholds -FCTrapCategories Other,PortStatus + $SnmpConfig = New-OVSnmpConfiguration -ReadCommunity MyR3adC0mmun1ty -AccessList '10.44.120.9/32','172.20.148.0/22' -TrapDestinations $SnmpDest1,$SnmpDest2 + + $CreatedLig = New-OVLogicalInterconnectGroup -Name $LigName -Bays $Bays -Snmp $SnmpConfig -EnableIgmpSnooping $True -InternalNetworks $InternalNetworks | Wait-OVTaskComplete | Get-OVLogicalInterconnectGroup + + # Get FC Network Objects + $FabricA = Get-OVNetwork -Name "Fabric A" -ErrorAction Stop + $FabricB = Get-OVNetwork -Name "Fabric B" -ErrorAction Stop + $DAFabricA = Get-OVNetwork -Name "DirectAttach A" -ErrorAction Stop + $DAFabricB = Get-OVNetwork -Name "DirectAttach B" -ErrorAction Stop + + # Create Ethernet Uplink Sets + $CreatedLig = $CreatedLig | New-OVUplinkSet -Name "Uplink Set 1" -Type "Ethernet" -Networks $ProdNetsA -nativeEthNetwork $ProdNetsA[0] -UplinkPorts "BAY1:X1","BAY1:X2" -EthMode "Auto" | Wait-OVTaskComplete | Get-OVLogicalInterconnectGroup -ErrorAction Stop + $CreatedLig = $CreatedLig | New-OVUplinkSet -Name "Uplink Set 2" -Type "Ethernet" -Networks $ProdNetsB -nativeEthNetwork $ProdNetsB[0] -UplinkPorts "BAY2:X1","BAY2:X2" -EthMode "Auto" | Wait-OVTaskComplete | Get-OVLogicalInterconnectGroup -ErrorAction Stop + + # FC Uplink Sets + $CreatedLig = $CreatedLig | New-OVUplinkSet -Name "FC Fabric A" -Type "FibreChannel" -Networks $FabricA -UplinkPorts "BAY1:X7" | Wait-OVTaskComplete | Get-OVLogicalInterconnectGroup -ErrorAction Stop + $CreatedLig = $CreatedLig | New-OVUplinkSet -Name "FC Fabric B" -Type "FibreChannel" -Networks $FabricB -UplinkPorts "BAY2:X7" | Wait-OVTaskComplete | Get-OVLogicalInterconnectGroup -ErrorAction Stop + $CreatedLig = $CreatedLig | New-OVUplinkSet -Name "DA Fabric A" -Type "FibreChannel" -Networks $DAFabricA -UplinkPorts "BAY1:X3",'BAY1:X4' | Wait-OVTaskComplete | Get-OVLogicalInterconnectGroup -ErrorAction Stop + $CreatedLig = $CreatedLig | New-OVUplinkSet -Name "DA Fabric B" -Type "FibreChannel" -Networks $DAFabricB -UplinkPorts "BAY2:X3",'BAY2:X4' | Wait-OVTaskComplete | Get-OVLogicalInterconnectGroup -ErrorAction Stop + + } + + Catch + { + + $PSCMdlet.ParameterSetName + + $PSCMdlet.ThrowTerminatingError($_) + + } + + Try + { + + $EGParams = @{ + + Name = "Default EG 1" + LogicalInterConnectGroup = $CreatedLig + ConfigurationScript = 'ADD USER "admin" "Supersecretpassword" +SET USER CONTACT "admin" "" +SET USER FULLNAME "admin" "" +SET USER ACCESS "admin" ADMINISTRATOR +ASSIGN SERVER 1-16 "admin" +ASSIGN INTERCONNECT 1-8 "admin" +ASSIGN OA "admin" +ENABLE USER "admin" +hponcfg all >> end_marker + + + + + + + + + + + + + +end_marker' + } + + $EnclosureGroup = New-OVEnclosureGroup @EGParams + + } + + Catch + { + + $PSCMdlet.ThrowTerminatingError($_) + + } + + Write-host "Sleeping 30 seconds" + start-sleep -Seconds 30 + + $params = @{ + + username = "3paradm"; + password = "3pardata"; + hostname = "172.18.11.11"; + domain = "NO DOMAIN" + + } + + Write-Host "Importing storage array: $($params.hostname)" + Try + { + + $Results = Add-OVStorageSystem @params | Wait-OVTaskComplete + + $Results = Get-OVStorageSystem -ErrorAction Stop | Add-OVStoragePool -Pool 'FST_CPG1','FST_CPG2' | Wait-OVTaskComplete + + $StorageVolume = Get-OVStoragePool -Pool 'FST_CPG1' -ErrorAction Stop | New-OVStorageVolume -Name 'DO NOT DELETE' -Capacity 1 + + } + + Catch + { + + $PSCMdlet.ThrowTerminatingError($_) + + } + + #Add Encl1 + Try + { + + $EnclosureAddParams = @{ + + Hostname = '172.18.1.11'; + Username = 'administrator'; + Password = 'password'; + EnclosureGroup = $EnclosureGroup + + } + + $Results = Add-OVEnclosure @EnclosureAddParams + + } + + Catch + { + + $PSCMdlet.ThrowTerminatingError($_) + + } + + Disconnect-OVMgmt + + Remove-Module HPEOneView.630 + +#endregion \ No newline at end of file diff --git a/Samples/Appliance_Backup_Sample.ps1 b/Samples/Appliance_Backup_Sample.ps1 new file mode 100644 index 0000000..49c857f --- /dev/null +++ b/Samples/Appliance_Backup_Sample.ps1 @@ -0,0 +1,103 @@ +############################################################################## +# Appliance_Backup_Sample.ps1 +# - Example script to automate appliance backup +# +# VERSION 3.0 +# +# (C) Copyright 2013-2024 Hewlett-Packard Development Company, L.P. +############################################################################## +<# +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +#> +############################################################################## + +<# +.SYNOPSIS +Appliance Backup Automation Script + +.DESCRIPTION +This PowerShell script will assist in automating the backup of an HP OneView appliance. + +.PARAMETER Location +The directory where the appliance generated backup file will be saved to. If the directory does not exist, 'C:\HPOneView_Backup' will automatically be created. + +.INPUTS +None. + +.OUTPUTS +System.String + +.LINK +None. + +.EXAMPLE +PS C:\> .\Appliance_Backup.ps1 + +Execute the backup of an appliance with default parameters. + +.EXAMPLE +PS C:\> .\Appliance_Backup.ps1 C:\Backups\MyAppliance + +Execute the backup of an appliance, specifying an alternate directory. + +#> + +[CmdletBinding()] +Param +( + + [parameter(Mandatory = $false, Position = 0)] + [String]$Location = 'C:\HPOneView_Backup' + +) + +#Begin Command Trace for logging purposes +Start-Transcript $Location\Appliance_backup$(get-date -uformat %y%m%d).trace + +#Create directory if it doesn't exist +if (-not(Test-Path $Location)) +{ + + New-Item -ItemType Directory -Path $Location + +} + +if (-not (get-module HPEOneView.700)) +{ + + Import-Module HPEOneView.700 + +} + +if (-not $ConnectedSessions) +{ + + $Appliance = Read-Host 'ApplianceName' + $Credential = Get-Credential -UserName Administrator -Message Password + + $ApplianceConnection = Connect-OVMgmt -Hostname $Appliance -Credential $Credential + +} + +#Execute the backup +New-OVBackup -Location $Location + +"Backup Complete $(Get-Date)" + +Stop-Transcript \ No newline at end of file diff --git a/Samples/ComposerApplianceConfig_Sample.ps1 b/Samples/ComposerApplianceConfig_Sample.ps1 new file mode 100644 index 0000000..8d9748c --- /dev/null +++ b/Samples/ComposerApplianceConfig_Sample.ps1 @@ -0,0 +1,477 @@ +############################################################################## +# ComposerApplianceConfig_Sample.ps1 +# - Example scripts for configuring an HPE OneView appliance (networking, NTP, +# etc.). +# +# VERSION 3.0 +# +# (C) Copyright 2013-2024 Hewlett Packard Enterprise Development LP +############################################################################## +<# +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +#> +############################################################################## + +[CmdletBinding()] +param +( + + [Parameter (Mandatory, HelpMessage = "Provide the Appliances DHCP Address.")] + [Alias('vm_ipaddr')] + [ValidateNotNullorEmpty()] + [IPAddress]$DhcpAddress, + + [Parameter (Mandatory, HelpMessage = "Provide the Appliances NEW Hostname or FQDN.")] + [String]$Hostname, + + [Parameter (Mandatory, HelpMessage = "Provide a [SecureString] pr [String] object representing the new appliance Administrator password.")] + [ValidateNotNullorEmpty()] + [Object]$NewPassword, + + [Parameter (Mandatory, HelpMessage = "Provide the Composer Primary Virtual IP.")] + [ValidateNotNullorEmpty()] + [IPAddress]$IPv4Address, + + [Parameter (Mandatory, HelpMessage = "Provide the Appliances NEW IPv4 Subnet.")] + [ValidateNotNullorEmpty()] + [String]$IPv4SubnetMask, + + [Parameter (Mandatory, HelpMessage = "Provide the Appliances NEW IPv4 Default Gateway.")] + [ValidateNotNullorEmpty()] + [IPAddress]$IPv4Gateway, + + [Parameter (Mandatory, HelpMessage = "Provide the Appliances NEW IPv4 DNS Servers.")] + [ValidateNotNullorEmpty()] + [Array]$IPv4DnsServers, + + [Parameter (Mandatory, HelpMessage = "Provide the Appliances NEW DNS Domain Name.")] + [ValidateNotNullorEmpty()] + [String]$DnsDomainName, + + [Parameter (Mandatory, HelpMessage = "Provide the Appliances NEW DNS Domain Name.")] + [ValidateNotNullorEmpty()] + [IPAddress]$ServiceIPv4Node1, + + [Parameter (Mandatory, HelpMessage = "Provide the Appliances NEW DNS Domain Name.")] + [ValidateNotNullorEmpty()] + [IPAddress]$ServiceIPv4Node2, + + [Parameter (Mandatory = $false, HelpMessage = "Provide the Appliances NEW IPv4 NTP Servers.")] + [ValidateNotNullorEmpty()] + [Array]$IPv4NtpServers, + + [Parameter (Mandatory = $False, HelpMessage = "Provide the Appliances NEW IPv6 Static Address.")] + [ValidateNotNullorEmpty()] + [IPAddress]$IPv6Address, + + [Parameter (Mandatory = $False, HelpMessage = "Provide the Appliances NEW IPv6 Static Address.")] + [ValidateNotNullorEmpty()] + [Int]$IPv6CidrMask, + + [Parameter (Mandatory = $False, HelpMessage = "Provide the Service IP for Node 1 NEW IPv6 Static Address.")] + [ValidateNotNullorEmpty()] + [IPAddress]$ServiceIPv6Node1, + + [Parameter (Mandatory = $False, HelpMessage = "Provide the Service IP for Node 2 NEW IPv6 Static Address.")] + [ValidateNotNullorEmpty()] + [IPAddress]$ServiceIPv6Node2 + +) + +if (-not (Get-Module HPEOneView.700)) +{ + + Import-Module HPEOneView.700 + +} + +#region + + Write-Host 'Waiting for appliance to respond to network test.' -NoNewline + + While (-not (Test-Connection -ComputerName $DhcpAddress.IPAddressToString -Quiet)) + { + + Write-Host '.' -NoNewline + + } + + Write-Host "" + + #Core Appliance Setup + + # Accept the EULA + if (-not (Get-OVEulaStatus -Appliance $DhcpAddress.IPAddressToString).Accepted ) + { + + Write-Host "Accepting EULA..." + + Try + { + + $ret = Set-OVEulaStatus -SupportAccess "yes" -Appliance $DhcpAddress.IPAddressToString + + } + + Catch + { + + $PSCMdlet.ThrowTerminatingError($_) + } + + } + + # For initial setup, connect first using "default" Administrator credentials: + Try + { + + Connect-OVMgmt -appliance $DhcpAddress.IPAddressToString -user "Administrator" -password "admin" + + } + + catch [HPEOneView.Appliance.PasswordChangeRequired] + { + + Write-Host "Set initial password" + + Try + { + + Set-OVInitialPassword -OldPassword "admin" -NewPassword $NewPassword -Appliance $DhcpAddress.IPAddressToString + + } + + Catch + { + + $PSCMdlet.ThrowTerminatingError($_) + + } + + } + + catch [HPEOneView.Appliance.AuthSessionException] + { + + Write-Host "Default password was already changed." + + } + + Catch + { + + $PSCMdlet.ThrowTerminatingError($_) + + } + + Write-Host "Reconnect with new password" + + Try + { + + $ApplianceConnection = Connect-OVMgmt -appliance $DhcpAddress.IPAddressToString -user Administrator -password $NewPassword + + } + + Catch + { + + $PSCMdlet.ThrowTerminatingError($_) + + } + + Write-Host "Set appliance networking configuration" + + $params = @{ + + Hostname = $Hostname; + IPv4Addr = $IPv4Address.IPAddressToString; + IPv4Subnet = $IPv4SubnetMask; + IPv4Gateway = $IPv4Gateway.IPAddressToString; + DomainName = $DnsDomainName; + IPv4NameServers = $IPv4DnsServers; + ServiceIPv4Node1 = $ServiceIPv4Node1; + ServiceIPv4Node2 = $ServiceIPv4Node2 + + } + + if ($IPv6Address) + { + + $params.Add('IPv6Type','STATIC') + $params.Add('IPv6Addr', $IPv6Address) + $params.Add('IPv6Subnet', $IPv6CidrMask) + $params.Add('ServiceIPv6Node1', $ServiceIPv6Node1) + $params.Add('ServiceIPv6Node2', $ServiceIPv6Node2) + + } + + Try + { + + $task = Set-OVApplianceNetworkConfig @params + + } + + Catch + { + + $PSCMdlet.ThrowTerminatingError($_) + + } + + if (-not($Global:ConnectedSessions | ? Name -EQ $Hostname)) + { + + Try + { + + $ApplianceConnection = Connect-OVMgmt -appliance $Hostname -user Administrator -password $NewPassword + + } + + Catch + { + + $PSCMdlet.ThrowTerminatingError($_) + + } + + } + + try + { + + Write-Host 'Setting Appliance NTP Servers' + + $Results = Set-OVApplianceDateTime -NtpServers $IPv4NtpServers + + } + + catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + #Configuring appliance LDAP/AD Security + $dc1 = New-OVLdapServer -Name dc1.domain.local + $dc2 = New-OVLdapServer -Name dc2.domain.local + + $AuthParams = @{ + + UserName = "ftoomey@domain.local" + Password = convertto-securestring -asplaintext "HPinv3nt" -force + + } + + Try + { + + $LdapAuthDirectory = New-OVLdapDirectory -Name 'domain.local' -AD -BaseDN 'dc=domain,dc=local' -servers $dc1,$dc2 @AuthParams + $LdapGroups = $LdapAuthDirectory | Show-OVLdapGroups @AuthParams + $InfrastructureAdminGroup = $LdapGroups | ? Name -match 'CI Manager Full' + $ServerAdminGroup = $LdapGroups | ? Name -match 'CI Manager Server' + $StorageAdminGroup = $LdapGroups | ? Name -match 'CI Manager Storage' + $NetworkAdminGroup = $LdapGroups | ? Name -match 'CI Manager Network' + New-OVLdapGroup -d $LdapAuthDirectory -GroupName $InfrastructureAdminGroup -Roles "Infrastructure administrator" @AuthParams + New-OVLdapGroup -d $LdapAuthDirectory -GroupName $NetworkAdminGroup -Roles "Network administrator" @AuthParams + New-OVLdapGroup -d $LdapAuthDirectory -GroupName $ServerAdminGroup -Roles "Server administrator" @AuthParams + New-OVLdapGroup -d $LdapAuthDirectory -GroupName $StorageAdminGroup -Roles "Storage administrator" @AuthParams + + } + + Catch + { + + $PSCMdlet.ThrowTerminatingError($_) + + } + + Try + { + + #Upload custom SPP Baseline + gci \\Server\software\SPP\bp-2016-07-11-00.iso | Add-OVBaseline + + } + + Catch + { + + $PSCMdlet.ThrowTerminatingError($_) + + } + + + # Create the new users + New-OVUser Nat -fullName "Nat Network Admin" -password hpinvent -roles "Network administrator" + New-OVUser Sarah -fullName "Sarah Server Admin" -password hpinvent -roles "Server administrator" + New-OVUser Sandy -fullName "Sandy SAN Admin" -password hpinvent -roles "Storage administrator" + New-OVUser Rheid -fullName "Rheid Read-Only" -password hpinvent -roles "Read only" + New-OVUser Bob -fullName "Bob Backup" -password hpinvent -roles "Backup administrator" + New-OVUser admin -fullName "admin" -password hpinvent -roles "Infrastructure administrator" + +#endregion + +#region + + #Resource Configuration + + $params = @{ + + hostname = "172.18.15.1"; + type = "BNA"; + username = "administrator"; + password = "pasword"; + UseSsl = $True + + } + + write-host "Importing BNA SAN Manager" + + Try + { + + Add-OVSanManager @params | Wait-OVTaskComplete + + } + + Catch + { + + $PSCMdlet.ThrowTerminatingError($_) + + } + + Write-Host "Creating network resources" + + # Management networks + Try + { + + New-OVNetwork -Name "MLAG VLAN 10" -type "Ethernet" -vlanId 10 -smartlink $true -purpose Management + + # Internal Networks + New-OVNetwork -Name "Internal Live Migration" -type "Ethernet" -vlanId 100 -smartlink $true -purpose VMMigration + New-OVNetwork -Name "Internal Heartbeat" -type "Ethernet" -vlanId 101 -smartlink $true -purpose Management + New-OVNetwork -Name "iSCSI Network" -type "Ethernet" -vlanId 3000 -smartlink $true -purpose ISCSI + + # VM Networks + 20,30,40,50 | % { New-OVNetwork -Name "MLAG Prod VLAN $_" -type "Ethernet" -vlanId $_ -smartlink $true -purpose General } + 101,102,103,104,105 | % { New-OVNetwork -Name "MLAG Dev VLAN $_" -type "Ethernet" -vlanId $_ -smartlink $true -purpose General } + + $AllMlagDevNetworks = Get-OVNetwork -Name "MLAG Dev VLAN" + $AllMlagNetworks = Get-OVNetwork -Name "MLAG VLAN*" + $InternalNetworks = Get-OVNetwork -Name Internal* + + # Create the network sets + New-OVNetworkSet -Name "Prod NetSet" -networks $AllMlagNetworks -untaggedNetwork $AllMlagNetworks[0] -typicalBandwidth 2500 -maximumBandwidth 10000 + New-OVNetworkSet -Name "Dev Networks A" -networks $AllMlagDevNetworks -untaggedNetwork $AllMlagDevNetworks[0] -typicalBandwidth 2500 -maximumBandwidth 10000 + + # Create the FC networks: + New-OVNetwork -Name "Fabric A" -type "FibreChannel" -typicalBandwidth 4000 -autoLoginRedistribution $true #-managedSan "SAN1_0" + New-OVNetwork -Name "Fabric B" -type "FibreChannel" -typicalBandwidth 4000 -autoLoginRedistribution $true #-managedSan "SAN1_1" + New-OVNetwork -Name "DirectAttach A" -type "FibreChannel" -typicalBandwidth 4000 -autoLoginRedistribution $true -fabricType DirectAttach + New-OVNetwork -Name "DirectAttach B" -type "FibreChannel" -typicalBandwidth 4000 -autoLoginRedistribution $true -fabricType DirectAttach + + } + + Catch + { + + $PSCMdlet.ThrowTerminatingError($_) + + } + + $params = @{ + + username = "3paradm"; + password = "3pardata"; + hostname = "172.18.11.11"; + domain = "NO DOMAIN" + + } + + Write-Host "Importing storage array: $($params.hostname)" + Try + { + + $Results = Add-OVStorageSystem @params | Wait-OVTaskComplete + + $Results = Get-OVStorageSystem | Add-OVStoragePool -Pool 'FST_CPG1','FST_CPG2' | Wait-OVTaskComplete + + } + + Catch + { + + $PSCMdlet.ThrowTerminatingError($_) + + } + + $SynergyLigParams = @{ + + Name = 'Default Synergy LIG'; + InterconnectBaySet = 3; + FabricModuleType = 'SEVC40F8'; + FrameCount = 3; + InternalNetworks = $InternalNetworks; + FabricRedundancy = 'HighlyAvailable' + Bays = @{ + Frame1 = @{Bay3 = 'SEVC40f8'; Bay6 = 'SE20ILM' }; + Frame2 = @{Bay3 = 'SE20ILM'; Bay6 = 'SEVC40f8'}; + Frame3 = @{Bay3 = 'SE20ILM'; Bay6 = 'SE20ILM'} + } + + } + + $CreatedLogicalInterconnectObject = New-OVLogicalInterconnectGroup @SynergyLigParams | Get-OVLogicalInterconnectGroup + + $UplinkSetParams = @{ + + InputObject = $CreatedLogicalInterconnectObject; + Name = 'MLag UplinkSet'; + Type = 'Ethernet'; + Networks = $AllMlagNetworks; + UplinkPorts = "Enclosure1:Bay3:Q1","Enclosure1:Bay3:Q2","Enclosure2:Bay6:Q1","Enclosure2:Bay6:Q2" + + } + + $CreateUplinkSetResults = New-OVUplinkSet @UplinkSetParams + + $LIG = Get-OVLogicalInterconnectGroup -Name 'Default Synergy LIG' + + $EgParams = @{ + + Name = 'Synergy Default EG'; + EnclosureCount = 3; + LogicalInterconnectGroupMapping = $LIG; + IPv4AddressType = 'DHCP' + + } + + $CreateEGResults = New-OVEnclosureGroup @EgParams + + Disconnect-OVMgmt + + Remove-Module HPEOneView.630 + +#endregion \ No newline at end of file diff --git a/Samples/ConfigureRemoteSupport_Sample.ps1 b/Samples/ConfigureRemoteSupport_Sample.ps1 new file mode 100644 index 0000000..fe699fb --- /dev/null +++ b/Samples/ConfigureRemoteSupport_Sample.ps1 @@ -0,0 +1,194 @@ +############################################################################## +# ConfigureRemoteSupport_Sample.ps1 +# - Example script to configure Remote Support +# +# VERSION 1.0 +# +# (C) Copyright 2013-2024 Hewlett Packard Enterprise Development LP +############################################################################## +<# +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +#> +############################################################################## + +[CmdletBinding()] +param +( + + [Parameter (Mandatory, HelpMessage = "Provide the Company Name.", ParameterSetName = 'Default')] + [Parameter (Mandatory, HelpMessage = "Provide the Company Name.", ParameterSetName = 'Default')] + [ValidateNotNullorEmpty()] + [String]$CompanyName, + + [Parameter (Mandatory = $false, HelpMessage = "Use to enable HPE marketing emails.", ParameterSetName = 'Default')] + [Parameter (Mandatory = $false, HelpMessage = "Use to enable HPE marketing emails.", ParameterSetName = 'InsightOnline')] + [Switch]$MarketingOptIn, + + [Parameter (Mandatory, HelpMessage = "Provide the authorized HPE Passport account to register the appliance with Insight Online.", ParameterSetName = 'InsightOnline')] + [ValidateNotNullorEmpty()] + [String]$InsightOnlineUsername = 'MyPassportAccount@domain.com', + + [Parameter (Mandatory, HelpMessage = "Provide the authorized HPE Passport account password to register the appliance with Insight Online.", ParameterSetName = 'InsightOnline')] + [ValidateNotNullorEmpty()] + [securestring]$InsightOnlinePassword = (ConvertTo-SecureString -String 'MyPassword' -AsPlainText -Force), + + [Parameter (Mandatory, HelpMessage = "Provide the default site Address.", ParameterSetName = 'Default')] + [Parameter (Mandatory, HelpMessage = "Provide the default site Address.", ParameterSetName = 'InsightOnline')] + [ValidateNotNullorEmpty()] + [String]$AddressLine1, + + [Parameter (Mandatory = $false, HelpMessage = "Provide the default site Address.", ParameterSetName = 'Default')] + [Parameter (Mandatory = $false, HelpMessage = "Provide the default site Address.", ParameterSetName = 'InsightOnline')] + [ValidateNotNullorEmpty()] + [String]$AddressLine2, + + [Parameter (Mandatory, HelpMessage = "Provide the default site City.", ParameterSetName = 'Default')] + [Parameter (Mandatory, HelpMessage = "Provide the default site City.", ParameterSetName = 'InsightOnline')] + [ValidateNotNullorEmpty()] + [String]$City, + + [Parameter (Mandatory, HelpMessage = "Provide the default site State or Provence.", ParameterSetName = 'Default')] + [Parameter (Mandatory, HelpMessage = "Provide the default site State or Provence.", ParameterSetName = 'InsightOnline')] + [ValidateNotNullorEmpty()] + [String]$State, + + [Parameter (Mandatory, HelpMessage = "Provide the default site Postal or Zip code.", ParameterSetName = 'Default')] + [Parameter (Mandatory, HelpMessage = "Provide the default site Postal or Zip code.", ParameterSetName = 'InsightOnline')] + [ValidateNotNullorEmpty()] + [String]$PostalCode, + + [Parameter (Mandatory, HelpMessage = "Provide the default site Country.", ParameterSetName = 'Default')] + [Parameter (Mandatory, HelpMessage = "Provide the default site Country.", ParameterSetName = 'InsightOnline')] + [ValidateNotNullorEmpty()] + [String]$Country, + + [Parameter (Mandatory, HelpMessage = "Provide the default site Timezone.", ParameterSetName = 'Default')] + [Parameter (Mandatory, HelpMessage = "Provide the default site Timezone.", ParameterSetName = 'InsightOnline')] + [ValidateNotNullorEmpty()] + [String]$TimeZone, + + [Parameter (Mandatory = $false, HelpMessage = "Provide the primary Remote Support contact as a Hashtable. Example: @{FirstName = 'Bob'; LastName = 'Smith'; Email = 'bob.smith@domain.com'; PrimaryPhone = '123-456-7890'; Language = 'en'; Default = `$true}", ParameterSetName = 'Default')] + [Parameter (Mandatory = $false, HelpMessage = "Provide the primary Remote Support contact as a Hashtable. Example: @{FirstName = 'Bob'; LastName = 'Smith'; Email = 'bob.smith@domain.com'; PrimaryPhone = '123-456-7890'; Language = 'en'; Default = `$true}")] + [ValidateNotNullorEmpty()] + [ValidateNotNullorEmpty()] + [Hashtable]$PrimaryContact, + + [Parameter (Mandatory = $false, HelpMessage = "Provide the secondary Remote Support contact as a Hashtable. Example: @{FirstName = 'Bob'; LastName = 'Smith'; Email = 'bob.smith@domain.com'; PrimaryPhone = '123-456-7890'; Language = 'en'; Default = `$true}", ParameterSetName = 'Default')] + [Parameter (Mandatory = $false, HelpMessage = "Provide the secondary Remote Support contact as a Hashtable. Example: @{FirstName = 'Bob'; LastName = 'Smith'; Email = 'bob.smith@domain.com'; PrimaryPhone = '123-456-7890'; Language = 'en'; Default = `$true}")] + [ValidateNotNullorEmpty()] + [Hashtable]$SecondaryContact, + + [Parameter (Mandatory = $false, HelpMessage = "Provide the Remote Support Reseller Partner as a Hashtable. Example: @{Name = 'My Reseller Partner'; Type = 'Reseller'; ResellerID = 1234567}", ParameterSetName = 'Default')] + [Parameter (Mandatory = $false, HelpMessage = "Provide the Remote Support Reseller Partner as a Hashtable. Example: @{Name = 'My Reseller Partner'; Type = 'Reseller'; ResellerID = 1234567}", ParameterSetName = 'InsightOnline')] + [ValidateNotNullorEmpty()] + [Hashtable]$ResellerPartner, + + [Parameter (Mandatory = $false, HelpMessage = "Provide the secondary Remote Support contact as a Hashtable. Example: @{Name = 'My Support Partner'; Type = 'Support'; ResellerID = 098765}", ParameterSetName = 'Default')] + [Parameter (Mandatory = $false, HelpMessage = "Provide the secondary Remote Support contact as a Hashtable. Example: @{Name = 'My Support Partner'; Type = 'Support'; ResellerID = 098765}", ParameterSetName = 'InsightOnline')] + [ValidateNotNullorEmpty()] + [Hashtable]$SupportPartner + + + +) + +if (-not (Get-Module HPEOneView.700)) +{ + + Import-Module POSH-HPEOneView.700 + +} + +if (-not $ConnectedSessions) +{ + + $Appliance = Read-Host 'ApplianceName' + $Credential = Get-Credential -UserName Administrator -Message Password + + $ApplianceConnection = Connect-OVMgmt -Hostname $Appliance -Credential $Credential + +} + +"Connected to appliance: {0} " -f ($ConnectedSessions | ? Default).Name | Write-Host + +#Add Primary (Default) Remote Support Contact +New-OVRemoteSupportContact @PrimaryContact + +if ($PSBoundParameters['SecondaryContact']) +{ + + New-OVRemoteSupportContact @SecondaryContact + +} + +#Set the datacenter site address +$DefaultSiteParams = @{ + + AddressLine1 = $AddressLine1; + State = $State; + City = $City; + PostalCode = $PostalCode; + Country = $Country; + TimeZone = $TimeZone + +} + +if ($PSBoundParameters['AddressLine2']) +{ + + $DefaultSiteParams.Add('AddressLine2',$AddressLine2) + +} + +Set-OVRemoteSupportDefaultSite @DefaultSiteParams + +#Add a new Reseller Partner +if ($PSBoundParameters['ResellerPartner']) +{ + + New-OVRemoteSupportPartner @ResellerPartner + +} + +#Add a new Support Partner +if ($PSBoundParameters['SupportPartner']) +{ + + New-OVRemoteSupportPartner @SupportPartner + +} + +#Register and authorize the appliance with your Company Name. Uncomment the end to enable Insight Online portal registration. +$EnableRemoteSupportParams = @{ + + CompanyName = $CompanyName; + MarketingOptIn = $MarketingOptIn.IsPresent + +} + +if ($PSCmdlet.ParameterSetName -eq 'InsightOnline') +{ + + $EnableRemoteSupportParams.Add('InsightOnlineUsername', $InsightOnlineUsername) + $EnableRemoteSupportParams.Add('InsightOnlinePassword', $InsightOnlinePassword) + +} + +Set-OVRemoteSupport @EnableRemoteSupportParams + diff --git a/Samples/Configure_IIS_WebDav_ExternalRepo_Sample.ps1 b/Samples/Configure_IIS_WebDav_ExternalRepo_Sample.ps1 new file mode 100644 index 0000000..5c9e29a --- /dev/null +++ b/Samples/Configure_IIS_WebDav_ExternalRepo_Sample.ps1 @@ -0,0 +1,300 @@ +############################################################################## +# Configure_IIS_WebDav_ExternalRepo_Sample.ps1 +# - Configure IIS WebDav server to support OneView 3.10 External Repository. +# Windows Server 2012 R2 or Windows Server 2016 +# +# VERSION 1.0 +# +# (C) Copyright 2013-2024 Hewlett Packard Enterprise Development LP +############################################################################## +<# +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +#> +############################################################################## + +[CmdletBinding()] +param +( + + [Parameter (Mandatory = $false, HelpMessage = "The IIS website name. Defaults to 'Default Web Site'.")] + [ValidateNotNullorEmpty()] + [String]$WebsiteName = 'Default Web Site', + + [Parameter (Mandatory, HelpMessage = "Specify the phyiscal path of the virtual directory.")] + [ValidateNotNullorEmpty()] + [String]$Path, + + [Parameter (Mandatory = $false, HelpMessage = "Specify the Virtual Directory Name.")] + [ValidateNotNullorEmpty()] + [String]$VirtualDirectoryName = "HPOneViewRemoteRepository", + + [Parameter (Mandatory, HelpMessage = "Specify the max size in GB for the repository.")] + [ValidateNotNullorEmpty()] + [Int]$Size, + + [Parameter (Mandatory = $false, HelpMessage = "Specify the max size in GB for the repository.")] + [Switch]$RequireSSL + +) + +function Test-IsAdmin +{ + + ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator") + +} + +if (-not(Test-IsAdmin)) +{ + + Write-Error -Message "Please run this script within an elevated PowerShell console." -Category AuthenticationError -ErrorAction Stop + +} + +$ErrorActionPreference = "Stop" +$FeatureName = 'Web-DAV-Publishing' + +if (-not(Get-WindowsFeature -Name Web-Server).Installed) +{ + + Write-Error -Message 'IIS is required to be installed. Please install the Web-Server feature on this host.' -Category NotInstalled -TargetObject 'WindowsFeature:Web-Server' + +} + + +if (-not(Get-WindowsFeature -Name $FeatureName).Installed) +{ + + Stop-Service w3svc + + Write-Host 'Installing WebDAV' -ForegroundColor Cyan + + Try + { + + $resp = Install-WindowsFeature -Name $FeatureName -IncludeManagementTools + + if ($resp.RestartNeeded -eq 'Yes') + { + + Write-Warning "A reboot is needed to complete installation. Please reboot the server, and re-run this script. It will continue the configuration of WebDAV." + + } + + Write-Host 'Done.' -ForegroundColor Green + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + Start-Service w3svc + +} + +if ((Get-WindowsFeature -Name $FeatureName).Installed -and $resp.RestartNeeded -ne 'Yes') +{ + + if (-not(Get-WindowsFeature -Name Web-Dir-Browsing).Installed) + { + + Write-Host 'Installing IIS Directory Browsing' -ForegroundColor Cyan + + Try + { + + $null = Install-WindowsFeature -Name Web-Dir-Browsing -IncludeManagementTools + + Write-Host 'Done.' -ForegroundColor Green + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + } + + Import-Module WebAdministration + + #Add Virtual Directory + Try + { + + if (-not(Test-Path IIS:\Sites\$WebsiteName\$VirtualDirectoryName)) + { + + $null = New-WebVirtualDirectory -Site $WebsiteName -Name $VirtualDirectoryName -PhysicalPath $Path + + } + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + #Check and enable Directory Browsing on the Virtual Directory + if (-not(Get-WebConfigurationProperty -Filter /system.webServer/directoryBrowse -Location "$WebsiteName/$VirtualDirectoryName" -Name enabled).Value) + { + + $null = Set-WebConfigurationProperty -Filter /system.webServer/directoryBrowse -Location "$WebsiteName/$VirtualDirectoryName" -Name enabled -Value $true + + } + + #Add custom HTTP Header for reposize + Try + { + + if (-not(Get-WebConfigurationProperty -Filter /system.webServer/httpProtocol/customHeaders -Location $WebsiteName -Name collection[name="MaxRepoSize"])) + { + + $null = Add-WebConfigurationProperty -PSPath ('MACHINE/WEBROOT/APPHOST/{0}' -f $WebsiteName) -Filter 'system.WebServer/httpProtocol/customHeaders' -Name . -Value @{name='MaxRepoSize'; value=('{0}G' -f $Size.ToString())} -ErrorAction Stop + + } + + elseif ((Get-WebConfigurationProperty -Filter /system.webServer/httpProtocol/customHeaders -Location $WebsiteName -Name collection[name="MaxRepoSize"]).Value -ne $Size.ToString()) + { + + $null = Set-WebConfigurationProperty -PSPath ('MACHINE/WEBROOT/APPHOST/{0}' -f $WebsiteName) -Filter '/system.WebServer/httpProtocol/customHeaders' -Name . -Value @{name='MaxRepoSize'; value=('{0}G' -f $Size.ToString())} -ErrorAction Stop + + } + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + #Add required MIME types + Try + { + + if (-not(Get-WebConfigurationProperty -Filter //staticContent -Location $WebsiteName -Name collection[fileExtension=".iso"])) + { + + Add-webconfigurationproperty -Filter "//staticContent" -PSPath ("IIS:\Sites\{0}" -f $WebsiteName) -name collection -value @{fileExtension='.iso'; mimeType='application/octet-stream'} + + } + + if (-not(Get-WebConfigurationProperty -Filter //staticContent -Location $WebsiteName -Name collection[fileExtension=".scexe"])) + { + + Add-webconfigurationproperty -Filter "//staticContent" -PSPath ("IIS:\Sites\{0}" -f $WebsiteName) -name collection -value @{fileExtension='.scexe'; mimeType='application/octet-stream'} + + } + + if ((Get-WebConfigurationProperty -Filter //staticContent -Location $WebsiteName -Name collection[fileExtension=".rpm"]).mimeType -ne "application/octet-stream") + { + + Set-WebConfigurationProperty -Filter "//staticContent/mimeMap[@fileExtension='.rpm']" -PSPath ("IIS:\Sites\{0}" -f $WebsiteName) -Name mimeType -Value "application/octet-stream" + + } + + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + + #Set WebDAV Access Rules + Try + { + + $NewRule = @{ + + users = "*"; + path = "*"; + access = "Read" + + } + + if (-not(Get-WebConfigurationProperty -Filter system.webServer/webdav/authoringRules -Location $WebsiteName -Name collection[users="*"])) + { + + $null = Add-WebConfiguration -Filter system.webServer/webdav/authoringRules -PSPath "MACHINE/WEBROOT/APPHOST" -Location $WebsiteName -Value $NewRule + + } + + if (-not(Get-WebConfigurationProperty -filter 'system.webServer/webdav/authoring' -Location $WebsiteName -Name Enabled).Value) + { + + [void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.Web.Administration") + + $IIS = new-object Microsoft.Web.Administration.ServerManager + $WebSite = $IIS.Sites["Default Web Site"] + + $GlobalConfig = $IIS.GetApplicationHostConfiguration() + $Config = $GlobalConfig.GetSection("system.webServer/webdav/authoring", "Default Web Site") + + if ($Config.OverrideMode -ne 'Allow') + { + + $Config.OverrideMode = "Allow" + $null = $IIS.CommitChanges() + + } + + Write-Host "Enabling WebDAV" -ForegroundColor Cyan + Set-WebConfigurationProperty -filter 'system.webServer/webdav/authoring' -Location $WebsiteName -Name enabled -Value $true + Write-Host "Done." -ForegroundColor Green + + } + + if (-not(Get-WebConfigurationProperty -filter 'system.webServer/webdav/authoring' -Location $WebsiteName -Name requireSsl).Value -and (Get-WebConfigurationProperty -filter 'system.webServer/webdav/authoring' -Location $WebsiteName -Name requireSsl).Value -ne $RequireSSL.IsPresent) + { + + Write-Host "Enabling WebDAV SSL" -ForegroundColor Cyan + Set-WebConfigurationProperty -filter 'system.webServer/webdav/authoring' -Location $WebsiteName -Name requireSsl -Value $RequireSSL.IsPresent + Write-Host "Done." -ForegroundColor Green + + } + + #Enable WebDAV properties required + Set-WebConfigurationProperty -Filter system.webServer/webdav/authoring -PSPath "MACHINE/WEBROOT/APPHOST" -Location $WebsiteName -name properties.allowAnonymousPropFind -Value $true + Set-WebConfigurationProperty -Filter system.webServer/webdav/authoring -PSPath "MACHINE/WEBROOT/APPHOST" -Location $WebsiteName -name properties.allowInfinitePropfindDepth -Value $true + + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + +} \ No newline at end of file diff --git a/Samples/CreateEnclosureGroup_Sample.ps1 b/Samples/CreateEnclosureGroup_Sample.ps1 new file mode 100644 index 0000000..0e5cf1a --- /dev/null +++ b/Samples/CreateEnclosureGroup_Sample.ps1 @@ -0,0 +1,78 @@ +############################################################################## +# CreateEnclosureGroupSample.ps1 +# - Example script for creating HPE Synergy Enclosure Group, Logical Interconnect Group, +# Logical Uplinks. +# +# VERSION 3.0 +# +# (C) Copyright 2013-2024 Hewlett Packard Enterprise Development LP +############################################################################## +<# +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +#> +############################################################################## + +if (-not (get-module HPEOneView.700)) +{ + + Import-Module HPEOneView.700 + +} + +if (-not $ConnectedSessions) +{ + + $Appliance = Read-Host 'ApplianceName' + $Credential = Get-Credential -UserName Administrator -Message Password + + $ApplianceConnection = Connect-OVMgmt -Hostname $Appliance -Credential $Credential + +} + +#Verify some Ethernet Networks exist +$networks = Get-OVNetwork -type Ethernet + +if ($networks -eq $null) +{ + + write-host "There are no defined Ethernet Networks. Please create some."; + + break + +} + +#Create the Logical Interconnect Group +$LIGName = "LIG Prod" +$Bays = @{1 = "FlexFabric";2 = "FlexFabric"} +$SNMP = @{readCommunity = "MyTr@p1"; enabled=$True; systemContact = "Network Admin"; snmpAccess = @("192.168.1.2/32","10.1.1.0/24");trapDestinations = @(@{trapDestination="myhost.local";communityString="MyTr@p2";trapFormat="SNMPv1";trapSeverities=@("Critical", "Major", "Minor", "Warning", "Normal", "Info", "Unknown");fcTrapCategories=@("PortStatus", "Other")})} + +$NewLig = New-OVLogicalInterconnectGroup -Name $LIGName -bays $bays -snmp $snmp | Wait-OVTaskComplete | Get-OVLogicalInterconnectGroup + +#Create an Ethernet Uplink Set +$Networks = "red","blue","green" | Get-OVNetwork -Type Ethernet +$FabricA = Get-OVNetwork -Name "Production Fabric A" -Type FibreChannel +$FabricB = Get-OVNetwork -Name "Production Fabric B" -Type FibreChannel +$newUT = $NewLig | New-OVUplinkSet -Name LUT1 -Type "Ethernet" -Networks $Networks -NativeEthNetwork $Networks[0] -UplinkPorts "BAY1:X4","BAY1:X5","BAY2:X4","BAY2:X5" -EthMode "Auto" +$NewLig = Get-OVLogicalInterconnectGroup -Name $LIGName +$newUT = $NewLig | New-OVUplinkSet -Name "Fabric A" -Type "FibreChannel" -Networks $FabricA -UplinkPorts "BAY1:X1,BAY1:X2" +$NewLig = Get-OVLogicalInterconnectGroup -Name $LIGName +$newUT = $NewLig | New-OVUplinkSet -Name "Fabric B" -Type "FibreChannel" -Networks $FabricB -UplinkPorts "BAY2:X1,BAY2:X2" + +# Create an enclosure group with this LIG +$enclGroup = New-OVEnclosureGroup -Name "Prod VC FlexFabric Group 1" -LogicalInterconnectGroup $NewLig diff --git a/Samples/DefineLogicalInterconnectGroup_AA_VC_Sample.ps1 b/Samples/DefineLogicalInterconnectGroup_AA_VC_Sample.ps1 new file mode 100644 index 0000000..d9f9e96 --- /dev/null +++ b/Samples/DefineLogicalInterconnectGroup_AA_VC_Sample.ps1 @@ -0,0 +1,64 @@ +############################################################################## +# DefineLogicalInterconnectGroup_AA_VC_Sample.ps1 +# - Example script for creating Logical Interconnect Group with A/A VC Networking. +# +# VERSION 3.0 +# +# (C) Copyright 2013-2024 Hewlett Packard Enterprise Development LP +############################################################################## +<# +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +#> +############################################################################## + +if (-not (get-module HPEOneView.700)) +{ + + Import-Module HPEOneView.700 + +} + +if (-not $ConnectedSessions) +{ + + $Appliance = Read-Host 'ApplianceName' + $Credential = Get-Credential -UserName Administrator -Message Password + + $ApplianceConnection = Connect-OVMgmt -Hostname $Appliance -Credential $Credential + +} + +$LIGName = "My AA Prod" +$Bays = @{1 = "FlexFabric";2 = "FlexFabric"} +$SNMP = @{readCommunity = "MyTr@p1"; enabled=$True; systemContact = "Network Admin"; snmpAccess = @("192.168.1.2/32","10.1.1.0/24");trapDestinations = @(@{trapDestination="myhost.local";communityString="MyTr@p2";trapFormat="SNMPv1";trapSeverities=@("Critical", "Major", "Minor", "Warning", "Normal", "Info", "Unknown");fcTrapCategories=@("PortStatus", "Other")})} + +$NewLig = New-OVLogicalInterconnectGroup -Name $LIGName -bays $bays -snmp $snmp | Wait-OVTaskComplete | Get-OVLogicalInterconnectGroup + +#Create an Ethernet Uplink Set +$ANetworks = Get-OVNetwork -Name 'Prod Vlan *-A' -Type Ethernet +$BNetworks = Get-OVNetwork -Name 'Prod Vlan *-B' -Type Ethernet +$FabricA = Get-OVNetwork -Name "Production Fabric A" -Type FibreChannel +$FabricB = Get-OVNetwork -Name "Production Fabric B" -Type FibreChannel +$newUT = $NewLig | New-OVUplinkSet -Name LUT1 -Type "Side A Uplink Set" -Networks $ANetworks -NativeEthNetwork $ANetworks[0] -UplinkPorts "BAY1:X4","BAY1:X5" -EthMode "Auto" +$NewLig = Get-OVLogicalInterconnectGroup -Name $LIGName +$newUT = $NewLig | New-OVUplinkSet -Name LUT1 -Type "Side B Uplink Set" -Networks $BNetworks -NativeEthNetwork $BNetworks[0] -UplinkPorts "BAY2:X4","BAY2:X5" -EthMode "Auto" +$NewLig = Get-OVLogicalInterconnectGroup -Name $LIGName +$newUT = $NewLig | New-OVUplinkSet -Name "Fabric A" -Type "FibreChannel" -Networks $FabricA -UplinkPorts "BAY1:X1,BAY1:X2" +$NewLig = Get-OVLogicalInterconnectGroup -Name $LIGName +$newUT = $NewLig | New-OVUplinkSet -Name "Fabric B" -Type "FibreChannel" -Networks $FabricB -UplinkPorts "BAY2:X1,BAY2:X2" diff --git a/Samples/DefineLogicalInterconnectGroup_Sample.ps1 b/Samples/DefineLogicalInterconnectGroup_Sample.ps1 new file mode 100644 index 0000000..8c8e0bb --- /dev/null +++ b/Samples/DefineLogicalInterconnectGroup_Sample.ps1 @@ -0,0 +1,73 @@ +############################################################################## +# DefineLogicalInterconnectGroup_Sample.ps1 +# - Example script for creating Logical Interconnect Groups. +# +# VERSION 1.0 +# +# (C) Copyright 2013-2024 Hewlett Packard Enterprise Development LP +############################################################################## +<# +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +#> +############################################################################## + +if (-not (get-module HPEOneView.700)) +{ + + Import-Module HPEOneView.700 + +} + +if (-not $ConnectedSessions) +{ + + $Appliance = Read-Host 'ApplianceName' + $Credential = Get-Credential -UserName Administrator -Message Password + + $ApplianceConnection = Connect-OVMgmt -Hostname $Appliance -Credential $Credential + +} + +#Verify some Ethernet Networks exist +$networks = Get-OVNetwork -type Ethernet + +if ($networks -eq $null) +{ + + write-host "There are no defined Ethernet Networks. Please create some."; + + break + +} + +$LIGName = "LIG Prod" +$Bays = @{1 = "FlexFabric";2 = "FlexFabric"} +$SNMP = @{readCommunity = "MyTr@p1"; enabled=$True; systemContact = "Network Admin"; snmpAccess = @("192.168.1.2/32","10.1.1.0/24");trapDestinations = @(@{trapDestination="myhost.local";communityString="MyTr@p2";trapFormat="SNMPv1";trapSeverities=@("Critical", "Major", "Minor", "Warning", "Normal", "Info", "Unknown");fcTrapCategories=@("PortStatus", "Other")})} + +$NewLig = New-OVLogicalInterconnectGroup -Name $LIGName -bays $bays -snmp $snmp | Wait-OVTaskComplete | Get-OVLogicalInterconnectGroup + +#Create an Ethernet Uplink Set +$Networks = "red","blue","green" | Get-OVNetwork -Type Ethernet +$FabricA = Get-OVNetwork -Name "Production Fabric A" -Type FibreChannel +$FabricB = Get-OVNetwork -Name "Production Fabric B" -Type FibreChannel +$newUT = $NewLig | New-OVUplinkSet -Name LUT1 -Type "Ethernet" -Networks $Networks -NativeEthNetwork $Networks[0] -UplinkPorts "BAY1:X4","BAY1:X5","BAY2:X4","BAY2:X5" -EthMode "Auto" +$NewLig = Get-OVLogicalInterconnectGroup -Name $LIGName +$newUT = $NewLig | New-OVUplinkSet -Name "Fabric A" -Type "FibreChannel" -Networks $FabricA -UplinkPorts "BAY1:X1,BAY1:X2" +$NewLig = Get-OVLogicalInterconnectGroup -Name $LIGName +$newUT = $NewLig | New-OVUplinkSet -Name "Fabric B" -Type "FibreChannel" -Networks $FabricB -UplinkPorts "BAY2:X1,BAY2:X2" diff --git a/Samples/DefineNetworks_AA_VC_Sample.ps1 b/Samples/DefineNetworks_AA_VC_Sample.ps1 new file mode 100644 index 0000000..a7a4759 --- /dev/null +++ b/Samples/DefineNetworks_AA_VC_Sample.ps1 @@ -0,0 +1,80 @@ +############################################################################## +# DefineNetworks_AA_VC_Sample.ps1 +# - Example scripts for defining A/A networks to be deployed with HP OneView. +# +# VERSION 3.0 +# +# (C) Copyright 2013-2024 Hewlett Packard Enterprise Development LP +############################################################################## +<# +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +#> +############################################################################## + +if (-not (get-module HPEOneView.700)) +{ + + Import-Module HPEOneView.700 + +} + +if (-not $ConnectedSessions) +{ + + $Appliance = Read-Host 'ApplianceName' + $Credential = Get-Credential -UserName Administrator -Message Password + + $ApplianceConnection = Connect-OVMgmt -Hostname $Appliance -Credential $Credential + +} + +# List any existing networks and network sets +write-host "Existing Networks:" +write-host "---------------------------" +write-host +Get-OVNetwork +write-host +write-host "Existing Network Sets:" +write-host "---------------------------" +write-host +Get-OVNetworkSet +write-host + +# Create some new network definitions: +$status = New-OVNetwork -Type "Ethernet" -Name "VLAN 10" -VlanId 10 -Smartlink $true +Get-OVNetwork -Name "VLAN 10" -Type Ethernet + +# Create additional Networks +20,30,40,50,60 | % { New-OVNetwork -Type "Ethernet" -Name "VLAN $_" -VlanId $_ -Smartlink $true } + +# Create Network Set, grouping 3 of these networks for convenience: +$network20 = Get-OVNetwork -Name "VLAN 20" -Type "Ethernet" +$network30 = Get-OVNetwork -Name "VLAN 30" -Type "Ethernet" +$network40 = Get-OVNetwork -Name "VLAN 40" -Type "Ethernet" +New-OVNetworkSet -Name "Production Networks" -UntaggedNetwork $network20 -Networks $network20, $network30, $network40 + +Get-OVNetworkSet -Name "Production Networks" + +# Create some FC networks: +New-OVNetwork -Name "Production Fabric A" -Type FC -typicalBandwidth 4000 -autoLoginRedistribution $true +New-OVNetwork -Name "Production Fabric B" -Type FC -typicalBandwidth 4000 -autoLoginRedistribution $true +New-OVNetwork -Name "DirectAttach Fabric A" -Type FC -typicalBandwidth 4000 -autoLoginRedistribution $true -fabrictype "DirectAttach" +New-OVNetwork -Name "DirectAttach Fabric B" -Type FC -typicalBandwidth 4000 -autoLoginRedistribution $true -fabrictype "DirectAttach" + +Get-OVNetwork \ No newline at end of file diff --git a/Samples/DefineNetworks_Sample.ps1 b/Samples/DefineNetworks_Sample.ps1 new file mode 100644 index 0000000..bb0c359 --- /dev/null +++ b/Samples/DefineNetworks_Sample.ps1 @@ -0,0 +1,84 @@ +############################################################################## +# DefineNetworks_Sample.ps1 +# - Example scripts for defining networks to be deployed with HP OneView. +# +# VERSION 3.0 +# +# (C) Copyright 2013-2024 Hewlett Packard Enterprise Development LP +############################################################################## +<# +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +#> +############################################################################## +if (-not (get-module HPEOneView.700)) +{ + + Import-Module HPEOneView.700 + +} + +if (-not $ConnectedSessions) +{ + + $Appliance = Read-Host 'ApplianceName' + $Credential = Get-Credential -UserName Administrator -Message Password + + $ApplianceConnection = Connect-OVMgmt -Hostname $Appliance -Credential $Credential + +} + +# List any existing networks and network sets +write-host "Existing Networks:" +write-host "---------------------------" +write-host +Get-OVNetwork +write-host +write-host "Existing Network Sets:" +write-host "---------------------------" +write-host +Get-OVNetworkSet +write-host + +# Create some new network definitions: +$status = New-OVNetwork -type "Ethernet" -name "red" -vlanId 10 -smartlink $true +$network10Uri = $status.Details.associatedResource.resourceUri +Write-host "Red URI: $network10Uri" + +New-OVNetwork -type "Ethernet" -name "blue" -vlanId 20 -smartlink $true +New-OVNetwork -type "Ethernet" -name "green" -vlanId 30 -smartlink $true +New-OVNetwork -type "Ethernet" -name "yellow" -vlanId 40 -smartlink $true +New-OVNetwork -type "Ethernet" -name "black" -vlanId 50 -smartlink $true + +#Use the REST API to bulk create networks +New-OVNetwork -Name "NetSuffix" -vlanRange "100-120,123,135" + +$network20 = Get-OVNetwork -name "blue" -type "Ethernet" +$network30 = Get-OVNetwork -name "green" -type "Ethernet" +$network40 = Get-OVNetwork -name "yellow" -type "Ethernet" + +# Now, create a "network set", grouping 3 of these networks for convenience: +New-OVNetworkSet -name "Production Networks" -UntaggedNetwork $network20 -Networks $network20,$network30,$network40 + +# Create some FC networks: +New-OVNetwork -name "Production Fabric A" -type FC -typicalBandwidth 4000 -autoLoginRedistribution $true +New-OVNetwork -name "Production Fabric B" -type FC -typicalBandwidth 4000 -autoLoginRedistribution $true +New-OVNetwork -name "DirectAttach Fabric A" -type FC -typicalBandwidth 4000 -autoLoginRedistribution $true -fabrictype "DirectAttach" +New-OVNetwork -name "DirectAttach Fabric B" -type FC -typicalBandwidth 4000 -autoLoginRedistribution $true -fabrictype "DirectAttach" + +Get-OVNetwork \ No newline at end of file diff --git a/Samples/Server_Multiconnection_AA_VC_Sample.ps1 b/Samples/Server_Multiconnection_AA_VC_Sample.ps1 new file mode 100644 index 0000000..b52c62e --- /dev/null +++ b/Samples/Server_Multiconnection_AA_VC_Sample.ps1 @@ -0,0 +1,167 @@ +############################################################################## +# Server_Multiconnection_Sample.ps1 +# +# Example script to demonstrate creating a Server Profile with the following: +# +# - Configure 2 NICs in paired with VLAN 10 +# - Configure 2 NICs in paired with VLAN 60 +# - Configure 2 NICs in paired with Production Networks Network Set (Production Networks) +# - Configure 2 FC connections to the Production Fabric A and B +# - Set requested bandwidth +# - Configures HPE Power Profile to Max Performance, and sets other BIOS Dependancies +# +# VERSION 1.0 +# +# (C) Copyright 2013-2024 Hewlett Packard Enterprise Development LP +############################################################################## +<# +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +#> +############################################################################## +if (-not (get-module HPEOneView.700)) +{ + + Import-Module HPEOneView.700 + +} + +if (-not $ConnectedSessions) +{ + + $Appliance = Read-Host 'ApplianceName' + $Username = Read-Host 'Username' + $Password = Read-Host 'Password' -AsSecureString + + $ApplianceConnection = Connect-OVMgmt -Hostname $Appliance -Username $Username -Password $Password + +} + +# Now view what enclosures have been imported +Write-Host "Here is the list of enclosures managed by this appliance" +Get-OVEnclosure + +# Now list all the servers that have been imported with their current state +$servers = Get-OVServer +Write-Host "There are" $servers.Count "servers managed by this appliance." +$servers | Sort-Object name | format-table -Property name, powerState, state, serverProfileUri -AutoSize + +# Make sure all the servers are powered off +ForEach ($server in $servers) { + if ($server.powerState -ne "Off") { + Write-Host "Server" $server.name "is" $server.powerState ". Powering it off..." + Set-OVServerPower -serverUri $server.uri -powerState "Off" + } +} + +# Now create a server profile for the first available server +ForEach ($server in $servers) { + if (($server.state -eq "NoProfileApplied") -and ($server.powerState -eq "Off")) { + return; + } +} + +if ($server.state -ne "NoProfileApplied") { + Write-Host "No suitable server found." + break; +} + +$profileName = "Profile-" + $server.serialNumber +Write-Host "Creating" $profileName "for server" $server.name + +# Create Connection ID's 1 and 2 +$netVlan10 = Get-OVNetwork "VLAN 10" +$conVlan10A = New-OVProfileConnection -id 1 -type Ethernet -requestedBW 1000 -network $netVlan10 +$conVlan10B = New-OVProfileConnection -id 2 -type Ethernet -requestedBW 1000 -network $netVlan10 + +# Create Connection ID's 3 and 4 +$netProdFCA = Get-OVNetwork "Production Fabric A" +$conFC1 = New-OVProfileConnection -id 3 -type FibreChannel -requestedBW 4000 -network $netProdFCA +$netProdFCB = Get-OVNetwork "Production Fabric B" +$conFC2 = New-OVProfileConnection -id 4 -type FibreChannel -requestedBW 4000 -network $netProdFCB + +# Create Connection ID's 5 and 6 +$netVlan60 = Get-OVNetwork "VLAN 60" +$conVlan60A = New-OVProfileConnection -id 5 -type Ethernet -requestedBW 2000 -network $netVlan60 +$conVlan60B = New-OVProfileConnection -id 6 -type Ethernet -requestedBW 2000 -network $netVlan60 + +# Create Connection ID's 7 and 8 +$netSetProd = Get-OVNetworkSet "Production Networks" +$conSetProdA = New-OVProfileConnection -id 7 -type Ethernet -requestedBW 3000 -network $netSetProd +$conSetProdB = New-OVProfileConnection -id 8 -type Ethernet -requestedBW 3000 -network $netSetProd + +#Build the connection list +$conList = @($conVlan10A, $conVlan10B, $conVlan60A, $conVlan60B, $conSetProdA, $conSetProdB, $conFC1, $conFC2) + +# ADVANCED SERVER SETTINGS +# First view the capabilities of the server hardware for this profile +$serverType = Send-OVRequest $server.serverHardwareTypeUri +Write-Host "Boot options for this server:" $serverType.bootCapabilities + +# Set the boot order for the server +$profileBootOrder = @("PXE", "HardDisk", "USB", "CD", "Floppy", "FibreChannelHba") + +# Configure some BIOS Settings (HP Power Profile, which will configure HP Power Regulator and other dependancies) +# Define an Array Collection +[System.Collections.ArrayList]$biosSettings = @() + +#Search for HP Power Profile BIOS Setting +$powerProfile = $serverType.biosSettings | where { $_.name -match "HPE Power Profile" } + +#Get Static High Performance Mode option ID +$maxPower = $powerProfile.options | where { $_.name -match "Maximum Performance" } + +#Save the setting +[Void]$biosSettings.add(@{ id = $powerProfile.id ; value = $maxPower.id}) + +#Check to see if there are additional BIOS Options that should be modified. +#NOTE: Setting the HP Power Profile will modify the HP Power Regulator BIOS Setting. +if ($maxPower.optionLinks) { + + foreach ($option in $maxPower.optionLinks) { + + [Void]$biosSettings.add(@{ id = $option.settingId ; value = $option.optionId}) + + } + +} + +#Create Profile +New-OVProfile -name $profileName -server Unassigned -serverHardwareType $serverType -eg "Prod VC FlexFabric Group 1" -connections $conList -manageBoot -bootOrder $bootOrder -bios -biosSettings $biosSettings | Wait-OVTaskComplete + +# Display the connections for our profile +Get-OVProfileConnectionList $profileName + +# Now update the firmware of the profile. +# List available SPP's on the appliance +Get-OVBaseline + +$sppFileName = Read-Host "Which SPP file do you want to select ('SPP*.iso'), or to skip firmware" +if ($sppFileName) { + $fw = Get-OVSppFile $sppFileName + # Now select the firmware SPP in the server profile + if ($serverType.firmwareUpdateSupported) { + $profile.firmwareSettings.manageFirmware = $true + $profile.firmwareSettings.firmwareBaselineUri = $fw.uri + $task = Set-OVResource $profile + $task = Wait-OVTaskComplete -taskUri $task.uri -timeout (New-TimeSpan -Minutes 30) + + } else { + Write-Host "Firmware update not supported for" $serverType.model + } +} \ No newline at end of file diff --git a/Samples/Server_Multiconnection_SAN_Storage_Sample.ps1 b/Samples/Server_Multiconnection_SAN_Storage_Sample.ps1 new file mode 100644 index 0000000..81c18ba --- /dev/null +++ b/Samples/Server_Multiconnection_SAN_Storage_Sample.ps1 @@ -0,0 +1,182 @@ +############################################################################## +# Server_Multiconnection_SAN_Storage_Sample.ps1 +# +# Example script to demonstrate creating a Server Profile with the following: +# +# - Configure 2 NICs in paired with Red +# - Configure 2 NICs in paired with Black +# - Configure 2 NICs in paired with NetworkSet (Production Networks) +# - Configure 2 FC connections to the Production Fabric A and B +# - Set requested bandwidth +# - Attach SAN Storage +# +# VERSION 3.1 +# +# (C) Copyright 2013-2024 Hewlett Packard Enterprise Development LP +############################################################################## +<# +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +#> +############################################################################## +if (-not (get-module HPEOneView.630)) +{ + + Import-Module HPEOneView.630 + +} + +if (-not $ConnectedSessions) +{ + + $Appliance = Read-Host 'ApplianceName' + $Username = Read-Host 'Username' + $Password = Read-Host 'Password' -AsSecureString + + $ApplianceConnection = Connect-OVMgmt -Hostname $Appliance -Username $Username -Password $Password + +} + +# Now view what enclosures have been imported +Write-Host "Here is the list of enclosures managed by this appliance" +Get-OVEnclosure + +# Now list all the servers that have been imported with their current state +$servers = Get-OVServer +Write-Host "There are [$servers.Count] servers managed by this appliance." +Get-OVServer + +# Make sure all the servers are powered off +$servers | % { + if ($_.powerState -ne "Off") { + Write-Host "Server '$_.name' is ($_.powerState). Powering off..." + $Server | Stop-OVServer -Confirm:$false + } +} + +# Now create a server profile for the first available server +$server = Get-OVServer -NoProfile | Select -First 1 + +$profileName = "Profile-" + $server.serialNumber +Write-Host "Creating" $profileName "for server" $server.name + +# Assume that networks "red" and "blue" are available for this server +$netRed = Get-OVNetwork "red" +$conRed1 = New-OVProfileConnection -id 1 -type Ethernet -requestedBW 1000 -network $netRed +$conRed2 = New-OVProfileConnection -id 2 -type Ethernet -requestedBW 1000 -network $netRed + +$netProdFCA = Get-OVNetwork "Production Fabric A" +$conFC1 = New-OVProfileConnection -id 3 -type FibreChannel -requestedBW 4000 -network $netProdFCA +$netProdFCB = Get-OVNetwork "Production Fabric B" +$conFC2 = New-OVProfileConnection -id 4 -type FibreChannel -requestedBW 4000 -network $netProdFCB + +$netBlack = Get-OVNetwork "black" +$conBlack1 = New-OVProfileConnection -id 5 -type Ethernet -requestedBW 2000 -network $netBlack +$conBlack2 = New-OVProfileConnection -id 6 -type Ethernet -requestedBW 2000 -network $netBlack + +$netSetProd = Get-OVNetworkSet "Production Networks" +$conSet1 = New-OVProfileConnection -id 7 -type Ethernet -requestedBW 3000 -network $netSetProd +$conSet2 = New-OVProfileConnection -id 8 -type Ethernet -requestedBW 3000 -network $netSetProd + +#Build array of connections for the profile +$conList = @($conRed1, $conRed2, $conBlack1, $conBlack2, $conSet1, $conSet2, $conFC1, $conFC2) + +#Attach Volumes +$volume1 = Get-OVStorageVolume -Name Volume1 | Get-OVProfileAttachVolume -volumeid 1 +$volume2 = Get-OVStorageVolume -Name SharedVolume1 | Get-OVProfileAttachVolume -volumeid 2 +$attachVolumes = @($volume1,$volume2) + +#Submit profile to the appliance +$task = New-OVProfile -name $profileName -server $server -connections $conList -SANStorage -HostOsType VMware -StorageVolume $attachVolumes -Async + +#Monitor the profile async task progress +Write-Host $task.name $task.taskStatus +$task = $task | Wait-OVTaskComplete + + +# Change Connection ID 5 and 6 to "green" in the profile we just created +$profile = Send-OVRequest $task.associatedResource.resourceUri +Write-Host "Adding network to" $profile.name + +#Validate the Server Power is off prior to modifying Connections (Requirement for 1.00 and 1.01) +if ($server.powerState -ne "Off") { + Write-Host "Server" $server.name "is" $server.powerState ". Powering it off..." + $Server | Stop-OVServer -Confirm:$false +} + +$netGreen = Get-OVNetwork "green" +$conGreen1 = New-OVProfileConnection -connectionId 5 -type Ethernet -network $netGreen +$conGreen2 = New-OVProfileConnection -connectionId 6 -type Ethernet -network $netGreen +$profile.connections = $profile.connections + $conGreen1 + $conGreen2 +$task = Set-OVResource $profile +$task = Wait-OVTaskComplete -taskUri $task.uri + +# Display the connections for our profile +$profile = Send-OVRequest $task.associatedResource.resourceUri +$profile.connections | Format-Table + +# ADVANCED SERVER SETTINGS +# First view the capabilities of the server hardware for this profile +$serverType = Send-OVRequest $profile.serverHardwareTypeUri +Write-Host "Boot options for this server:" $serverType.bootCapabilities + +# Set the boot order for the server +$profile.boot.order = @("PXE", "HardDisk", "USB", "CD", "Floppy", "FibreChannelHba") +$profile.boot.manageBoot = $true +Write-Host "Set boot order to" $profile.boot.order + +#Set the BIOS setting to disable external USB ports +Write-Host "There are" $serverType.biosSettings.Count "possible BIOS settings for this server" +foreach ($setting in $serverType.biosSettings) { + if ($setting.name.Contains("USB Control")) { + foreach ($option in $setting.options) { + if ($option.name.Contains("External")) { + $profile.bios.manageBios = $true + $profile.bios.overriddenSettings = + @(@{id=$setting.id;value=$option.id}) + Write-Host $setting.name ":" $option.name + break + } + } + break + } + } + +# Let's update the profile with boot order and BIOS settings and validate the result +$task = Set-OVResource $profile +$task = Wait-OVTaskComplete -Task $task -timeout (New-TimeSpan -Minutes 20) +$profile = Send-OVRequest $task.associatedResource.resourceUri + +# Now update the firmware of the profile. +# List available SPP's on the appliance +Get-OVBaseline + +$sppFileName = Read-Host "Which SPP file do you want to select ('SPP*.iso'), or to skip firmware" +if ($sppFileName) { + $fw = Get-OVBaseline -FileName $sppFileName + # Now select the firmware SPP in the server profile + if ($serverType.firmwareUpdateSupported) { + $profile.firmwareSettings.manageFirmware = $true + $profile.firmwareSettings.firmwareBaselineUri = $fw.uri + $task = Set-OVResource $profile + $task = Wait-OVTaskComplete -taskUri $task.uri -timeout (New-TimeSpan -Minutes 30) + + } else { + Write-Host "Firmware update not supported for" $serverType.model + } +} \ No newline at end of file diff --git a/Samples/Server_Multiconnection_Sample.ps1 b/Samples/Server_Multiconnection_Sample.ps1 new file mode 100644 index 0000000..86d92f2 --- /dev/null +++ b/Samples/Server_Multiconnection_Sample.ps1 @@ -0,0 +1,171 @@ +############################################################################## +# Server_Multiconnection_Sample.ps1 +# +# Example script to demonstrate creating a Server Profile with the following: +# +# - Configure 2 NICs in paired with Red +# - Configure 2 NICs in paired with Black +# - Configure 2 NICs in paired with NetworkSet (Production Networks) +# - Configure 2 FC connections to the Production Fabric A and B +# - Set requested bandwidth +# +# VERSION 3.0 +# +# (C) Copyright 2013-2024 Hewlett Packard Enterprise Development LP +############################################################################## +<# +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +#> +############################################################################## +if (-not (get-module HPEOneView.630)) +{ + + Import-Module HPEOneView.630 + +} + +if (-not $ConnectedSessions) +{ + + $Appliance = Read-Host 'ApplianceName' + $Username = Read-Host 'Username' + $Password = Read-Host 'Password' -AsSecureString + + $ApplianceConnection = Connect-OVMgmt -Hostname $Appliance -Username $Username -Password $Password + +} + +# Now view what enclosures have been imported +Write-Host "Here is the list of enclosures managed by this appliance" +Get-OVEnclosure + +# Now list all the servers that have been imported with their current state +$servers = Get-OVServer +Write-Host "There are" $servers.Count "servers managed by this appliance." +$servers + +# Make sure all the servers are powered off +ForEach ($server in $servers) { + if ($server.powerState -ne "Off") { + Write-Host "Server" $server.name "is" $server.powerState ". Powering it off..." + $Server | Stop-OVServer -Confirm:$false + } +} + +# Now create a server profile for the first available server +$Server = Get-OVServer -NoProfile | Select -First 1 + +$profileName = "Profile-" + $server.serialNumber +Write-Host "Creating" $profileName "for server" $server.name + +# Assume that networks "red" and "blue" are available for this server +$netRed = Get-OVNetwork "red" +$conRed1 = New-OVProfileConnection -id 1 -type Ethernet -requestedBW 1000 -network $netRed +$conRed2 = New-OVProfileConnection -id 2 -type Ethernet -requestedBW 1000 -network $netRed + +$netProdFCA = Get-OVNetwork "Production Fabric A" +$conFC1 = New-OVProfileConnection -id 3 -type FibreChannel -requestedBW 4000 -network $netProdFCA +$netProdFCB = Get-OVNetwork "Production Fabric B" +$conFC2 = New-OVProfileConnection -id 4 -type FibreChannel -requestedBW 4000 -network $netProdFCB + +$netBlack = Get-OVNetwork "black" +$conBlack1 = New-OVProfileConnection -id 5 -type Ethernet -requestedBW 2000 -network $netBlack +$conBlack2 = New-OVProfileConnection -id 6 -type Ethernet -requestedBW 2000 -network $netBlack + +$netSetProd = Get-OVNetworkSet "Production Networks" +$conSet1 = New-OVProfileConnection -id 7 -type Ethernet -requestedBW 3000 -network $netSetProd +$conSet2 = New-OVProfileConnection -id 8 -type Ethernet -requestedBW 3000 -network $netSetProd + +$conList = @($conRed1, $conRed2, $conBlack1, $conBlack2, $conSet1, $conSet2, $conFC1, $conFC2) +$task = New-OVProfile -name $profileName -server $server -connections $conList -Async +Write-Host $task.name $task.taskStatus +$task = $task | Wait-OVTaskComplete + + +# Change Connection ID 5 and 6 to "green" in the profile we just created +$profile = Send-OVRequest $task.associatedResource.resourceUri +Write-Host "Adding network to" $profile.name + +#Validate the Server Power is off prior to modifying Connections (Requirement for 1.00 and 1.01) +if ($server.powerState -ne "Off") { + Write-Host "Server" $server.name "is" $server.powerState ". Powering it off..." + $Server | Stop-OVServer -Confirm:$false +} + +$netGreen = Get-OVNetwork "green" +$conGreen1 = New-OVProfileConnection -connectionId 5 -type Ethernet -network $netGreen +$conGreen2 = New-OVProfileConnection -connectionId 6 -type Ethernet -network $netGreen +$profile.connections = $profile.connections + $conGreen1 + $conGreen2 +$task = Set-OVResource $profile +$task = Wait-OVTaskComplete -taskUri $task.uri + +# Display the connections for our profile +$profile = Send-OVRequest $task.associatedResource.resourceUri +$profile.connections | Format-Table + +# ADVANCED SERVER SETTINGS +# First view the capabilities of the server hardware for this profile +$serverType = Send-OVRequest $profile.serverHardwareTypeUri +Write-Host "Boot options for this server:" $serverType.bootCapabilities + +# Set the boot order for the server +$profile.boot.order = @("PXE", "HardDisk", "USB", "CD", "Floppy", "FibreChannelHba") +$profile.boot.manageBoot = $true +Write-Host "Set boot order to" $profile.boot.order + +#Set the BIOS setting to disable external USB ports +Write-Host "There are" $serverType.biosSettings.Count "possible BIOS settings for this server" +foreach ($setting in $serverType.biosSettings) { + if ($setting.name.Contains("USB Control")) { + foreach ($option in $setting.options) { + if ($option.name.Contains("External")) { + $profile.bios.manageBios = $true + $profile.bios.overriddenSettings = + @(@{id=$setting.id;value=$option.id}) + Write-Host $setting.name ":" $option.name + break + } + } + break + } + } + +# Let's update the profile with boot order and BIOS settings and validate the result +$task = Set-OVResource $profile +$task = Wait-OVTaskComplete -taskUri $task.uri -timeout (New-TimeSpan -Minutes 20) +$profile = Send-OVRequest $task.associatedResource.resourceUri + +# Now update the firmware of the profile. +# List available SPP's on the appliance +Get-OVBaseline + +$sppFileName = Read-Host "Which SPP file do you want to select ('SPP*.iso'), or to skip firmware" +if ($sppFileName) { + $fw = Get-OVBaseline -FileName $sppFileName + # Now select the firmware SPP in the server profile + if ($serverType.firmwareUpdateSupported) { + $profile.firmwareSettings.manageFirmware = $true + $profile.firmwareSettings.firmwareBaselineUri = $fw.uri + $task = Set-OVResource $profile + $task = Wait-OVTaskComplete -Task $task -timeout (New-TimeSpan -Minutes 30) + + } else { + Write-Host "Firmware update not supported for" $serverType.model + } +} \ No newline at end of file diff --git a/Samples/Server_Profile_Template_Multiconnection_Sample.ps1 b/Samples/Server_Profile_Template_Multiconnection_Sample.ps1 new file mode 100644 index 0000000..4ba468d --- /dev/null +++ b/Samples/Server_Profile_Template_Multiconnection_Sample.ps1 @@ -0,0 +1,116 @@ +############################################################################## +# Server_Profile_Template_Multiconnection_Sample.ps1 +# +# Example script to demonstrate creating a Server Profile Template +# with the following: +# +# - HPE Synery 480 Gen 10 +# - Set BootMode to UEFIOptimized +# - Set PXEBootPolicy to IPv4 +# - Configure 2 NICs in assigned to the Management VLAN +# - Configure 2 NICs for VM connectivity +# - Configure 2 HBAs for Shared Storage connectivity +# - Local Storage +# - Firmware management +# +# Then create a Server Profile from the Template, assigning to a specific +# server. +# +# VERSION 4.0 +# +# (C) Copyright 2013-2024 Hewlett Packard Enterprise Development LP +############################################################################## +<# +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +#> +############################################################################## + +if (-not (get-module HPEOneView.700)) +{ + + Import-Module HPEOneView.700 + +} + +$MyConnection = Connect-OVMgmt -Hostname 192.168.19.90 -Credential (Get-Credential -Username Administrator -Message Password) + +# View the connected HPE OneView appliances from the library by displaying the global $ConnectedSessions variable +$ConnectedSessions + +# Now view what enclosures have been imported +Get-OVEnclosure + +# Now list all the servers that have been imported with their current state +Get-OVServer + +# Next, show the avialble servers from the available Server Hardware Type +$SY480Gen10SHT = Get-OVServerHardwareType -name "SY 480 Gen10 1" -ErrorAction Stop +Get-OVServer -ServerHardwareType $SY480Gen10SHT -NoProfile + +$TemplateName = "Hypervisor Cluster Node Template v1" +$TemplateDescription = "Corp standard hypervisor cluster node, version 1.0" +$eg = Get-OVEnclosureGroup -Name "DCS Synergy Default EG" +$Baseline = Get-OVBaseline -FileName 'SPP_2017_10_20171215_for_HPE_Synergy_Z7550-96455.iso' -ErrorAction Stop +$con1 = Get-OVNetwork -Name "Management Network (VLAN1)" -ErrorAction Stop | New-OVServerProfileConnection -ConnectionID 1 -Name 'Management Network (VLAN1) Connection 1' -Bootable -Priority Primary +$con2 = Get-OVNetwork -Name "Management Network (VLAN1)" -ErrorAction Stop | New-OVServerProfileConnection -ConnectionID 2 -Name 'Management Network (VLAN1) Connection 2' +$con3 = Get-OVNetworkSet -Name 'Prod NetSet' -ErrorAction Stop | New-OVProfileConnection -ConnectionId 3 -Name 'VM Traffic Connection 3' +$con4 = Get-OVNetworkSet -Name 'Prod NetSet' -ErrorAction Stop | New-OVProfileConnection -ConnectionId 4 -Name 'VM Traffic Connection 4' +$con5 = Get-OVNetwork -Name "Prod Fabric A" -ErrorAction Stop | New-OVServerProfileConnection -ConnectionID 5 -Name 'Prod Fabric A Connection 5' +$con6 = Get-OVNetwork -Name "Prod Fabric B" -ErrorAction Stop | New-OVServerProfileConnection -ConnectionID 6 -Name 'Prod Fabric B Connection 6' +$LogicalDisk1 = New-OVServerProfileLogicalDisk -Name 'Disk 1' -RAID RAID1 +$StorageController = New-OVServerProfileLogicalDiskController -ControllerID Embedded -Mode RAID -Initialize -LogicalDisk $LogicalDisk1 + +$params = @{ + Name = $TemplateName; + Description = $TemplateDescription; + ServerHardwareType = $SY480Gen10SHT; + EnclosureGroup = $eg; + Connections = $con1, $con2, $con3 ,$con4, $con5, $con6; + Firmware = $true; + Baseline = $Baseline; + FirmwareMode = 'FirmwareAndSoftware' + BootMode = "UEFIOptimized"; + PxeBootPolicy = "IPv4"; + ManageBoot = $True; + BootOrder = "HardDisk"; + LocalStorage = $True; + StorageController = $StorageController; + HideUnusedFlexnics = $True +} + +# Create Server Profile Template +New-OVServerProfileTemplate @params | Wait-OVTaskComplete + +# Get the created Server Profile Template +$spt = Get-OVServerProfileTemplate -Name $TemplateName -ErrorAction Stop + +# Create Server Profile from Server Profile Template, searching for a SY480 Gen10 server with at least 4 CPU and 512GB of RAM +Get-OVServer -ServerHardwareType $SY480Gen10SHT -NoProfile -ErrorAction Stop | ? { ($_.processorCount * $_.processorCoreCount) -ge 4 -and $_.memoryMb -ge (512 * 1024) } | Select -First 4 -OutVariable svr + +# Make sure servers are powered off +$svr | Stop-OVServer -Confirm:$false + +# Create the number of Servers from the $svr collection +1..($svr.Count) | % { + + New-OVServerProfile -Name "Hyp-Clus-0$_" -Assignment Server -Server $svr[($_ - 1)] -ServerProfileTemplate $spt -Async + +} + +Get-OVTask -State Running | Wait-OVTaskComplete \ No newline at end of file diff --git a/Samples/Server_Profile_Template_Rack_Server_Sample.ps1 b/Samples/Server_Profile_Template_Rack_Server_Sample.ps1 new file mode 100644 index 0000000..d7cce9e --- /dev/null +++ b/Samples/Server_Profile_Template_Rack_Server_Sample.ps1 @@ -0,0 +1,101 @@ +############################################################################## +# Server_Profile_Template_Rack_Server_Sample.ps1 +# +# Example script to demonstrate creating a Server Profile Template +# with the following: +# +# - DL380 Gen10 Plus +# - Set BootMode to UEFIOptimized +# - Set PXEBootPolicy to IPv4 +# - Local Storage +# - Firmware management +# +# Then create a Server Profile from the Template, assigning to a specific +# server. +# +# VERSION 1.0 +# +# (C) Copyright 2013-2024 Hewlett Packard Enterprise Development LP +############################################################################## +<# +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +#> +############################################################################## + +if (-not (get-module HPEOneView.700)) +{ + + Import-Module HPEOneView.700 + +} + +$MyConnection = Connect-OVMgmt -Hostname 192.168.19.90 -Credential (Get-Credential -Username Administrator -Message Password) + +# View the connected HPE OneView appliances from the library by displaying the global $ConnectedSessions variable +$ConnectedSessions + +# Now list all the servers that have been imported with their current state +Get-OVServer + +# Next, show the avialble servers from the available Server Hardware Type +$DL380SHT = Get-OVServerHardwareType -name "DL380 Gen10 Plus" -ErrorAction Stop + +Get-OVServer -ServerHardwareType $DL380SHT -NoProfile + +$TemplateName = "Production Node Template v1" +$TemplateDescription = "Enterprise production node, version 1.0" +$Baseline = Get-OVBaseline -FileName 'P45316_001_gen10spp-2021_10_0-SPP2021100_2021_1012_13.iso' -ErrorAction Stop +$LogicalDisk1 = New-OVServerProfileLogicalDisk -Name 'Boot' -RAID RAID1 -DriveType SATASSD -Bootable $true +$LogicalDisk2 = New-OVServerProfileLogicalDisk -Name 'Data1' -RAID RAID6 -DriveType SAS -NumberofDrives 8 +$StorageController = New-OVServerProfileLogicalDiskController -ControllerID Embedded -Mode RAID -Initialize -LogicalDisk $LogicalDisk1, $LogicalDisk2 + +$params = @{ + Name = $TemplateName; + Description = $TemplateDescription; + ServerHardwareType = $DL380SHT; + Firmware = $true; + Baseline = $Baseline; + FirmwareMode = 'FirmwareAndSoftware' + BootMode = "BIOS"; + ManageBoot = $True; + BootOrder = "HardDisk"; + LocalStorage = $True; + StorageController = $StorageController +} + +# Create Server Profile Template +New-OVServerProfileTemplate @params | Wait-OVTaskComplete + +# Get the created Server Profile Template +$spt = Get-OVServerProfileTemplate -Name $TemplateName -ErrorAction Stop + +# Create Server Profile from Server Profile Template, searching for a SY480 Gen10 server with at least 32 CPU and 512GB of RAM +Get-OVServer -InputObject $spt -NoProfile | Where-Object { ($_.processorCount * $_.processorCoreCount) -ge 32 -and $_.memoryMb -ge (512 * 1024) } | Select -First 4 -OutVariable svr + +# Make sure servers are powered off +$svr | Where-Object powerState -ne "Off" | Stop-OVServer -Confirm:$false + +# Create the number of Servers from the $svr collection +1..($svr.Count) | % { + + New-OVServerProfile -Name ("Node {0:000}" -f $_) -Assignment Server -Server $svr[($_ - 1)] -ServerProfileTemplate $spt -Async + +} + +Get-OVTask -State Running | Wait-OVTaskComplete \ No newline at end of file diff --git a/Samples/Wipe_Appliance.ps1 b/Samples/Wipe_Appliance.ps1 new file mode 100644 index 0000000..0212ca8 --- /dev/null +++ b/Samples/Wipe_Appliance.ps1 @@ -0,0 +1,257 @@ +############################################################################## +# Wipe_Appliance.ps1 +# - Remove ALL resource from an appliance (useful to clean a system between demos). +# +# VERSION 3.00 +# +# (C) Copyright 2013-2024 Hewlett Packard Enterprise Development LP +############################################################################## +# The information contained herein is subject to change without notice. +# The only warranties for HP products and services are set forth in the +# express warranty statements accompanying such products and services. +# Nothing herein should be construed as constituting an additional warranty. +# HP shall not be liable for technical or editorial errors or omissions +# contained herein. +# +############################################################################## +[CmdletBinding(SupportsShouldProcess, ConfirmImpact = 'High')] +param +( + + [Parameter (Mandatory)] + [ValidateNotNullorEmpty()] + [String]$Hostname, + + [Parameter (Mandatory)] + [ValidateNotNullorEmpty()] + [String]$Username, + + [Parameter (Mandatory)] + [ValidateNotNullorEmpty()] + [Object]$Password + +) + +if ($PSCmdlet.ShouldProcess($Hostname,("remove all resources on appliance"))) +{ + + if (! (Get-Module -Name 'HPEOneView.630')) + { + + Import-Module HPEOneView.630 + + } + + # First connect to the CI Management Appliance (if not already connected) + if (! $ConnectedSessions) + { + + Try + { + + $Params = @{ + + Hostname = $Hostname; + Username = $Username; + Password = $Password + + } + + Connect-OVMgmt @Params + + } + + Catch + { + + PSCmdlet.ThrowTerminatingError($_) + + } + + } + + Try + { + + ############################################################ + # REMOVE CONFIGURATION (for cleanup after/between demos) # + ############################################################ + + # Delete ALL Server Profiles + $tasks = Get-OVServerProfile | Remove-OVServerProfile -Force -Confirm:$false | Wait-OVTaskComplete + + if ($tasks | ? taskState -ne 'Completed') { + + $Tasks | ? taskState -ne 'Completed' | Format-List + + Write-Error '1 or more Remove Server Profile tasks failed to complete successfully.' -ErrorAction Stop + + } + + # Delete ALL Server Profile Templates + $tasks = Get-OVServerProfileTemplate | Remove-OVServerProfileTemplate -Confirm:$false | Wait-OVTaskComplete + + if ($tasks | ? taskState -ne 'Completed') { + + $Tasks | ? taskState -ne 'Completed' | Format-List + + Write-Error '1 or more Remove Server Profile Template tasks failed to complete successfully.' -ErrorAction Stop + + } + + # Remove ALL iPDUs + $tasks = Get-OVPowerDevice | Remove-OVPowerDevice -Force -Confirm:$false | Wait-OVTaskComplete + + if ($tasks | ? taskState -ne 'Completed') { + + $Tasks | ? taskState -ne 'Completed' | Format-List + + Write-Error '1 or more Remove Power Device tasks failed to complete successfully.' -ErrorAction Stop + + } + + # Remove ALL Enclosures + $tasks = Get-OVEnclosure | Remove-OVEnclosure -Force -Confirm:$false | Wait-OVTaskComplete + + if ($tasks | ? taskState -ne 'Completed') { + + $Tasks | ? taskState -ne 'Completed' | Format-List + + Write-Error '1 or more Remove Enclosure tasks failed to complete successfully.' -ErrorAction Stop + + } + + # Remove ALL Rack Servers + $tasks = Get-OVServer | Remove-OVServer -Force -Confirm:$false | Wait-OVTaskComplete + + if ($tasks | ? taskState -ne 'Completed') { + + $Tasks | ? taskState -ne 'Completed' | Format-List + + Write-Error '1 or more Remove Server Hardware Resources tasks failed to complete successfully.' -ErrorAction Stop + + } + + # Delete ALL Enclosure Groups: + $tasks = Get-OVEnclosureGroup | Remove-OVEnclosureGroup -Force -Confirm:$false + + if ($tasks | ? Message -ne 'Resource deleted successfully.') { + + $Tasks | ? Message -ne 'Resource deleted successfully.' | Format-List + + Write-Error '1 or more Remove Enclosure Group requests failed to complete successfully.' -ErrorAction Stop + + } + + # Delete ALL Logical Interconnect Groups + $tasks = Get-OVLogicalInterconnectGroup | Remove-OVLogicalInterconnectGroup -Force -Confirm:$false | Wait-OVTaskComplete + + if ($tasks | ? taskState -ne 'Completed') { + + $Tasks | ? taskState -ne 'Completed' | Format-List + + Write-Error '1 or more Remove Logical Interconnect Group tasks failed to complete successfully.' -ErrorAction Stop + + } + + # Delete ALL Network-Sets + $tasks = Get-OVNetworkSet | Remove-OVNetworkSet -Confirm:$false | Wait-OVTaskComplete + + if ($tasks | ? taskState -ne 'Completed') { + + $Tasks | ? taskState -ne 'Completed' | Format-List + + Write-Error '1 or more Remove Network Set tasks failed to complete successfully.' -ErrorAction Stop + + } + + # Delete ALL Networks + $tasks = Get-OVNetwork | Remove-OVNetwork -Confirm:$false | Wait-OVTaskComplete + + if ($tasks | ? taskState -ne 'Completed') { + + $Tasks | ? taskState -ne 'Completed' | Format-List + + Write-Error '1 or more Remove Network tasks failed to complete successfully.' -ErrorAction Stop + + } + + # Delete ALL Storage Volumes + $tasks = Get-OVStorageVolume | Remove-OVStorageVolume -Force -Confirm:$false | Wait-OVTaskComplete + + if ($tasks | ? taskState -ne 'Completed') { + + $Tasks | ? taskState -ne 'Completed' | Format-List + + Write-Error '1 or more Remove Storage Volume tasks failed to complete successfully.' -ErrorAction Stop + + } + + # Delete ALL Storage Pools + $tasks = Get-OVStoragePool | Remove-OVStoragePool -Force -Confirm:$false | Wait-OVTaskComplete + + if ($tasks | ? taskState -ne 'Completed') { + + $Tasks | ? taskState -ne 'Completed' | Format-List + + Write-Error '1 or more Remove Storage Pool tasks failed to complete successfully.' -ErrorAction Stop + + } + + # Delete ALL Storage Systems + $tasks = Get-OVStorageSYstem | Remove-OVStorageSystem -Force -Confirm:$false | Wait-OVTaskComplete + + if ($tasks | ? taskState -ne 'Completed') { + + $Tasks | ? taskState -ne 'Completed' | Format-List + + Write-Error '1 or more Remove Storage System tasks failed to complete successfully.' -ErrorAction Stop + + } + + # Delete ALL SAN Managers + $tasks = Get-OVSanManager | Remove-OVSanManager -Confirm:$false | Wait-OVTaskComplete + + if ($tasks | ? taskState -ne 'Completed') { + + $Tasks | ? taskState -ne 'Completed' | Format-List + + Write-Error '1 or more Remove SAN Manager tasks failed to complete successfully.' -ErrorAction Stop + + } + + # Delete ALL Unmanaged Devices + $tasks = Get-OVUnmanagedDevice | Remove-OVUnmanagedDevice -Force -Confirm:$false + + if ($tasks | ? Message -ne 'Resource deleted successfully.') { + + $Tasks | ? Message -ne 'Resource deleted successfully.' | Format-List + + Write-Error '1 or more Remove Unmanaged Device requests failed to complete successfully.' -ErrorAction Stop + + } + + } + + Catch + { + + $PSCmdlet.ThrowTerminatingError($_) + + } + +} + +elseif ($PSBoundParameters['Whatif']) +{ + + "[{0}] -WhatIf provided." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + +} + +else +{ + + "[{0}] User cancelled." -f $MyInvocation.InvocationName.ToString().ToUpper() | Write-Verbose + +} \ No newline at end of file diff --git a/Server.format.ps1xml b/Server.format.ps1xml new file mode 100644 index 0000000..3783a92 --- /dev/null +++ b/Server.format.ps1xml @@ -0,0 +1,2080 @@ + + + + + + ServerHardware+Firmware-GroupingFormat + + + + + + 4 + + Server: + + + $_.Name + + + + + + + + + + + + + EnclosureFirmware-GroupingFormat + + + + + + 4 + + Enclosure: + + + $_.Name + + + + + + + + + + + + + + + MigratableServer + + HPEOneView.Servers.MigratableServer + + + + + + + Left + + + + Left + + + + Left + + + + Left + + + + + + + + Name + + + Model + + + Status + + + ServerProfileName + + + + + + + + + RackManager + + HPEOneView.Servers.RackManager + + + + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + + + + + Name + + + SerialNumber + + + State + + + Status + + + LicenseIntent + + + Model + + + PartNumber + + + + + + + + + RackManager.SubResources + + HPEOneView.Servers.SubResources + + + + + + + + Chassis + + + + Partitions + + + + Managers + + + + + + + + + SubResources.Chassis + + HPEOneView.Servers.Chassis + + + + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + + + + + Name + + + SerialNumber + + + State + + + Status + + + PhysicalLocation + + + PartitionName + + + + + + + + + ServerHardware + + HPEOneView.ServerHardare + + + + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + + + + + name + + + serverName + + + status + + + powerState + + + serialNumber + + + shortModel + + + romVersion + + + $_.mpModel + " " + ($_.mpFirmwareVersion -split " ")[0] + + + + if (-not($_.serverProfileUri)) { 'No Profile' } + else { (Send-OVRequest $_.serverProfileUri -hostname $_.ApplianceConnection.Name).name } + + + + licensingIntent + + + + + + + + + ServerHardware + + HPEOneView.ServerHardware + + + + + + + + name + + + + model + + + + formFactor + + + + + + $_.adapters | % { + + "{0} {1} - {2}" -f $_.location,$_.slot,$_.model + + } + + + + + + + + + + + ServerHardwareType + + HPEOneView.ServerHardwareType + + + + + + + Left + + + + Left + + + + Left + + + + Left + + + + + + + + name + + + model + + + formFactor + + + + + $_.adapters | % { + + "{0} {1} - {2}" -f $_.location,$_.slot,$_.model + + } + + + + + + + + + + + ServerHardwareType + + HPEOneView.ServerHardwareType + + + + + + + + name + + + + model + + + + formFactor + + + + + + $_.adapters | % { + + "{0} {1} - {2}" -f $_.location,$_.slot,$_.model + + } + + + + + + + + + + + ServerProfileTemplate + + HPEOneView.ServerProfileTemplate + + + + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + + + + + name + + + status + + + "{0}" -f (Send-OVRequest $_.serverHardwareTypeUri -Hostname $_.ApplianceConnection.Name).name + + + "{0}" -f (Send-OVRequest $_.enclosureGroupUri -Hostname $_.ApplianceConnection.Name).name + + + affinity + + + + (Send-OVRequest ("/rest/index/associations?parentUri={0}&name=server_profile_template_to_server_profiles" -f $_.uri) -Hostname $_.ApplianceConnection.Name).members | % { + + "{0}" -f (Send-OVRequest $_.childUri -ApplianceConnection $_.ApplianceConnection.Name).name + + } + + + + + + + + + + ServerProfileTemplate + + HPEOneView.ServerProfileTemplate + + + + + + + + name + + + + status + + + + description + + + + "{0}" -f (Send-OVRequest $_.serverHardwareTypeUri -Hostname $_.ApplianceConnection.Name).name + + + + "{0}" -f (Send-OVRequest $_.enclosureGroupUri -Hostname $_.ApplianceConnection.Name).name + + + + affinity + + + + "{0} ({1})" -f $_.serialNumber,$_.serialNumberType + + + + "{0} ({1})" -f $_.uuid,$_.serialNumberType + + + + "{0}" -f $_.connections.count + + + + "{0}" -f $_.bios.manageBios + + + + + + + + + ServerProfile + + HPEOneView.ServerProfile + + + + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + + + + + name + + + status + + + templateCompliance + + + "{0}" -f (Send-OVRequest $_.serverProfileTemplateUri -Hostname $_.ApplianceConnection.Name).name + + + "{0}" -f (Send-OVRequest $_.serverHardwareUri -Hostname $_.ApplianceConnection.Name).name + + + "{0}" -f (Send-OVRequest $_.serverHardwareTypeUri -Hostname $_.ApplianceConnection.Name).name + + + "{0}" -f (Send-OVRequest $_.enclosureGroupUri -Hostname $_.ApplianceConnection.Name).name + + + affinity + + + + + + + + + ServerProfile + + HPEOneView.ServerProfile + + + + + + + + name + + + + status + + + + description + + + + templateCompliance + + + + "{0}" -f (Send-OVRequest $_.serverProfileTemplateUri -Hostname $_.ApplianceConnection.Name).name + + + + "{0}" -f (Send-OVRequest $_.serverHardwareUri -Hostname $_.ApplianceConnection.Name).name + + + + "{0}" -f (Send-OVRequest $_.serverHardwareTypeUri -Hostname $_.ApplianceConnection.Name).name + + + + "{0}" -f (Send-OVRequest $_.enclosureGroupUri -Hostname $_.ApplianceConnection.Name).name + + + + affinity + + + + "{0} ({1})" -f $_.serialNumber,$_.serialNumberType + + + + "{0} ({1})" -f $_.uuid,$_.serialNumberType + + + + "{0}" -f $_.connections.count + + + + "{0}" -f $_.bios.manageBios + + + + + + + + + connections + + HPEOneView.ServerProfile.Connection + + + + + + 2 + Left + + + + 12 + Left + + + + 30 + Left + + + + 12 + Left + + + + 10 + Left + + + + 20 + Left + + + + 10 + Left + + + + 32 + Left + + + + + + + id + + + functionType + + + $profileCache[$_.networkUri] + + + "{0} Gbps" -f ($_.requestedMbps / 1000) + + + "{0} Gbps" -f ($_.maximumMbps / 1000) + + + + $bootSetting = New-Object System.Collections.ArrayList + + [void]$bootSetting.Add($_.boot.priority) + + if ($_.boot.targets) + { + + for ($i=0; $i -eq $boot.targets.count; $i++) { [void]$bootSetting.Add("WWN $($_.boot.targets[$i].arrayWwpn)`nLUN $($_.boot.targets[$i].lun)") } + + } + + elseif ($_.functionType -eq "FibreChannel" -and -not ($_.boot.priority -eq "NotBootable") -and -not ($_.boot.targets)) + { + + [void]$bootSetting.Add("(Use Adapter BIOS)") + + } + + $bootSetting | Out-String | % { $_ -replace '^\s+|\s+$' } + + + + portId + + + + $address = New-Object System.Collections.ArrayList + + if ($_.macType -eq "Virtual" -and $_.mac) { [void]$address.Add("MAC $($_.mac) (V)") } + elseif ($_.macType -eq "Physical" -and $_.mac) { [void]$address.Add("MAC $($_.mac) (p)") } + + if ($_.wwpnType -eq "Virtual" -and $_.wwnn) { [void]$address.Add("WWNN $($_.wwnn) (v)") } + elseif ($_.wwpnType -eq "Physical" -and $_.wwnn) { [void]$address.Add("WWNN $($_.wwnn) (p)") } + + if ($_.wwpnType -eq "Virtual" -and $_.wwpn) { [void]$address.Add("WWPN $($_.wwpn) (v)") } + elseif ($_.wwpnType -eq "Physical" -and $_.wwpn) { [void]$address.Add("WWPN $($_.wwpn) (p)") } + + $address | Out-String | % { $_ -replace '^\s+|\s+$' } + + + + + + + + + + ConnectionList + + HPEOneView.ServerProfile.ConnectionList + + + + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + + + + + serverProfile + + + cid + + + portId + + + functionType + + + Network + + + + + if ($_.macType -eq "Virtual" -and $_.mac) { "{0} (V)" -f $_.mac } + elseif ($_.macType -eq "Physical" -and $_.mac) { "{0} (P)" -f $_.mac } + + + + + + if ($_.wwpnType -eq "Virtual" -and $_.wwpn) { "{0} (V)" -f $_.wwpn } + elseif ($_.wwpnType -eq "Physical" -and $_.wwpn) { "{0} (P)" -f $_.wwpn } + + + + boot + + + + + if (-not ([String]::IsNullOrEmpty($_.arrayTarget))) + { + + if ($_.functionType -eq 'FibreChannel') + { + + [regex]::Replace($_.arrayTarget, '(..)', '$1:').Trim(":") + + } + + else + { + + $_.arrayTarget + + } + + } + + elseif ($_.boot -ne "NotBootable" -and [String]::IsNullOrEmpty($_.arrayTarget)) + { + + "UseAdapterBIOS" + + } + + + + + lun + + + + + + + + + ServerUtilization + + HPEOneView.ServerUtilization + + + + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + + + + Name + + + CPUCurrent + + + PowerCurrent + + + AmbientTemperature + + + LastUpdated + + + + + + + + + Enclosure + + HPEOneView.Servers.Enclosure + + + + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + + + + name + + + enclosureType + + + state + + + serialNumber + + + rackName + + + + if ($_.enclosureGroupUri) { (Send-OVRequest $_.enclosureGroupUri -HostName $_.ApplianceConnection.Name).name } + else { "N/A" } + + + + "{0}/{1}" -f (($_.deviceBays | ? { $_.devicePresence -eq "Present" -or $_.devicePresence -eq "subsumed"}) | Measure-Object).Count,$_.deviceBays.count + + + + + + + + + Enclosure + + HPEOneView.Enclosure + + + + + + + + name + + + + enclosureType + + + + state + + + + serialNumber + + + + rackName + + + + + if ($_.enclosureGroupUri) { (Send-OVRequest $_.enclosureGroupUri -Hostname $_.ApplianceConnection.Name).name } + else { "N/A" } + + + + + "{0}/{1}" -f (($_.deviceBays | ? { $_.devicePresence -eq "Present" -or $_.devicePresence -eq "subsumed"}) | Measure-Object).Count,$_.deviceBays.count + + + + + + + + + EnclosureUtilization + + HPEOneView.EnclosureUtilization + + + + + + + Left + + + + Left + + + + Left + + + + Left + + + + + + + Name + + + PowerCurrent + + + AmbientTemperature + + + LastUpdated + + + + + + + + + LogicalEnclosure + + HPEOneView.LogicalEnclosure + + + + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + + + + name + + + state + + + + $_ApplianceConnectionName = $_.ApplianceConnection.Name + ($_.enclosureUris | % { Send-OVRequest $_ -Hostname $_ApplianceConnectionName }).name + + + + (Send-OVRequest $_.enclosureGroupUri -Hostname $_.ApplianceConnection.Name).name + + + + $_ApplianceConnectionName = $_.ApplianceConnection.Name + ($_.logicalInterconnectUris | % { Send-OVRequest $_ -Hostname $_ApplianceConnectionName }).name + + + + + + + + + + LogicalEnclosure + + HPEOneView.LogicalEnclosure + + + + + + + + name + + + + state + + + + + $_ApplianceConnectionName = $_.ApplianceConnection.Name + ($_.enclosureUris | % { Send-OVRequest $_ -Hostname $_ApplianceConnectionName }).name + + + + + (Send-OVRequest $_.enclosureGroupUri -Hostname $_.ApplianceConnection.Name).name + + + + + $_ApplianceConnectionName = $_.ApplianceConnection.Name + ($_.logicalInterconnectUris | % { Send-OVRequest $_ -Hostname $_ApplianceConnectionName }).name + + + + + + + + + + Enclosure + + HPEOneView.EnclosureGroup + + + + + + + Left + + + + Left + + + + Left + + + + + + + name + + + + + $_HostName = $_.ApplianceConnection.Name + + ($_.associatedLogicalInterconnectGroups | % { (send-OVrequest $_ -Hostname $_HostName).Name }) -join "," + + + + + + ((Send-OVRequest -Uri "/rest/index/associations/resources?count=-1&start=0&name='ENCLOSURE_GROUP_TO_LOGICAL_ENCLOSURE'&parentUri='$($_.uri)'" -Hostname $_.ApplianceConnection.Name).members | % { $_.childResource.name}) -join "," + + + + + + + + + + UnmanagedResource + + HPEOneView.UnmanagedResource + + + + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + + + + name + + + model + + + "{0} U" -f $_.height + + + ipv4Address + + + ipv6Address + + + "{0} Watts" -f $_.maxPwrConsumed + + + + + + + + + PotentialPowerConnection + + HPEOneView.PowerDevice.PotentialPowerConnection + + + + + + + Left + + + + Left + + + + Left + + + + Left + + + + + + + name + + + model + + + deviceConnection + + + deviceConnectionSide + + + + + + + + + PotentialPowerConnection + + HPEOneView.PowerDevice.PotentialPowerConnection + + + + + + + + name + + + + model + + + + deviceConnection + + + + deviceConnectionSide + + + + + + + + + ServerProfileMessage + + HPEOneView.ServerProfileMessage + + + + + + + Left + + + + Left + + + + Left + + + + + + + ServerProfileName + + + status + + + message + + + + + + + + + ServerProfileMessage + + HPEOneView.ServerProfileMessage + + + + + + + + ServerProfileName + + + + createdTime + + + + status + + + + message + + + + recommendedActions + + + + + + + + + ServerProfileCompliancePreview + + HPEOneView.ServerProfile.CompliancePreviewe + + + + + + + + Name + + + + IsOnlineUpdate + + + + AutomaticUpdates + + + + ManualUpdates + + + + + + + + + ServerProfileCompliancePreview + + HPEOneView.ServerProfile.CompliancePreview + + + + + + + Left + + + + Left + + + + Left + + + + Left + + + + + + + Name + + + IsOnlineUpdate + + + AutomaticUpdates + + + ManualUpdates + + + + + + + + + ContractAndWarrantyStatus + + HPEOneView.RemoteSupport.ContractAndWarrantyStatus + + + + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + + + + + ResourceName + + + ResourceSerialNumber + + + IsEntitled + + + EntitlementPackage + + + EntitlementStatus + + + CoverageDays + + + OfferEndDate + + + + + + + + + RemoteSupportResourceSetting + + HPEOneView.RemoteSupport.ResourceSetting + + + + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + + + + ResourceName + + + supportEnabled + + + $_.SalesChannelPartner.name + + + $_.SupportChannelPartner.name + + + '{0} {1}' -f $_.PrimaryContact.firstName,$_.PrimaryContact.lastName + + + '{0} {1}' -f $_.SecondaryContact.firstName,$_.SecondaryContact.lastName + + + + + + + + + Servers+Firmware + + HPEOneView.Servers.ServerHardware+Firmware + + + Name + ServerHardware+Firmware-GroupingFormat + + + + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + + + + + Component + + + ComponentType + + + Installed + + + BaselineVersion + + + BaselineName + + + + + + + + + Enclosure+Firmware + + HPEOneView.Servers.Enclosure+Firmware + + + Name + EnclosureFirmware-GroupingFormat + + + + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + + + + Component + + + ComponentModel + + + Installed + + + BaselineVersion + + + BaselineName + + + + + + + + + + + LogicalJBOD + + HPEOneView.Servers.LogicalJBOD + + + + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + + + + Name + + + State + + + "{0} {1}" -f $_.Interface, $_.Media + + + [HPEOneView.Utilities.Library]::IntToStorageString(([int]$_.MinSize * 1GB)) + + + [HPEOneView.Utilities.Library]::IntToStorageString(([int]$_.MaxSize * 1GB)) + + + Drives + + + UsedBy + + + + + + + + + + PhysicalDrive + + HPEOneView.Servers.PhysicalDrive + + + + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + + + + Location + + + Model + + + [HPEOneView.Utilities.Library]::IntToStorageString($_.Capacity) + + + DriveTechnology + + + IsAllocated + + + FailurePredicted + + + "{0}%" -f $_.LifeRemaining + + + + + + + + + + FirmwareCompliancePreview + + HPEOneView.Servers.ServerHardware+FirmwareCompliancePreview + + + + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + + + + ComponentName + + + Location + + + InstalledVersion + + + BaselineVersion + + + Operation + + + UpdateRequired + + + + + + + + + + + \ No newline at end of file diff --git a/Storage.format.ps1xml b/Storage.format.ps1xml new file mode 100644 index 0000000..7a9ff79 --- /dev/null +++ b/Storage.format.ps1xml @@ -0,0 +1,2290 @@ + + + + + AvailableDrivesFromDriveEnclosures + + HPEOneView.Storage.AvailableDiskDrive + + + + + + + AvailableDrivesFromDriveEnclosures-GroupingFormat + + + + + + 4 + + SASLogicalInterconnectName: + + SASLogicalInterconnectName + + + + + + + + + + + + + + ManagedSanZone + + HPEOneView.Storage.ManagedSan.Zone + + + + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + + + + + $_.ApplianceConnection.Name + + + ManagedSan + + + Name + + + State + + + Status + + + $_.Members.Name + + + + + + + + + ManagedSanZone + + HPEOneView.Storage.ManagedSan.Zone + + + + + + + + $_.ApplianceConnection.Name + + + + ManagedSAN + + + + Name + + + + State + + + + Status + + + + wwn + + + + Members + + + + Created + + + + Modified + + + + + + + + + ManagedSanZoneAlias + + HPEOneView.Storage.ManagedSan.Zone.Alias + + + + + + + Left + + + + Left + + + + + + + + Name + + + WWN + + + + + + + + + ManagedSanZoneAlias + + HPEOneView.Storage.ManagedSan.Zone.Alias + + + + + + + + Name + + + + WWN + + + + + + + + + Endpoint + + HPEOneView.Storage.San.Endpoint + + + + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + + + + + $_.ApplianceConnection.Name + + + wwn + + + portType + + + isOnline + + + sanName + + + zoneName + + + + + + + + + sanvolumes + + HPEOneView.Profile.SanVolume + + + + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + + + + + id + + + status + + + "{0}" -f $profileCache[$_.volumeUri].name + + + lunType + + + "{0}" -f $profileCache[$_.volumeStoragePoolUri].name + + + "{0} GB" -f ($profileCache[$_.volumeUri].provisionedCapacity / 1gb) + + + "{0}" -f $profileCache[$_.volumeUri].provisionType + + + if ($profileCache[$_.volumeUri].shareable) { "{0}" -f "Shared" } else { "{0}" -f "Private" } + + + + + + + + + StorageVolume + + HPEOneView.Storage.Volume + + + + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + + + + + name + + + provisioningType + + + '{0:N2} GB' -f ($_.provisionedCapacity / 1GB) + + + + if ($_.isShareable) { "Shared"} + else { "Private" } + + + + (Send-OVRequest -Uri (Send-OVRequest $_.storagePoolUri -Hostname $_.ApplianceConnection.Name).storageSystemUri -Hostname $_.ApplianceConnection.Name).name + + + (Send-OVRequest $_.storagePoolUri -Hostname $_.ApplianceConnection.Name).name + + + + if (-not([String]::IsNullOrEmpty($_.deviceSpecificAttributes.snapshotPoolUri))) + { + (Send-OVRequest $_.deviceSpecificAttributes.snapshotPoolUri -Hostname $_.ApplianceConnection.Name).name + } + + + + + $associationProfileToVol = (Send-OVRequest ("/rest/index/associations?childUri=$($_.uri)&name=server_profiles_to_storage_volumes") -Hostname $_.ApplianceConnection.Name).members + if ($associationProfileToVol) { + $profileNames = $associationProfileToVol | % { (Send-OVRequest $_.parentUri -Hostname $_.ApplianceConnection.Name).name } + [Array]::Sort([array]$profileNames) + $profileNames + } + + else { "No server profiles" } + + + + + + + + + + StorageVolume + + HPEOneView.Storage.Volume + + + + + + + + name + + + + "{0} ({1})" -f $_.state, $_.stateReason + + + + description + + + + lunWwn + + + + provisioningType + + + + '{0:N2} GB' -f ($_.provisionedCapacity / 1GB) + + + + '{0:N2} GB' -f ($_.allocatedCapacity / 1GB) + + + + + if ($_.isShareable) { "Shared"} + else { "Private" } + + + + + (Send-OVRequest -Uri (Send-OVRequest $_.storagePoolUri -Hostname $_.ApplianceConnection.Name).storageSystemUri -Hostname $_.ApplianceConnection.Name).name + + + + + (Send-OVRequest $_.storagePoolUri -Hostname $_.ApplianceConnection.Name).name + + + + + + if (-not([String]::IsNullOrEmpty($_.deviceSpecificAttributes.snapshotPoolUri))) + { + (Send-OVRequest $_.deviceSpecificAttributes.snapshotPoolUri -Hostname $_.ApplianceConnection.Name).name + } + + + + + '{0}' -f (Send-OVRequest $_.deviceSpecificAttributes.snapshotPoolUri -Hostname $_.ApplianceConnection.Name).deviceSpecificAttributes.supportedRAIDLevel + + + + deviceVolumeName + + + + + $associationProfileToVol = (Send-OVRequest ("/rest/index/associations?childUri=$($_.uri)&name=server_profiles_to_storage_volumes") -Hostname $_.ApplianceConnection.Name).members + if ($associationProfileToVol) { + $profileNames = $associationProfileToVol | % { (Send-OVRequest $_.parentUri -Hostname $_.ApplianceConnection.Name).name } + [Array]::Sort([array]$profileNames) + $profileNames + } + + else { "No server profiles" } + + + + + + + + + + VolumeTemplate + + HPEOneView.Storage.VolumeTemplate + + + + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + + + + + name + + + '{0:N2} GB' -f ($_.properties.size.default / 1GB) + + + '{0}' -f $_.properties.provisioningType.default + + + + if ($_.properties.isShareable.default) { "Shared"} + else { "Private" } + + + + "{0}" -f (Send-OVRequest $_.compatibleStorageSystemsUri -Hostname $_.ApplianceConnection.Name).members.displayName + + + "{0}" -f (Send-OVRequest $_.storagePoolUri -Hostname $_.ApplianceConnection.Name).name + + + + if (-not([String]::IsNullOrEmpty($_.properties.snapshotPool.default))) + { + (Send-OVRequest $_.properties.snapshotPool.default -Hostname $_.ApplianceConnection.Name).name + } + + + + + + + + + + VolumeTemplate + + HPEOneView.Storage.VolumeTemplate + + + + + + + + name + + + + state + + + + description + + + + '{0}' -f $_.properties.provisioningType.default + + + + '{0:N2} GB' -f ($_.properties.size.default / 1GB) + + + + + if ($_.properties.isShareable.default) { "Shared"} + else { "Private" } + + + + + "{0}" -f (Send-OVRequest $_.compatibleStorageSystemsUri -Hostname $_.ApplianceConnection.Name).members.displayName + + + + "{0}" -f (Send-OVRequest $_.storagePoolUri -Hostname $_.ApplianceConnection.Name).name + + + + + if (-not([String]::IsNullOrEmpty($_.properties.snapshotPool.default))) + { + (Send-OVRequest $_.properties.snapshotPool.default -Hostname $_.ApplianceConnection.Name).name + } + + + + + deviceVolumeName + + + + + + + + + StorageVolumeSnapshot + + HPEOneView.Storage.VolumeSnapshot + + + + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + + + + + "{0}" -f $_.ApplianceConnection.Name + + + name + + + (Send-OVRequest $_.storageVolumeUri -Hostname $_.ApplianceConnection.Name).name + + + "{0} ({1})" -f $_.state, $_.stateReason + + + '{0:N2} GB' -f ($_.capacity / 1GB) + + + + + + + + + StorageVolumeSnapshot + + HPEOneView.Storage.VolumeSnapshot + + + + + + + + "{0}" -f $_.ApplianceConnection.Name + + + + name + + + + (Send-OVRequest $_.storageVolumeUri -Hostname $_.ApplianceConnection.Name).name + + + + "{0} ({1})" -f $_.state, $_.stateReason + + + + '{0:N2} GB' -f ($_.capacity / 1GB) + + + + + + + + + StorageSystemDiscoveredPool + + HPEOneView.Storage.System.DiscoveredPool + + + + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + + + + + name + + + domain + + + deviceType + + + raidLevel + + + + '{0:N2} GB' -f ($_.totalCapacity / 1GB) + + + + + '{0:N2} GB' -f ($_.allocatedCapacity.totalAllocatedCapacity / 1GB) + + + + + '{0:N2} GB' -f ($_.freeCapacity / 1GB) + + + + + + + + + + StorageSystemDiscoveredPool + + HPEOneView.Storage.System.DiscoveredPool + + + + + + + + name + + + + Status + + + + if ($_.storageSystemUri) { (Send-OVRequest $_.storageSystemUri -Hostname $_.ApplianceConnection.Name).name } + + + + $_.deviceSpecificAttributes.deviceType + + + + $_.deviceSpecificAttributes.supportedRAIDLevel + + + + '{0:N2} GB' -f ($_.totalCapacity / 1GB) + + + + '{0:N2} GB' -f ($_.allocatedCapacity.totalAllocatedCapacity / 1GB) + + + + '{0:N2} GB' -f ($_.freeCapacity / 1GB) + + + + (Send-OVRequest "/rest/index/resources?category=storage-volumes&query=storage_volume_storagepool_uri:'$($_.uri)'" -Hostname $_.ApplianceConnection.Name).count + + + + (Send-OVRequest "/rest/index/resources?sort=name:asc&category=storage-volume-templates&query=storagePoolUri:'$($_.uri)'" -Hostname $_.ApplianceConnection.Name).count + + + + + + + + + StorageSystemPool + + HPEOneView.Storage.StoragePool + + + + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + + + + + name + + + state + + + status + + + if ($_.storageSystemUri) { (Send-OVRequest $_.storageSystemUri -Hostname $_.ApplianceConnection.Name).name } + + + $_.deviceSpecificAttributes.deviceType + + + $_.deviceSpecificAttributes.supportedRAIDLevel + + + + '{0:N2} GB' -f ($_.totalCapacity / 1GB) + + + + + '{0:N2} GB' -f ($_.allocatedCapacity.totalAllocatedCapacity / 1GB) + + + + + '{0:N2} GB' -f ($_.freeCapacity / 1GB) + + + + + + + + + + StorageSystemPool + + HPEOneView.Storage.StoragePool + + + + + + + + name + + + + Status + + + + if ($_.storageSystemUri) { (Send-OVRequest $_.storageSystemUri -Hostname $_.ApplianceConnection.Name).name } + + + + $_.deviceSpecificAttributes.deviceType + + + + $_.deviceSpecificAttributes.supportedRAIDLevel + + + + '{0:N2} GB' -f ($_.totalCapacity / 1GB) + + + + '{0:N2} GB' -f ($_.allocatedCapacity.totalAllocatedCapacity / 1GB) + + + + '{0:N2} GB' -f ($_.freeCapacity / 1GB) + + + + (Send-OVRequest "/rest/index/resources?category=storage-volumes&query=storage_volume_storagepool_uri:'$($_.uri)'" -Hostname $_.ApplianceConnection.Name).count + + + + (Send-OVRequest "/rest/index/resources?sort=name:asc&category=storage-volume-templates&query=storagePoolUri:'$($_.uri)'" -Hostname $_.ApplianceConnection.Name).count + + + + + + + + + SanManager + + HPEOneView.Storage.SanManager + + + + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + + + + name + + + status + + + state + + + providerDisplayName + + + deviceManagerVersion + + + + $managedSans = New-Object System.Collections.ArrayList + if ($_.managedSansUri) + { + + $resp = Send-OVRequest $_.managedSansUri -Hostname $_.ApplianceConnection.Name + foreach ($member in $resp.members) { [void]$managedSans.Add($member.name) } + + $managedSans + + } + + else { "None" } + + + + + + + + + + SanManager + + HPEOneView.Storage.SanManager + + + + + + + + name + + + + status + + + + state + + + + providerDisplayName + + + + deviceManagerVersion + + + + + $managedSans = New-Object System.Collections.ArrayList + if ($_.managedSansUri) + { + + $resp = Send-OVRequest $_.managedSansUri -Hostname $_.ApplianceConnection.Name + foreach ($member in $resp.members) { [void]$managedSans.Add($member.name) } + + $managedSans + + } + + else { "None" } + + + + + + + + + + ManagedSan + + HPEOneView.Storage.ManagedSan + + + + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + + + + name + + + state + + + status + + + principalSwitch + + + $_.associatedNetworks.name -join ', ' + + + zoningState + + + + if ($_.sanPolicy.zoningPolicy -eq "NoZoning") { "No" } + else { "Yes" } + + + + $_.sanPolicy.zoningPolicy + + + $_.sanPolicy.enableAliasing + + + + + + + + + ManagedSan + + HPEOneView.Storage.ManagedSan + + + + + + + + name + + + + status + + + + state + + + + principalSwitch + + + + $_.associatedNetworks.name -join ', ' + + + + zoningState + + + + + if ($_.sanPolicy.zoningPolicy -eq "NoZoning") { "No" } + else { "Yes" } + + + + + $_.sanPolicy.zoningPolicy + + + + $_.sanPolicy.enableAliasing + + + + + + + + + StorageSystem + + HPEOneView.Storage.System + + + + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + + + + name + + + family + + + state + + + status + + + $_.deviceSpecificAttributes.serialNumber + + + $_.deviceSpecificAttributes.model + + + $_.deviceSpecificAttributes.managedDomain + + + $_.deviceSpecificAttributes.wwn + + + $_.deviceSpecificAttributes.firmware + + + + + + + + + StorageSystem + + HPEOneView.Storage.System + + + + + + + + name + + + + status + + + + state + + + + serialNumber + + + + model + + + + managedDomain + + + + wwn + + + + firmware + + + + '{0:N2} TB' -f ($_.totalCapacity / 1TB) + + + + '{0:N2} TB' -f ($_.allocatedCapacity / 1TB) + + + + '{0:N2} TB' -f ($_.freeCapacity / 1TB) + + + + $_.sanPolicy.enableAliasing + + + + + + + + + StorageSystemPort + + HPEOneView.Storage.System.Port + + + + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + + + + name + + + $StorageSystemPortModeEnum[$_.mode] + + + connectionState + + + status + + + protocolType + + + address + + + expectedSanName + + + actualSanName + + + groupName + + + + + + + + + StorageSystemPort + + HPEOneView.Storage.System.Port + + + + + + + + portName + + + + status + + + + state + + + + protocolType + + + + address + + + + expectedNetworkName + + + + + if ($_.actualNetworkUri -and (-not($_.actualNetworkUri -eq "unknown"))) + { + $net = Send-OVRequest $_.actualNetworkUri -Hostname $_.ApplianceConnection.Name + if ($net.fabricType -eq "FabricAttach") {"$($net.name) [FA]"} + else {" $($net.name) [DA]"} + } + else { $_.actualNetworkUri } + + + + + groupName + + + + + + + + + DriveEnclosure + + HPEOneView.Storage.DriveEnclosure + + + + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + + + + $_.ApplianceConnection.Name + + + name + + + powerState + + + state + + + serialNumber + + + + '{0}/{1}' -f ($_.driveBays | ? drive).count, $_.driveBayCount + + + + ioAdapterCount + + + + + + + + + DriveEnclosure + + HPEOneView.Storage.DriveEnclosure + + + + + + + + $_.ApplianceConnection.Name + + + + name + + + + powerState + + + + state + + + + model + + + + serialNumber + + + + + '{0}/{1}' -f ($_.driveBays | ? drive).count, $_.driveBayCount + + + + + ioAdapterCount + + + + + + + + + + DriveEnclosureIoAdapter + + HPEOneView.Storage.DriveEnclosure.IoAdapter + + + + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + + + + $_.ApplianceConnection.Name + + + name + + + powerState + + + status + + + serialNumber + + + + '{0}/{1}' -f ($_.driveBays | ? drive).count, $_.driveBayCount + + + + ioAdapterCount + + + + + + + + + DriveEnclosureIoAdapter + + HPEOneView.Storage.DriveEnclosure.IoAdapter + + + + + + + + $_.ApplianceConnection.Name + + + + name + + + + powerState + + + + status + + + + model + + + + serialNumber + + + + + '{0}/{1}' -f ($_.driveBays | ? drive).count, $_.driveBayCount + + + + + ioAdapterCount + + + + + + + + + DriveBay + + HPEOneView.Storage.DriveEnclosure.DriveBay + + + + + + + Left + + + + Left + + + + Left + + + + Left + + + + + + + name + + + state + + + model + + + + + [int64]$_value = [int64]$_.drive.capacity * 1024 * 1024 * 1024 + + If ($_value -ge 1TB) { [string]::Format("{0:0.#}TB", [math]::Round($_value / 1TB,1)) } + ElseIf ($_value -ge 1GB) { [string]::Format("{0:0}GB", $_value / 1GB) } + ElseIf ($_value -ge 1MB) { [string]::Format("{0:0}MB", $_value / 1MB) } + ElseIf ($_value -ge 1KB) { [string]::Format("{0:0}KB", $_value / 1KB) } + ElseIf ($_value -gt 0) { [string]::Format("{0:0.00}B", $_value) } + Else {""} + + + + + + + + + + + DriveBay + + HPEOneView.Storage.DriveEnclosure.DriveBay + + + + + + + + name + + + + state + + + + model + + + + + + [int64]$_value = [int64]$_.drive.capacity * 1024 * 1024 * 1024 + + If ($_value -ge 1TB) { [string]::Format("{0:0.#}TB", [math]::Round($_value / 1TB,1)) } + ElseIf ($_value -ge 1GB) { [string]::Format("{0:0}GB", $_value / 1GB) } + ElseIf ($_value -ge 1MB) { [string]::Format("{0:0}MB", $_value / 1MB) } + ElseIf ($_value -ge 1KB) { [string]::Format("{0:0}KB", $_value / 1KB) } + ElseIf ($_value -gt 0) { [string]::Format("{0:0.00}B", $_value) } + Else {""} + + + + + + + + + + + DriveBayDiskDrive + + HPEOneView.Storage.DriveEnclosure.DriveBay.Drive + + + + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + + + + name + + + status + + + state + + + model + + + + + [int64]$_value = [int64]$_.capacity * 1024 * 1024 * 1024 + + If ($_value -ge 1TB) { [string]::Format("{0:0.#}TB", [math]::Round($_value / 1TB,1)) } + ElseIf ($_value -ge 1GB) { [string]::Format("{0:0}GB", $_value / 1GB) } + ElseIf ($_value -ge 1MB) { [string]::Format("{0:0}MB", $_value / 1MB) } + ElseIf ($_value -ge 1KB) { [string]::Format("{0:0}KB", $_value / 1KB) } + ElseIf ($_value -gt 0) { [string]::Format("{0:0.00}B", $_value) } + Else {""} + + + + + firmwareVersion + + + serialNumber + + + + + + + + + DriveBayDiskDrive + + HPEOneView.Storage.DriveEnclosure.DriveBay.Drive + + + + + + + + name + + + + status + + + + state + + + + model + + + + deviceInterface + + + + driveMedia + + + + '{0}Gbps' -f $_.linkRateInGbs + + + + '{0:00}K' -f ($_.rotationalRpms / 1000) + + + + + + [int64]$_value = [int64]$_.capacity * 1024 * 1024 * 1024 + + If ($_value -ge 1TB) { [string]::Format("{0:0.#}TB", [math]::Round($_value / 1TB,1)) } + ElseIf ($_value -ge 1GB) { [string]::Format("{0:0}GB", $_value / 1GB) } + ElseIf ($_value -ge 1MB) { [string]::Format("{0:0}MB", $_value / 1MB) } + ElseIf ($_value -ge 1KB) { [string]::Format("{0:0}KB", $_value / 1KB) } + ElseIf ($_value -gt 0) { [string]::Format("{0:0.00}B", $_value) } + Else {""} + + + + + + firmwareVersion + + + + serialNumber + + + + + + + + + AvailableDiskDrive + + HPEOneView.Storage.AvailableDiskDrive + + + type + AvailableDrivesFromDriveEnclosures-GroupingFormat + + + + + + + Left + + + + Left + + + + Left + + + + Left + + + + + + + Type + + + Capacity + + + NumberAvailable + + + DriveEnclosureName + + + + + + + + + LogicalJBOD + + HPEOneView.Storage.LogicalJBOD + + + + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + + + + Name + + + State + + + "{0} {1}" -f $_.Interface, $_.Media + + + [HPEOneView.Utilities.Library]::IntToStorageString(([int]$_.MinSize * 1GB)) + + + [HPEOneView.Utilities.Library]::IntToStorageString(([int]$_.MaxSize * 1GB)) + + + UsedBy + + + Drives + + + + + + + + + Drive + + HPEOneView.Storage.Drive + + + + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + + + + Name + + + State + + + DriveEnclosureName + + + Model + + + SerialNumber + + + [HPEOneView.Utilities.Library]::IntToStorageString(([int]$_.Capacity * 1GB)) + + + LogicalJbodName + + + + + + + + + AvailableDriveType + + HPEOneView.Storage.AvailableDriveType + + + + + + + Left + + + + Left + + + + Left + + + + Left + + + + Left + + + + + + + SASLogicalInterconnectName + + + DriveEnclosureName + + + Type + + + [HPEOneView.Utilities.Library]::IntToStorageString(([int]$_.Capacity * 1GB)) + + + NumberAvailable + + + + + + + + + + + \ No newline at end of file diff --git a/en-US/HPEOneView.900.psm1-help.xml b/en-US/HPEOneView.900.psm1-help.xml new file mode 100644 index 0000000..5baf698 --- /dev/null +++ b/en-US/HPEOneView.900.psm1-help.xml @@ -0,0 +1,110266 @@ + + + + + + + Add-OVApplianceTrustedCertificate + + Add X.509 SSL certificates to appliance trusted store. + + Add + OVApplianceTrustedCertificate + + + HPE OneView performs certificate validation for all Transport Layer Security (TLS) communications between the appliance and external servers or devices. These checks guarantee confidentiality, integrity, and authentication with the remote end-point. + +In production environments, Hewlett Packard Enterprise strongly recommends that certificate validation be enabled. In environments where security is not a concern, such as a testing environment, certificate validation can optionally be disabled. + +This Cmdlet will allow an administrator to add X.509 compliant SSL certificates to the appliance trusted store. + +Minimum required privileges: + + * Infrastructure Administrator to add certificate authority certificates and server certificates. + * Network administrator, Server administrator, Software administrator, or Storage administrator to add server certificates. + + + + + Add-OVApplianceTrustedCertificate + + Path + + The filesystem object of the X.509 public SSL certificate to add. + + System.IO.FileInfo + + + CertObject + + Specify the public Base64 X.509 certificate of the remote endpoint to add to the appliances internal trust store. + + Object + + + ComputerName + + The remote endpoint Computer Name or IP Address. This should match either the X.509 Subject or Subject Alternative Name fields with in the cert object. If omitting the -CertObject parameter, the Cmdlet will initiate a TCP connection in order to retrieve the certificate. Use the -Port parameter to specify the correct TCP port the SSL/TLS service is listening on. + + String + + + Port + + Specify the TCP port where the TLS/SSL service is bound and listening on. Use with the -ComputerName parameter. + + Int + + + AliasName + + Specify an alias name of the certificate stored on the appliance. By default, the Subject name will be used. + + String + + + Force + + Use to force add an untrusted (self signed or a certificate authority certificate has not been added to the appliance) certificate into the appliances trust store. + + SwitchParameter + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] objects or Name property values. + + Object + + + + Add-OVApplianceTrustedCertificate + + Path + + The filesystem object of the X.509 public SSL certificate to add. + + System.IO.FileInfo + + + CertObject + + Specify the public Base64 X.509 certificate of the remote endpoint to add to the appliances internal trust store. + + Object + + + ComputerName + + The remote endpoint Computer Name or IP Address. This should match either the X.509 Subject or Subject Alternative Name fields with in the cert object. If omitting the -CertObject parameter, the Cmdlet will initiate a TCP connection in order to retrieve the certificate. Use the -Port parameter to specify the correct TCP port the SSL/TLS service is listening on. + + String + + + Port + + Specify the TCP port where the TLS/SSL service is bound and listening on. Use with the -ComputerName parameter. + + Int + + + TrustCertChain + + When providing a certificate, either with -Path, -CertObject or -ComputerName, use this parameter to build the certificate chain that issued the certificate to the endpoint. In order for the certificate chain to automatically be built, the issuing and root authority certificates must be trusted from the operating system running PowerShell. + + SwitchParameter + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] objects or Name property values. + + Object + + + + + + + AliasName + + Specify an alias name of the certificate stored on the appliance. By default, the Subject name will be used. + + String + + String + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] objects or Name property values. + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + SwitchParameter + + False + + + CertObject + + Specify the public Base64 X.509 certificate of the remote endpoint to add to the appliances internal trust store. + + Object + + Object + + + + + ComputerName + + The remote endpoint Computer Name or IP Address. This should match either the X.509 Subject or Subject Alternative Name fields with in the cert object. If omitting the -CertObject parameter, the Cmdlet will initiate a TCP connection in order to retrieve the certificate. Use the -Port parameter to specify the correct TCP port the SSL/TLS service is listening on. + + String + + String + + + + + Force + + Use to force add an untrusted (self signed or a certificate authority certificate has not been added to the appliance) certificate into the appliances trust store. + + SwitchParameter + + SwitchParameter + + + + + Path + + The filesystem object of the X.509 public SSL certificate to add. + + System.IO.FileInfo + + System.IO.FileInfo + + + + + Port + + Specify the TCP port where the TLS/SSL service is bound and listening on. Use with the -ComputerName parameter. + + Int + + Int + + + + + TrustCertChain + + When providing a certificate, either with -Path, -CertObject or -ComputerName, use this parameter to build the certificate chain that issued the certificate to the endpoint. In order for the certificate chain to automatically be built, the issuing and root authority certificates must be trusted from the operating system running PowerShell. + + SwitchParameter + + SwitchParameter + + + + + + + + + System.IO.FileInfo + + + The filesystem object of the X.509 public SSL certificate to add. + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + Asynchronous task resource to monitor. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-ChildItem C:\Path\srv1-pub.cer | Add-OVApplianceTrustedCertificate + + Add the provided offline certificate to the appliance trust store. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Add-OVApplianceTrustedCertificate -ComputerName $RemoteBackupHostname -Port 443 -AliasName backupserver -Async -Outvariable Task + + Use the Cmdlet to add the remote certificate to the appliance trust store without waiting for the task to complete. + + + + + + + + + + -------------------------- EXAMPLE 3 -------------------------- + + + + Add-OVApplianceTrustedCertificate -ComputerName server1-ilo.domain.com -AliasName server1iLo -force + + Use the Cmdlet to add the self signed iLO certificate to the appliance. + + + + + + + + + + + + + Get-OVApplianceTrustedCertificate + + + + Remove-OVApplianceTrustedCertificate + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/add-ovappliancetrustedcertificate + + + + + + + + Add-OVBaseline + + Upload new SPP Baseline or hotfix to appliance firmware repository. + + Add + OVBaseline + + + The appliance provides reliable and simplified firmware management across the data center. Using the firmware management features built in to the appliance, you can define firmware baselines and perform firmware updates across many resources. When you add a resource to the appliance, the appliance automatically updates the resource firmware to the minimum version required to be managed by the appliance or version defined to be a baseline. + +A firmware bundle, also known as an HPE Service Pack for ProLiant (SPP), is a comprehensive collection of firmware and system software components, all tested together as a single solution stack that includes drivers, agents, utilities, and firmware packages. Firmware bundles enable you to update firmware on HPE ProLiant servers, controllers, storage, servers, interconnects, and enclosures. + +NOTE: If you attempt to add a firmware bundle that does not contain the required firmware version and components, the firmware bundle is uploaded with a warning message in the appliance firmware repository. The warning message displays the missing components in the firmware bundle. All the components below the minimum required versions are considered as missing. + +Retrieve the list of SPPs or hotfixes which have been uploaded to the appliance, and their detail. You can examine the included components and their versions reported by the baseline. + +Please note that any file name that contains the . (period, CHAR46) character will be replaced with _ (underscore, CHAR95). + +Example: My.Spp.To.Upload.201605.iso will become My_Spp_To_Upload_201605.iso. + +Minimum required privileges: Infrastructure administrator, Network administrator, or Server administrator + + + + + Add-OVBaseline + + File + + The full path and file name of the SPP file. The function returns an error if the file path cannot be validated. + + System.IO.File + + + CompSigFile + + When adding a Gen10 hotfix component, the associated compsig file is required to validate the digital signature of the hotfix. Use this parameter to accompany the hotfix file upload to the repository. + + System.IO.File[] + + + Scope + + Provide an HPEOneView.Appliance.ScopeCollection resource object to initially associate with. Resource can also be added to scope using the Add-OVResourceToScope Cmdlet. + + HPEOneView.Appliance.ScopeCollection[] + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + + UseInvokeWebRequest + + Use to override the libraries default use of System.Net.WebRequest .Net class support for syncronously uploading a file. This parameter should only be used when uploading baselines larger than 2GB. Using this parameter will not display any status progress during file transfer. + + SwitchParameter + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + Array + + (${Global:ConnectedSessions} | ? Default) + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + SwitchParameter + + False + + + CompSigFile + + When adding a Gen10 hotfix component, the associated compsig file is required to validate the digital signature of the hotfix. Use this parameter to accompany the hotfix file upload to the repository. + + System.IO.File[] + + System.IO.File[] + + + + + File + + The full path and file name of the SPP file. The function returns an error if the file path cannot be validated. + + System.IO.File + + System.IO.File + + + + + Scope + + Provide an HPEOneView.Appliance.ScopeCollection resource object to initially associate with. Resource can also be added to scope using the Add-OVResourceToScope Cmdlet. + + HPEOneView.Appliance.ScopeCollection[] + + HPEOneView.Appliance.ScopeCollection[] + + False + + + UseInvokeWebRequest + + Use to override the libraries default use of System.Net.WebRequest .Net class support for syncronously uploading a file. This parameter should only be used when uploading baselines larger than 2GB. Using this parameter will not display any status progress during file transfer. + + SwitchParameter + + SwitchParameter + + False + + + + + + + System.IO.FileSystemInfo + + + File System object from Get-ChildItem of the baseline ISO image to upload. + + + + + + + + System.Management.Automation.PSCustomObject + + + + The progress of uploading the file to the appliance, and in-progress or completion result. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Add-OVBaseline -File "C:\Users\me\Documents\SPP2012060B.2012.0525.1.iso" + + Upload SPP ISO to all connected appliances. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Add-OVBaseline -File (Get-ChildItem .\CP672214.exe) + + Upload the specified hotfix to all connected appliances. + + + + + + + + + + -------------------------- EXAMPLE 3 -------------------------- + + + + $HotFixFile = dir .\CP672214.exe +$CompSigFile = dir .\CP672214.compsig +Add-OVBaseline -File $HotFixFile -CompSigFile $CompSigFile + + Upload the specified Gen10 hotfix and its associated compsig file to the connected appliance. + + + + + + + + + + -------------------------- EXAMPLE 4 -------------------------- + + + + $HotFixFile = dir .\cp044597.exe +$CompSigFiles = dir .\cp044597_part*.compsig +Add-OVBaseline -File $HotFixFile -CompSigFile $CompSigFiles + + Upload the specified Gen10 hotfix and its associated compsig files to the connected appliance. + + + + + + + + + + + + + Get-OVBaseline + + + + Get-OVBaselineRepository + + + + Remove-OVBaseline + + + + Show-OVBaselineRepositorySize + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/add-ovbaseline + + + + + + + + Add-OVClusterManager + + Add new hypervisor manager. + + Add + OVClusterManager + + + Hypervisor Manager is software for managing virtualized environments. Through the HPE OneView Hypervisor Manager resource, you can create, import, configure, and manage hypervisors and hypervisor clusters. A hypervisor manager provides +the hostname and credentials to register with HPE OneView. HPE OneView uses these details to communicate with a hypervisor manager to perform tasks such as add, edit, and remove hypervisors or hypervisor clusters. + +You can register a new hypervisor cluster manager with HPE OneView by providing the hostname and credentials. The registered hypervisor manager contains preferences, which are used as default hypervisor or cluster settings during hypervisor cluster profile creation. You can modify the hypervisor manager preferences using the edit operation. You can override these values in a hypervisor cluster profile. + +A valid hypervisor manager certificate must be added to HPE OneView trust store to be able to successfully communicate with a hypervisor manager. + +The user must have an infrastructure administrator privilege to register or update the hypervisor manager resource in +HPE OneView. You can assign scopes to the hypervisor manager resource in HPE OneView. + +Minimum required privileges: Infrastructure administrator + + + + + Add-OVClusterManager + + Hostname + + IP or FQDN address of the hypervisor manager. + + String + + + Credential + + Use this parameter to provide the cluster manager credentials. + + PSCredential + + + DisplayName + + Override display name of the hypervisor manager. By default Hostname will be used. + + String + + + Port + + HTTPS port of the target hypervisor manager. Default is 443. + + Int + + + TrustLeafCertificate + + If the resource SSL certificate is not trusted, use this parameter to add the certificate to the appliance trust store. + + SwitchParameter + + + Scope + + Provide an [HPEOneView.Appliance.ScopeCollection] resource object to initially associate with. Resource can also be added to scope using the Add-OVResourceToScope Cmdlet. + + Object + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + SwitchParameter + + False + + + Credential + + Use this parameter to provide the cluster manager credentials. + + PSCredential + + PSCredential + + + + + DisplayName + + Override display name of the hypervisor manager. By default Hostname will be used. + + String + + String + + + + + Hostname + + IP or FQDN address of the hypervisor manager. + + String + + String + + + + + Port + + HTTPS port of the target hypervisor manager. Default is 443. + + Int + + Int + + 443 + + + Scope + + Provide an [HPEOneView.Appliance.ScopeCollection] resource object to initially associate with. Resource can also be added to scope using the Add-OVResourceToScope Cmdlet. + + Object + + Object + + AllResourcesInScope + + + TrustLeafCertificate + + If the resource SSL certificate is not trusted, use this parameter to add the certificate to the appliance trust store. + + SwitchParameter + + SwitchParameter + + + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + Async Task resource to monitor progress. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Add-OVClusterManager -Hostname vcenter.domain.local -Credential (Get-Credential -Username administrator@vsphere.local -Message Password) + + Add hypervisor manager by providing prompted PSCredential. + + + + + + + + + + + + + Get-OVClusterManager + + + + Remove-OVClusterManager + + + + Set-OVClusterManager + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/cluster/add-ovclustermanager + + + + + + + + Add-OVClusterNode + + Add a new cluster member to an existing cluster. + + Add + OVClusterNode + + + A hypervisor is software deployed on a server node that creates and runs virtual machines. Hypervisors are clustered to ensure high availability, to optimize resource utilization, and to be fault tolerant. A hypervisor cluster profile enables you to deploy and manage a cluster of hypervisors running on servers managed by HPE OneView and orchestrates consistent configuration on cluster of server nodes to share the same workload. + +A hypervisor cluster profile and the associated server profile template are used to define a consistent configuration from server nodes to hypervisors in the cluster. The server profiles define physical server configurations for server nodes in the cluster, which are derived from hypervisor cluster profile and the associated server profile template. The hypervisor profiles define network and storage configurations for hypervisors in the cluster, which are derived from hypervisor cluster profile. Hypervisor network and storage configurations in the hypervisor cluster profile are defined based on physical server configuration to ensure consistent configuration from server node to hypervisor. + +You can import additional hypervisors into the hypervisor cluster profile by adding existing hypervisors. Use this option if you are deploying the hypervisor OS on the server nodes outside of HPE OneView. This option helps you to deploy and manage hypervisor clusters using the hypervisor OS deployment tool of your choice. + +To add a node to an existing cluster, a server profile must be assigned to a server resource, created from the same server profile template the cluster was created from. The hypervisor OS must be installed and host added to the hypervisor manager using its management interface. + +Minimum required privileges: Infrastructure administrator, Server administrator, Server profile architect, or Server profile administrator. + + + + + Add-OVClusterNode + + ComputerName + + The computer name of the hypervisor host to add. + + String + + + Credential + + Use this parameter to provide the hypervisor manager credentials. + + PSCredential + + + Scope + + Provide an HPEOneView.Appliance.ScopeCollection resource object to initially associate with. Resource can also be added to scope using the Add-OVResourceToScope Cmdlet. + + Object + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + SwitchParameter + + False + + + ComputerName + + The computer name of the hypervisor host to add. + + String + + String + + + + + Credential + + Use this parameter to provide the hypervisor manager credentials. + + PSCredential + + PSCredential + + + + + Scope + + Provide an HPEOneView.Appliance.ScopeCollection resource object to initially associate with. Resource can also be added to scope using the Add-OVResourceToScope Cmdlet. + + Object + + Object + + AllResourcesInScope + + + + + + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Add-OVClusterNode + + Default example + + + + + + + + + + + + + Add-OVClusterNodeToCluster + + + + Enter-OVClusterNodeMaintenanceMode + + + + Exit-OVClusterNodeMaintenanceMode + + + + Get-OVClusterNode + + + + Update-OVClusterNode + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/cluster/add-ovclusternode + + + + + + + + Add-OVEnclosure + + Import a support HPE BladeSystem c-Class enclosure. + + Add + OVEnclosure + + + An enclosure (HPE c-Class BladeSystem enclosure or Synergy frame) is a physical structure with device bays supporting compute, networking, and storage building blocks. These building blocks share the enclosure's common power, cooling, and management infrastructure. + +This Cmdlet will import an HPE BladeSystem c7000 enclosure for HPE OneView management. The Onboard Administrator needs to have at least an IP Address for each OA module, and a valid Administrator account. An Enclosure Group must also be created. + +NOTE: HPE Synergy enclosures are automatically discovered when their frame link manager is connected to the Synergy management ring. + +This Cmdlet will attempt a connection to the XML Reply interface to examine if an existing VC Domain is present. If so, you are prompted if you wish to continue and force import the enclosure. + +CRITICAL: FORCE IMPORT OF AN ENCLOSURE WILL DELETE ANY EXISTING VC DOMAIN CONFIGURATION, AND NOT PERFORM ANY VC DOMAIN CONFIGURATION MIGRATION. PLEASE BACKUP YOUR VC DOMAIN IF YOU WISH TO RESTORE TO ITS ORIGINAL CONFIGURATION. + +If you wish to migrate the enclosure from a Virtual Connect Manager or Virtual Connect Enterprise Manager configuration, please use the Invoke-OVVcmMigration Cmdlet. + +Minimum required privileges: Infrastructure administrator or Server administrator. + + + + + Add-OVEnclosure + + Hostname + + IP Address, Hostname or FQDN of the Primary C7000 Onboard Administrator (OA). + + String + + + EnclosureGroup + + Enclosure Group Name to associate with the enclosure to import. + + Object + + + Username + + Administrator account of the target OA. Can be either an OA Local Administrator or Active Directory (AD) account if the OA is configured for AD authentication. + + String + + + Password + + Administrator Account password of the OA specified. Value can be [System.String] or [System.Security.SecureString]. + + Object + + + LicensingIntent + + Specifies whether the intent is to apply either OneView or OneView w/o iLO licenses to the servers in the enclosure being imported. + +Accepted values are + + * OneView + * OneViewNoiLO + + String + + + Baseline + + Baseline File Name, Name, URI or Object. + +Examples: + +$FileName = "bp-hp-service-pack-for-proliant-oneview-2014-11-30-05.iso" +$Name = "HPE Service Pack For ProLiant OneView 2014 11 13" + + Object + + + ForceInstallFirmware + + Force the installation of the provided Firmware Baseline. + + SwitchParameter + + + Scope + + Provide an array of <HPEOneView.Appliance.ScopeResource> Scope resource(s) to initially add. + + Array + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + + WhatIf + + + + + + + Confirm + + When attempting to add an enclosure to the appliance, the appliance will validate the target enclosure is not already claimed. If it is, this parameter is used when the server has been claimed by another appliance to bypass the confirmation prompt, and force add the server resource. + + SwitchParameter + + + + Add-OVEnclosure + + Hostname + + IP Address, Hostname or FQDN of the Primary C7000 Onboard Administrator (OA). + + String + + + EnclosureGroup + + Enclosure Group Name to associate with the enclosure to import. + + Object + + + Credential + + Use this parameter if you want to provide a PSCredential object instead. + + PSCredential + + + LicensingIntent + + Specifies whether the intent is to apply either OneView or OneView w/o iLO licenses to the servers in the enclosure being imported. + +Accepted values are + + * OneView + * OneViewNoiLO + + String + + + Baseline + + Baseline File Name, Name, URI or Object. + +Examples: + +$FileName = "bp-hp-service-pack-for-proliant-oneview-2014-11-30-05.iso" +$Name = "HPE Service Pack For ProLiant OneView 2014 11 13" + + Object + + + ForceInstallFirmware + + Force the installation of the provided Firmware Baseline. + + SwitchParameter + + + Scope + + Provide an array of <HPEOneView.Appliance.ScopeResource> Scope resource(s) to initially add. + + Array + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + + WhatIf + + + + + + + Confirm + + When attempting to add an enclosure to the appliance, the appliance will validate the target enclosure is not already claimed. If it is, this parameter is used when the server has been claimed by another appliance to bypass the confirmation prompt, and force add the server resource. + + SwitchParameter + + + + Add-OVEnclosure + + Hostname + + IP Address, Hostname or FQDN of the Primary C7000 Onboard Administrator (OA). + + String + + + Credential + + Use this parameter if you want to provide a PSCredential object instead. + + PSCredential + + + Monitored + + Add the specified enclosure for monitor only management. You can view hardware for inventory and status information only. Omitting this parameter, you can apply configurations, deploy server profiles, monitor operation status, collect statistics, and alert users to specific conditions. + + SwitchParameter + + + Scope + + Provide an array of <HPEOneView.Appliance.ScopeResource> Scope resource(s) to initially add. + + Array + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + + WhatIf + + + + + + + Confirm + + When attempting to add an enclosure to the appliance, the appliance will validate the target enclosure is not already claimed. If it is, this parameter is used when the server has been claimed by another appliance to bypass the confirmation prompt, and force add the server resource. + + SwitchParameter + + + + Add-OVEnclosure + + Hostname + + IP Address, Hostname or FQDN of the Primary C7000 Onboard Administrator (OA). + + String + + + Username + + Administrator account of the target OA. Can be either an OA Local Administrator or Active Directory (AD) account if the OA is configured for AD authentication. + + String + + + Password + + Administrator Account password of the OA specified. Value can be [System.String] or [System.Security.SecureString]. + + Object + + + Monitored + + Add the specified enclosure for monitor only management. You can view hardware for inventory and status information only. Omitting this parameter, you can apply configurations, deploy server profiles, monitor operation status, collect statistics, and alert users to specific conditions. + + SwitchParameter + + + Scope + + Provide an array of <HPEOneView.Appliance.ScopeResource> Scope resource(s) to initially add. + + Array + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + + WhatIf + + + + + + + Confirm + + When attempting to add an enclosure to the appliance, the appliance will validate the target enclosure is not already claimed. If it is, this parameter is used when the server has been claimed by another appliance to bypass the confirmation prompt, and force add the server resource. + + SwitchParameter + + + + + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + SwitchParameter + + False + + + Baseline + + Baseline File Name, Name, URI or Object. + +Examples: + +$FileName = "bp-hp-service-pack-for-proliant-oneview-2014-11-30-05.iso" +$Name = "HPE Service Pack For ProLiant OneView 2014 11 13" + + Object + + Object + + + + + Confirm + + When attempting to add an enclosure to the appliance, the appliance will validate the target enclosure is not already claimed. If it is, this parameter is used when the server has been claimed by another appliance to bypass the confirmation prompt, and force add the server resource. + + SwitchParameter + + SwitchParameter + + + + + Credential + + Use this parameter if you want to provide a PSCredential object instead. + + PSCredential + + PSCredential + + + + + EnclosureGroup + + Enclosure Group Name to associate with the enclosure to import. + + Object + + Object + + + + + ForceInstallFirmware + + Force the installation of the provided Firmware Baseline. + + SwitchParameter + + SwitchParameter + + False + + + Hostname + + IP Address, Hostname or FQDN of the Primary C7000 Onboard Administrator (OA). + + String + + String + + + + + LicensingIntent + + Specifies whether the intent is to apply either OneView or OneView w/o iLO licenses to the servers in the enclosure being imported. + +Accepted values are + + * OneView + * OneViewNoiLO + + String + + String + + OneView + + + Monitored + + Add the specified enclosure for monitor only management. You can view hardware for inventory and status information only. Omitting this parameter, you can apply configurations, deploy server profiles, monitor operation status, collect statistics, and alert users to specific conditions. + + SwitchParameter + + SwitchParameter + + False + + + Password + + Administrator Account password of the OA specified. Value can be [System.String] or [System.Security.SecureString]. + + Object + + Object + + + + + Scope + + Provide an array of <HPEOneView.Appliance.ScopeResource> Scope resource(s) to initially add. + + Array + + Array + + + + + Username + + Administrator account of the target OA. Can be either an OA Local Administrator or Active Directory (AD) account if the OA is configured for AD authentication. + + String + + String + + + + + WhatIf + + + + + + + + + + + + + + + HPEOneView.EnclosureGroup [System.Management.Automation.PSCustomObject] + + + Enclosure Group Resource that will be used to set the Enlosure policy. + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + Async task Resource object for monitoring the enclosure import process. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Add-OVEnclosure -oa "192.168.1.1" -enclGroupName EG1 -user admin -pass hpinvent -license OneView + + Add a new enclosure to the appliance, using the EG1 Enclosure Group. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Add-OVEnclosure -oa "192.168.1.1" -enclGroupName EG1 -user admin -pass hpinvent -license OneView -confirm:$false + + Add a new enclosure to the appliance, using the EG1 Enclosure Group, and force add the target enclosure. + +THIS IS A DESTRUCTIVE PROCESS IF AN EXISTING VC DOMAIN EXISTS. + + + + + + + + + + -------------------------- EXAMPLE 3 -------------------------- + + + + Add-OVEnclosure -oa "192.168.1.1" -user admin -pass hpinvent -monitored + + Add a new enclosure to the appliance for monitoring only. + + + + + + + + + + + + + Get-OVEnclosure + + + + Get-OVEnclosureGroup + + + + Invoke-OVVcmMigration + + + + New-OVEnclosureGroup + + + + Remove-OVEnclosure + + + + Remove-OVEnclosureGroup + + + + Reset-OVEnclosureDevice + + + + Set-OVEnclosure + + + + Set-OVEnclosureActiveFLM + + + + Set-OVEnclosureGroup + + + + Update-OVEnclosure + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/servers/add-ovenclosure + + + + + + + + Add-OVFabricManager + + Add an external fabric manager. + + Add + OVFabricManager + + + Fabric Managers is a resource manager in HPE OneView that enables integration of a Cisco ACI fabric (an external entity) with HPE Synergy. A fabric manager aligns HPE OneView resources as defined by Cisco Application Policy Infrastructure Controller (APIC) policies. It represents a remote Cisco APIC or an APIC cluster that manages a Cisco ACI fabric. + +You can operate a fabric manager after adding it in HPE OneView and configure a list of tenants to cover policies necessary for HPE Synergy and Cisco APIC integration. + +Remediation of networks, network sets, and logical interconnects Remediation is a process to convert a noncompliant health state of an HPE OneView resource to a compliant health state with respect to APIC policy definitions. + +The following conditions cause the fabric manager to be unable to synchronize with network policies: + + * One or more networks connected across uplink sets in a logical interconnect within HPE Synergy have the same VLAN tag + * The two networks are shared across tenants + +When a fabric manager is non compliant with APIC network policies, a software remediation enables a fabric manager to synchronize with network policies. A compliance report is generated immediately after adding a fabric manager and is updated again after remediation. The compliance report details actions that you can perform to remediate inconsistencies. There are indicators for compliant, noncompliant, and compliance-check progress for each resource. Every tenant has a list of consistent and inconsistent reports based on the compliance records generated for a tenant. An inconsistency appears in the form of an alert, which contains an action choice: auto-remediate or manual. If you choose to auto-remediate, an automatic update of the selected HPE OneView resource will initiate. + +The Cisco APIC administrator provides the user login information to HPE OneView administrator using which fabric manager connects with the Cisco APIC. The Cisco APIC user must have Read all role and Read only access level to allow the fabric manager to retrieve all the required information when connected to the Cisco APIC. + + * Read-all User role for connectivity and protocol configuration under fabric infrastructure. + * Read only Access level for accessing system configuration with no privileges to modify the system state. + +Minimum required privileges: Infrastructure administrator or Network administrator. + + + + + Add-OVFabricManager + + ManagementAddress + + The fabric managers primary IP Address or FQDN. + + String + + + Name + + The fabric managers resource name to use. + + String + + + Credential + + Use this parameter if you want to provide a PSCredential object instead. + + PSCredential + + + SecondaryManagementAddress + + The fabric managers secondary IP Address or FQDN. + + String + + + TertiearyManagementAddress + + The fabric managers tertieary IP Address or FQDN. + + String + + + TrustLeafCertificate + + If the resource SSL certificate is not trusted, use this parameter to add the certificate to the appliance trust store. + + SwitchParameter + + + EnableAutomaticRemediation + + You can resolve your resource inconsistencies manually or automatically. + +Automatic remediation + +Automatically resolve resource inconsistencies, using the Automatic remediation option on the Add Fabric Manager or Edit Fabric Manager screen. When you enable this option, all inconsistencies that are eligible for automatic remediation are detected and resolved without your intervention. + +When you disable automatic remediation, you must confirm to resolve all the inconsistencies that are eligible for remediation. + +NOTE: By default, automatic remediation is disabled on fabric managers that were added in older versions of HPE OneView. + +Manual remediation + +Manual remediation means that the proposed remediation has a confict with the existing configuration of the HPE OneView and need to be resolved manually. + +Use the activity log (Get-OVAlert) to view the remediation status of the inconsistencies. In the activity log, an alert is created for every inconsistency and a task is created for every remediation. The alert status of all inconsistencies that were resolved automatically is set to cleared. The alert status of all inconsistencies that require manual remediation remain active. + +Use this parameter to enable automatic remediation. If you wish to explicitly disable, use `-EnableAutomaticRemediation:$false` + + SwitchParameter + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + Array + + (${Global:ConnectedSessions} | ? Default) + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + SwitchParameter + + False + + + Credential + + Use this parameter if you want to provide a PSCredential object instead. + + PSCredential + + PSCredential + + False + + + EnableAutomaticRemediation + + You can resolve your resource inconsistencies manually or automatically. + +Automatic remediation + +Automatically resolve resource inconsistencies, using the Automatic remediation option on the Add Fabric Manager or Edit Fabric Manager screen. When you enable this option, all inconsistencies that are eligible for automatic remediation are detected and resolved without your intervention. + +When you disable automatic remediation, you must confirm to resolve all the inconsistencies that are eligible for remediation. + +NOTE: By default, automatic remediation is disabled on fabric managers that were added in older versions of HPE OneView. + +Manual remediation + +Manual remediation means that the proposed remediation has a confict with the existing configuration of the HPE OneView and need to be resolved manually. + +Use the activity log (Get-OVAlert) to view the remediation status of the inconsistencies. In the activity log, an alert is created for every inconsistency and a task is created for every remediation. The alert status of all inconsistencies that were resolved automatically is set to cleared. The alert status of all inconsistencies that require manual remediation remain active. + +Use this parameter to enable automatic remediation. If you wish to explicitly disable, use `-EnableAutomaticRemediation:$false` + + SwitchParameter + + SwitchParameter + + + + + ManagementAddress + + The fabric managers primary IP Address or FQDN. + + String + + String + + + + + Name + + The fabric managers resource name to use. + + String + + String + + + + + SecondaryManagementAddress + + The fabric managers secondary IP Address or FQDN. + + String + + String + + + + + TertiearyManagementAddress + + The fabric managers tertieary IP Address or FQDN. + + String + + String + + + + + TrustLeafCertificate + + If the resource SSL certificate is not trusted, use this parameter to add the certificate to the appliance trust store. + + SwitchParameter + + SwitchParameter + + + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + Async Task resource to monitor progress. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Add-OVFabricManager -Name ProdFabricManager -ManagementAddress fabricmgr1-vip.domain.local -SecondaryManagementAddress fabricmgr1-vip2.domain.local + + Add the specified farbic manager with a redundant address. + + + + + + + + + + + + + Get-OVFabricManager + + + + Remove-OVFabricManager + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/networking/add-ovfabricmanager + + + + + + + + Add-OVLdapServer + + Add a new LDAP Directory Server. + + Add + OVLdapServer + + + You can configure HPE OneView to use an external enterprise directory service for user authentication. HPE OneView supports the following enterprise directory services: + + * Active Directory + * OpenLDAP + +When you use a directory service, directory users are granted HPE OneView permissions using their group membership in the directory. After defining a directory service, use the User and Groups screen to define permissions for directory groups. +Directory groups are assigned one or more HPE OneView permissions. A directory user is assigned the HPE OneView permissions that represent the union of the permissions for all the directory groups that the user is a member of. Only after permissions are defined for directory groups, directory users are authenticated into the appliance. + +This Cmdlet will add a new LDAP Directory Server to an existing authentication directory. + +When a directory is configured on the appliance, you can specify one or more directory servers that can be accessed for the directory service. If more than one directory server is added for a directory, they are assumed to be replicated servers for high availability or disaster tolerance. If one directory server is not reachable, the other configured servers are accessed for authenticating the user. + +NOTE: + + * If you use a cluster for your directory server configuration, the cluster hostname can be specified as the directory server. Hewlett Packard Enterprise recommends using a cluster for your directory server configuration instead of configuring replicated directory servers in the appliance. + + * Directory search operations can be time consuming depending on your directory configuration and network latency affecting login time. When using Active Directory with many domains, for optimal login performance, configure a global catalog for your directory server. + +User login formats used for authentication + +To support user login with only the user name specified, the following formats are tried to authenticate with the directory service: + +If the user name is not an email address (denoted by the presence of an @ character) or a \ character (to denote the domain\user name format), logins are attempted in the following order: + + * The user name is treated as the logon name, and directory-name gets prepended as directory-name\user-name, for example: example\jane. + * The user name is treated as a UID. + * The user name is treated as Common Name (CN). + +NOTE: If the Active Directory Server Service configured in HPE OneView has a user lock-out policy (defined, for example, on n number of successive failed login attempts), Hewlett Packard Enterprise recommends that you use the email or the domain\user name format to log into HPE OneView. If email or domain\user name format is not used (instead, just the user name is used), HPE OneView internally tries different login formats as described previously. This may result in locking out the user from the GUI on a single failed login attempt (wrong password). To minimize login attempts, configure the directory display name to be the same as the first component of the directories fully qualified domain name. For example, assign the HPE OneView name example for the directory example.com. + +Minimum required privileges: Infrastructure administrator. + + + + + Add-OVLdapServer + + InputObject + + The LDAP Directory Object from Get-OVLdapDirectory. + + Object + + + Hostname + + Directory server name or IP Address to add. + + String + + + Username + + Directory Username to authenticate with in order to validate LDAP configuration. + + String + + + SSLPort + + Directory Servers LDAP SSL Port. + + Int32 + + + Certificate + + Directory Server SSL Certificate, either location to Base64 Cert or multi-line string value. If omitted, the Cmdlet will attempt to retrieve the Directory Servers Secure LDAP Certiciate. + + Object + + + Password + + Directory User account password in order to validate LDAP configuration. Can be System.String or System.Security.SecureString object. + + Object + + + TrustLeafCertificate + + When adding a new LDAP directory server, the certificate may not be trusted. Use this switch to force trust the certificate. Or, use the Add-OVApplianceTrustedCertificate to add the enterprise issuing certificate authority"s certificate. + + SwitchParameter + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. + + Object + + + + Add-OVLdapServer + + InputObject + + The LDAP Directory Object from Get-OVLdapDirectory. + + Object + + + Hostname + + Directory server name or IP Address to add. + + String + + + Credential + + Use this parameter if you want to provide a PSCredential object instead. + + PSCredential + + + SSLPort + + Directory Servers LDAP SSL Port. + + Int32 + + + Certificate + + Directory Server SSL Certificate, either location to Base64 Cert or multi-line string value. If omitted, the Cmdlet will attempt to retrieve the Directory Servers Secure LDAP Certiciate. + + Object + + + TrustLeafCertificate + + When adding a new LDAP directory server, the certificate may not be trusted. Use this switch to force trust the certificate. Or, use the Add-OVApplianceTrustedCertificate to add the enterprise issuing certificate authority"s certificate. + + SwitchParameter + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. + + Object + + + + + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Certificate + + Directory Server SSL Certificate, either location to Base64 Cert or multi-line string value. If omitted, the Cmdlet will attempt to retrieve the Directory Servers Secure LDAP Certiciate. + + Object + + Object + + + + + Credential + + Use this parameter if you want to provide a PSCredential object instead. + + PSCredential + + PSCredential + + + + + Hostname + + Directory server name or IP Address to add. + + String + + String + + + + + InputObject + + The LDAP Directory Object from Get-OVLdapDirectory. + + Object + + Object + + + + + Password + + Directory User account password in order to validate LDAP configuration. Can be System.String or System.Security.SecureString object. + + Object + + Object + + + + + SSLPort + + Directory Servers LDAP SSL Port. + + Int32 + + Int32 + + 636 + + + TrustLeafCertificate + + When adding a new LDAP directory server, the certificate may not be trusted. Use this switch to force trust the certificate. Or, use the Add-OVApplianceTrustedCertificate to add the enterprise issuing certificate authority"s certificate. + + SwitchParameter + + SwitchParameter + + + + + Username + + Directory Username to authenticate with in order to validate LDAP configuration. + + String + + String + + + + + + + + + HPEOneView.Appliance.AuthDirectory [System.Management.Automation.PSCustomObject] + + + Authentication Directory object that will have the LDAP Server added to. + + + + + + + + HPEOneView.Appliance.AuthDirectory [System.Management.Automation.PSCustomObject] + + + + Updated Authentication Directory. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVLdapDirectory -Name MyDirectory | Add-OVLdapServer -Name servera.domain.com -Username MyAdminName -Password (ConvertTo-SecureString "MyPAssword" -AsPlanText -Force) + + Add a new LDAP Directory server. + + + + + + + + + + + + + New-OVLdapServer + + + + Remove-OVLdapServer + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/security/add-ovldapserver + + + + + + + + Add-OVPowerDevice + + Import a power device. + + Add + OVPowerDevice + + + Power delivery devices provide power to IT hardware. A typical power topology in a data center includes power delivery devices such as power feeds, breaker panels, branch circuits, and power distribution units (PDUs), as well as the load segments, outlet bars, and outlet components of these devices. Adding your power delivery devices to the appliance enables power management using thermal limits, rated capacity, and derated capacity. + +Power Delivery Devices describes the following classes of devices: + + * Intelligent Power Distribution Units (iPDUs), which the appliance can automatically discover and control. + * Other power delivery devices that the appliance cannot discover. By manually adding these devices to the appliance, they become available for tracking, inventory, and power management purposes. + +Regardless of how power delivery devices are added to the appliance, the appliance automatically generates the same types of analysis (capacity, redundancy, and configuration). For iPDUs, the appliance gathers statistical data and reports errors. + +Connectivity and synchronization with the appliance + +The appliance monitors the connectivity status of iPDUs. If the appliance loses connectivity with an iPDU, an alert displays until connectivity is restored. The appliance will try to resolve connectivity issues and clear the alert automatically, but if it cannot, you must resolve the issue and manually refresh the iPDU to bring it in synchronization with the appliance. + +The appliance also monitors iPDU to remain synchronized with changes to hardware and power connections. However, some changes to devices made outside of the control of the appliance (from iLO or the OA, for example) may cause them to become out of synchronization with the appliance. You may have to manually refresh devices that lose synchronization with the appliance. + +Minimum required privilegesMinimum required privileges: Infrastructure administrator or Server administrator. + + + + + Add-OVPowerDevice + + Hostname + + Hostname of the iPDU, either IP Address or FQDN. + + String + + + Username + + Warning: This parameter is deprecated. Please transition to the -Credential parameter. + +Administrator account of the target iPDU. + + String + + + Password + + Warning: This parameter is deprecated. Please transition to the -Credential parameter. + +Account password of the iPDU specified. + + String + + + Credential + + Use this parameter if you want to provide a PSCredential object instead. + + PSCredential + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. + + Object + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + TrustLeafCertificate + + If the iPDU SSL certificate is not trusted, use this Cmdlet to add the certificate to the appliance trust store. + + SwitchParameter + + + Force + + Force the import of the iPDU when currently managed by another HPE OneView appliance. + + SwitchParameter + + + WhatIf + + + + SwitchParameter + + + Confirm + + + + SwitchParameter + + + + + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + SwitchParameter + + False + + + Confirm + + + + SwitchParameter + + SwitchParameter + + + + + Credential + + Use this parameter if you want to provide a PSCredential object instead. + + PSCredential + + PSCredential + + + + + Force + + Force the import of the iPDU when currently managed by another HPE OneView appliance. + + SwitchParameter + + SwitchParameter + + False + + + Hostname + + Hostname of the iPDU, either IP Address or FQDN. + + String + + String + + + + + Password + + Warning: This parameter is deprecated. Please transition to the -Credential parameter. + +Account password of the iPDU specified. + + String + + String + + + + + TrustLeafCertificate + + If the iPDU SSL certificate is not trusted, use this Cmdlet to add the certificate to the appliance trust store. + + SwitchParameter + + SwitchParameter + + False + + + Username + + Warning: This parameter is deprecated. Please transition to the -Credential parameter. + +Administrator account of the target iPDU. + + String + + String + + + + + WhatIf + + + + SwitchParameter + + SwitchParameter + + + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + Async Task resource to monitor progress. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Add-OVPowerDevice -Hostname ipdu24.example.com -Credential (Get-Credential) + + Add the iPDU to the appliance. + + + + + + + + + + + + + Add-OVPowerDeviceConnection + + + + Get-OVPowerDevice + + + + New-OVPowerDevice + + + + Remove-OVPowerDevice + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/facilities/add-ovpowerdevice + + + + + + + + Add-OVRackManager + + Add supported Rack Manager (HPE Superdome Flex) resource. + + Add + OVRackManager + + + A rack manager platform is a multi-node system. The nodes are housed within a rack or across racks, and are centrally managed by a management controller. The Rack Managers screen enables you to manage and visualize the physical location of rack manager platforms within a rack. + +A rack manager platform consists of the following: + + * One or more chassis - The chassis are individual nodes that are used to build logical components such as systems or partitions. Each chassis is a physical container for system components like the compute, storage, or network nodes. In an HPE Superdome Flex Server, the chassis are 5U nodes that represent the compute nodes with CPU, memory, I/O, power supplies, and fans. + * One or more systems or partitions - The system is a logical entity that functions as a server, and runs a single instance of an operating system to host services. In HPE OneView, the partition is modeled as a server hardware resource. In an HPE Superdome Flex Server, the systems are also called partitions. A partition consists of one or more compute chassis that are interconnected through an ultra-fast fabric. Each partition starts with a base chassis and can be extended using expansion chassis to form a large system. + * One or more managers - The manager component manages the rack manager platform, and hosts the management controller function. HPE OneView communicates with the rack manager through this management controller enabling system administration, control, and platform management of the rack manager platform. Some platforms have multiple manager components to support redundancy. In an HPE Superdome Flex Server, the manager component is called the Rack Management Controller (RMC). The RMC hosts the DMTF Redfish APIs. + * One or more racks - The racks physically contain all the rack manager platform components. + +When you add a rack manager, HPE OneView automatically applies the HPE OneView Standard license to the rack manager. HPE OneView discovers and monitors the hardware subcomponents of the rack manager. + +Minimum required privileges: Infrastructure administrator or Server administrator. + + + + + Add-OVRackManager + + ComputerName + + The IP/Address of the supported rack manager + + String + + + Credential + + Use this parameter if you want to provide a PSCredential object instead. + + PSCredential + + + Scope + + Provide an HPEOneView.Appliance.ScopeCollection resource object to initially associate with. Resource can also be added to scope using the Add-OVResourceToScope Cmdlet. + + Object + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + Force + + Force add the resource. Use if you need to override the claim of a resource, and force the connected appliance to add. Do know if the resource was claimed or added to a different appliance, it will no longer be able to monitor and/or manage the resource. + + SwitchParameter + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + Array + + (${Global:ConnectedSessions} | ? Default) + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + SwitchParameter + + False + + + ComputerName + + The IP/Address of the supported rack manager + + String + + String + + + + + Credential + + Use this parameter if you want to provide a PSCredential object instead. + + PSCredential + + PSCredential + + + + + Force + + Force add the resource. Use if you need to override the claim of a resource, and force the connected appliance to add. Do know if the resource was claimed or added to a different appliance, it will no longer be able to monitor and/or manage the resource. + + SwitchParameter + + SwitchParameter + + + + + Scope + + Provide an HPEOneView.Appliance.ScopeCollection resource object to initially associate with. Resource can also be added to scope using the Add-OVResourceToScope Cmdlet. + + Object + + Object + + AllResourcesInScope + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + Async task Resource object for configuring port monitoring on the requested logical intercinnect. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + $Credential = Get-Credential -Username Administrator -Message "RackManager Password" Add-OVRackManager -ComputerName rackmanger1.domain.com -Credential $Credential + + Add the specified rack manager. + + + + + + + + + + + + + Get-OVRackManager + + + + Remove-OVRackManager + + + + Update-OVRackManager + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/servers/add-ovrackmanager + + + + + + + + Add-OVRackToDataCenter + + Add rack resource to DataCenter. + + Add + OVRackToDataCenter + + + A rack is a physical structure that contains IT equipment such as enclosures, rack managers, servers, power delivery devices, and unmanaged devices (an unmanaged device uses slots in the rack and consumes power or exhausts heat, but it is not managed by the appliance). You can manage your racks and the equipment in them by adding them to the appliance. Having your racks managed by the appliance enables you to use the appliance for space and power planning. The appliance also gathers statistical data and monitors the power and temperature of the racks it manages. + +When you add an enclosure to the appliance, it automatically creates a rack and places the enclosure in it. The appliance places into the rack all enclosures connected by management link cables. When enclosures are added, the appliance places them in the rack from top to bottom. When an enclosure is placed in an Intelligent Series Rack, the enclosure slots are automatically detected. For other racks, to accurately depict the layout of your enclosures within the rack you must edit the rack to place the enclosure in the proper slots. + +You can use the appliance to view and manage your rack configuration and power delivery topology. You can specify the physical dimensions of the rack (width, height, and depth), the number of U slots, and the location of each piece of equipment in the rack. You can specify the rack PDUs that provide power to the rack, and their physical position in the rack or on either side. You can also describe how the devices in the rack are connected to those PDUs. + +The appliance automatically discovers the rack height and rack model for a ProLiant server with Location Discovery Services and updates the physical locations of devices when they are relocated within and between racks for c7000 enclosures. + +NOTE: When the appliance discovers Intelligent Series Racks, it sets the rack height automatically using the Intelligent Rack Location Discovery Services for c7000 enclosures. For non-intelligent racks or for empty racks, the default rack height is 42U. + +After adding a rack to the appliance for management, you can add the rack to a data center to visualize the data center layout and to monitor device power and cooling data. + +After the rack is under management, you can configure the power delivery topology with redundant and uninterruptible power supplies to the devices in the rack. + +Minimum required privileges: Infrastructure administrator or Server administrator. + + + + + Add-OVRackToDataCenter + + InputObject + + The Rack object from Get-OVRack. + + Object + + + DataCenter + + The DataCenter object from Get-OVDataCenter. + + Object + + + X + + The X coordinate in the DC. Value can be in US Feet or Millimeters. If specifying Millimeters, you need to include the -Millimeters switch parameter. Feet will be converted to Millimeters. + + Int32 + + + Y + + The Y coordinate in the DC. Value can be in US Feet or Millimeters. If specifying Millimeters, you need to include the -Millimeters switch parameter. Feet will be converted to Millimeters. + + Int32 + + + Millimeters + + If X and/or Y are in Millimeters, you must include this parameter. + + SwitchParameter + + + Rotate + + Specify the degree rotation of the rack. +Allowed range 0 to 360 + + Int + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + DataCenter + + The DataCenter object from Get-OVDataCenter. + + Object + + Object + + + + + InputObject + + The Rack object from Get-OVRack. + + Object + + Object + + + + + Millimeters + + If X and/or Y are in Millimeters, you must include this parameter. + + SwitchParameter + + SwitchParameter + + False + + + Rotate + + Specify the degree rotation of the rack. +Allowed range 0 to 360 + + Int + + Int + + 0 + + + X + + The X coordinate in the DC. Value can be in US Feet or Millimeters. If specifying Millimeters, you need to include the -Millimeters switch parameter. Feet will be converted to Millimeters. + + Int32 + + Int32 + + 0 + + + Y + + The Y coordinate in the DC. Value can be in US Feet or Millimeters. If specifying Millimeters, you need to include the -Millimeters switch parameter. Feet will be converted to Millimeters. + + Int32 + + Int32 + + 0 + + + + + + + HPEOneView.Facilities.Rack [System.Management.Automation.PSCustomObject] + + + Rack resource object from Get-OVRack. + + + + + + + + HPEOneView.Facilities.DataCenter [System.Management.Automation.PSCustomObject] + + + + Updated DataCenter object with the newly added Rack resource in the contents property. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + $DC = Get-OVDataCenter -Name Houston_DC1 -ErrorAction Stop +$X = 10 +$Y = 12 +Get-OVRack -Name MyRack -ErrorAction Stop | Add-OVRackToDataCenter -DataCenter $DC -X $X -Y $Y + + Add "MyRack" to "Houston_DC1" datacenter object, located at 10",12". + + + + + + + + + + + + + Get-OVDataCenter + + + + Get-OVRack + + + + Add-OVResourceToRack + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/facilities/add-ovracktodatacenter + + + + + + + + Add-OVRemoteFrame + + Add remote HPE Synergy Frame to Composer. + + Add + OVRemoteFrame + + + A Synergy frame is automatically added during hardware setup. If the Synergy frame is connected to a group of linked Synergy frames, each Synergy frame in the group is discovered as part of hardware setup. Additional Synergy frames added after initial hardware setup are discovered automatically when a cable is connected from the LINK port on the frame link module of an already discovered frame to the LINK port on the frame link module of another frame with factory settings. + +Remote frame link topologies, which include remote HPE Synergy Frames, do not include Synergy Composers. Management LAN connectivity enables remote frame link topologies to be managed by the Synergy Composers in the primary frame link topology. You can use the Add remote enclosures option to bring remote frame link topologies under management. The remote frame link topology must be in the same VLAN as the primary frame link topology, due to IPv6 Link Local restrictions. You can use this Cmdlet to add remote enclosures to manage enclosures for which LINK cabling is not directly connected to the primary frame link topology. This allows HPE OneView to manage enclosures that are spread across racks and rows in the datacenter. + +Minimum required privileges: Infrastructure administrator or Hardware setup. + + + + + Add-OVRemoteFrame + + Hostname + + The IPv6 Link Local address of the remote frame. This can be viewed from the Frame Link Module (FLM) console using a crash cart. + + String + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + SwitchParameter + + + + + Hostname + + The IPv6 Link Local address of the remote frame. This can be viewed from the Frame Link Module (FLM) console using a crash cart. + + String + + String + + + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + Async task Resource object for monitoring. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Add-OVRemoteFrame -Hostname fe80::c8f:fbcb:aa8a:97c8 + + Add the specified remote HPE Synergy Frame. + + + + + + + + + + + + + Get-OVEnclosure + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/servers/add-ovremoteframe + + + + + + + + Add-OVResourceToLabel + + Associate resource with new or existing Label. + + Add + OVResourceToLabel + + + Labels identify resources so that you can organize them into groups. After labeling your resources, you can quickly view them by searching on the labels. For example, you might want to identify the servers that are used primarily by the Finance team, or identify the storage systems assigned to the Asia/Pacific division. + +Resources supporting labels also have filters to allow you to filter by the labels that have been placed on the resource. The global search can be used to search for resources by label. + +Using this Cmdlet will add supported resources to a new or existing Label. If the Label does not exist, it will be created. + +Minimum required privileges: Edit privileges for the resource. + + + + + Add-OVResourceToLabel + + Name + + The name of the Label to associate resources to. If Label does not exist, a new one will be created. + + String + + + InputObject + + The collection of resources to associate the label with. + + Object + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + InputObject + + The collection of resources to associate the label with. + + Object + + Object + + + + + Name + + The name of the Label to associate resources to. If Label does not exist, a new one will be created. + + String + + String + + + + + + + + + System.Array + + + Collection of resources to associate with the label. + + + + + + + + System.Management.Automation.PSCustomObject + + + + The created or modified Label resource. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + $Resources = Get-OVNetwork -Name Finance* -ErrorAction Stop +$Resources += Get-OVServerHardware -Name Finance* +Add-OVResourceToLabel -Name Finance -InputObject $Resources + + Collect various resources for Finance, creating a new label called "Finance". + + + + + + + + + + + + + Get-OVLabel + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/facilities/add-ovresourcetolabel + + + + + + + + Add-OVResourceToRack + + Add supported resource to rack. + + Add + OVResourceToRack + + + A rack is a physical structure that contains IT equipment such as enclosures, rack managers, servers, power delivery devices, and unmanaged devices (an unmanaged device uses slots in the rack and consumes power or exhausts heat, but it is not managed by the appliance). You can manage your racks and the equipment in them by adding them to the appliance. Having your racks managed by the appliance enables you to use the appliance for space and power planning. The appliance also gathers statistical data and monitors the power and temperature of the racks it manages. + +When you add an enclosure to the appliance, it automatically creates a rack and places the enclosure in it. The appliance places into the rack all enclosures connected by management link cables. When enclosures are added, the appliance places them in the rack from top to bottom. When an enclosure is placed in an Intelligent Series Rack, the enclosure slots are automatically detected. For other racks, to accurately depict the layout of your enclosures within the rack you must edit the rack to place the enclosure in the proper slots. + +You can use the appliance to view and manage your rack configuration and power delivery topology. You can specify the physical dimensions of the rack (width, height, and depth), the number of U slots, and the location of each piece of equipment in the rack. You can specify the rack PDUs that provide power to the rack, and their physical position in the rack or on either side. You can also describe how the devices in the rack are connected to those PDUs. + +The appliance automatically discovers the rack height and rack model for a ProLiant server with Location Discovery Services and updates the physical locations of devices when they are relocated within and between racks for c7000 enclosures. + +NOTE: When the appliance discovers Intelligent Series Racks, it sets the rack height automatically using the Intelligent Rack Location Discovery Services for c7000 enclosures. For non-intelligent racks or for empty racks, the default rack height is 42U. + +After adding a rack to the appliance for management, you can add the rack to a data center to visualize the data center layout and to monitor device power and cooling data. + +After the rack is under management, you can configure the power delivery topology with redundant and uninterruptible power supplies to the devices in the rack. + +Minimum required privileges: Edit privileges for the resource. + + + + + Add-OVResourceToRack + + InputObject + + The supported resource object to add. +Supported resource objects are: + * Enclosures + * Servers + * Rack manager + * Power device + * Unmanaged device + + Object + + + Rack + + The Rack object from Get-OVRack. + + Object + + + ULocation + + The rack unit location where the resource is located. + + Int32 + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + InputObject + + The supported resource object to add. +Supported resource objects are: + * Enclosures + * Servers + * Rack manager + * Power device + * Unmanaged device + + Object + + Object + + + + + Rack + + The Rack object from Get-OVRack. + + Object + + Object + + + + + ULocation + + The rack unit location where the resource is located. + + Int32 + + Int32 + + 0 + + + + + + + HPEOneView.Facilities.Rack [System.Management.Automation.PSCustomObject] + + + Rack resource object from Get-OVRack. + + + + + + + + HPEOneView.Facilities.Rack [System.Management.Automation.PSCustomObject] + + + + Updated rack object with the newly added resources in the contents property. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + $Rack = Get-OVRack -Name MyRack221 -ErrorAction Stop +$Servers = Get-OVServers -Name Prod221* -ErrorAction Stop +$_U = 1 +ForEach ($Server in $Servers) { + Add-OVResourceToRack -InputObject $Server -Rack $Rack -ULocation $_U + $_U += $Server.formFactor.Replace("U",$null) +} + + Add "Prod221" (DL) servers to "MyRack221" rack object, starting at Rack U 1, and increasing the location based on the form factor of the DL servers. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + $Rack = Get-OVRack -Name MyRack222 -ErrorAction Stop +$Enclosures = Get-OVEnclosures -Name Encl-Prod* -ErrorAction Stop | ? rackName -eq $Rack.name +$_U = 1 +ForEach ($Enclosure in $Enclosures) { + Add-OVResourceToRack -InputObject $Enclosure -Rack $Rack -ULocation $_U + $_U += 10 +} + + Add Enclosures which the Onboard Administrators report are in "MyRack222", and add them to "MyRack222" rack object, starting at Rack U 1, and increasing the location by 10U. + + + + + + + + + + + + + Get-OVDataCenter + + + + Get-OVRack + + + + Add-OVRackToDataCenter + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/facilities/add-ovresourcetorack + + + + + + + + Add-OVResourceToScope + + Add supported resource(s) to a Scope. + + Add + OVResourceToScope + + + A scope is a grouping of resources that can be used to restrict the range of an operation or action. For example, you can create scopes based on: + + * Organization or department (Marketing, Research and Development, Finance) + * Usage (Production, Development, Testing) + * Skills (Linux, Windows) + +For example, a data center could be organized so that all servers running Linux are monitored using one scope and all servers running MS Windows are monitored using another scope. Email notifications can be configured such that Windows technicians are notified for issues on the servers running Windows and Linux technicians are notified for issues on the servers running Linux. + +When scopes are defined and resources assigned to them, you can: + + * Restrict the resources displayed in the user interface (UI) to those assigned to the scope. + * Restrict user permissions to grant access only to the resources in a scope. + * Configure filtered email notifications for alerts based on previously-defined scopes. + +This Cmdlet will add supported resources to a specified Scope. All the resources in these categories can be added to +or removed from a scope: + + * Enclosure Groups + * Enclosures + * Logical Enclosures + * Server Hardware + * Rack Managers + * Server Profiles + * Server Profile Templates + * OS Deployment Plans + * Networks (Ethernet, FC, and FCoE) + * Network Sets + * Hypervisor Cluster Profiles, Hypervisor Profiles, Hypervisor Managers + * Interconnects, excluding SAS resources + * Logical Interconnects, excluding SAS resources + * Logical Interconnect Groups, excluding SAS resources + * Switches + * Logical Switches + * Logical Switch Groups + * Storage Pools + * Volume Sets + * Volume Templates + * Volumes + +NOTE: Resources in other categories are considered to be included in all scopes, and they cannot be removed. + +Minimum required privileges: Infrastructure administrator, scope administrator, scope operator + + + + + Add-OVResourceToScope + + Scope + + The Scope resource to add the resource(s) to. + + HPEOneView.Appliance.ScopeCollection[] + + + InputObject + + The supported resource object to add to the intended scope provided in the -Scope parameter. + + Object + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. + + Object + + + + + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + SwitchParameter + + + + + InputObject + + The supported resource object to add to the intended scope provided in the -Scope parameter. + + Object + + Object + + + + + Scope + + The Scope resource to add the resource(s) to. + + HPEOneView.Appliance.ScopeCollection[] + + HPEOneView.Appliance.ScopeCollection[] + + + + + + + + + HPEOneView.Appliance.ScopeCollection + + + Scope resource object from Get-OVScope. + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + Asynchronous task resource that updates the Scope and associated resources. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + $Resources += Get-OVNetwork -Name ProdVLan* +$Resources += Get-OVServer -Name Encl1* +Get-OVScope -Name MyScope | Add-OVResourceToScope -InputObject $Resources + + Add the resources collected to the MyScope scope. + + + + + + + + + + + + + Remove-OVResourceFromScope + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/add-ovresourcetoscope + + + + + + + + Add-OVSanManager + + Add a supported SAN Manager + + Add + OVSanManager + + + SAN managers are a resource in HPE OneView that represent a connection to an external entity through which SANs are discovered and managed. The external entity can be vendor-specific management software or a physical switch. + +SANs are created outside of HPE OneView in the SAN manager vendor?s management interface. Once created, SANs can be discovered and managed in HPE OneView using the SAN Manager resource. + +When managing SAN managers, HPE OneView does not permit a SAN to be managed through more than one SAN manager. When associating an HPE OneView network to the SAN, the choice of which SAN to associate determines which SAN manager will be used to manage the SAN. Any subsequent change to a new SAN manager application requires to go through a phased migration process. + +HPE OneView supports SAN managers from different vendors. Supported SAN Managers are: + + * Brocade SAN Network Advisor + * Brocade FOS capable switches. Not all Brocade FC switches support FOS REST API. Please refer to Brocade/Brocade FC switch documentation for more information. + * HPE Networking 5900CP (FC or FCoE) + * HPE Networking 5900AF (FC-only) + * Cisco Nexus (FC or FCoE) + * Cisco MDS (FC-only) + +Minimum required privileges: Infrastructure administrator or Storage administrator. + + + + + Add-OVSanManager + + Type + + SAN Manager type to add. Accepted values are: + + * BrocadeFOS + * FOS + * HP + * HPE + * Cisco + + The following parameter values are no longer supported and have been removed: + + * Brocade + * BNA + * Brocade Network Advisor + + String + + + Hostname + + FQDN or IP Address of the SAN Manager + + String + + + Port + + TCP Port of the SAN Manager. The default port for Brocade Network Advisor is "5989". The default port for HPN 5900CP is "161". + + Int32 + + + Username + + Username used to authenticate and manage the SAN Manager. This is only applicable for BNA SAN Manager. + + String + + + Password + + Password used to authenticate and manage the SAN Manager. This is only applicable for BNA SAN Manager. Can be either String or System.Security.SecureString type. + + Object + + + Credential + + Use this parameter if you want to provide a PSCredential object. + + PSCredential + + + UseSsl + + Use to enable SSL communication with the SAN Manager (specifically for the Brocade Network Advisor or BrocadeFOS SAN Manager type + + SwitchParameter + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + + + Add-OVSanManager + + Type + + SAN Manager type to add. Accepted values are: + + * BrocadeFOS + * FOS + * HP + * HPE + * Cisco + + The following parameter values are no longer supported and have been removed: + + * Brocade + * BNA + * Brocade Network Advisor + + String + + + Hostname + + FQDN or IP Address of the SAN Manager + + String + + + SnmpUserName + + The SNMPv3 Community User Name. + + String + + + Port + + TCP Port of the SAN Manager. The default port for Brocade Network Advisor is "5989". The default port for HPN 5900CP is "161". + + Int32 + + + SnmpAuthLevel + + The SNMPv3 Authentication Level. Allowed values are: + + * None - No Security is required, only the SNMPv3 UserName is provided. + * AuthOnly - SNMPv3 Authentication Encryption Security Level only. Must also provide -SnmpAuthProtocol and -SnmpAuthPassword parameters. + * AuthAndPriv - SNMPv3 Authentication Encryption Security and Privacy Levels. Must also provide -SnmpAuthProtocol, -SnmpAuthPassword, -SnmpPrivProtocol and -SnmpPrivPassword parameters. + + String + + + SnmpAuthProtocol + + SNMPv3 Password Encryption Protocol. Allowed values are: + + * SHA + * MD5 + + String + + + SnmpAuthPassword + + SNMPv3 UserName Password. Can be either System.String or System.Security.SecureString type. + + Object + + + SnmpPrivProtocol + + SNMPv3 Privacy Protocol. Allowed values are: + + * AES + * DES + + String + + + SnmpPrivPassword + + SNMPv3 Privacy Encryption Password. Can be either String or System.Security.SecureString type. + + Object + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + Array + + (${Global:ConnectedSessions} | ? Default) + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + SwitchParameter + + False + + + Credential + + Use this parameter if you want to provide a PSCredential object. + + PSCredential + + PSCredential + + + + + Hostname + + FQDN or IP Address of the SAN Manager + + String + + String + + + + + Password + + Password used to authenticate and manage the SAN Manager. This is only applicable for BNA SAN Manager. Can be either String or System.Security.SecureString type. + + Object + + Object + + + + + Port + + TCP Port of the SAN Manager. The default port for Brocade Network Advisor is "5989". The default port for HPN 5900CP is "161". + + Int32 + + Int32 + + 0 + + + SnmpAuthLevel + + The SNMPv3 Authentication Level. Allowed values are: + + * None - No Security is required, only the SNMPv3 UserName is provided. + * AuthOnly - SNMPv3 Authentication Encryption Security Level only. Must also provide -SnmpAuthProtocol and -SnmpAuthPassword parameters. + * AuthAndPriv - SNMPv3 Authentication Encryption Security and Privacy Levels. Must also provide -SnmpAuthProtocol, -SnmpAuthPassword, -SnmpPrivProtocol and -SnmpPrivPassword parameters. + + String + + String + + None + + + SnmpAuthPassword + + SNMPv3 UserName Password. Can be either System.String or System.Security.SecureString type. + + Object + + Object + + + + + SnmpAuthProtocol + + SNMPv3 Password Encryption Protocol. Allowed values are: + + * SHA + * MD5 + + String + + String + + + + + SnmpPrivPassword + + SNMPv3 Privacy Encryption Password. Can be either String or System.Security.SecureString type. + + Object + + Object + + + + + SnmpPrivProtocol + + SNMPv3 Privacy Protocol. Allowed values are: + + * AES + * DES + + String + + String + + + + + SnmpUserName + + The SNMPv3 Community User Name. + + String + + String + + + + + Type + + SAN Manager type to add. Accepted values are: + + * BrocadeFOS + * FOS + * HP + * HPE + * Cisco + + The following parameter values are no longer supported and have been removed: + + * Brocade + * BNA + * Brocade Network Advisor + + String + + String + + + + + UseSsl + + Use to enable SSL communication with the SAN Manager (specifically for the Brocade Network Advisor or BrocadeFOS SAN Manager type + + SwitchParameter + + SwitchParameter + + False + + + Username + + Username used to authenticate and manage the SAN Manager. This is only applicable for BNA SAN Manager. + + String + + String + + + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + Asynchronous task resource to monitor. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + $task = Add-OVSanManager -type BNA -hostname BNA.contoso.com -Credential (Get-Credential) -usessl +Wait-OVTaskComplete -InputObject $task + + Add a new Brocade Network Advisor SAN Manager. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + # Define the SNMPv3 auth protocol and levels +$CiscoSanManagerSnmpUserName = "ssh-user-SHA-AES128" +$CiscoSanManagerSnmpAuthLevel = "AuthAndPriv" +$CiscoSanManagerSnmpAuthProtocol = "SHA" +$CiscoSanManagerSnmpPrivProtocol = "aes-128" +$CiscoSanManagerSnmpAuthPassword = ConvertTo-SecureString -String "MyPassword" -AsPlainText -Force +$CiscoSanManagerSnmpPrivPassword = ConvertTo-SecureString -String "MyPassword" -AsPlainText -Force + +# Define the parameters for the two SAN fabric switches to add +$Params = @(@{ + + Hostname = "172.18.20.1"; + Type = "Cisco"; + SnmpUsername = $CiscoSanManagerSnmpUserName; + SnmpAuthLevel = $CiscoSanManagerSnmpAuthLevel; + SnmpAuthProtocol = $CiscoSanManagerSnmpAuthProtocol; + SnmpAuthPassword = $CiscoSanManagerSnmpAuthPassword; + SnmpPrivProtocol = $CiscoSanManagerSnmpPrivProtocol; + SnmpPrivPassword = $CiscoSanManagerSnmpPrivPassword + +}, @{ + + Hostname = "172.18.20.2"; + Type = "Cisco"; + SnmpUsername = $CiscoSanManagerSnmpUserName; + SnmpAuthLevel = $CiscoSanManagerSnmpAuthLevel; + SnmpAuthProtocol = $CiscoSanManagerSnmpAuthProtocol; + SnmpAuthPassword = $CiscoSanManagerSnmpAuthPassword; + SnmpPrivProtocol = $CiscoSanManagerSnmpPrivProtocol; + SnmpPrivPassword = $CiscoSanManagerSnmpPrivPassword + +}) + +# Add the SAN fabric switches as SAN managers +$Params | % { Add-OVSanManager @_ | Wait-OVTaskComplete } + + Add two Cisco FC SAN switches as SAN Managers. + + + + + + + + + + + + + Get-OVSanManager + + + + Remove-OVSanManager + + + + Set-OVSanManager + + + + Update-OVSanManager + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/storage/add-ovsanmanager + + + + + + + + Add-OVServer + + Import a physical server. + + Add + OVServer + + + A server hardware resource represents an instance of a server being managed or monitored by HPE OneView. + +For a managed server hardware resource, the configuration can be applied by assigning a server profile to it. + +Servers are associated with a server hardware type. A server hardware type captures the details of the relevant physical configuration for server hardware and defines which settings are available to server profiles that are to be assigned to that type of server hardware. + +Servers can be added into HPE OneView as either Managed or Monitored. + +Managed + +HPE OneView manages the server enabling you to apply configurations, assign server profiles, monitor operation status, collect statistics, and alert users to specific conditions. Server blades that are in a managed enclosure will automatically be added as managed. Managed servers require an HPE OneView Advanced or an HPE OneView Advanced w/o iLO license. + +For HPE Superdome Flex Server, server chassis that are in a rack manager will automatically be added as managed if the firmware installed on the rack manager supports managed mode features. + +Monitored + +HPE OneView monitors the hardware for inventory and hardware status only. The server is managed outside of HPE OneView. Server blades that are in a monitored enclosure are added as monitored. Monitored servers use a free license called HPE OneView Standard. + +For HPE Superdome Flex Server, server chassis that are in a rack manager are added as monitored if the firmware installed on the rack manager does not support managed mode features. + +You cannot remove a server that is part of an enclosure or rack manager from the appliance using either Remove-OVServer. You must remove the rack manager instead using Remove-OVRackManager. Removing a rack manager from management removes its partitions and associations. To remove a HPE BladeSystem or HPE Synergy server, it must be physically removed from the enclosure it is hosted within. + +Minimum required privileges: Infrastructure administrator or Server administrator. + + + + + Add-OVServer + + Hostname + + Hostname of the server's iLO, either IP Address or FQDN. + + String + + + Username + + This parameter is now deprecated. Please transition to using the -Credential parameter. + +Administrator account of the target iLO. + + String + + + Password + + This parameter is now deprecated. Please transition to using the -Credential parameter. + +Account password of the iLO specified. Can be String or SecureString. + + Object + + + Credential + + Use this parameter if you want to provide a PSCredential object instead. + + PSCredential + + + LicensingIntent + + Specifies whether the intent is to apply either OneView or OneView w/o iLO licenses to the server being imported. This is only required when the -Managed parameter switch is provided. If you include the -Monitored switch, LicenseIntent should not be provided. + +Accepted values are + + * OneView + * OneViewNoiLO + + String + + + Scope + + Provide an array of <HPEOneView.Appliance.ScopeResource> Scope resource(s) to initially add. + + Array + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. + + Object + + + WhatIf + + + + + + + Confirm + + When attempting to add a Server to the appliance, the appliance will validate the target Server is not already claimed. If it is, this parameter is used when the server has been claimed by another appliance to bypass the confirmation prompt, and force add the server resource. + + SwitchParameter + + + + Add-OVServer + + Hostname + + Hostname of the server's iLO, either IP Address or FQDN. + + String + + + Monitored + + Add the specified server for monitor only management. You can view hardware for inventory and status information only. Omitting this parameter, you can apply configurations, deploy server profiles, monitor operation status, collect statistics, and alert users to specific conditions. + + SwitchParameter + + + Username + + This parameter is now deprecated. Please transition to using the -Credential parameter. + +Administrator account of the target iLO. + + String + + + Password + + This parameter is now deprecated. Please transition to using the -Credential parameter. + +Account password of the iLO specified. Can be String or SecureString. + + Object + + + Credential + + Use this parameter if you want to provide a PSCredential object instead. + + PSCredential + + + Scope + + Provide an array of <HPEOneView.Appliance.ScopeResource> Scope resource(s) to initially add. + + Array + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. + + Object + + + WhatIf + + + + + + + Confirm + + When attempting to add a Server to the appliance, the appliance will validate the target Server is not already claimed. If it is, this parameter is used when the server has been claimed by another appliance to bypass the confirmation prompt, and force add the server resource. + + SwitchParameter + + + + + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + SwitchParameter + + False + + + Confirm + + When attempting to add a Server to the appliance, the appliance will validate the target Server is not already claimed. If it is, this parameter is used when the server has been claimed by another appliance to bypass the confirmation prompt, and force add the server resource. + + SwitchParameter + + SwitchParameter + + + + + Credential + + Use this parameter if you want to provide a PSCredential object instead. + + PSCredential + + PSCredential + + + + + Hostname + + Hostname of the server's iLO, either IP Address or FQDN. + + String + + String + + + + + LicensingIntent + + Specifies whether the intent is to apply either OneView or OneView w/o iLO licenses to the server being imported. This is only required when the -Managed parameter switch is provided. If you include the -Monitored switch, LicenseIntent should not be provided. + +Accepted values are + + * OneView + * OneViewNoiLO + + String + + String + + OneView + + + Monitored + + Add the specified server for monitor only management. You can view hardware for inventory and status information only. Omitting this parameter, you can apply configurations, deploy server profiles, monitor operation status, collect statistics, and alert users to specific conditions. + + SwitchParameter + + SwitchParameter + + False + + + Password + + This parameter is now deprecated. Please transition to using the -Credential parameter. + +Account password of the iLO specified. Can be String or SecureString. + + Object + + Object + + + + + Scope + + Provide an array of <HPEOneView.Appliance.ScopeResource> Scope resource(s) to initially add. + + Array + + Array + + + + + Username + + This parameter is now deprecated. Please transition to using the -Credential parameter. + +Administrator account of the target iLO. + + String + + String + + + + + WhatIf + + + + + + + + + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + Returns an async task resource to monitor. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Add-OVServer -Hostname serverilo.contoso.com -Credential (Get-Credential) -LicenseIntent OneView + + Add serverilo.contoso.com to the appliance, with the OneView license. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Add-OVServer -Hostname serverilo2.contoso.com -Credential (Get-Credential) -Monitored + + Add serverilo2.contoso.com to the appliance as a monitored only device. + + + + + + + + + + + + + Convert-OVServerProfile + + + + Convert-OVServerProfileTemplate + + + + ConvertTo-OVServerProfileTemplate + + + + Copy-OVServerProfile + + + + Get-OVServer + + + + Get-OVServerHardwareType + + + + Get-OVServerProfile + + + + Get-OVServerProfileConnectionList + + + + Get-OVServerProfileMessage + + + + Get-OVServerProfileTemplate + + + + Join-OVServerProfileToTemplate + + + + New-OVServerProfile + + + + New-OVServerProfileAssign + + + + New-OVServerProfileAttachVolume + + + + New-OVServerProfileConnection + + + + New-OVServerProfileLogicalDisk + + + + New-OVServerProfileLogicalDiskController + + + + New-OVServerProfileTemplate + + + + Remove-OVServer + + + + Remove-OVServerProfile + + + + Remove-OVServerProfileTemplate + + + + Restart-OVServer + + + + Save-OVServerProfile + + + + Save-OVServerProfileTemplate + + + + Set-OVServerHardwareType + + + + Set-OVServerPower + + + + Set-OVServerProfile + + + + Set-OVServerProfileTemplate + + + + Start-OVServer + + + + Stop-OVServer + + + + Update-OVServer + + + + Update-OVServerHardwareLicenseIntent + + + + Update-OVServerProfile + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/servers/add-ovserver + + + + + + + + Add-OVSmtpAlertEmailFilter + + Add SMTP email alert filter + + Add + OVSmtpAlertEmailFilter + + + Email alerting feature notifies specified recipients when a certain alert occurs. When this feature is configured and enabled, the appliance performs these steps in addition to posting the alert: + + * The appliance compares the alert to configured search criteria. + * If the alert matches, it creates an email message containing the text of the alert. + * The appliance sends the email message to designated recipients in both plain text and HTML MIME types. Sending in both types allows the recipient?s mail application to determine the display. + +You can enable or disable this email notification feature, or you can enable or disable individual filter notifications, as required. + +The appliance provides for as many as 100 recipient and filter combinations, and allows as many as 50 recipients in a single email message. This flexibility lets you fine-tune which alert messages are sent and to whom. For example, you can configure the appliance to send Warning alerts to one recipient and Critical alerts to another. + +This Cmdlet will help create an advanced alert to the specified recipient(s). You can also use the Cmdlet to add default OneView Remote Support alerting to specified recipient(s) using the -RemoteSupportFilter parameter. Appliance Email notification must be configured. + +Minimum required privileges: Infrastructure administrator. + + + + + Add-OVSmtpAlertEmailFilter + + Name + + Name of the Filter you are creating. + + String + + + Emails + + Destination EMail address(es). + + Net.Mail.MailAddress[] + + + Filter + + REST API filter specifying the resource category, URI, name, and severity. + +Example: CPU status:"warning" or status:"critical" + + String + + + SenderEmail + + Sending email address option to set filters-specific email sender address. + + mailaddress + + + SenderEmailPassword + + Sending email address option is provided, you can optionally specify an email address password to authenticate with. + + securestring + + + Scope + + Scope(s) the Filter should apply to. Omitting parameter will apply filter to all resources. + + HPEOneView.Appliance.ScopeCollection[] + + + ScopeMatchPreference + + If providing multiple Scope resources, specify AND or OR to indicate match preference. + + String + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + Add-OVSmtpAlertEmailFilter + + RemoteSupportFilter + + Use to create the HPE OneView Remote Support email filter for service events. + + SwitchParameter + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + SwitchParameter + + + + + Emails + + Destination EMail address(es). + + Net.Mail.MailAddress[] + + Net.Mail.MailAddress[] + + + + + Filter + + REST API filter specifying the resource category, URI, name, and severity. + +Example: CPU status:"warning" or status:"critical" + + String + + String + + + + + Name + + Name of the Filter you are creating. + + String + + String + + + + + RemoteSupportFilter + + Use to create the HPE OneView Remote Support email filter for service events. + + SwitchParameter + + SwitchParameter + + + + + Scope + + Scope(s) the Filter should apply to. Omitting parameter will apply filter to all resources. + + HPEOneView.Appliance.ScopeCollection[] + + HPEOneView.Appliance.ScopeCollection[] + + + + + ScopeMatchPreference + + If providing multiple Scope resources, specify AND or OR to indicate match preference. + + String + + String + + OR + + + SenderEmail + + Sending email address option to set filters-specific email sender address. + + mailaddress + + mailaddress + + + + + SenderEmailPassword + + Sending email address option is provided, you can optionally specify an email address password to authenticate with. + + securestring + + securestring + + + + + + + + + Net.Mail.MailAddress[] + + + Array of email address recipient(s). + + + + + + + + HPEOneView.Appliance.TaskResource {System.Management.Automation.PSCustomObject} + + + + Returns an async task resource to monitor. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Add-OVSmtpAlertEmailFilter -Name "Monitor CPU Error and Warning conditions" -query "CPU status:warning or status:critical" -emails admin1@domain.com,admin2@domain.com + + Set SMTP Alert to notify when system CPU status is either "warning" or "critical", and email 2 addresses. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Add-OVSmtpAlertEmailFilter -Name "My Test Filter 3" -Filter "status:critical" -Emails "user1@domain.com","user2@domain.com" -Scope "My new Scope","My new Scope2" -Async + + Create a new email critical alert for the two scope names, and return the Async Task object without waiting. + + + + + + + + + + -------------------------- EXAMPLE 3 -------------------------- + + + + Add-OVSmtpAlertEmailFilter -RemoteSupportFilter + + Create OneView Remote Support filter on the appliance. + + + + + + + + + + + + + Get-OVSMTPConfig + + + + Set-OVSMTPConfig + + + + Test-OVEmailAlert + + + + Get-OVSmtpAlertEmailFilter + + + + Set-OVSmtpAlertEmailFilter + + + + Remove-OVSmtpAlertEmailFilter + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/add-ovsmtpalertemailfilter + + + + + + + + Add-OVStoragePool + + Add managed Storage Pools. + + Add + OVStoragePool + + + NOTE: This Cmdlet has been replaced by Set-OVStoragePool. This Cmdlet only exists for backwards compatibility. + +A storage pool is an aggregation of physical storage resources (disks) in a storage system. Storage systems contain information about the storage ports through which they can be accessed. You can provision logical storage spaces, known as volumes, from storage pools. + +You can select one or more storage pools for management when adding a storage system to the appliance. Storage pools are created on a storage system using the management software for that system. + +NOTE: For HPE Nimble storage, you can define folders within pools in the Nimble administrative user interface. +You cannot create or delete storage pools from the appliance. Storage pools are automatically discovered during the storage system add or refresh. After you elect to manage storage pools, you can provision volumes on them. + +All storage pools that are usable in HPE OneView are visible on the Storage Pools screen. Pools refreshed into HPE OneView are initially designated as discovered, and must be explicitly set to managed by editing the pool in HPE OneView using the Edit action on the storage pool screen. + +A storage system must first be added to the appliance before a storage pool can be managed. + +Storage pools are scoped resources. You can associate a scope to a pool to restrict who can use the pool. + +Minimum required privileges: Infrastructure administrator or Storage administrator. + + + + + Add-OVStoragePool + + StorageSystem + + The Storage System object from Get-OVStorageSystem + + Object + + + Pool + + One or more storage pool name resource(s) to be added during storage system import. + +Example: $pools = "cpg1","cpg2" + + String[] + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Pool + + One or more storage pool name resource(s) to be added during storage system import. + +Example: $pools = "cpg1","cpg2" + + String[] + + String[] + + + + + StorageSystem + + The Storage System object from Get-OVStorageSystem + + Object + + Object + + + + + + + + + HPEOneView.Storage.System [System.Management.Automation.PSCustomObject] + + + Storage System resource object from Get-OVStorageSystem. + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + Async task resource. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Add-OVStoragePool -StorageSystem HP3PAR_1 -Pool HP_CPG1 + + Add the "HP_CPG1" Storage Pool that is managed in the HP3PAR_1 Storage System. PoolName parameter data type will be converted from System.String to System.Collections.ArrayList . + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + $myPools = "cpg1","cpg2" +Add-OVStoragePool -StorageSystem (Get-OVStorageSystem -Name HP3PAR_1) -Pool $myPools + + Add the "HP_CPG1" Storage Pool that is managed in the HP3PAR_1 Storage System. + + + + + + + + + + + + + Get-OVStoragePool + + + + Remove-OVStoragePool + + + + Set-OVStoragePool + + + + Update-OVStoragePool + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/storage/add-ovstoragepool + + + + + + + + Add-OVStorageSystem + + Import a supported Storage System + + Add + OVStorageSystem + + + A storage system is a storage device from which logical disks (volumes) can be provisioned and presented to servers through Fibre Channel ports or iSCSI IP addresses. Bringing SAN storage systems under management of the appliance enables you to add and create volumes. You can then attach volumes to server profiles through volume attachments. This enables the server hardware assigned to the server profiles to access the SAN storage system. StorveServe, StoreVirtual, and Nimble are the supported storage system types. + +This Cmdlet will assist with importing a supported Storage System. In order for the Storage Ports to be mapped to Expected Networks, either a Supported SAN Manager will need to be configured, or Fibre Channel Direct Attach networks will have to exist. + +When adding supported HP 3PAR storage systems, please make sure "startwsapi" has been executed from the HP 3PAR CLI, which enables the HP 3PAR REST API that is required by HPE OneView. + +Minimum required privileges: Infrastructure administrator or Storage administrator. + + + + + Add-OVStorageSystem + + Hostname + + IP Address or FQDN of the storage systems. + + String + + + Credential + + Provide the credentials to authenticate to the storage system. + + PSCredential + + + Username + + NOTE: This parameter is now deprecated. Please update to the -Credential parameter. + +Administrator account of the target storage system. + + String + + + Password + + NOTE: This parameter is now deprecated. Please update to the -Credential parameter. + +Password of administrator account password. Can either be String or System.Security.SecureString. + + Object + + + Family + + Specify the type of Storage System to add: + + * Alletra6000 + * Alletra9000 + * Nimble + * StorageVirtual + * StoreServ + * Primera + + String + + + Domain + + Specify the HPE 3PAR Virtual Domain name. Default is "NO DOMAIN". The value provided is CAsesEnSItive. + + String + + + Ports + + Specify the Host Ports and Expected Network in an Array of PSCustomObject entries. + +Example: @{"1:1:1"="Fabric A";"2:2:2"="Fabric B"} + + Object + + + PortGroups + + Specify the Host Ports to group together. + +Example: @{"1:1:1" = "PG1"; "2:2:2" = "PG2"} + + Hashtable + + + ShowSystemDetails + + By default, the Cmdlet will no longer display the details about the Storage System. Use this parameter to display information about the storage system when adding to the appliance. + + SwitchParameter + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + + + Add-OVStorageSystem + + Hostname + + IP Address or FQDN of the storage systems. + + String + + + Credential + + Provide the credentials to authenticate to the storage system. + + PSCredential + + + Username + + NOTE: This parameter is now deprecated. Please update to the -Credential parameter. + +Administrator account of the target storage system. + + String + + + Password + + NOTE: This parameter is now deprecated. Please update to the -Credential parameter. + +Password of administrator account password. Can either be String or System.Security.SecureString. + + Object + + + Family + + Specify the type of Storage System to add: + + * Alletra6000 + * Alletra9000 + * Nimble + * StorageVirtual + * StoreServ + * Primera + + String + + + VIPS + + Specify the StoreVirtual or Nimble VIP(s) and associated Ethernet Network. + +Example: + + @{"10.158.11.42" = $EthernetNetwork} + +or + + @{"10.158.11.42" = $EthernetNetwork1; "10.158.12.42" = $EthernetNetwork2;} + + Hashtable + + + ShowSystemDetails + + By default, the Cmdlet will no longer display the details about the Storage System. Use this parameter to display information about the storage system when adding to the appliance. + + SwitchParameter + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + Array + + (${Global:ConnectedSessions} | ? Default) + + + Credential + + Provide the credentials to authenticate to the storage system. + + PSCredential + + PSCredential + + + + + Domain + + Specify the HPE 3PAR Virtual Domain name. Default is "NO DOMAIN". The value provided is CAsesEnSItive. + + String + + String + + NO DOMAIN + + + Family + + Specify the type of Storage System to add: + + * Alletra6000 + * Alletra9000 + * Nimble + * StorageVirtual + * StoreServ + * Primera + + String + + String + + StoreServ + + + Hostname + + IP Address or FQDN of the storage systems. + + String + + String + + + + + Password + + NOTE: This parameter is now deprecated. Please update to the -Credential parameter. + +Password of administrator account password. Can either be String or System.Security.SecureString. + + Object + + Object + + + + + PortGroups + + Specify the Host Ports to group together. + +Example: @{"1:1:1" = "PG1"; "2:2:2" = "PG2"} + + Hashtable + + Hashtable + + + + + Ports + + Specify the Host Ports and Expected Network in an Array of PSCustomObject entries. + +Example: @{"1:1:1"="Fabric A";"2:2:2"="Fabric B"} + + Object + + Object + + + + + ShowSystemDetails + + By default, the Cmdlet will no longer display the details about the Storage System. Use this parameter to display information about the storage system when adding to the appliance. + + SwitchParameter + + SwitchParameter + + + + + Username + + NOTE: This parameter is now deprecated. Please update to the -Credential parameter. + +Administrator account of the target storage system. + + String + + String + + + + + VIPS + + Specify the StoreVirtual or Nimble VIP(s) and associated Ethernet Network. + +Example: + + @{"10.158.11.42" = $EthernetNetwork} + +or + + @{"10.158.11.42" = $EthernetNetwork1; "10.158.12.42" = $EthernetNetwork2;} + + Hashtable + + Hashtable + + + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + Add Storage System Async Task. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + $task = Add-OVStorageSystem -hostname "3par-array.consoto.com" -Credential (Get-Credential) -Async +Wait-OVTaskComplete -InputObject $task + + Add the Storage System using default settings, and let the appliance detect the connected Storage System Ports. (A supported SAN Manager must first be added, and Managed SANs mapped to the specific FC Network resources.) + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + $StorageSystemPorts = @{"1:1:1" = "Fabric A"; "2:1:1" = "Fabric A"; "1:1:2" = "Fabric B"; "2:1:2" = "Fabric B"} +$StoragePortGroups = @{"1:1:1"= "PG1"; "2:1:1" = "PG1"; "1:1:2" = "PG2"; "2:1:2" = "PG2"} +Add-OVStorageSystem -hostname "3par-array.consoto.com" -username 3paradm -password 3pardata -Domain VirtaulDomain1 -Ports $StorageSystemPorts -PortGroups $StoragePortGroups | Wait-OVTaskComplete + + Add the Storage System using default settings, and specify the Storage System Ports that will be assigned to the Expected Networks. + + + + + + + + + + -------------------------- EXAMPLE 3 -------------------------- + + + + $IscsiNetwork = Get-OVNetwork -Name "IscsiNetwork" -ErrorAction Stop +$NimbleAddress = "nimble.domain.com" +$StorageSystemPSCredential = Get-Credential -Username administrator +Add-OVStorageSystem -Family Nimble -Hostname $NimbleAddress -Credential $StorageSystemPSCredential -VIPS @{ "192.168.191.22" = $IscsiNetwork } + + Add a Nimble iSCSI storage system with PSCredential object. + + + + + + + + + + + + + Get-OVStorageSystem + + + + Get-OVStoragePool + + + + Set-OVStoragePool + + + + Get-OVStorageVolumeSet + + + + Remove-OVStorageSystem + + + + Show-OVStorageSystemPerformancePolicy + + + + Update-OVStorageSystem + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/storage/add-ovstoragesystem + + + + + + + + Add-OVStorageVolume + + Import an existing Storage Volume resource. + + Add + OVStorageVolume + + + A volume represents a logical disk provisioned from a storage pool on a storage system. + +A volume can be used by a single server (private) or can be used by multiple servers (shared). + +You can attach volumes to one or more servers by configuring a volume attachment in the server profile. The volume attachment manages volume presentation on the storage system (StoreServ port selection, host and vLUN creation) as well as SAN zoning on SANs (with automatic zoning enabled) that connect the server and storage system. + +Using volume templates, you can create multiple volumes with the same configuration. + +You can increase (grow) the capacity of a volume by editing it. You cannot decrease the capacity of a volume. + +This Cmdlet will help add an existing storage volume that was provisioned on the Storage System. In order to import an existing storage volume, the following prerequisites must be met: + + * The storage system that contains the volume you want to add is being managed by the appliance, and the volume must be within the same 3Par virtual domain as the managed storage system. + * The storage pool that contains the volume you want to add is being managed by the appliance. + * The snapshot storage pool defined for the volume you want to add is being managed by the appliance. + +The Storage Volume's WWN or device name will be needed, which can be retrieved from the storage system management console. + +Minimum required privileges: Infrastructure administrator or Storage administrator. + + + + + Add-OVStorageVolume + + StorageSystem + + The Storage System where the volume will be imported from. Volume to be imported must be provisioned to the same Managed Domain as the Storage System. + + Object + + + StorageDeviceName + + The Storage Systems Device Name of the volume. This can be found in either the 3PAR IMC, CLI or HPE SSMC by looking at the provisioned volume and copying the "Name" property. + + String + + + VolumeName + + Specify the Storage Volume Name. + + String + + + VolumeID + + Warning: This parameter is deprecated. Please use the -StorageDeviceName parameter. + +The 128bit WWN FC address of the volume to be imported. Address must be in the following format: AA:BB:CC:DD:EE:AA:BB:CC:DD:EE:AA:BB:CC:DD:EE:AA + + String + + + Description + + Provide a description for the volume. + + String + + + Shared + + Include this switch to mark the Storage Volume as a Shareable resource for shared volume access. +Default: Private + + SwitchParameter + + + Scope + + Provide an HPEOneView.Appliance.ScopeCollection resource object to initially associate with. Resource can also be added to scope using the Add-OVResourceToScope Cmdlet. + + HPEOneView.Appliance.ScopeCollection[] + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + + + + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Description + + Provide a description for the volume. + + String + + String + + + + + Scope + + Provide an HPEOneView.Appliance.ScopeCollection resource object to initially associate with. Resource can also be added to scope using the Add-OVResourceToScope Cmdlet. + + HPEOneView.Appliance.ScopeCollection[] + + HPEOneView.Appliance.ScopeCollection[] + + False + + + Shared + + Include this switch to mark the Storage Volume as a Shareable resource for shared volume access. +Default: Private + + SwitchParameter + + SwitchParameter + + False + + + StorageDeviceName + + The Storage Systems Device Name of the volume. This can be found in either the 3PAR IMC, CLI or HPE SSMC by looking at the provisioned volume and copying the "Name" property. + + String + + String + + + + + StorageSystem + + The Storage System where the volume will be imported from. Volume to be imported must be provisioned to the same Managed Domain as the Storage System. + + Object + + Object + + + + + VolumeID + + Warning: This parameter is deprecated. Please use the -StorageDeviceName parameter. + +The 128bit WWN FC address of the volume to be imported. Address must be in the following format: AA:BB:CC:DD:EE:AA:BB:CC:DD:EE:AA:BB:CC:DD:EE:AA + + String + + String + + + + + VolumeName + + Specify the Storage Volume Name. + + String + + String + + + + + + + + + HPEOneView.Storage.System [System.Management.Automation.PSCustomObject] + + + Storage Pool resource object + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + Async create task + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Add-OVStorageVolume -StorageSystem (Get-OVStorageSystem -Name 3ParSys1) -StorageDeviceName MyStorageVol1 -VolumeName MyStorageVol1 + + Import the volume "MyStorageVol1" from the "3ParSys1" Storage System. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Get-OVStorageSystem -Name 3ParSys1 | Add-OVStorageVolume -StorageDeviceName MyStorageVol1 -VolumeName MyStorageVol1 + + Import the volume "MyStorageVol1" from the "3ParSys1" Storage System using the pipeline. + + + + + + + + + + -------------------------- EXAMPLE 3 -------------------------- + + + + Get-OVStorageSystem -Name 3ParSys1 | Add-OVStorageVolume -StorageDeviceName ClusterSharedVol1 -VolumeName ClusterSharedVol1 -Shared + + Import a volume using the storage device name "ClusterSharedVol1" on the "3ParSys1" Storage System. + + + + + + + + + + + + + ConvertTo-OVStorageVolume + + + + Get-OVStorageVolume + + + + Get-OVStorageVolumeSet + + + + Get-OVStorageVolumeSnapShot + + + + Get-OVStorageVolumeTemplate + + + + Get-OVStorageVolumeTemplatePolicy + + + + New-OVStorageVolume + + + + New-OVStorageVolumeSnapshot + + + + New-OVStorageVolumeTemplate + + + + Remove-OVStorageVolume + + + + Remove-OVStorageVolumeSnapshot + + + + Remove-OVStorageVolumeTemplate + + + + Set-OVStorageVolume + + + + Set-OVStorageVolumeTemplate + + + + Set-OVStorageVolumeTemplatePolicy + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/storage/add-ovstoragevolume + + + + + + + + Clear-OVAlert + + [DEPRECATED] Clear an Alert status. + + Clear + OVAlert + + + DEPRECATED as of 2.0. Please use Set-OVAlert + + + + + Clear-OVAlert + + + + + + + + + + None. + + + + + + + + + + + None + + + + + + + + + + + + + + Get-OVAlert + + + + Remove-OVAlert + + + + Set-OVAlert + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/clear-ovalert + + + + + + + + Connect-OVComputeOpsManagement + + Reestablish appliance connection to Compute Ops Management. + + Connect + OVComputeOpsManagement + + + HPE GreenLake for Compute Ops Management is a cloud-based as-a-Service application that manages various operations of HPE OneView appliances. By integrating HPE OneView with HPE GreenLake for Compute Ops Management will unify server inventory and centralize management to a single console. To enable the cloud management service for HPE OneView, you must onboard the appliance in the Compute Ops Management application in HPE GreenLake by using the Enable-OVComputeOpsManagement and Set-OVComputeOpsManagement Cmdlets. + +This Cmdlet is used to re-connect an already configured, yet disconnected appliance. + +Minimum required privileges: Infrastructure administrator + + + + + Connect-OVComputeOpsManagement + + ApplianceConnection + + Specify one or more HPEOneView.Appliance.Connection object(s) or Name property value(s). + +Default Value: ${Global:ConnectedSessions} | ? Default + + Object + + + + + + + ApplianceConnection + + Specify one or more HPEOneView.Appliance.Connection object(s) or Name property value(s). + +Default Value: ${Global:ConnectedSessions} | ? Default + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + + + + + None. You cannot pipe objects to this cmdlet. + + + + + + + + + + + HPOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + Async task resource to monitor. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Connect-OVComputeOpsManagement + + + Reestablish connection to Compute Ops Management. + + + + + + + + + + + + + Disable-OVComputeOpsManagement + + + + Enable-OVComputeOpsmanagement + + + + Get-OVComputeOpsManagement + + + + Set-OVComputeOpsManagement + + + + Set-OVApplianceProxy + + + + Online: + https://hpe-docs.gitbook.io/posh-hpeoneview/cmdlets/v9.00/appliance/connect-ovcomputeopsmanagement + + + + + + + + Connect-OVMgmt + + Initiate a connection to an HPE OneView appliance. + + Connect + OVMgmt + + + This Cmdlet establishes a connection to the specified HPE OneView or HPE Synergy Composer appliance. When the connection is successful, the user establishes a session for use with subsequent Cmdlet requests. The effective user permissions are established on the first connection. Please refer to about_appliance_connection_permissions and about_appliance_connections for more information about initiating multiple appliance connections. + +Appliance hostname or IP can include an alternate TCP port number. While the appliance does not allow the default TCP port 443 to be changed, the appliance could reside behind a firewall, which is redirecting an alternate TCP port number. + +If the appliance is configured to Common Access Card (CAC) authentication, the -Certificate parameter is required. If the CAC requires a PIN to unlock, the user will be prompted by the credential service to provide that value. The Cmdlet does not offer the ability to retrieve or store the CAC PIN. + +Minimum required privileges: Read-only. + + + + + Connect-OVMgmt + + Hostname + + The hostname or IP address of the appliance. + + String + + + UserName + + Warning: This parameter is now obsolete. Please transition to using the -Credential parameter. + +User name to authenticate. + + String + + + AuthLoginDomain + + The Directory Name for LDAP/Active Directory authentication, or LOCAL for appliance internal user accounts. + +Default is determined by connecting to the requested appliance and retrieving the default login directory. If not LOCAL, and you attempt to use an embedded user account, you must use -AuthLoginDomain parameter with the Local value. + + String + + + Password + + Warning: This parameter is now obsolete. Please transition to using the -Credential parameter. + +Password to log into the appliance. Can be either System.String or SecureString value. + + Object + + + LoginAcknowledge + + When a Login Message has been configured and acknowledgement is Required, use this parameter to acknowledge it during the initial call. Otherwise, if omitted, and a Login Banner acknowledgement is required, the caller will be prompted. This prompt does not support the -Confirm parameter. + + SwitchParameter + + + + Connect-OVMgmt + + Hostname + + The hostname or IP address of the appliance. + + String + + + Certificate + + Provide the X.509 certificate/SmartCard digital badge in order to authenticate to a supported appliance. Two-factor authentication must be configured on the appliance in order to provide a X.509 certificate. + + Object + + + LoginAcknowledge + + When a Login Message has been configured and acknowledgement is Required, use this parameter to acknowledge it during the initial call. Otherwise, if omitted, and a Login Banner acknowledgement is required, the caller will be prompted. This prompt does not support the -Confirm parameter. + + SwitchParameter + + + + Connect-OVMgmt + + Hostname + + The hostname or IP address of the appliance. + + String + + + Credential + + Use this parameter if you want to provide a PSCredential object instead. + + PSCredential + + + AuthLoginDomain + + The Directory Name for LDAP/Active Directory authentication, or LOCAL for appliance internal user accounts. + +Default is determined by connecting to the requested appliance and retrieving the default login directory. If not LOCAL, and you attempt to use an embedded user account, you must use -AuthLoginDomain parameter with the Local value. + + String + + + LoginAcknowledge + + When a Login Message has been configured and acknowledgement is Required, use this parameter to acknowledge it during the initial call. Otherwise, if omitted, and a Login Banner acknowledgement is required, the caller will be prompted. This prompt does not support the -Confirm parameter. + + SwitchParameter + + + + + + + AuthLoginDomain + + The Directory Name for LDAP/Active Directory authentication, or LOCAL for appliance internal user accounts. + +Default is determined by connecting to the requested appliance and retrieving the default login directory. If not LOCAL, and you attempt to use an embedded user account, you must use -AuthLoginDomain parameter with the Local value. + + String + + String + + LOCAL + + + Certificate + + Provide the X.509 certificate/SmartCard digital badge in order to authenticate to a supported appliance. Two-factor authentication must be configured on the appliance in order to provide a X.509 certificate. + + Object + + Object + + + + + Credential + + Use this parameter if you want to provide a PSCredential object instead. + + PSCredential + + PSCredential + + + + + Hostname + + The hostname or IP address of the appliance. + + String + + String + + + + + LoginAcknowledge + + When a Login Message has been configured and acknowledgement is Required, use this parameter to acknowledge it during the initial call. Otherwise, if omitted, and a Login Banner acknowledgement is required, the caller will be prompted. This prompt does not support the -Confirm parameter. + + SwitchParameter + + SwitchParameter + + False + + + Password + + Warning: This parameter is now obsolete. Please transition to using the -Credential parameter. + +Password to log into the appliance. Can be either System.String or SecureString value. + + Object + + Object + + + + + UserName + + Warning: This parameter is now obsolete. Please transition to using the -Credential parameter. + +User name to authenticate. + + String + + String + + + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + HPEOneView.Appliance.Connection + + + + When a valid connection is established with an appliance, this object is then added to ${Global:ConnectedSessions} connection tracker variable. The object returned will contain the following public properties: ============================================================================== + | Name | Type | Value | + |----------------------------------------------------------------------------- + | AuthLoginDomain | String | Local | + ------------------------------------------------------------------------------ + | ConnectionId | Int | 1 | + ------------------------------------------------------------------------------ + | Name | String | Hostname value | + ---------------------- ------------------------------------------------------- + | SessionID | String | AUTH string returned from API | + ------------------------------------------------------------------------------ + | ApplianceType | String | Indicate connected appliance type. | + -------------------- --------------------------------------------------------- + | UserName | String | Username value | + ------------------------------------------------------------------------------ + | AuthType | String | Credential or Certificate/2FA | + ------------------------------------------------------------------------------ + | ActivePermissions | IList | Collection of Scopes and permissions | + ------------------------------------------------------------------------------ + | ApplianceSecurityRoles | IList | Collection of roles | + ------------------------------------------------------------------------------ + | Default | Boolean | Is connection default for library | + ------------------------------------------------------------------------------ + + + + + System.Management.Automation.ErrorRecord + + + + On error, appliance response is returned as a terminating error. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Connect-OVMgmt -appliance myappliance.domain.com +ConnectionID Name UserName AuthLoginDomain +------------ ---- -------- --------------- +1 myappliance.domain.com Administrator LOCAL + + Connect to a specific appliance FQDN. The user will be prompted for authentication provider, user name and password. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Connect-OVMgmt -appliance myappliance.domain.com:11223 + + Connect to a specific appliance, where the target TCP port isn't the default. The user will be prompted for authentication provider, user name and password. + + + + + + + + + + -------------------------- EXAMPLE 3 -------------------------- + + + + $MySmartCard = gci Cert:\CurrentUser\my | ? { $_.EnhancedKeyUsageList.FriendlyName -match "Smart Card Logon" } +Connect-OVMgmt -appliance myappliance.domain.com -Certificate $MySmartCard + + Connect to a specific appliance using a digital badge. + + + + + + + + + + + + + Disconnect-OVMgmt + + + + about_Appliance_Connection_Permissions + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/library/connect-ovmgmt + + + [${Global:ConnectedSessions}] + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/library/connect-ovmgmt + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/library/connect-ovmgmt + + + + + + + + Convert-OVServerProfile + + Migrate Server Profile. + + Convert + OVServerProfile + + + Use this Cmdlet to change the Server Hardware Type and/or Enclosure Group set within the Server Profile. Changing to +a different server hardware type may change the capabilities available to the server profile. Changing the enclosure group may change the connections which are available for the profile. + + * The server hardware field will be set to "unassigned", requiring re-seletion of server hardware. + * It may also cause incompatibilities with the current configuration. + * All deployed connections will have their port assignment set to "Auto". + * Any incompatibilities will be flagged when the server profile is committed. + * If the new server hardware type does not support the local storage configuration, some storage may be lost. + * If the enclosure group is changed, mezzanine storage is lost and the disk drives are released. + * To prevent data loss, cancel this operation and backup data before applying the profile. + * Any change in the server hardware type will lead to the associated volume loss. + * If the server profile is associated with a server profile template, the server profile will become inconsistent with the template. The server profile should be unassociated with the template before or after the migration. + +Minimum required privileges: Infrastructure administrator or Server administrator. + + + + + Convert-OVServerProfile + + InputObject + + The HPEOneView.ServerProfile object from Get-OVServerProfile. + + Object + + + ServerHardwareType + + Specify the HPEOneView.ServerHardwareType object to transform to. BIOS Settings will be reset to defaults, and Connection FlexNIC assignment will be reset back to Auto. + + Object + + + EnclosureGroup + + Specify the target HPEOneView.EnclosureGroup resource object. By changing the Enclosure Group, assigned Networks with Connections that do not exist on in the associated Logical Interconnect Group(s), the Connection may not be assigned to an available FlexNIC. + + Object + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + + WhatIf + + + + + + + Confirm + + Override confirmation prompt. + + SwitchParameter + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + Array + + (${Global:ConnectedSessions} | ? Default) + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + SwitchParameter + + False + + + Confirm + + Override confirmation prompt. + + SwitchParameter + + SwitchParameter + + + + + EnclosureGroup + + Specify the target HPEOneView.EnclosureGroup resource object. By changing the Enclosure Group, assigned Networks with Connections that do not exist on in the associated Logical Interconnect Group(s), the Connection may not be assigned to an available FlexNIC. + + Object + + Object + + + + + InputObject + + The HPEOneView.ServerProfile object from Get-OVServerProfile. + + Object + + Object + + + + + ServerHardwareType + + Specify the HPEOneView.ServerHardwareType object to transform to. BIOS Settings will be reset to defaults, and Connection FlexNIC assignment will be reset back to Auto. + + Object + + Object + + + + + WhatIf + + + + + + + + + + + + + + + HPEOneView.ServerProfile + + + The Server Profile resource object to transform. + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + Async Task resource to monitor progress of the Server Profile transformation. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + $ServerProfile = Get-OVServerProfile -Name "Prod Server 1" -ErrorAction Stop +$NewServerHardwareType = Get-OVServerHardwareType -Name "BL460 Gen9 3" -ErrorAction Stop +Convert-OVServerProfile -InputObject $ServerProfile -ServerHardwareType $NewServerHardwareType + + Transform the specified server profile object to a different server hardware type resource. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + $ServerProfile = Get-OVServerProfile -Name "Prod Server 1" -ErrorAction Stop +$NewEnclosureGroup = Get-OVEnclosureGroup -Name "Dev EG 1" -ErrorAction Stop +Convert-OVServerProfile -InputObject $ServerProfile -EnclosureGroup $NewEnclosureGroup + + Transform the specified server profile object to a different enclosure group resource. + + + + + + + + + + -------------------------- EXAMPLE 3 -------------------------- + + + + $ServerProfile = Get-OVServerProfile -Name "Prod Server 1" -ErrorAction Stop +$NewEnclosureGroup = Get-OVEnclosureGroup -Name "Dev EG 1" -ErrorAction Stop +$NewServerHardwareType = Get-OVServerHardwareType -Name "BL460 Gen9 3" -ErrorAction Stop +Convert-OVServerProfile -InputObject $ServerProfile -EnclosureGroup $NewEnclosureGroup -ServerHardwareType $NewServerHardwareType + + Transform the specified server profile object to a different enclosure group and server hardware type resource. + + + + + + + + + + + + + Convert-OVServerProfileTemplate + + + + ConvertTo-OVServerProfileTemplate + + + + Copy-OVServerProfile + + + + Get-OVServerProfile + + + + Get-OVServerProfileConnectionList + + + + Get-OVServerProfileMessage + + + + Get-OVServerProfileTemplate + + + + Join-OVServerProfileToTemplate + + + + New-OVServerProfile + + + + New-OVServerProfileAssign + + + + New-OVServerProfileAttachVolume + + + + New-OVServerProfileConnection + + + + New-OVServerProfileLogicalDisk + + + + New-OVServerProfileLogicalDiskController + + + + New-OVServerProfileTemplate + + + + Remove-OVServerProfile + + + + Remove-OVServerProfileTemplate + + + + Save-OVServerProfile + + + + Save-OVServerProfileTemplate + + + + Set-OVServerProfile + + + + Set-OVServerProfileTemplate + + + + Update-OVServerProfile + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/servers/convert-ovserverprofile + + + + + + + + Convert-OVServerProfileTemplate + + Migrate Server Profile Template. + + Convert + OVServerProfileTemplate + + + Use this Cmdlet to change the Server Hardware Type and/or Enclosure Group set within the Server Profile Template. Changing to a different server hardware type may change the capabilities available to the server profile. Changing the enclosure group may change the connections which are available for the profile template. + + * It may also cause incompatibilities with the current configuration. + * All defined connections will have their port assignment set to "Auto". + * Any incompatibilities will be flagged when the server profile template is committed. + * If the new server hardware type does not support the local storage configuration, some storage may not be configurable. + * If the enclosure group is changed, mezzanine storage for HPE Synergy is lost and the disk drives are released. + * Any change in the server hardware type will lead to the associated volume loss. + +Minimum required privileges: Infrastructure administrator or Server administrator. + + + + + Convert-OVServerProfileTemplate + + InputObject + + The HPEOneView.ServerProfileTemplate object from Get-OVServerProfileTemplate. + + Object + + + ServerHardwareType + + Specify the HPEOneView.ServerHardwareType object to transform to. BIOS Settings will be reset to defaults, and Connection FlexNIC assignment will be reset back to Auto. + + Object + + + EnclosureGroup + + Specify the target HPEOneView.EnclosureGroup resource object. By changing the Enclosure Group, assigned Networks with Connections that do not exist on in the associated Logical Interconnect Group(s), the Connection may not be assigned to an available FlexNIC. + + Object + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + + WhatIf + + default content + + SwitchParameter + + + Confirm + + Override confirmation prompt. + + SwitchParameter + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + Array + + (${Global:ConnectedSessions} | ? Default) + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + SwitchParameter + + False + + + Confirm + + Override confirmation prompt. + + SwitchParameter + + SwitchParameter + + + + + EnclosureGroup + + Specify the target HPEOneView.EnclosureGroup resource object. By changing the Enclosure Group, assigned Networks with Connections that do not exist on in the associated Logical Interconnect Group(s), the Connection may not be assigned to an available FlexNIC. + + Object + + Object + + + + + InputObject + + The HPEOneView.ServerProfileTemplate object from Get-OVServerProfileTemplate. + + Object + + Object + + + + + ServerHardwareType + + Specify the HPEOneView.ServerHardwareType object to transform to. BIOS Settings will be reset to defaults, and Connection FlexNIC assignment will be reset back to Auto. + + Object + + Object + + + + + WhatIf + + default content + + SwitchParameter + + SwitchParameter + + + + + + + + + HPEOneView.ServerProfileTemplate + + + The Server Profile Template resource object to transform. + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + Async Task resource to monitor progress of the Server Profile transformation. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + $SPT = Get-OVServerProfileTemplate -Name "My Template Name" -ErrorAction Stop +$NewServerHardwareType = Get-OVServerHardwareType -Name "SY480 Gen10 2" -ErrorAction Stop +Convert-OVServerProfileTemplate -InputObject $SPT -ServerHardwareType $NewServerHardwareType + + Transform the specified server profile template object to a different server hardware type resource. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + $SPT = Get-OVServerProfileTemplate -Name "My Template Name" -ErrorAction Stop +$NewEnclosureGroup = Get-OVEnclosureGroup -Name "Dev EG 1" -ErrorAction Stop +Convert-OVServerProfileTemplate -InputObject $SPT -EnclosureGroup $NewEnclosureGroup + + Transform the specified server profile template object to a different enclosure group resource. + + + + + + + + + + -------------------------- EXAMPLE 3 -------------------------- + + + + $SPT = Get-OVServerProfileTemplate -Name "My Template Name" -ErrorAction Stop +$NewEnclosureGroup = Get-OVEnclosureGroup -Name "Dev EG 1" -ErrorAction Stop +$NewServerHardwareType = Get-OVServerHardwareType -Name "BL460 Gen9 3" -ErrorAction Stop +Convert-OVServerProfileTemplate -InputObject $SPT -EnclosureGroup $NewEnclosureGroup -ServerHardwareType $NewServerHardwareType + + Transform the specified server profile template object to a different enclosure group and server hardware type resource. + + + + + + + + + + + + + ConvertTo-OVServerProfileTemplate + + + + Get-OVServerProfileTemplate + + + + New-OVServerProfileTemplate + + + + Remove-OVServerProfileTemplate + + + + Save-OVServerProfileTemplate + + + + Set-OVServerProfileTemplate + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/servers/convert-ovserverprofiletemplate + + + + + + + + ConvertTo-OVImageStreamerConfiguration + + Convert Logical Enclosure to support HPE Image Streamer. + + ConvertTo + OVImageStreamerConfiguration + + + Convert Logical Enclosure and associated Enclosure Group and Logical Interconnect Group to support Internal Image Streamer configuration. HPE Synergy Virtual Connect Logical Interconnect Group must reside in Bays 3 and 6 in order to be reconfigured. + +When using this Cmdlet, a service outage will occur, as the Logical Enclosure will need to be recreated. This means Server Profiles will be unassigned, Logical Enclosure removed then recreated, and then Server Profiles reassigned to their original location. If the Logical Enclosure contains HPE Synergy SAS Logical Interconnects, data loss may occur, +as the Server Profiles may not be assigned in the right order, which would cause disk selection to assign different physical disks. Please make sure all data is backed up prior to migration. By Default, the Cmdlet will not migrate a Logical Enclosure if SAS Logical Interconnects are found. To override, use the -IgnoreSasLogicalInterconnects switch, +which again may cause loss of data. + +Any associated Enclosure Groups with the Virtual Connect Ethernet Logical Interconnect Group will also be modified. If this is not intended, you should first remove the Logical Interconnect Group from the Enclosure Group before executing this Cmdlet. + +Minimum required privileges: Infrastructure administrator or Server administrator. + + + + + ConvertTo-OVImageStreamerConfiguration + + InputObject + + Provide the Logical Enclosure resource object or name that will be recreated. + + Object + + + UplinkSetName + + The Uplink Set Name to be added. + + Name + + + DeploymentNetwork + + Provide the Deployment Network object. Must be associated with a valid IPv4 Subnet that is within the same subnet as the Composer. + + Object + + + UplinkPorts + + Specify 4 redundant Uplink Ports. + + Array + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + WhatIf + + + + + + + Confirm + + + + + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Confirm + + + + + + + + + + + DeploymentNetwork + + Provide the Deployment Network object. Must be associated with a valid IPv4 Subnet that is within the same subnet as the Composer. + + Object + + Object + + + + + InputObject + + Provide the Logical Enclosure resource object or name that will be recreated. + + Object + + Object + + + + + UplinkPorts + + Specify 4 redundant Uplink Ports. + + Array + + Array + + @("Enclosure1:Bay3:Q1.1","Enclosure1:Bay3:Q2.1","Enclosure2:Bay6:Q1.1","Enclosure2:Bay6:Q2.1") + + + UplinkSetName + + The Uplink Set Name to be added. + + Name + + Name + + + + + WhatIf + + + + + + + + + + + + + + + HPEOneView.LogicalEnclosure [System.Management.Automation.PSCustomObject] + + + HPE Synergy Logical Enclosure to convert. + + + + + + + + System.Management.Automation.PSCustomObject + + + + If the Logical Enclosure cannot be removed or re-created, as PSCustomObject with original Server Profile location is provided. Object properties are Name, ProfileUri, ServerSerialNumber. + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + The async task for each Server Profile that will be re-assigned for the caller to monitor. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + $LE = Get-OVLogicalEnclosure -Name MyLE1 -ErrorAction Stop +$UplinkPorts = @("Enclosure1:Bay3:Q3.1","Enclosure1:Bay3:Q4.1","Enclosure2:Bay6:Q3.1","Enclosure2:Bay6:Q4.1") +$UplinkSetName = "ImageStreamer UplinkSet" +$DeploymentNetwork = Get-OVNetwork -Name "ImageStreamer Deployment" -ErrorAction Stop +ConvertTo-OVImageStreamerConfiguration -InputObject $le -UplinkSetName $UplinkSetName -UplinkPorts $UplinkPorts -DeploymentNetwork $DeploymentNetwork -IgnoreSasLogicalInterconnects + + Convert the MyLE1 Logical Enclosure to support Image Streamer, specifying uplink ports, OS Deployment Network and to ignore found SAS Logical Interconnects if found. + + + + + + + + + + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/servers/convertto-ovimagestreamerconfiguration + + + + + + + + ConvertTo-OVPowerShellScript + + Create PowerShell script from resource. + + ConvertTo + OVPowerShellScript + + + This Cmdlet will assist administrators or scripters to help generate script code from specific resources. The code generated is a starting point to be used for repeating similar tasks performed by the UI, or to incorporate into scripts or workflows. + +The following resources are supported by this Cmdlet: + + * Baselines (Get-OVBaseline) + * Appliance address pool ranges (Get-OVAddressPoolRange) + * Appliance address pool Subnets (Get-OVAddressPoolSubnet) + * Appliance Date Time and Locale (Get-OVApplianceDateTime) + * Appliance LDAP Directory (Get-OVLdapDirectory) + * Appliance LDAP Directory Group (Get-OVLdapGroup) + * Appliance SNMP configuration (Get-OVSnmpReadCommunity) + * Appliance SNMPv3 Users (Get-OVSnmpV3User) + * Appliance Email Notifications (Get-OVApplianceProxy) + * Appliance Proxy (Get-OVApplianceProxy) + * Appliance User (Get-OVUser) + * Scopes (Get-OVScope) + * Network (Get-OVNetwork) + * Network Set (Get-OVNetworkSet) + * SAN Manager (Get-OVSanManager) + * Storage System (Get-OVStorageSystem) + * Storage Pool (Get-OVStoragePool) + * Storage Volume Template (Get-OVStorageVolumeTemplate) + * Storage Volume (Get-OVStorageVolume) + * Logical Interconnect Group (Get-OVLogicalInterconnectGroup) + * Logical Enclosure Group (Get-OVEnclosureGroup) + * Logical Enclosure (Get-OVLogicalEnclosure) + * Server Profile Template (Get-OVServerProfileTemplate) + * Server Profile (Get-OVServerProfile) + + + + + ConvertTo-OVPowerShellScript + + InputObject + + Resource object from supported Cmdlets. + + Object + + + Export + + Location where to write UTF-8 file. + + System.IO.FileInfo + + + Append + + Indicte if the export file should be appended. By default, a new file will be created with new content. + + SwitchParameter + + + + + + + Append + + Indicte if the export file should be appended. By default, a new file will be created with new content. + + SwitchParameter + + SwitchParameter + + + + + Export + + Location where to write UTF-8 file. + + System.IO.FileInfo + + System.IO.FileInfo + + + + + InputObject + + Resource object from supported Cmdlets. + + Object + + Object + + + + + + + + + Various objects are supported. + + + + + + + + + + + System.String + + + + String output of generated code. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVServerProfile | ConvertTo-OVPowerShellScript + + Generate PowerShell script code for the returned server profile objects. + + + + + + + + + + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/library/convertto-ovpowershellscript + + + + + + + + ConvertTo-OVServerProfileTemplate + + Create a Server Profile Template from Server Profile. + + ConvertTo + OVServerProfileTemplate + + + This Cmdlet will allow the user to "clone" or create a Server Profile Template from an existing Server Profile object. Not all Server Profile features will be converted to a Server Profile Template. For instance, the following features are not supported with a Server Profile Template: + + * Import existing local Smart Array Logical Disk configuration + * Attach SAN Storage Volumes must be assigned a unique LUN ID + +If the source Server Profile has the "Import existing logical drives" enabled, this setting will be disabled, and the Local Disk Configuration policy will be set to "disabled". + +If any SAN Storage Volume attachments contain an "Auto" LUN value, it will be set to "Manual", with the LUN ID set to a unique value based on the Array Index value. + +Minimum required privileges: Infrastructure administrator or Server administrator. + + + + + ConvertTo-OVServerProfileTemplate + + InputObject + + A source Server Profile Object or Resource Name. + + Object + + + Name + + The Server Profile Template Name to assign. If omitted, then a new name of "Copy of - {Original_Name}" will be defined. + + String + + + Description + + The Server Profile description. + + String + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + + + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + SwitchParameter + + False + + + Description + + The Server Profile description. + + String + + String + + + + + InputObject + + A source Server Profile Object or Resource Name. + + Object + + Object + + + + + Name + + The Server Profile Template Name to assign. If omitted, then a new name of "Copy of - {Original_Name}" will be defined. + + String + + String + + + + + + + + + HPEOneView.ServerProfile [System.Management.Automation.PSCustomObject] + + + A Server Profile resource object from Get-OVServerProfile. + + + + + System.Collections.ArrayList + + + Multiple HPEOneView.ServerProfile [System.Management.Automation.PSCustomObject] objects. + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] objects. + + + + Asynchronous task of the Server Profile Template creation request. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVServerProfile -Name MyProfile | ConvertTo-OVServerProfileTemplate -Name "Hypervisor Gold Template 1" + + Use Get-OVServerProfile to retrieve the "MyProfile" object, creating a new Server Profile Template "Hyervisor Gold Template 1". + + + + + + + + + + + + + Convert-OVServerProfileTemplate + + + + Get-OVServerProfileTemplate + + + + New-OVServerProfileTemplate + + + + Remove-OVServerProfileTemplate + + + + Save-OVServerProfileTemplate + + + + Set-OVServerProfileTemplate + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/servers/convertto-ovserverprofiletemplate + + + + + + + + ConvertTo-OVStorageVolume + + Convert an existing Storage Volume Snapshot to a Storage Volume. + + ConvertTo + OVStorageVolume + + + A snapshot is a virtual copy of an existing volume at a point in time. You can use a snapshot as a backup of a volume, and then use the snapshot to revert a volume to the backup, or to create new volumes from the snapshot. +A snapshot is a static copy of a volume at the point the snapshot is created. Snapshots are not updated to reflect changes in the volume since the snapshot was taken. + +A new volume created from a snapshot will be the same size as the snapshot and will contain all of the data in the snapshot. The two volumes are logically unrelated, but physically, unchanged data is only stored once between the two volumes. + +Reverting a volume to a snapshot will revert to the data the volume contained when the snapshot was taken. The size of the volume will remain the same as when it was reverted. For example, if you take a snapshot of a 50 GiB volume, grow the volume to 100 GiB, and then revert to the snapshot, the volume will be 100 GiB with the data from the 50 GiB snapshot. + +Reverting to a snapshot of a volume will cause all data created or changed since the snapshot was taken to be lost. Backup your data to prevent data loss. + +NOTE: You cannot create a volume from an HPE Nimble storage system snapshot from HPE OneView. + +Minimum required privileges: Infrastructure administrator, Server administrator, or Storage administrator. + + + + + ConvertTo-OVStorageVolume + + InputObject + + Provide the snapshot resource object to convert managed by the appliance. + + Object + + + Name + + The Storage Volume Name. + + String + + + Description + + The description of the storage volume. + + String + + + SharingMode + + Specify if the new storage volume should be Private or Shared. + + String + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + +Default Value: ${Global:ConnectSessions} | ? Default + + Object + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + + + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + +Default Value: ${Global:ConnectSessions} | ? Default + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + SwitchParameter + + False + + + Description + + The description of the storage volume. + + String + + String + + + + + InputObject + + Provide the snapshot resource object to convert managed by the appliance. + + Object + + Object + + + + + Name + + The Storage Volume Name. + + String + + String + + + + + SharingMode + + Specify if the new storage volume should be Private or Shared. + + String + + String + + + + + + + + + HPEOneView.Storage.VolumeSnapshot [System.Management.Automation.PSCustomObject] + + + Storage Volume Snapshot resource object. + + + + + + + + System.Collections.ArrayList <HPEOneView.Appliance.TaskResource> + + + + Multiple resources + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + Create Storage Volume async task. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + $Volume = Get-OVStorageVolume -Name PrivVolume1 | Get-OVStorageVolumeSnapshot | Select-Object -Last 1 +ConvertTo-OVStorageVolume -Name "Copy of PrivVolume1" + + Get the most recent snapshot of PrivVolume1 and convert it to a volume. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + $Snapshots = Get-OVStorageVolume "Volume 1" | Get-OVStorageVolumeSnapshot +$Snapshots | ? { ((Get-Date $_.created -Format d) -eq (Get-Date 02/23/2016 -format d)} | ConvertTo-OVStorageVolume -Name "Copy of Volume 1" | Wait-OVTaskComplete + + Get all of the available storage volume snapshots for "Volume 1", then convert the snapshot created on the specified date to a storage volume resource. + + + + + + + + + + + + + Add-OVStorageVolume + + + + Get-OVStorageVolume + + + + Get-OVStorageVolumeSet + + + + Get-OVStorageVolumeSnapShot + + + + Get-OVStorageVolumeTemplate + + + + Get-OVStorageVolumeTemplatePolicy + + + + New-OVStorageVolume + + + + New-OVStorageVolumeSnapshot + + + + New-OVStorageVolumeTemplate + + + + Remove-OVStorageVolume + + + + Remove-OVStorageVolumeSnapshot + + + + Remove-OVStorageVolumeTemplate + + + + Set-OVStorageVolume + + + + Set-OVStorageVolumeTemplate + + + + Set-OVStorageVolumeTemplatePolicy + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/storage/convertto-ovstoragevolume + + + + + + + + Copy-OVServerProfile + + Copy or clone a server profile. + + Copy + OVServerProfile + + + You can copy a server profile to server hardware of the same server hardware type and in the same enclosure group (for servers). If you are deploying multiple servers of the same type into the same enclosure, you can create a server profile template to streamline server provisioning. + +This Cmdlet will copy a source Server Profile to a new instance You can assign the copy to an existing Server Device, or specify "unassigned". + +Minimum required privileges: Infrastructure administrator or Server administrator + + + + + Copy-OVServerProfile + + InputObject + + The object of the source server profile to be copied. + + Object + + + DestinationName + + The name of the destination server profile that will be created. If omitted, the new name will have "Copy of " +prefixed to the source name. + + String + + + Assign + + The object of the target server to assign the new profile to. If omitted, profile will be "unassigned" + + Object + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + + WhatIf + + + + + + + Confirm + + + + + + + + + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Assign + + The object of the target server to assign the new profile to. If omitted, profile will be "unassigned" + + Object + + Object + + unassigned + + + Confirm + + + + + + + + + + + DestinationName + + The name of the destination server profile that will be created. If omitted, the new name will have "Copy of " +prefixed to the source name. + + String + + String + + + + + InputObject + + The object of the source server profile to be copied. + + Object + + Object + + + + + WhatIf + + + + + + + + + + + + + + + System.Management.Automation.PSCustomObject + + + Server Profile resource object + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + Profile Create async task + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVServerProfile -Name "Profile 1" | Copy-OVServerProfile + + Copy "Profile 1" to a new Server Profile that is unassigned and named "Copy of Profile 1". + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Copy-OVServerProfile -InputObject (Get-OVServerProfile -Name "Profile 1") -DestinationName "Profile 2" + + Copy "Profile 1" to a new Server Profile that is unassigned and named "Profile 2". + + + + + + + + + + -------------------------- EXAMPLE 3 -------------------------- + + + + $ServerProfile = Get-OVServerProfile -Name "Profile 1" +$Server = Get-OVServer -Name "Encl1, Bay 9" +Copy-OVServerProfile -InputObject $ServerProfile -DestinationName "Profile 2" -assign $Server + + Copy "Profile 1" to a new Server Profile that is assigned to "Encl1, Bay 9" named "Profile 2". + + + + + + + + + + -------------------------- EXAMPLE 4 -------------------------- + + + + $ServerProfile = Get-OVServerProfile -Name "Profile Template" +11.16 | % { Copy-OVServerProfile -InputObject $ServerProfile -DestinationName "Profile $_" -Assign "Encl1, bay $_" } + + Copy 5 Server Profiles from "Profile Template" that will be assigned to bays 11 - 16 of Encl1. + + + + + + + + + + + + + Convert-OVServerProfile + + + + Convert-OVServerProfileTemplate + + + + ConvertTo-OVServerProfileTemplate + + + + Get-OVServerProfile + + + + Get-OVServerProfileConnectionList + + + + Get-OVServerProfileMessage + + + + Get-OVServerProfileTemplate + + + + Join-OVServerProfileToTemplate + + + + New-OVServerProfile + + + + New-OVServerProfileAssign + + + + New-OVServerProfileAttachVolume + + + + New-OVServerProfileConnection + + + + New-OVServerProfileLogicalDisk + + + + New-OVServerProfileLogicalDiskController + + + + New-OVServerProfileTemplate + + + + Remove-OVServerProfile + + + + Remove-OVServerProfileTemplate + + + + Save-OVServerProfile + + + + Save-OVServerProfileTemplate + + + + Set-OVServerProfile + + + + Set-OVServerProfileTemplate + + + + Update-OVServerProfile + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/servers/copy-ovserverprofile + + + + + + + + Disable-OVApplianceComplexPasswords + + Disable appliance complex password policy. + + Disable + OVApplianceComplexPasswords + + + Disables whether users are required to have complex passwords. This option does not force existing users to change their passwords, nor has any impact on directory accounts. By default, the appliance does not enforce complex passwords during creating or modifying internal user account passwords. Use this Cmdlet to disable the policy. + +Minimum required privileges: Infrastructure administrator + + + + + Disable-OVApplianceComplexPasswords + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + + WhatIf + + Perform a test to identify the beahvior before executing the Cmdlet. Will not modify resources. + + SwitchParameter + + + Confirm + + Override the confirmation prompt. + + SwitchParameter + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + Array + + (${Global:ConnectedSessions} | ? Default) + + + Confirm + + Override the confirmation prompt. + + SwitchParameter + + SwitchParameter + + + + + WhatIf + + Perform a test to identify the beahvior before executing the Cmdlet. Will not modify resources. + + SwitchParameter + + SwitchParameter + + + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + System.Management.Automation.PSCustomObject + + + + Appliance global security settings. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Disable-OVApplianceComplexPasswords + + Disable complex password policy on the appliance. + + + + + + + + + + + + + Enable-OVApplianceComplexPasswords + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/disable-ovappliancecomplexpasswords + + + + + + + + Disable-OVApplianceDataAtRestEncryption + + Turn off HPE Synergy Composer data at rest encryption. + + Disable + OVApplianceDataAtRestEncryption + + + HPE OneView encrypts sensitive data, such as managed device credentials, when it is stored on-disk in the appliance. The HPE OneView appliance encryption key (AEK) is used internally to encrypt the credentials for managed devices (such +as, iLO, onboard administrator, frame link module). By default, the AEK is stored on the HPE Synergy Composer disk and also included in the appliance backup. This could pose a security risk in case the disk is stolen. + +The secure data-at-rest option, when enabled, stores the AEK off-disk in Composer NVRAM, and does not include the key +in the appliance backup. Enabling this option requires the administrator to save a copy of the AEK (recovery AEK) for +use in the following circumstances: + + * When restoring a backup taken when a different AEK was in effect. + * To successfully boot the system in the unlikely event that the system copy of the key is corrupted. + * A backup is being restored to a different new Composer or to the same Composer that has been factory reset. + +The administrator must store the recovery AEK in a secure location, where it can be only accessed by authorized personnel. In the rare circumstance where the key cannot be read from the Composer NVRAM or the key gets corrupted, the administrator must use the appliance maintenance console to upload the AEK recovery copy, based on the error resolution message displayed. In the rare circumstance where the Composer NVRAM itself becomes inaccessible, users can choose to disable secure-data-at-rest option until the hardware issue itself is resolved. + +If the downloaded recovery key and the AEK stored in the Composer NVRAM are both lost, the appliance data cannot be recovered. + +Using this Cmdlet will disable data at rest encryption on configured and support HPE Synergy Composer appliances. + +Minimum required privileges: Infrastructure administrator. + + + + + Disable-OVApplianceDataAtRestEncryption + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + WhatIf + + + + SwitchParameter + + + Confirm + + + + SwitchParameter + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Confirm + + + + SwitchParameter + + SwitchParameter + + + + + WhatIf + + + + SwitchParameter + + SwitchParameter + + + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + Asynchronous task resource to monitor. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Disable-OVApplianceDataAtRestEncryption + + Disable appliance data at rest encryption. + + + + + + + + + + + + + Enable-OVApplianceDataAtRestEncryption + + + + Get-OVApplianceDataAtRestEncryption + + + + New-OVApplianceDataAtRestEncryptionKey + + + + Save-OVApplianceDataAtRestEncryptionKey + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/security/disable-ovappliancedataatrestencryption + + + + + + + + Disable-OVApplianceServiceConsoleAccess + + Disable appliance service console access. + + Disable + OVApplianceServiceConsoleAccess + + + HPE OneView contains a technical feature that will allow an on-site Authorized technical support to access your system, through the system console, to assess problems that you have reported. This access will be controlled by a password generated by HPE that will only be provided to the Authorized technical support. You can enable or disable access at any time while the system is running. Hewlett Packard Enterprise recommends that you enable service console access so that an Authorized technical support can diagnose your system in the event of a a system failure. + +Use this Cmdlet to disable service console access. + +Minimum required privileges: Infrastructure administrator + + + + + Disable-OVApplianceServiceConsoleAccess + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + + WhatIf + + + + SwitchParameter + + + Confirm + + Override prompt. + + SwitchParameter + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + Array + + (${Global:ConnectedSessions} | ? Default) + + + Confirm + + Override prompt. + + SwitchParameter + + SwitchParameter + + + + + WhatIf + + + + SwitchParameter + + SwitchParameter + + + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + Asynchronous task resource to monitor + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Disable-OVApplianceServiceConsoleAccess + + Disable service console access on the appliance. + + + + + + + + + + + + + Enable-OVApplianceServiceConsoleAccess + + + + Get-OVApplianceServiceConsoleAccess + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/disable-ovapplianceserviceconsoleaccess + + + + + + + + Disable-OVApplianceSshAccess + + Disable appliance SSH access. + + Disable + OVApplianceSshAccess + + + HPE OneView supports Secure Shell (SSH) to remotely access the appliance to perform maintenance and recovery operations. Without SSH access, you must access the virtual machine system console. To avoid requiring a console access, SSH access is enabled by default. However, remote access to maintenance and recovery operations is considered a security risk by some users. Therefore, HPE OneView provides the option to disable remote access to the appliance via SSH. + +Use this Cmdlet to disable appliance SSH access. + +Minimum required privileges: Infrastructure administrator + + + + + Disable-OVApplianceSshAccess + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + + WhatIf + + + + SwitchParameter + + + Confirm + + Override confirmation prompt. + + SwitchParameter + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + Array + + (${Global:ConnectedSessions} | ? Default) + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + SwitchParameter + + False + + + Confirm + + Override confirmation prompt. + + SwitchParameter + + SwitchParameter + + + + + WhatIf + + + + SwitchParameter + + SwitchParameter + + + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + Asynchronous task resource to monitor + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Disable-OVApplianceSshAccess + + Disable appliance SSH access. + + + + + + + + + + + + + Enable-OVApplianceSshAccess + + + + Get-OVApplianceSshAccess + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/disable-ovappliancesshaccess + + + + + + + + Disable-OVApplianceStrictSecurityCipherSuite + + Disable strict use of strong GCM (Galois/Counter Mode) ciphers for an appliance. + + Disable + OVApplianceStrictSecurityCipherSuite + + + A cipher suite is a set of algorithms that help secure a network connection that uses TLS for communication. The set of algorithms that cipher suites usually contain include: a key exchange algorithm, a bulk encryption algorithm, and a Message Authentication Code (MAC) algorithm. See the "Algorithms, cipher suites, and protocols for securing the appliance" topic in the Online Help for details on the appliance cipher suites. + +When using this Cmdlet, strong GCM cipher suites are no longer enforced for client connections to the appliance and revert back to default appliance cipher suites. For more information on what available cipher suites would be in use, please see the "Algorithms, cipher suites, and protocols for securing the appliance" topic in the Online Help for further details. + +IMPORTANT: Changing this setting will cause the appliance to reboot. Further, OneView will NOT be able to manage servers or enclosures with the setting enabled if they are not at a minimum version of iLO or Onboard Administrator firmware. Refer to the following advisory for required minimum firmware versions and configuration settings before enabling this security setting: https://support.hpe.com/hpsc/doc/public/display?docId=emr_na-a00117772en_us + + + + + Disable-OVApplianceStrictSecurityCipherSuite + + ApplianceConnection + + Specify one or more HPEOneView.Appliance.Connection object(s) or Name property value(s). + +Default Value: ${Global:ConnectedSessions} | ? Default + + Object + + + WhatIf + + + + SwitchParameter + + + Confirm + + + + SwitchParameter + + + + + + + ApplianceConnection + + Specify one or more HPEOneView.Appliance.Connection object(s) or Name property value(s). + +Default Value: ${Global:ConnectedSessions} | ? Default + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Confirm + + + + SwitchParameter + + SwitchParameter + + + + + WhatIf + + + + SwitchParameter + + SwitchParameter + + + + + + + + + None. You cannot pipe objects to this cmdlet. + + + + + + + + + + + HPOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + Async task resource to monitor. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Disable-OVApplianceStrictSecurityCipherSuite + + + Disable strict use of GCM ciphers. + + + + + + + + + + + + + Enable-OVApplianceStrictSecurityCipherSuite + + + + Wait-OVTaskComplete + + + + Online: + https://hpe-docs.gitbook.io/posh-hpeoneview/cmdlets/v9.00/appliance/disable-ovappliancestrictsecurityciphersuite + + + + + + + + Disable-OVApplianceTwoFactorAuthentication + + Disable appliance two-factor authentication settings. + + Disable + OVApplianceTwoFactorAuthentication + + + Enabling two-factor authentication allows you to use smart cards (for example, Common Access Cards (CAC), or Personal Identity Verification (PIV) cards) to authenticate within HPE OneView. The client certificate embedded in the smart card is presented to HPE OneView by the library. The client certificate must be signed by a root or intermediate Certificate Authority (CA) that has been previously imported into the HPE OneView appliance. The appliance authenticates the client certificate to validate that the user name specified in the certificate is that of a valid user recognized by the directory server configuration in HPE OneView. + +When two-factor authentication is enabled, HPE OneView uses a Microsoft Active Directory service account set up and owned by the user to access an Active Directory entry for the user, rather than using an account associated with the user name received during first time login. + +Use this Cmdlet to configure two factor authentication state of the connected appliance. An Active Directory authentication directory must be configured, with a Service Account, and the root or issuing certificate authority Base64 certificate must be uploaded to appliance. + +Required: Infrastructure administrator + + + + + Disable-OVApplianceTwoFactorAuthentication + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + + WhatIf + + + + SwitchParameter + + + Confirm + + + + SwitchParameter + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + Array + + (${Global:ConnectedSessions} | ? Default) + + + Confirm + + + + SwitchParameter + + SwitchParameter + + + + + WhatIf + + + + SwitchParameter + + SwitchParameter + + + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + System.Management.Automation.PSCustomObject + + + + Appliance global security settings. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Disable-OVApplianceTwoFactorAuthentication + + Disable two-factor authentication on the connected appliance. + + + + + + + + + + + + + Get-OVApplianceTwoFactorAuthentication + + + + Set-OVApplianceTwoFactorAuthentication + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/disable-ovappliancetwofactorauthentication + + + + + + + + Disable-OVCertificateRevocationChecking + + Disable appliance certificate revocation checking. + + Disable + OVCertificateRevocationChecking + + + Hewlett Packard Enterprise strongly recommends that you enable strict certificate validation checks after completing an update as appropriate for your enterprise security policies. HPE OneView supports devices using self-signed certificates and devices using formal CA-signed certificates. CA-signed certificates offer benefits such as revocation checking and overall simplified management. HPE OneView enables users to import a CA CRL file and to perform the appropriate revocation checking on existing certificates in the trust store and for certificates received during communication with a managed device or external server. + +This Cmdlet will disable certificate revocation validation on the specified appliance. By disabling this setting, the appliance will not validate the certificate has been revoked by an issuing certificate authority. This setting has no applicability to self-signed certificates. + +Minimum required privileges: Infrastructure administrator + + + + + Disable-OVCertificateRevocationChecking + + ApplianceConnection + + Specify one or more HPEOneView.Appliance.Connection object(s) or Name property value(s). + +Default Value: ${Global:ConnectedSessions} | ? Default + + Object + + + WhatIf + + + + SwitchParameter + + + Confirm + + + + SwitchParameter + + + + + + + ApplianceConnection + + Specify one or more HPEOneView.Appliance.Connection object(s) or Name property value(s). + +Default Value: ${Global:ConnectedSessions} | ? Default + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Confirm + + + + SwitchParameter + + SwitchParameter + + + + + WhatIf + + + + SwitchParameter + + SwitchParameter + + + + + + + + + None. You cannot pipe objects to this cmdlet. + + + + + + + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Disable-OVCertificateRevocationChecking + + + Default example + + + + + + + + + + + + + Enable-OVCertificateRevocationChecking + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/library/disable-ovcertificaterevocationchecking + + + + + + + + Disable-OVCertificateValidation + + Disable appliance TLS/SSL certificate validation. + + Disable + OVCertificateValidation + + + HPE OneView performs certificate validation for all Transport Layer Security (TLS) communications between the appliance and external servers or devices. These checks guarantee confidentiality, integrity, and authentication with the remote end-point. + +In production environments, Hewlett Packard Enterprise strongly recommends that certificate validation be enabled. In +environments where security is not a concern, such as a testing environment, certificate validation can optionally be +disabled. + +If certificate validation is disabled, any sensitive data such as credentials are transmitted insecurely. Make sure to use only local user accounts and not enterprise directory-based accounts to avoid transmitting enterprise login credentials over the network when certificate validation is disabled. + +NOTE: When upgrading from earlier releases, the certificates in use by the currently monitored or managed devices are +imported into the HPE OneView trust store and alerts are generated for issues such as expired certificates. These automatically added certificates are either a device"s self signed certificate or the leaf certificate for a certificate authority (CA) signed certificate. Using CA-signed certificates can simplify the device trust process. + +Certificate checking is enabled by default, but some of the stricter validation checks are relaxed to maintain communications with all devices, even those with certificate issues. The relaxed checking includes: + + * Not performing expiration checks for self signed certificates + * For certificate authority (CA) signed certificates, relaxed certificate revocation list (CRL) checking. + +The relaxed checking gives the administrator time to address any expired certificates, to upload trusted CA root and intermediate certificates, and upload the appropriate CRLs. + +Hewlett Packard Enterprise strongly recommends that you enable strict certificate validation checks after completing an update as appropriate for your enterprise security policies. See Manage Certificates for additional information on certificate management. + +HPE OneView supports devices using self signed certificates and devices using formal CA-signed certificates. CA-signed certificates offer benefits such as revocation checking and overall simplified management. + +HPE OneView enables users to import a CA CRL file and to perform the appropriate revocation checking on existing certificates in the trust store and for certificates received during communication with a managed device or external server. + +WARNING: Modifying the appliance setting will require the appliance to be rebooted. + +WARNING: If 2-factor authentication is configured, this policy cannot be disabled. + +Minimum required privileges: Infrastructure administrator + + + + + Disable-OVCertificateValidation + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + + WhatIf + + + + SwitchParameter + + + Confirm + + Override the confirmation prompt. + + SwitchParameter + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + Array + + (${Global:ConnectedSessions} | ? Default) + + + Confirm + + Override the confirmation prompt. + + SwitchParameter + + SwitchParameter + + + + + WhatIf + + + + SwitchParameter + + SwitchParameter + + + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + System.Management.Automation.PSCustomObject + + + + Appliance global security settings. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Disable-OVCertificateValidation + + Disable certificate validation on the appliance. + + + + + + + + + + + + + Enable-OVCertificateValidation + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/disable-ovcertificatevalidation + + + + + + + + Disable-OVComposerIlo + + Disable HPE Synergy Composer2 iLO remote connectivity. + + Disable + OVComposerIlo + + + You can configure the HPE Synergy Composer2 for remote access through its embedded management processor (iLO). This configuration enables you to manage the Composer2 remotely and perform specific Composer2 management operations that previously required accessing the Composer console locally in the data center. + +Use this Cmdlet to disable remote access to the HPE Synergy Composer2 iLO. Disabling external iLO access will delete the configured iLO user account and unassign the user specified static IPv4 and IPv6 addresses. + +Minimum required privileges: Infrastructure administrator + + + + + Disable-OVComposerIlo + + InputObject + + The object from Get-OVComposerIloStatus. + + Object + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + ApplianceConnection + + Specify one or more HPEOneView.Appliance.Connection object(s) or Name property value(s). + +Default Value: ${Global:ConnectedSessions} | ? Default + + Object + + + WhatIf + + + + SwitchParameter + + + Confirm + + + + SwitchParameter + + + + Disable-OVComposerIlo + + InputObject + + The object from Get-OVComposerIloStatus. + + Object + + + DisableIPv6Address + + Use to unconfigure the user specified IPv6 address of the iLO. The iLO will no longer be accessible by this address. This paramete cannot be combined with the -DisableIPv4Address parameter. + + SwitchParameter + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + ApplianceConnection + + Specify one or more HPEOneView.Appliance.Connection object(s) or Name property value(s). + +Default Value: ${Global:ConnectedSessions} | ? Default + + Object + + + WhatIf + + + + SwitchParameter + + + Confirm + + + + SwitchParameter + + + + Disable-OVComposerIlo + + InputObject + + The object from Get-OVComposerIloStatus. + + Object + + + DisableIPv4Address + + Use to unconfigure the user specified IPv4 address of the iLO. The iLO will no longer be accessible by this address. This paramete cannot be combined with the -DisableIPv6Address parameter. + + SwitchParameter + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + ApplianceConnection + + Specify one or more HPEOneView.Appliance.Connection object(s) or Name property value(s). + +Default Value: ${Global:ConnectedSessions} | ? Default + + Object + + + WhatIf + + + + SwitchParameter + + + Confirm + + + + SwitchParameter + + + + + + + ApplianceConnection + + Specify one or more HPEOneView.Appliance.Connection object(s) or Name property value(s). + +Default Value: ${Global:ConnectedSessions} | ? Default + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + SwitchParameter + + False + + + Confirm + + + + SwitchParameter + + SwitchParameter + + + + + DisableIPv4Address + + Use to unconfigure the user specified IPv4 address of the iLO. The iLO will no longer be accessible by this address. This paramete cannot be combined with the -DisableIPv6Address parameter. + + SwitchParameter + + SwitchParameter + + + + + DisableIPv6Address + + Use to unconfigure the user specified IPv6 address of the iLO. The iLO will no longer be accessible by this address. This paramete cannot be combined with the -DisableIPv4Address parameter. + + SwitchParameter + + SwitchParameter + + + + + InputObject + + The object from Get-OVComposerIloStatus. + + Object + + Object + + + + + WhatIf + + + + SwitchParameter + + SwitchParameter + + + + + + + + + HPEOneView.Appliance.HardwareConfig [System.Management.Automation.PSCustomObject] + + + The appliance hardware configuration object from Get-OVComposerIloStatus. + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + Async task resource to monitor. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + $ComposerAppliance = Get-OVComposerIloStatus | Where-Object IsExternallyAccessible +Disable-OVComposerIlo + + + Disable HPE Synergy Composer 2 iLO's that are configured for remote connectivity. The configued iLO user and IP Address(es) will be removed from the iLO. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + $ComposerAppliance = Get-OVComposerIloStatus | Where-Object IsExternallyAccessible +Disable-OVComposerIlo -DisableIPv6Address + + + Disable only the configured IPv6 address on the HPE Synergy Composer 2 iLO's that are configured for remote connectivity. + + + + + + + + + + + + + Enable-OVComposerIlo + + + + Get-OVComposerIloStatus + + + + Set-OVComposerIlo + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/disable-ovcomposerilo + + + + + + + + Disable-OVComputeOpsManagement + + Disable Compute Ops Management configuration. + + Disable + OVComputeOpsManagement + + + HPE GreenLake for Compute Ops Management is a cloud-based as-a-Service application that manages various operations of HPE OneView appliances. By integrating HPE OneView with HPE GreenLake for Compute Ops Management will unify server inventory and centralize management to a single console. To enable the cloud management service for HPE OneView, you must onboard the appliance in the Compute Ops Management application in HPE GreenLake by using the Enable-OVComputeOpsManagement and Set-OVComputeOpsManagement Cmdlets. + +This Cmdlet is used to dsiable connectivity to Compute Ops Management. + +Minimum required privileges: Infrastructure administrator + + + + + Disable-OVComputeOpsManagement + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + ApplianceConnection + + Specify one or more HPEOneView.Appliance.Connection object(s) or Name property value(s). + +Default Value: ${Global:ConnectedSessions} | ? Default + + Object + + + WhatIf + + + + SwitchParameter + + + Confirm + + + + SwitchParameter + + + + + + + ApplianceConnection + + Specify one or more HPEOneView.Appliance.Connection object(s) or Name property value(s). + +Default Value: ${Global:ConnectedSessions} | ? Default + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + SwitchParameter + + False + + + Confirm + + + + SwitchParameter + + SwitchParameter + + + + + WhatIf + + + + SwitchParameter + + SwitchParameter + + + + + + + + + None. You cannot pipe objects to this cmdlet. + + + + + + + + + + + HPOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + Async task resource to monitor. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Disable-OVComputeOpsManagement + + + Disable Compute Ops Management configuration on the appliance. + + + + + + + + + + + + + Connect-OVComputeOpsManagement + + + + Enable-OVComputeOpsmanagement + + + + Get-OVComputeOpsManagement + + + + Set-OVComputeOpsManagement + + + + Online: + https://hpe-docs.gitbook.io/posh-hpeoneview/cmdlets/v9.00/appliance/disable-ovcomputeopsmanagement + + + + + + + + Disable-OVDebug + + Disable specific appliance-level component debug logging. + + Disable + OVDebug + + + FOR HPE Support USE ONLY. This Cmdlet will disable appliance level component debug logging for during issue triage, by setting the Level to INFO. Do not use this Cmdlet unless otherwise instructed by HPE Support. + + + + + Disable-OVDebug + + Scope + + The Scope of the LoggerName. + + String + + + LoggerName + + The internal component name. + + String + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. + + Object + + + + + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + LoggerName + + The internal component name. + + String + + String + + + + + Scope + + The Scope of the LoggerName. + + String + + String + + + + + + + + + HPEOneView.Appliance.Connection + + + HPE OneView Appliance Connection object. + + + + + + + + System.Management.Automation.PSCustomObject + + + + + + + + + + + + + + Enable-OVDebug + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/library/disable-ovdebug + + + + + + + + Disable-OVDeviceUid + + Disable unit identification (UID) of a device. + + Disable + OVDeviceUid + + + Authorized users can control the unit identification (UID) light on an HPE Synergy frame and its servers, interconnects, and frame link modules through the UI. Illuminating the UID light on the front of a device helps an on-site technician to locate the hardware in the data center. + +A UID icon is displayed on the Enclosures screen, the Server Hardware screen, and the Interconnects screen. On the Enclosures screen, the enclosure overview displays the UID icon on its frame link modules, servers, and interconnects. + +WARNING: The UID light blinks automatically to indicate that a critical operation is underway, such as Remote Console access for server hardware or a firmware update. Do not remove power from a device when its UID light is blinking. + +Minimum required privileges: Infrastructure administrator, Server administrator (for enclosure, server, and frame link module UID lights), Network administrator (for interconnect UID lights) + + + + + Disable-OVDeviceUid + + InputObject + + Resource object to turn off the UID. Supported resources are server hardware, enclosures and interconnects. + +NOTE: HPE BladeSystem C7000 enclosures and interconnects are not supported, but the inserted servers are. + + Object + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + + + + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + InputObject + + Resource object to turn off the UID. Supported resources are server hardware, enclosures and interconnects. + +NOTE: HPE BladeSystem C7000 enclosures and interconnects are not supported, but the inserted servers are. + + Object + + Object + + + + + + + + + HPEOneView.ServerHardware [System.Management.Automation.PSCustomObject] + + + Server Hardware or Enclosure resource. + + + + + HPEOneView.Enclosure [System.Management.Automation.PSCustomObject] + + + Enclosure resource. + + + + + HPEOneView.Networking.Interconnect [System.Management.Automation.PSCustomObject] + + + Interconnect resource. + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + If successful, returns Appliance Async Task object to monitor. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVServer -Name "MyEncl, Bay 1" | Disable-OVDeviceUid | Wait-OVTaskComplete + + Disable the UID for "MyEncl, Bay 1" server. + + + + + + + + + + + + + Enable-OVDeviceUid + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/servers/disable-ovdeviceuid + + + + + + + + Disable-OVLdapLocalLogin + + Disable local authentication logins. + + Disable + OVLdapLocalLogin + + + You can configure HPE OneView to use an external enterprise directory service for user authentication. HPE OneView supports the following enterprise directory services: + + * Active Directory + * OpenLDAP + +When you use a directory service, directory users are granted HPE OneView permissions using their group membership in the directory. After defining a directory service, use the User and Groups screen to define permissions for directory groups. +Directory groups are assigned one or more HPE OneView permissions. A directory user is assigned the HPE OneView permissions that represent the union of the permissions for all the directory groups that the user is a member of. Only after permissions are defined for directory groups, directory users are authenticated into the appliance. + +If you want to authenticate all logins to the appliance through a directory service, you must disable local logins. Also, if a directory is inaccessible in some special cases, you can enable the emergency local login. To enable emergency local login, you must disable local logins. + +NOTE: +Local logins cannot be disabled until you log in using an authentication directory service as an Infrastructure administrator. Verify that you can log in to the appliance as an Infrastructure administrator from the authentication directory service before continuing. + +Minimum required privileges: Infrastructure administrator. + + + + + Disable-OVLdapLocalLogin + + EnableEmergencyLocalLogin + + Boolean value to enable ($true) or disable ($false) emergency local login. Must be set to $false when SmartCardLoginOnly is set and used from Set-OVApplianceTwoFactorAuthentication. + + Bool + + + EmergencyLoginAllowType + + Allow emergency login access if the configured authentication directory(ies) are unavailable. Highest security is obtained by restricting the local administrator account to "ApplianceConsoleOnly". Choose "NetworkAndApplianceConsole" to allow emergency access via the network. + + String + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + WhatIf + + + + SwitchParameter + + + Confirm + + + + SwitchParameter + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Confirm + + + + SwitchParameter + + SwitchParameter + + + + + EmergencyLoginAllowType + + Allow emergency login access if the configured authentication directory(ies) are unavailable. Highest security is obtained by restricting the local administrator account to "ApplianceConsoleOnly". Choose "NetworkAndApplianceConsole" to allow emergency access via the network. + + String + + String + + + + + EnableEmergencyLocalLogin + + Boolean value to enable ($true) or disable ($false) emergency local login. Must be set to $false when SmartCardLoginOnly is set and used from Set-OVApplianceTwoFactorAuthentication. + + Bool + + Bool + + + + + WhatIf + + + + SwitchParameter + + SwitchParameter + + + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + System.Management.Automation.PSCustomObject + + + + Appliance Authentication Directory setting. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Disable-OVLdapLocalLogin + + Disable local logins on the appliance, and does not allow emergency local login by default. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Disable-OVLdapLocalLogin -EnableEmergencyLocalLogin $true -EmergencyLoginAllowType NetworkAndApplianceConsole + + Disable local logins on the appliance, but allow emergency login access via SSH maintenance console or from the service console of the appliance. + + + + + + + + + + + + + Enable-OVLdapLocalLogin + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/security/disable-ovldaplocallogin + + + + + + + + Disable-OVLogicalInterconnectPortMonitoring + + Disable port monitoring for a logical interconnect. + + Disable + OVLogicalInterconnectPortMonitoring + + + Port monitoring enables you to send a copy of every Ethernet or Fibre Channel frame coming in and going out of a downlink (server-facing) port to another port. To evaluate network traffic between ports, you can connect debugging equipment, such as a network analyzer. This capability is important in a server environment where there is limited physical access to the network interfaces on the servers. + +Restrictions: + + * You cannot use Virtual Connect to forward captured traffic to a server. For more information, see the HPE Virtual Connect for c-Class BladeSystem User Guide in the Hewlett Packard Enterprise Information Library. + * You can configure one network analyzer port (the uplink port) for up to 16 downlink server ports within a logical interconnect. + * The HPE Virtual Connect 16Gb 24-Port Fibre Channel Module monitors 1 downlink server port. + * HPE Virtual Connect 16Gb 24-Port Fibre Channel Module firmware must be 4.00 or later + +Minimum required privileges: Network administrator + + + + + Disable-OVLogicalInterconnectPortMonitoring + + InputObject + + The HPEOneView.Networking.LogicalInterconnect resource from Get-OVLogicalInterconnect. + + Object + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + Array + + (${Global:ConnectedSessions} | ? Default) + + + InputObject + + The HPEOneView.Networking.LogicalInterconnect resource from Get-OVLogicalInterconnect. + + Object + + Object + + + + + + + + + HPEOneView.Networking.LogicalInterconnect [System.Management.Automation.PSCustomObject] + + + Logical Interconnect resource object from Get-OVLogicalInterconnect + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + Async task Resource object for configuring port monitoring on the requested logical intercinnect. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVLogicalInterconnect -Name "Encl1" -ErrorAction Stop | Disable-OVLogicalInterconnectPortMonitoring + + Disable port monitoring for the specified logical interconnect resource. + + + + + + + + + + + + + Enable-OVLogicalInterconnectPortMonitoring + + + + Get-OVLogicalInterconnectPortMonitoring + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/networking/disable-ovlogicalinterconnectportmonitoring + + + + + + + + Disable-OVMaintenanceMode + + Disable compute resource into maintenance mode. + + Disable + OVMaintenanceMode + + + Performing routine maintenance operations on servers causes many events to be generated on the associated server hardware resource and server profile. If notification features are enabled, the events cause many email notifications. While the maintenance activity is in progress, you might not want to receive all the notifications. + +Enabling server maintenance mode prevents the appliance from sending any email notifications that are related to the server hardware and its associated profile. While the notifications are blocked, maintenance mode does not affect normal server or profile operations, and all events generated on the server are seen on the HPE OneView appliance UI. + +Disabling maintenance mode causes email notifications to return to normal. No attempt is made to send any events that occurred during the maintenance mode. However, if the health of the server is not OK when maintenance mode is disabled, a single event will be sent, alerting that the server is in a non-healthy state. + +Minimum required privileges: Infrastructure administrator, Network administrator + + + + + Disable-OVMaintenanceMode + + InputObject + + Either a server hardware or server profile resource. + + Object + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + ApplianceConnection + + Aliases [-Appliance] + +Specify one or more HPEOneView.Appliance.Connection object(s) or Name property value(s). + +Default Value: ${Global:ConnectedSessions} | ? Default + + Object + + + WhatIf + + + + + + + Confirm + + + + + + + + + + + ApplianceConnection + + Aliases [-Appliance] + +Specify one or more HPEOneView.Appliance.Connection object(s) or Name property value(s). + +Default Value: ${Global:ConnectedSessions} | ? Default + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + SwitchParameter + + False + + + Confirm + + + + + + + + + + + InputObject + + Either a server hardware or server profile resource. + + Object + + Object + + + + + WhatIf + + + + + + + + + + + + + + + HPEOneView.ServerHardware [System.Management.Automation.PSCustomObject] + + + A server hardware resource from the appliance. + + + + + HPEOneView.ServerProfile [System.Management.Automation.PSCustomObject] + + + A server profile resource from the appliance. + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + Async task resource object to monitor. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + $Server = Get-OVServer -Name "Encl1, bay 1" +Disable-OVMaintenanceMode -InputObject $Server + + Disable the maintenance mode state of the specific server resource. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + $ServerProfile = Get-OVServerProfile -Name "My Profile 1" +Disable-OVMaintenanceMode -InputObject $ServerProfile + + Disable the maintenance mode state of the specific server resource that is associated with the server profile. + + + + + + + + + + -------------------------- EXAMPLE 3 -------------------------- + + + + Get-OVServer -MaintenanceMode $True | Disable-OVMaintenanceMode + + Get all of the server resources that are in maintenance mode, and disable it. + + + + + + + + + + + + + Enable-OVMaintenanceMode + + + + Get-OVServer + + + + Get-OVServerProfile + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/servers/disable-ovmaintenancemode + + + + + + + + Disable-OVMSDSC + + Disable Microsoft DSC Support + + Disable + OVMSDSC + + + Using this Cmdlet will create and/or modify UseMSDSC (REG_DWORD) located at HKCU:\Software\Hewlett-Packard\HPOneView, to 0 (False). By disabling support, the module will no longer overload Write-Host. + +Use Enable-OVMsDSC to enable support. + + + + + Disable-OVMSDSC + + + + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + None. + + + + + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Disable-OVMSDSC + + Configures Registry value to no longer overload Write-Host. + + + + + + + + + + + + + Enable-OVMSDSC + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/library/disable-ovmsdsc + + + + + + + + Disable-OVRemoteSupport + + Disable Remote Support for a supported resource. + + Disable + OVRemoteSupport + + + Register with Hewlett Packard Enterprise to allow automatic case creation for hardware failures on servers and enclosures and to enable Proactive Care. Once enabled, all eligible devices added in the future will be automatically enabled for remote support. + +Hewlett Packard Enterprise recommends enabling all features and benefits provided by HPE OneView Remote Support so you can receive fast, accurate 'phone home' support and service per your contractual terms with Hewlett Packard Enterprise. Hewlett Packard Enterprise securely collects your HPE IT hardware diagnostics, configuration and telemetry information to provide you with remote support and services. The data is handled and managed to respect your privacy. For more information, Hewlett Packard Enterprise's Privacy Statement can be found at http://privacy.hpe.com. + +Enabling Remote Support configures your devices being remotely supported to securely send support or service events, IT configuration information, diagnostic, and telemetry information to Hewlett Packard Enterprise, together with your support contact information. No other business information is collected and the data is managed according to the Hewlett Packard Enterprise's Privacy Statement. + +This Cmdlet will disable Remote Support for a compute or enclosure resource. If Remote Support has been disabled globally on the appliance, this Cmdlet is unnecessary. + +Minimum required privileges: Infrastructure administrator, Server administrator, or Server firmware operator + + + + + Disable-OVRemoteSupport + + InputObject + + The compute or enclosure resource to enable Remote Support for. + + Object + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + WhatIf + + + + + + + Confirm + + + + + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + SwitchParameter + + False + + + Confirm + + + + + + + + + + + InputObject + + The compute or enclosure resource to enable Remote Support for. + + Object + + Object + + + + + WhatIf + + + + + + + + + + + + + + + HPEOneView.ServerHardware [System.Management.Automation.PSCustomObject] + + + A Gen8 or newer generation server hardware resource object from Get-OVServer. + + + + + HPEOneView.Enclosure [System.Management.Automation.PSCustomObject] + + + An enclosure from Get-OVEnclosure. + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + Async task Resource object for monitoring. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVServer -Name Prod* | Disable-OVRemoteSupport + + Get the servers with their name matching "Prod" and disable Remote Support for those resources. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + $Enclosure = Get-OVEnclosure -Name Enclosure-1A +Disable-OVRemoteSupport -InputObject $Enclosure + + Get the specific enclosure resource and disable Remote Support. + + + + + + + + + + + + + Enable-OVRemoteSupport + + + + Get-OVRemoteSupport + + + + Get-OVRemoteSupportContact + + + + Get-OVRemoteSupportDataCollectionSchedule + + + + Get-OVRemoteSupportDefaultSite + + + + Get-OVRemoteSupportEntitlementStatus + + + + Get-OVRemoteSupportPartner + + + + Get-OVRemoteSupportSetting + + + + New-OVRemoteSupportContact + + + + New-OVRemoteSupportPartner + + + + Remove-OVRemoteSupportContact + + + + Remove-OVRemoteSupportPartner + + + + Set-OVRemoteSupport + + + + Set-OVRemoteSupportDataCollectionSchedule + + + + Set-OVRemoteSupportDefaultSite + + + + Set-OVRemoteSupportPrimaryContact + + + + Set-OVRemoteSupportSetting + + + + Start-OVRemoteSupportCollection + + + + Update-OVRemoteSupportEntitlement + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/disable-ovremotesupport + + + + + + + + Disable-OVRemoteSyslog + + Disable remote syslog. + + Disable + OVRemoteSyslog + + + The remoteSyslog API provides the ability to configure remote logging on devices managed by OneView. This Cmdlet handles disabling the remote syslog configuration. Only a single destination can be set. When configured, the HPE OneView appliance will deploy the SysLog settings to managed resources automatically. + +Minimum required privileges: Infrastructure administrator, Server administrator + + + + + Disable-OVRemoteSyslog + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + SwitchParameter + + false + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + If successful, returns Appliance Async Task object to monitor. + + + + + System.Collections.ArrayList <HPEOneView.Appliance.TaskResource> + + + + Collection of Appliance Async Task objects to monitor. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Disable-OVRemoteSyslog + + Disable remote syslog configuration on all connected appliances. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Disable-OVRemoteSyslog -ApplianceConnection appliance1.domain.com -Async | Wait-OVTaskComplete + + Disable remote syslog configuration on the specific connected appliance. + + + + + + + + + + + + + Enable-OVRemoteSyslog + + + + Get-OVRemoteSyslog + + + + Set-OVRemoteSyslog + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/disable-ovremotesyslog + + + + + + + + Disconnect-OVMgmt + + Logoff from the appliance. + + Disconnect + OVMgmt + + + This Cmdlet will logoff the current user, which terminates the user session, on the specified HPE OneView appliance. When logging off of an appliance, and multiple connections have been established, the next appliance connection within ${Global:ApplianceConnections} is made the default connection. To change the default connection to a different appliance, use Set-OVApplianceDefaultConnection. + + + + + Disconnect-OVMgmt + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + $ConnectedSessions | Where-Object Default + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + None. + + + + + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + $Connection1 = Connect-OVMgmt MyAppliance.domain.com +Disconnect-OVMgmt -Hostname $Connection1 + + Disconnect from the specific appliance session. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Disconnect-OVMgmt -Hostname 1 + + Disconnect ConnectionID 1 appliance session. + + + + + + + + + + -------------------------- EXAMPLE 3 -------------------------- + + + + $ConnectedSessions | Disconnect-OVMgmt + + Disconnect all appliance sessions. + + + + + + + + + + + + + Connect-OVMgmt + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/library/disconnect-ovmgmt + + + + + + + + Enable-OVApplianceComplexPasswords + + Enable appliance complex password policy. + + Enable + OVApplianceComplexPasswords + + + Enables whether users are required to have complex passwords. This option does not force existing users to change their passwords, nor has any impact on directory accounts. By default, the appliance does not enforce complex passwords during creating or modifying internal user account passwords. Use this Cmdlet to enable the policy. + +Complex passwords must contain the following: + + * Minimum of 14 characters + * Minimum of one uppercase character + * Minimum of one lowercase character + * Minimum one number + * Minimum of one special character. For example: !@#$^*_-=+,.? + * No whitespace + +Minimum required privileges: Infrastructure administrator + + + + + Enable-OVApplianceComplexPasswords + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + Array + + (${Global:ConnectedSessions} | ? Default) + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + System.Management.Automation.PSCustomObject + + + + Appliance global security settings. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Enable-OVApplianceComplexPasswords + + Enable appliance complex password policy. + + + + + + + + + + + + + Disable-OVApplianceComplexPasswords + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/enable-ovappliancecomplexpasswords + + + + + + + + Enable-OVApplianceDataAtRestEncryption + + Turn on HPE Synergy Composer data at rest encryption. + + Enable + OVApplianceDataAtRestEncryption + + + HPE OneView encrypts sensitive data, such as managed device credentials, when it is stored on-disk in the appliance. The HPE OneView appliance encryption key (AEK) is used internally to encrypt the credentials for managed devices (such +as, iLO, onboard administrator, frame link module). By default, the AEK is stored on the HPE Synergy Composer disk and also included in the appliance backup. This could pose a security risk in case the disk is stolen. + +The secure data-at-rest option, when enabled, stores the AEK off-disk in Composer NVRAM, and does not include the key +in the appliance backup. Enabling this option requires the administrator to save a copy of the AEK (recovery AEK) for +use in the following circumstances: +When restoring a backup taken when a different AEK was in effect. + +To successfully boot the system in the unlikely event that the system copy of the key is corrupted. + +A backup is being restored to a different new Composer or to the same Composer that has been factory reset. + +The administrator must store the recovery AEK in a secure location, where it can be only accessed by authorized personnel. In the rare circumstance where the key cannot be read from the Composer NVRAM or the key gets corrupted, the administrator must use the appliance maintenance console to upload the AEK recovery copy, based on the error resolution message displayed. In the rare circumstance where the Composer NVRAM itself becomes inaccessible, users can choose to disable secure-data-at-rest option until the hardware issue itself is resolved. + +If the downloaded recovery key and the AEK stored in the Composer NVRAM are both lost, the appliance data cannot be recovered. + +Using this Cmdlet will enable data at rest encryption for supported HPE Synergy composers. The appliance encryption key (AEK) will automatically be downloaded and saved to the value of the -Location parameter. By default, this will be the working directory where the Cmdlet is executed in. + +Minimum required privileges: Infrastructure administrator + + + + + Enable-OVApplianceDataAtRestEncryption + + Location + + The file location where to save the appliance encription key (AEK). The AEK should be stored in a secure location. + + String + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + WhatIf + + + + SwitchParameter + + + Confirm + + + + SwitchParameter + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Confirm + + + + SwitchParameter + + SwitchParameter + + + + + Location + + The file location where to save the appliance encription key (AEK). The AEK should be stored in a secure location. + + String + + String + + (get-location).Path + + + WhatIf + + + + SwitchParameter + + SwitchParameter + + + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + Asynchronous task resource to monitor. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Enable-OVApplianceDataAtRestEncryption + + Enable data at rest encryption, where the AEK is saved to the working directory. + + + + + + + + + + + + + Disable-OVApplianceDataAtRestEncryption + + + + Get-OVApplianceDataAtRestEncryption + + + + New-OVApplianceDataAtRestEncryptionKey + + + + Save-OVApplianceDataAtRestEncryptionKey + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/security/enable-ovappliancedataatrestencryption + + + + + + + + Enable-OVApplianceServiceConsoleAccess + + Enable appliance service console access. + + Enable + OVApplianceServiceConsoleAccess + + + HPE OneView contains a technical feature that will allow an on-site Authorized technical support to access your system, through the system console, to assess problems that you have reported. This access will be controlled by a password generated by HPE that will only be provided to the Authorized technical support. You can enable or disable access at any time while the system is running. Hewlett Packard Enterprise recommends that you enable service console access so that an Authorized technical support can diagnose your system in the event of a a system failure. + +Use this Cmdlet to enable service console access. + +Minimum required privileges: Infrastructure administrator + + + + + Enable-OVApplianceServiceConsoleAccess + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + Array + + (${Global:ConnectedSessions} | ? Default) + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + System.Management.Automation.PSCustomObject + + + + Appliance global security settings. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Enable-OVApplianceServiceConsoleAccess + + Enable appliance service console access. + + + + + + + + + + + + + Disable-OVApplianceServiceConsoleAccess + + + + Get-OVApplianceServiceConsoleAccess + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/enable-ovapplianceserviceconsoleaccess + + + + + + + + Enable-OVApplianceSshAccess + + Enable appliance SSH access. + + Enable + OVApplianceSshAccess + + + HPE OneView supports Secure Shell (SSH) to remotely access the appliance to perform maintenance and recovery operations. Without SSH access, you must access the virtual machine system console. To avoid requiring a console access, SSH access is enabled by default. However, remote access to maintenance and recovery operations is considered a security risk by some users. Therefore, HPE OneView provides the option to disable remote access to the appliance via SSH. + +Use this Cmdlet to enable appliance SSH access. + +Minimum required privileges: Infrastructure administrator + + + + + Enable-OVApplianceSshAccess + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + Array + + (${Global:ConnectedSessions} | ? Default) + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + SwitchParameter + + False + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + Asynchronous task resource to monitor + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Enable-OVApplianceSshAccess + + Enable appliance SSH access. + + + + + + + + + + + + + Disable-OVApplianceSshAccess + + + + Get-OVApplianceSshAccess + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/enable-ovappliancesshaccess + + + + + + + + Enable-OVApplianceStrictSecurityCipherSuite + + Enforce strict use of strong GCM (Galois/Counter Mode) ciphers for an appliance. + + Enable + OVApplianceStrictSecurityCipherSuite + + + A cipher suite is a set of algorithms that help secure a network connection that uses TLS for communication. The set of algorithms that cipher suites usually contain include: a key exchange algorithm, a bulk encryption algorithm, and a Message Authentication Code (MAC) algorithm. See the "Algorithms, cipher suites, and protocols for securing the appliance" topic in the Online Help for details on the appliance cipher suites. + +When using this Cmdlet, strong GCM cipher suites are enforced for client connections to the appliance. The list of cipher-suites used when this is enabled for each appliance cryptography mode are: + +HTTPS(port 443) cipher suites +* LEGACY cryptography mode: + * TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 + * TLS_DHE_RSA_WITH_AES_256_GCM_SHA384 + * TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 + * TLS_DHE_RSA_WITH_AES_128_GCM_SHA256 +* FIPS cryptography mode: + * TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 + * TLS_DHE_RSA_WITH_AES_256_GCM_SHA384 + * TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 +* CNSA cryptography mode: + * TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 + +State Change Message Bus/AMQPS(port 5671) cipher suites +* LEGACY cryptography mode: + * TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 + * TLS_DHE_RSA_WITH_AES_256_GCM_SHA384 + * TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 + * TLS_DHE_RSA_WITH_AES_128_GCM_SHA256 +* FIPS cryptography mode: + * TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 + * TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 +* CNSA cryptography mode: + * TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 + +IMPORTANT: Changing this setting will cause the appliance to reboot. Further, OneView will NOT be able to manage servers or enclosures with the setting enabled if they are not at a minimum version of iLO or Onboard Administrator firmware. Refer to the following advisory for required minimum firmware versions and configuration settings before enabling this security setting: https://support.hpe.com/hpsc/doc/public/display?docId=emr_na-a00117772en_us + + + + + Enable-OVApplianceStrictSecurityCipherSuite + + ApplianceConnection + + Specify one or more HPEOneView.Appliance.Connection object(s) or Name property value(s). + +Default Value: ${Global:ConnectedSessions} | ? Default + + Object + + + WhatIf + + + + SwitchParameter + + + Confirm + + + + SwitchParameter + + + + + + + ApplianceConnection + + Specify one or more HPEOneView.Appliance.Connection object(s) or Name property value(s). + +Default Value: ${Global:ConnectedSessions} | ? Default + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Confirm + + + + SwitchParameter + + SwitchParameter + + + + + WhatIf + + + + SwitchParameter + + SwitchParameter + + + + + + + + + None. You cannot pipe objects to this cmdlet. + + + + + + + + + + + HPOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + Async task resource to monitor. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Enable-OVApplianceStrictSecurityCipherSuite + + + Enable strict use of GCM ciphers. + + + + + + + + + + + + + Disable-OVApplianceStrictSecurityCipherSuite + + + + Wait-OVTaskComplete + + + + Online: + https://hpe-docs.gitbook.io/posh-hpeoneview/cmdlets/v9.00/appliance/enable-ovappliancestrictsecurityciphersuite + + + + + + + + Enable-OVCertificateRevocationChecking + + Enable appliance certificate revocation checking. + + Enable + OVCertificateRevocationChecking + + + Hewlett Packard Enterprise strongly recommends that you enable strict certificate validation checks after completing an update as appropriate for your enterprise security policies. HPE OneView supports devices using self-signed certificates and devices using formal CA-signed certificates. CA-signed certificates offer benefits such as revocation checking and overall simplified management. HPE OneView enables users to import a CA CRL file and to perform the appropriate revocation checking on existing certificates in the trust store and for certificates received during communication with a managed device or external server. + +This Cmdlet will enables certificate revocation validation on the specified appliance. When enabled and a certificate revocation list URL is present within a certificate authority's certificate, the appliance will validate if the certificate has been revoked. A revoked certificate is then no longer valid and must be replaced on the device. This setting has no applicability to self-signed certificates. + +WARNING: Appliance will reboot when executing this Cmdlet. + +Minimum required privileges: Infrastructure administrator + + + + + Enable-OVCertificateRevocationChecking + + SkipRevocationCheck + + This option controls whether HPE OneView treats a missing CRL as an error during certificate validation. By default, this option is enabled and HPE OneView performs overall certificate validation with the exception of revocation checking. If you do not have the CRL files issued by the CA certificates, any communication with devices or remote servers that have certificates signed by those CAs will fail until new CRLs are uploaded for all of those CA certificates. Those CA certificates can be identified by navigating to the manage certificate dialog in the settings and filtering by state of "CRL not found" + + bool + + + AllowExpiredCRLs + + This setting controls how HPE OneView treats expired CRLs. When enabled, HPE OneView allows CRLs that are expired and continues to perform the revocation checks for that CRL. Use the -NotifyExpiredMissingCRLs parameter to be notified via an alert when CRL(s) are about to be or have expired. + + bool + + + NotifyExpiredMissingCRLs + + When enabled, alerts are displayed when there is no CRL uploaded for a CA, a CRL is about to expire, or a CRL has already expired. + + bool + + + EnableAutoCRLDownload + + When the setting is enabled, a scheduled automatic CRL downloader on the appliance checks the validity of all the CRLs that are available in the appliance, and updates the CRLs that have expired or are about to expire. The downloader also downloads new CRLs during this process if the CRLs were not previously downloaded. The scheduled time for running the job is set to 12AM UTC. The appliance checks for CRLs every day that are about to expire. If any of the CRLs are about to expire in three days, the appliance downloads the latest available CRL. This prevents the expiration of CRLs on the appliance. You can configure the schedule for downloading the latest available CRLs using Set-OVCertificateRevocationInterval. If there is a failure during the CRL download, the appliance retries the operation three times before raising an alert. + + bool + + + ApplianceConnection + + Specify one or more HPEOneView.Appliance.Connection object(s) or Name property value(s). + +Default Value: ${Global:ConnectedSessions} | ? Default + + Object + + + WhatIf + + + + SwitchParameter + + + Confirm + + + + SwitchParameter + + + + + + + AllowExpiredCRLs + + This setting controls how HPE OneView treats expired CRLs. When enabled, HPE OneView allows CRLs that are expired and continues to perform the revocation checks for that CRL. Use the -NotifyExpiredMissingCRLs parameter to be notified via an alert when CRL(s) are about to be or have expired. + + bool + + bool + + + + + ApplianceConnection + + Specify one or more HPEOneView.Appliance.Connection object(s) or Name property value(s). + +Default Value: ${Global:ConnectedSessions} | ? Default + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Confirm + + + + SwitchParameter + + SwitchParameter + + + + + EnableAutoCRLDownload + + When the setting is enabled, a scheduled automatic CRL downloader on the appliance checks the validity of all the CRLs that are available in the appliance, and updates the CRLs that have expired or are about to expire. The downloader also downloads new CRLs during this process if the CRLs were not previously downloaded. The scheduled time for running the job is set to 12AM UTC. The appliance checks for CRLs every day that are about to expire. If any of the CRLs are about to expire in three days, the appliance downloads the latest available CRL. This prevents the expiration of CRLs on the appliance. You can configure the schedule for downloading the latest available CRLs using Set-OVCertificateRevocationInterval. If there is a failure during the CRL download, the appliance retries the operation three times before raising an alert. + + bool + + bool + + + + + NotifyExpiredMissingCRLs + + When enabled, alerts are displayed when there is no CRL uploaded for a CA, a CRL is about to expire, or a CRL has already expired. + + bool + + bool + + + + + SkipRevocationCheck + + This option controls whether HPE OneView treats a missing CRL as an error during certificate validation. By default, this option is enabled and HPE OneView performs overall certificate validation with the exception of revocation checking. If you do not have the CRL files issued by the CA certificates, any communication with devices or remote servers that have certificates signed by those CAs will fail until new CRLs are uploaded for all of those CA certificates. Those CA certificates can be identified by navigating to the manage certificate dialog in the settings and filtering by state of "CRL not found" + + bool + + bool + + + + + WhatIf + + + + SwitchParameter + + SwitchParameter + + + + + + + + + None. You cannot pipe objects to this cmdlet. + + + + + + + + + + + None + + + + Appliance will reboot. + + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Enable-OVCertificateRevocationChecking + + + Default example + + + + + + + + + + + + + Disable-OVCertificateRevocationChecking + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/library/enable-ovcertificaterevocationchecking + + + + + + + + Enable-OVCertificateValidation + + Enable appliance TLS/SSL certificate validation. + + Enable + OVCertificateValidation + + + HPE OneView performs certificate validation for all Transport Layer Security (TLS) communications between the appliance and external servers or devices. These checks guarantee confidentiality, integrity, and authentication with the remote end-point. + +In production environments, Hewlett Packard Enterprise strongly recommends that certificate validation be enabled. In environments where security is not a concern, such as a testing environment, certificate validation can optionally be disabled. + +If certificate validation is disabled, any sensitive data such as credentials are transmitted insecurely. Make sure to use only local user accounts and not enterprise directory-based accounts to avoid transmitting enterprise login credentials over the network when certificate validation is disabled. + +NOTE: When upgrading from earlier releases, the certificates in use by the currently monitored or managed devices are imported into the HPE OneView trust store and alerts are generated for issues such as expired certificates. These automatically added certificates are either a device"s self signed certificate or the leaf certificate for a certificate authority (CA) signed certificate. Using CA-signed certificates can simplify the device trust process. + +Certificate checking is enabled by default, but some of the stricter validation checks are relaxed to maintain communications with all devices, even those with certificate issues. The relaxed checking includes: + + * Not performing expiration checks for self signed certificates + * For certificate authority (CA) signed certificates, relaxed certificate revocation list (CRL) checking. + +The relaxed checking gives the administrator time to address any expired certificates, to upload trusted CA root and intermediate certificates, and upload the appropriate CRLs. + +Hewlett Packard Enterprise strongly recommends that you enable strict certificate validation checks after completing an update as appropriate for your enterprise security policies. See Manage Certificates for additional information on certificate management. + +HPE OneView supports devices using self signed certificates and devices using formal CA-signed certificates. CA-signed certificates offer benefits such as revocation checking and overall simplified management. + +HPE OneView enables users to import a CA CRL file and to perform the appropriate revocation checking on existing certificates in the trust store and for certificates received during communication with a managed device or external server. + +WARNING: Modifying the appliance setting will require the appliance to be rebooted. + +Minimum required privileges: Infrastructure administrator + + + + + Enable-OVCertificateValidation + + CheckForSelfSignedExpiry + + Enable ($true) or Disable ($false) the option to check for expiration of self signed certificates if you want to perform expiration checks for self signed certificates. By default, self signed certificate expiry is not enabled. + + Bool + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + + WhatIf + + + + SwitchParameter + + + Confirm + + Override the confirmation prompt. + + SwitchParameter + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + Array + + (${Global:ConnectedSessions} | ? Default) + + + CheckForSelfSignedExpiry + + Enable ($true) or Disable ($false) the option to check for expiration of self signed certificates if you want to perform expiration checks for self signed certificates. By default, self signed certificate expiry is not enabled. + + Bool + + Bool + + + + + Confirm + + Override the confirmation prompt. + + SwitchParameter + + SwitchParameter + + + + + WhatIf + + + + SwitchParameter + + SwitchParameter + + + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + System.Management.Automation.PSCustomObject + + + + Appliance global security settings. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Enable-OVCertificateValidation + + Enable certificate validation setting on the appliance. + + + + + + + + + + + + + Disable-OVCertificateValidation + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/enable-ovcertificatevalidation + + + + + + + + Enable-OVComposerHANode + + Promote Standby Composer node to Active. + + Enable + OVComposerHANode + + + This Cmdlet will help transition the Standby Composer node to the Active Role. Use this Cmdlet in order to perform maintenance on the Active node, or to remove the Active node from the Synergy management ring. The standby appliance must be accessible to and fully synchronized with the active appliance. + +NOTE: The appliance is unavailable during the role exchange and unable to respond to requests while services are reassigned. + +HPE OneView services will be stopped on the active appliance and restarted on the standby appliance. Operations in progress might fail and need to be restarted. + +Minimum required privileges: Infrastructure administrator or Software administrator. + + + + + Enable-OVComposerHANode + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. + + Object + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + WhatIf + + + + SwitchParameter + + + Confirm + + + + SwitchParameter + + + + + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + SwitchParameter + + False + + + Confirm + + + + SwitchParameter + + SwitchParameter + + + + + WhatIf + + + + SwitchParameter + + SwitchParameter + + + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + The Async task resource of the role transition request + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Enable-OVComposerHANode + + Transition the Standby Composer node in the default Appliance Connection. + + + + + + + + + + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/enable-ovcomposerhanode + + + + + + + + Enable-OVComposerIlo + + Enable HPE Synergy Composer2 iLO for remote connectivity. + + Enable + OVComposerIlo + + + You can configure the HPE Synergy Composer2 for remote access through its embedded management processor (iLO). This configuration enables you to manage the Composer2 remotely and perform specific Composer2 management operations that previously required accessing the Composer console locally in the data center. + +After remote access to a Composer2 iLO is configured, you can: + + * Use the iLO Integrated Remote Console (iLO IRC) to access the Composer2 physical console. The physical console provides access to the HPE OneView maintenance console. The Composer2 iLO has an independent IPaddress and is accessible even when the Composer2 is not available. + * Mount a virtual USB drive on the Composer2 through iLO and perform critical operations such as reimage,restore, backup, and create support dump without physically accessing the appliance. + * Power on or off the appliance. + +You can configure the iLO of the HPE Synergy Composer2 for remote access using this Cmdlet. All the Composer2 nodes that are present in the enclosures managed by HPE OneView can be configured, including standby or standalone Composer2 nodes. The following are the settings that you can configure for the Composer2 iLO in HPE OneView: + + * The iLO user account and password that are required to log in to the Composer2 iLO. + * Network parameters that allow you to access the Composer2 iLO from an external browser. The network parameters include iLO hostname, iLO IP address, subnet mask, gateway, and DNS server names. Both IPv4 and IPv6 addresses are supported. + +Supported operations on the Composer2 through the iLO Integrated Remote Console + +You can perform the following operations when using the HPE Synergy Composer2 iLO Integrated Remote Console (iLO IRC): + + * Switch between the graphical console or the Composer2 maintenance console. By default, the Composer2 console displays a graphical browser interface. Use Ctrl+Alt+F1 and Ctrl+Alt+F2 to switch between the graphical interface and the maintenance console. + * For the first-time setup, Hewlett Packard Enterprise recommends that you configure the appliance network before the hardware discovery process starts. + * Power on and off the appliance using the integrated power control options on the iLO remote console. + * Use the Composer2 iLO virtual media feature to have a USB drive on your local workstation mounted as a virtual USB drive on the Composer2. + +Virtually mounting the USB drive allows you to: + + * Reimage the Composer2 from a DD image on the virtual USB drive. + * Create a support dump file on the virtual USB drive. + + NOTE: If both virtual USB drive and local USB drive are plugged into the Composer2, by default the virtual USB drive is selected. To choose the USB drive that is plugged into the Composer2, unmount the virtual USB drive. In the iLO IRC, select Virtual Drives and clear the virtual drive selection to unmount the virtual USB drive. You can also unmount the virtual USB drive from the maintenance console of HPE OneView. + + * Restore the Composer2 from a backup image on the virtual USB drive. + +Requirements + + * A single iLO user account is supported. Creating a user account replaces any existing user account. + * The iLO username cannot be Administrator or start with an _. + +NOTE: The iLO user account is assigned a predefined set of privileges that allows the user to perform a restricted set of iLO operations. Specifically, the iLO account has permissions to control power, use the iLO Integrated Remote Console (iLO IRC), and use the iLO Virtual Media. + +Minimum required privileges: Infrastructure administrator + + + + + Enable-OVComposerIlo + + InputObject + + The object from Get-OVComposerIloStatus. + + Object + + + Username + + The iLO account to be created. The account name must not begin with an '_' (underscore), or be the built-in Administrator account. + + String + + + Password + + The SecureString of a password to set for the user account. + + SecureString + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + ApplianceConnection + + Specify one or more HPEOneView.Appliance.Connection object(s) or Name property value(s). + +Default Value: ${Global:ConnectedSessions} | ? Default + + Object + + + WhatIf + + + + SwitchParameter + + + Confirm + + + + SwitchParameter + + + + Enable-OVComposerIlo + + InputObject + + The object from Get-OVComposerIloStatus. + + Object + + + Username + + The iLO account to be created. The account name must not begin with an '_' (underscore), or be the built-in Administrator account. + + String + + + Password + + The SecureString of a password to set for the user account. + + SecureString + + + IPv4Address + + Use to configure a specific static IPv4 address to the iLO of the Composer appliance. + + IPAddress + + + IPv4SubnetMask + + Use to set the subnet mask, either in decimal noted or CIDR format. + + String + + + IPv4Gateway + + Use to configure what the default gateway is for the subnet. + + IPAddress + + + IPv4DnsServer + + Optionally configure the Primary and Secondary DNS server address(es). + + IPAddress[] + + + IPv6Address + + Use to configure the static IPv6 address to the iLO of the Compose appliance. + + IPAddress + + + IPv6SubnetMask + + Use to set the subnet mask, either in decimal noted or CIDR format. + + String + + + IPv6Gateway + + Use to set the subnet mask, either in decimal noted or CIDR format. + + IPAddress + + + IPv6DnsServer + + Optionally configure the Primary and Secondary DNS server address(es). + + IPAddress[] + + + IloHostname + + Use to specify a the iLO subsystem hostname. If omitted, a randomly generated name will be created. + + String + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + ApplianceConnection + + Specify one or more HPEOneView.Appliance.Connection object(s) or Name property value(s). + +Default Value: ${Global:ConnectedSessions} | ? Default + + Object + + + WhatIf + + + + SwitchParameter + + + Confirm + + + + SwitchParameter + + + + + + + ApplianceConnection + + Specify one or more HPEOneView.Appliance.Connection object(s) or Name property value(s). + +Default Value: ${Global:ConnectedSessions} | ? Default + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + SwitchParameter + + False + + + Confirm + + + + SwitchParameter + + SwitchParameter + + + + + IPv4Address + + Use to configure a specific static IPv4 address to the iLO of the Composer appliance. + + IPAddress + + IPAddress + + + + + IPv4DnsServer + + Optionally configure the Primary and Secondary DNS server address(es). + + IPAddress[] + + IPAddress[] + + + + + IPv4Gateway + + Use to configure what the default gateway is for the subnet. + + IPAddress + + IPAddress + + + + + IPv4SubnetMask + + Use to set the subnet mask, either in decimal noted or CIDR format. + + String + + String + + + + + IPv6Address + + Use to configure the static IPv6 address to the iLO of the Compose appliance. + + IPAddress + + IPAddress + + + + + IPv6DnsServer + + Optionally configure the Primary and Secondary DNS server address(es). + + IPAddress[] + + IPAddress[] + + + + + IPv6Gateway + + Use to set the subnet mask, either in decimal noted or CIDR format. + + IPAddress + + IPAddress + + Use to configure what the default gateway is for the subnet. + + + IPv6SubnetMask + + Use to set the subnet mask, either in decimal noted or CIDR format. + + String + + String + + + + + IloHostname + + Use to specify a the iLO subsystem hostname. If omitted, a randomly generated name will be created. + + String + + String + + + + + InputObject + + The object from Get-OVComposerIloStatus. + + Object + + Object + + + + + Password + + The SecureString of a password to set for the user account. + + SecureString + + SecureString + + + + + Username + + The iLO account to be created. The account name must not begin with an '_' (underscore), or be the built-in Administrator account. + + String + + String + + + + + WhatIf + + + + SwitchParameter + + SwitchParameter + + + + + + + + + HPEOneView.Appliance.HardwareConfig [System.Management.Automation.PSCustomObject] + + + The appliance hardware configuration object from Get-OVComposerIloStatus. + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + Async task resource to monitor. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + $SecurePassword = Read-Host "Password" -AsSecureString +$ComposerAppliance = Get-OVComposerIloStatus +Enable-OVComposerIlo -InputObject $ComposerAppliance -Hostname Myilohost.domian.com -Username iloadm -Password $SecurePassword + + + Enable HPE Synergy Composer 2 iLO remote connectivity, by setting the specified hostname, useraccount and secure password. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + $SecurePassword = Read-Host "Password" -AsSecureString +$ComposerAppliance = Get-OVComposerIloStatus +Enable-OVComposerIlo -InputObject $ComposerAppliance -Hostname Myilohost.domian.com -Username iloadm -Password $SecurePassword -IPv4Address 10.148.23.10 -IPv4SubnetMask 24 -IPv4Gateway 10.148.23.1 -IPv4DnsServer 10.10.4.23 + + + Enable HPE Synergy Composer 2 iLO remote connectivity, by setting the specified hostname, useraccount, secure password and static IPv4 address. + + + + + + + + + + -------------------------- EXAMPLE 3 -------------------------- + + + + $SecurePassword = Read-Host "Password" -AsSecureString +$ComposerAppliance = Get-OVComposerIloStatus +Enable-OVComposerIlo -InputObject $ComposerAppliance -Hostname Myilohost.domian.com -Username iloadm -Password $SecurePassword -IPv6Address fd51:df0f:1f8c:4916::1 -IPv4SubnetMask 64 -IPv6Gateway fe80::1:1 + + + Enable HPE Synergy Composer 2 iLO remote connectivity, by setting the specified hostname, useraccount, secure password and static IPv6 address. + + + + + + + + + + + + + Disable-OVComposerIlo + + + + Get-OVComposerIloStatus + + + + Set-OVComposerIlo + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/enable-ovcomposerilo + + + + + + + + Enable-OVComputeOpsmanagement + + Enable Compute Ops Management configuration. + + Enable + OVComputeOpsmanagement + + + HPE GreenLake for Compute Ops Management is a cloud-based as-a-Service application that manages various operations of HPE OneView appliances. By integrating HPE OneView with HPE GreenLake for Compute Ops Management will unify server inventory and centralize management to a single console. To enable the cloud management service for HPE OneView, you must onboard the appliance in the Compute Ops Management application in HPE GreenLake by using this Cmdlet to first generate the appliance ID. Once the Cmdlet completes successfully, use the Get-OVComputeOpsManagement Cmdlet to retreive the appliance ID needed in the HPE GreenLake for Compute Ops Management to generate an activation key. You can use this same Cmdlet with the -ActivationKey parameter, or Set-OVComputeOpsManagement Cmdlet to set the activation key for the appliance. + +Minimum required privileges: Infrastructure administrator + + + + + Enable-OVComputeOpsmanagement + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + ApplianceConnection + + Specify one or more HPEOneView.Appliance.Connection object(s) or Name property value(s). + +Default Value: ${Global:ConnectedSessions} | ? Default + + Object + + + + Enable-OVComputeOpsmanagement + + ActivationKey + + String value of the appliance unique activation key from the HPE GreenLake for Compute Ops Management portal. + + string + + + + + + + ActivationKey + + String value of the appliance unique activation key from the HPE GreenLake for Compute Ops Management portal. + + string + + string + + + + + ApplianceConnection + + Specify one or more HPEOneView.Appliance.Connection object(s) or Name property value(s). + +Default Value: ${Global:ConnectedSessions} | ? Default + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + SwitchParameter + + False + + + + + + + None. You cannot pipe objects to this cmdlet. + + + + + + + + + + + HPOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + Async task resource to monitor. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + [PS] C:\> Enable-OVComputeOpsManagement +Appliance Name Owner Created Duration +--------- ---- ----- ------- --- +appliance.domain.com Edit Compute Ops Management settings Administrator 9/20/2023 6:42:02 PM 00ΓǪ + +[PS] C:\> Get-OVComputeOpsManagement + +Management : Enabled +ApplianceID : ed0538b9-011e-48d4-a70a-5b108e029ed1 +AccountID : a23cb1d4ecbe0aeca28966cc2ae80cb3 +ConnectionState : Connected +Region : us-west +Url : https://us-west2.compute.cloud.hpe.com/ +ApplianceConnection : appliance.domain.com + + Enable the Compute Ops Management agent on the appliance, generating the appliance ID. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + $ActivationKey = "string" +Enable-OVComputeOpsManagement -ActivationKey $ActivationKey + + Activate the appliance. + + + + + + + + + + + + + Connect-OVComputeOpsManagement + + + + Disable-OVComputeOpsManagement + + + + Get-OVComputeOpsManagement + + + + Set-OVComputeOpsManagement + + + + Set-OVApplianceProxy + + + + Online: + https://hpe-docs.gitbook.io/posh-hpeoneview/cmdlets/v9.00/appliance/enable-ovcomputeopsmanagement + + + + + + + + Enable-OVDebug + + Enable specific appliance-level component debug logging. + + Enable + OVDebug + + + FOR HPE Support USE ONLY. This Cmdlet will enable appliance level component debug logging for during issue triage. Do not use this Cmdlet unless otherwise instructed by HPE Support. + + + + + Enable-OVDebug + + Scope + + The Scope of the LoggerName. + + String + + + LoggerName + + The internal component name. + + String + + + Level + + The verbose level to enable. Allowed values are: + + * ERROR + * WARN + * DEBUG + * TRACE + + String + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. + + Object + + + + + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Level + + The verbose level to enable. Allowed values are: + + * ERROR + * WARN + * DEBUG + * TRACE + + String + + String + + + + + LoggerName + + The internal component name. + + String + + String + + + + + Scope + + The Scope of the LoggerName. + + String + + String + + + + + + + + + HPEOneView.Appliance.Connection + + + HPE OneView Appliance Connection object. + + + + + + + + System.Management.Automation.PSCustomObject + + + + + + + + + + + + + + Disable-OVDebug + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/library/enable-ovdebug + + + + + + + + Enable-OVDeviceUid + + Enable unit identification (UID) of a device. + + Enable + OVDeviceUid + + + Authorized users can control the unit identification (UID) light on an HPE Synergy frame and its servers, interconnects, and frame link modules through the UI. Illuminating the UID light on the front of a device helps an on-site technician to locate the hardware in the data center. + +A UID icon is displayed on the Enclosures screen, the Server Hardware screen, and the Interconnects screen. On the Enclosures screen, the enclosure overview displays the UID icon on its frame link modules, servers, and interconnects. + +Use this Cmdlet to enable the UID light on a resource. + +NOTE: The UID light blinks automatically to indicate that a critical operation is underway, such as Remote Console access for server hardware or a firmware update. Do not remove power from a device when its UID light is blinking. + +Minimum required privileges: Infrastructure administrator, Server administrator (for enclosure, server, and frame link module UID lights), Network administrator (for interconnect UID lights) + + + + + Enable-OVDeviceUid + + InputObject + + Resource object to turn on the UID. Supported resources are Server Hardware and Enclosures. + + Object + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + InputObject + + Resource object to turn on the UID. Supported resources are Server Hardware and Enclosures. + + Object + + Object + + + + + + + + + HPEOneView.ServerHardware [System.Management.Automation.PSCustomObject] or HPEOneView.Enclosure [System.Management.Automation.PSCustomObject] + + + Server Hardware or Enclosure resource. + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + If successful, returns Appliance Async Task object to monitor. + + + + + System.Collections.ArrayList <HPEOneView.Appliance.TaskResource> + + + + Collection of Appliance Async Task objects to monitor. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVServer -Name "MyEncl, Bay 1" | Enable-OVDeviceUid | Wait-OVTaskComplete + + Enable the UID for "MyEncl, Bay 1" server. + + + + + + + + + + + + + Disable-OVDeviceUid + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/servers/enable-ovdeviceuid + + + + + + + + Enable-OVLdapLocalLogin + + Enable local authentication logins. + + Enable + OVLdapLocalLogin + + + You can configure HPE OneView to use an external enterprise directory service for user authentication. HPE OneView supports the following enterprise directory services: + + * Active Directory + * OpenLDAP + +When you use a directory service, directory users are granted HPE OneView permissions using their group membership in the directory. After defining a directory service, use the User and Groups screen to define permissions for directory groups. Directory groups are assigned one or more HPE OneView permissions. A directory user is assigned the HPE OneView permissions that represent the union of the permissions for all the directory groups that the user is a member of. Only after permissions are defined for directory groups, directory users are authenticated into the appliance. + +If you want to authenticate all logins to the appliance through a directory service, you must disable local logins. Also, if a directory is inaccessible in some special cases, you can enable the emergency local login. To enable emergency local login, you must disable local logins. + +Minimum required privileges: Infrastructure administrator. + + + + + Enable-OVLdapLocalLogin + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + WhatIf + + + + SwitchParameter + + + Confirm + + + + SwitchParameter + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Confirm + + + + SwitchParameter + + SwitchParameter + + + + + WhatIf + + + + SwitchParameter + + SwitchParameter + + + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + System.Management.Automation.PSCustomObject + + + + Appliance Authentication Directory setting. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Enable-OVLdapLocalLogin + + Enable local logins on the appliance. + + + + + + + + + + + + + Disable-OVLdapLocalLogin + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/security/enable-ovldaplocallogin + + + + + + + + Enable-OVLogicalInterconnectPortMonitoring + + Enable port monitoring for a logical interconnect. + + Enable + OVLogicalInterconnectPortMonitoring + + + Port monitoring provides the ability to analyze traffic passing through monitored ports by mirroring the traffic from one port to another port on one switch or a switch connected to a network analyzer. The Network analyzer port is the destination for the mirrored traffic. The network analyzer port (the mirrored-to uplink port or downlink port) is for the downlink server ports within a single enclosure. There is a single mirrored-to port per logical interconnect. + +The Network analyzer port must be provisioned to an uplink set of both the logical interconnect and its parent logical interconnect group. Downlink port mirroring is only supported on the physical ports. Once a connection is established to any one of the physical ports on the Mezzanine adapter, then all the ports on that adapter change to Flex mode, and therefore cannot be used as analyzer ports. + +Port monitoring is supported only on a physical port and applied only to a downlink port. You can configure port monitoring on a logical interconnect only with the interconnect modules that are in configured state. Ports that are mirrored are known as monitored ports or mirror-from-port. Port where the packets are copied is known as analyzer port or mirror-to-port. The physical interconnect modules of a logical interconnect contain all the port monitoring configurations. To configure port monitoring, specify one or more source ports along with a destination port. The destination port is also known as mirror-to port (MTP). + +The MTP receives a copy of the ingress or egress traffic as configured on monitored source ports. The monitored port mirrors the ingress or egress traffic. To monitor the Ethernet traffic direction from a source port, select one of the following options: + + * To server: To monitor only ingress traffic. + * From server: To monitor only egress traffic. + * Both: To monitor both ingress and egress traffic. + +Virtual Connect module uplink ports must not be used as a destination for these externally generated traffic types: + + * Switched Port Analyzer (SPAN) + * Remote Switch Port Analyzer (RSPAN) + * Any other mirrored type traffic + +Interconnects +---------------------------------------------------------------------------------------------------------------- +You can monitor up to 60 downlink server ports on a logical interconnect. To analyze the Ethernet traffic on monitored ports, use either local port monitoring or remote port monitoring. + +HPE Virtual Connect SE 40Gb F8 Module for HPE Synergy and HPE Virtual Connect SE 100Gb F32 Module for HPE Synergy +---------------------------------------------------------------------------------------------------------------- +You can configure uplink ports as monitored ports to mirror ingress, egress, or traffic in both directions. Ingress is the traffic flowing to the uplink port. Egress is the traffic flowing from the uplink port. + + * Uplink ports and downlink ports can be monitored for both local and remote port monitoring. + * The same uplink port cannot be configured as both analyzer and monitored port. + * Only uplinks that are part of an uplink set can be configured for monitoring. + +Removing a monitored port from existing uplink set is not allowed. The port monitoring must be disabled to remove the monitored port from the uplink set. + +HPE Virtual Connect SE 100Gb F32 Module for HPE Synergy +---------------------------------------------------------------------------------------------------------------- +Use the Analyzer port speed option to configure the speed of the network analyzer port. + +For example, if you want to operate an HPE Virtual Connect SE 100Gb F32 Module for HPE Synergy having 25 GB per second speed at a speed of 10 GB per second, you must set the Analyzer port speed to 10 GB per second. + +Similarly, you can configure the Forward Error Correction (FEC) mode using the Analyzer port FEC mode option. You can customize both the analyzer port speed and FEC mode based on the hardware requirement. + +Minimum required privileges: Infrastructure administrator or Network administrator + + + + + + Enable-OVLogicalInterconnectPortMonitoring + + InputObject + + HPEOneView.Networking.LogicalInterconnect from Get-OVLogicalInterconnect. + + Object + + + AnalyzerPort + + Specifies the network analyzer port (the mirrored-to uplink port) for the downlink server ports within a single enclosure. There is a single "mirrored-to port" per logical interconnect. The port string value format must be "EnclosureID:BayID:FaceplateName" + +Example: "Enclosure2:Bay6:Q1.1" + + + Object + + + MonitoredPorts + + An Array of Hashtable or PSCustomObject containing the desired port to monitor. The "Port" property format must be "EnclosureID:BayID:ServerDownlinkPortID". The ServerDownlinkPortID must be the full physical port, as port monitoring mirrors the entire downlink port, regardless the number of FlexNICs configured. + +Example: @{Port = "Enclosure1:Bay1:D2"; Direction = "toserver"} + +The "Direction" property value must be one of the following: + + * MonitoredToServer + * MonitoredFromServer + * Both + + Hashtable + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + + + Enable-OVLogicalInterconnectPortMonitoring + + InputObject + + HPEOneView.Networking.LogicalInterconnect from Get-OVLogicalInterconnect. + + Object + + + MonitoredPorts + + An Array of Hashtable or PSCustomObject containing the desired port to monitor. The "Port" property format must be "EnclosureID:BayID:ServerDownlinkPortID". The ServerDownlinkPortID must be the full physical port, as port monitoring mirrors the entire downlink port, regardless the number of FlexNICs configured. + +Example: @{Port = "Enclosure1:Bay1:D2"; Direction = "toserver"} + +The "Direction" property value must be one of the following: + + * MonitoredToServer + * MonitoredFromServer + * Both + + Hashtable + + + UplinkSetName + + The name of the uplink set provisioned to the specified logical interconnect resource provided in the InputObject parameter. The uplink set must: + + * Be provisioned to both the logical interconnect and its associated parent logical interconnect group. + * Contain a singular, tagged Ethernet network. + * The Ethernet network must not be assigned to any server profile connections, or other uplink sets. + * The uplink set must only contain a single uplink port. + + Hashtable + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + + + + + + AnalyzerPort + + Specifies the network analyzer port (the mirrored-to uplink port) for the downlink server ports within a single enclosure. There is a single "mirrored-to port" per logical interconnect. The port string value format must be "EnclosureID:BayID:FaceplateName" + +Example: "Enclosure2:Bay6:Q1.1" + + + Object + + Object + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + Array + + (${Global:ConnectedSessions} | ? Default) + + + InputObject + + HPEOneView.Networking.LogicalInterconnect from Get-OVLogicalInterconnect. + + Object + + Object + + + + + MonitoredPorts + + An Array of Hashtable or PSCustomObject containing the desired port to monitor. The "Port" property format must be "EnclosureID:BayID:ServerDownlinkPortID". The ServerDownlinkPortID must be the full physical port, as port monitoring mirrors the entire downlink port, regardless the number of FlexNICs configured. + +Example: @{Port = "Enclosure1:Bay1:D2"; Direction = "toserver"} + +The "Direction" property value must be one of the following: + + * MonitoredToServer + * MonitoredFromServer + * Both + + Hashtable + + Hashtable + + + + + UplinkSetName + + The name of the uplink set provisioned to the specified logical interconnect resource provided in the InputObject parameter. The uplink set must: + + * Be provisioned to both the logical interconnect and its associated parent logical interconnect group. + * Contain a singular, tagged Ethernet network. + * The Ethernet network must not be assigned to any server profile connections, or other uplink sets. + * The uplink set must only contain a single uplink port. + + Hashtable + + Hashtable + + + + + + + + + HPEOneView.Networking.LogicalInterconnect [System.Management.Automation.PSCustomObject] + + + Logical Interconnect resource object from Get-OVLogicalInterconnect + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + Async task Resource object for configuring port monitoring on the requested logical intercinnect. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + $LogicalInterconnect = Get-OVLogicalInterconnect -Name "Encl1-Default VC FF LIG" +$MonitoredPorts = @( + @{Port = "Enclosure1:Bay3:D2"; Direction = "MonitoredToServer"}, + @{Port = "Enclosure1:Bay3:D3"; Direction = "MonitoredFromServer"}, + @{Port = "Enclosure2:Bay6:D7"; Direction = "Both"} + +) + +Enable-OVLogicalInterconnectPortMonitoring -InputObject $LogicalInterconnect -AnalyzerPort "Enclosure1:Bay3:Q1.1" -MonitoredPorts $MonitoredPorts + + Enable port monitoring for the specific logical interconnect. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Get-OVLogicalInterconnect -Name "LE1-Default VC LIG" | Enable-OVLogicalInterconnectPortMonitoring -AnalyzerPort "Enclosure1:Bay3:Q1.1" -MonitoredPorts @{Port = "Enclosure1:Bay3:d1"; Direction = "Both"}, @{Port = "Enclosure2:Bay6:d1"; Direction = "Both"} + + Enable port monitoring for the specific logical interconnect. + + + + + + + + + + -------------------------- EXAMPLE 3 -------------------------- + + + + $UplinkSetName = "RSPAN Analyzer" +$UplinkSetPort = "Enclosure1:Bay3:Q6.1" +$LogicalInterconnectName = "Encl1-Default VC FF LIG" +$RSPANNetworkName = "RSPAN Network" +$RSPANNetworkVlanID = "411" + +If (-not ($RSPANNetwork = Get-OVNetwork -Name $RSPANNetworkName -Type Ethernet -ErrorAction SilentlyContinue)) { + + New-OVNetwork -Name $RSPANNetworkName -VlanID $RSPANNetworkVlanID + +} + +# Get the logical interconnect resource +$LogicalInterconnect = Get-OVLogicalInterconnect -Name $LogicalInterconnectName -ErrorAction Stop + +# Get the associated logical interconnect group resource from the logical interconnect +$LogicalInterconnectGroup = Get-OVLogicalInterconnectGroup -InputObject $LogicalInterconnect + +# Add a new uplink set to the LIG associated with the LI +$UplinkSetParams = @{ + + InputObject = $LogicalInterconnectGroup; + Name = $UplinkSetName; + Type = 'Ethernet'; + Networks = $RSPANNetwork; + UplinkPorts = $UplinkSetPort + +} + +# Create the new uplink set to the logical interconnect group +New-OVUplinkSet @UplinkSetParams + +# Update the LI from parent +Update-OVLogicalInterconnect -InputObject $LogicalInterconnect + +# Configure port monitoring with the new uplink set configuration +$MonitoredPorts = @( + @{Port = "Enclosure1:Bay3:D2"; Direction = "MonitoredToServer"}, + @{Port = "Enclosure1:Bay3:D3"; Direction = "MonitoredFromServer"}, + @{Port = "Enclosure2:Bay6:D7"; Direction = "Both"} + +) + +Enable-OVLogicalInterconnectPortMonitoring -InputObject $LogicalInterconnect -UplinkSetName $UplinkSetName -MonitoredPorts $MonitoredPorts + + Configure remote session (RSPAN) port monitoring. + + + + + + + + + + + + + Disable-OVLogicalInterconnectPortMonitoring + + + + Get-OVLogicalInterconnectPortMonitoring + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/networking/enable-ovlogicalinterconnectportmonitoring + + + + + + + + Enable-OVMaintenanceMode + + Enable compute resource into maintenance mode. + + Enable + OVMaintenanceMode + + + Performing routine maintenance operations on servers causes many events to be generated on the associated server hardware resource and server profile. If notification features are enabled, the events cause many email notifications. While the maintenance activity is in progress, you might not want to receive all the notifications. + +Enabling server maintenance mode prevents the appliance from sending any email notifications that are related to the server hardware and its associated profile. While the notifications are blocked, maintenance mode does not affect normal server or profile operations, and all events generated on the server are seen on the HPE OneView appliance UI. + +Disabling maintenance mode causes email notifications to return to normal. No attempt is made to send any events that occurred during the maintenance mode. However, if the health of the server is not OK when maintenance mode is disabled, a single event will be sent, alerting that the server is in a non-healthy state. + +Minimum required privileges: Infrastructure administrator, Network administrator + + + + + Enable-OVMaintenanceMode + + InputObject + + Either a server hardware or server profile resource. + + Object + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + ApplianceConnection + + Aliases [-Appliance] + +Specify one or more HPEOneView.Appliance.Connection object(s) or Name property value(s). + +Default Value: ${Global:ConnectedSessions} | ? Default + + Object + + + WhatIf + + + + + + + Confirm + + + + + + + + + + + ApplianceConnection + + Aliases [-Appliance] + +Specify one or more HPEOneView.Appliance.Connection object(s) or Name property value(s). + +Default Value: ${Global:ConnectedSessions} | ? Default + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + SwitchParameter + + False + + + Confirm + + + + + + + + + + + InputObject + + Either a server hardware or server profile resource. + + Object + + Object + + + + + WhatIf + + + + + + + + + + + + + + + HPEOneView.ServerHardware [System.Management.Automation.PSCustomObject] + + + A server hardware resource from the appliance. + + + + + HPEOneView.ServerProfile [System.Management.Automation.PSCustomObject] + + + A server profile resource from the appliance. + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + Async task resource object to monitor. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + $Server = Get-OVServer -Name "Encl1, bay 1" +Enable-OVMaintenanceMode -InputObject $Server + + nEnable the maintenance mode state of the specific server resource. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + $ServerProfile = Get-OVServerProfile -Name "My Profile 1" +Enable-OVMaintenanceMode -InputObject $ServerProfile + + nEnable the maintenance mode state of the specific server resource that is associated with the server profile. + + + + + + + + + + + + + Disable-OVMaintenanceMode + + + + Get-OVServer + + + + Get-OVServerProfile + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/servers/enable-ovmaintenancemode + + + + + + + + Enable-OVMSDSC + + Enable Microsoft DSC Support + + Enable + OVMSDSC + + + Using this Cmdlet will create and/or modify UseMSDSC (REG_DWORD) located at HKCU:\Software\Hewlett-Packard\HPOneView, to 1 (True). By enabling support, the module will overload Write-Host, and instead issue Write-Verbose commands. + +Use Disable-OVMsDSC to disable support. + + + + + Enable-OVMSDSC + + + + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + None. + + + + + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Enable-OVMSDSC + + Configures Registry value to overload Write-Host, which then uses Write-Verbose. + + + + + + + + + + + + + Disable-OVMSDSC + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/library/enable-ovmsdsc + + + + + + + + Enable-OVRemoteSupport + + Enable Remote Support for a supported resource. + + Enable + OVRemoteSupport + + + Register with Hewlett Packard Enterprise to allow automatic case creation for hardware failures on servers and enclosures and to enable Proactive Care. Once enabled, all eligible devices added in the future will be automatically enabled for remote support. + +Hewlett Packard Enterprise recommends enabling all features and benefits provided by HPE OneView Remote Support so you can receive fast, accurate 'phone home' support and service per your contractual terms with Hewlett Packard Enterprise. Hewlett Packard Enterprise securely collects your HPE IT hardware diagnostics, configuration and telemetry information to provide you with remote support and services. The data is handled and managed to respect your privacy. For more information, Hewlett Packard Enterprise's Privacy Statement can be found at http://privacy.hpe.com. + +Enabling Remote Support configures your devices being remotely supported to securely send support or service events, IT configuration information, diagnostic, and telemetry information to Hewlett Packard Enterprise, together with your support contact information. No other business information is collected and the data is managed according to the Hewlett Packard Enterprise's Privacy Statement. + +This Cmdlet will enable Remote Support for a compute or enclosure resource. Remote Support must be enabled globally on the appliance in order to use this Cmdlet. + +Minimum required privileges: Infrastructure administrator, Server administrator, or Server firmware operator + + + + + Enable-OVRemoteSupport + + InputObject + + The compute or enclosure resource to enable Remote Support for. + + Object + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + SwitchParameter + + False + + + InputObject + + The compute or enclosure resource to enable Remote Support for. + + Object + + Object + + + + + + + + + HPEOneView.ServerHardware [System.Management.Automation.PSCustomObject] + + + A Gen8 or newer generation server hardware resource object from Get-OVServer. + + + + + HPEOneView.Enclosure [System.Management.Automation.PSCustomObject] + + + A Gen8 or newer generation server hardware resource object from Get-OVServer. + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + Async task Resource object for monitoring. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVServer -Name Prod* | Enable-OVRemoteSupport + + Get the servers with their name matching "Prod" and enable Remote Support for those resources. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + $Enclosure = Get-OVEnclosure -Name Enclosure-1A +Enable-OVRemoteSupport -InputObject $Enclusre + + Get the specific enclosure resource and enable Remote Support. + + + + + + + + + + + + + Disable-OVRemoteSupport + + + + Get-OVRemoteSupport + + + + Get-OVRemoteSupportContact + + + + Get-OVRemoteSupportDataCollectionSchedule + + + + Get-OVRemoteSupportDefaultSite + + + + Get-OVRemoteSupportEntitlementStatus + + + + Get-OVRemoteSupportPartner + + + + Get-OVRemoteSupportSetting + + + + New-OVRemoteSupportContact + + + + New-OVRemoteSupportPartner + + + + Remove-OVRemoteSupportContact + + + + Remove-OVRemoteSupportPartner + + + + Set-OVRemoteSupport + + + + Set-OVRemoteSupportDataCollectionSchedule + + + + Set-OVRemoteSupportDefaultSite + + + + Set-OVRemoteSupportPrimaryContact + + + + Set-OVRemoteSupportSetting + + + + Start-OVRemoteSupportCollection + + + + Update-OVRemoteSupportEntitlement + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/enable-ovremotesupport + + + + + + + + Enable-OVRemoteSyslog + + Enable remote syslog. + + Enable + OVRemoteSyslog + + + The remoteSyslog API provides the ability to configure remote logging on devices managed by OneView. This Cmdlet handles enabling the remote syslog configuration. Only a single destination can be set. When configured, the HPE OneView appliance will deploy the SysLog settings to managed resources automatically. + +Minimum required privileges: Infrastructure administrator, Server administrator + + + + + Enable-OVRemoteSyslog + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + SwitchParameter + + false + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + If successful, returns Appliance Async Task object to monitor. + + + + + System.Collections.ArrayList <HPEOneView.Appliance.TaskResource> + + + + Collection of Appliance Async Task objects to monitor. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Enable-OVRemoteSyslog + + Enable remote syslog configuration on all connected appliances. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Enable-OVRemoteSyslog -ApplianceConnection appliance1.domain.com -Async | Wait-OVTaskComplete + + Enable remote syslog configuration on the specific connected appliance. + + + + + + + + + + + + + Disable-OVRemoteSyslog + + + + Get-OVRemoteSyslog + + + + Set-OVRemoteSyslog + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/enable-ovremotesyslog + + + + + + + + Enter-OVClusterNodeMaintenanceMode + + Request a cluster node member to enter maintenance mode. + + Enter + OVClusterNodeMaintenanceMode + + + A cluster in an active state runs a shared workload, like virtual machines within a Hypervisor Cluster. When you place a cluster node into maintenance mode, the workload running on the cluster member is migrated to other available cluster member. While in maintenance state the server administrator can perform updates on the host software, server hardware, or both, preventing business downtime. + +After the maintenance operation on the cluster member completes, you must release it from maintenance mode to resume hosting the shared workload. + +Minimum required privileges: Infrastructure administrator, Server administrator, Server Profile administrator, Server Profile architect, or Server Profile operator + + + + + Enter-OVClusterNodeMaintenanceMode + + InputObject + + The cluster member from Get-OVClusterNode + + Object + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + WhatIf + + + + SwitchParameter + + + Confirm + + Use to override the confirmation prompt. + + SwitchParameter + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + SwitchParameter + + False + + + Confirm + + Use to override the confirmation prompt. + + SwitchParameter + + SwitchParameter + + + + + InputObject + + The cluster member from Get-OVClusterNode + + Object + + Object + + + + + WhatIf + + + + SwitchParameter + + SwitchParameter + + + + + + + + + HPEOneView.Cluster.ClusterNode [System.Management.Automation.PSCustomObject] + + + Cluster node member from Get-OVClusterNode. + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + Asynchronous task resource to monitor. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVClusterNode -Name Cluster1-Node1 | Enter-OVClusterNodeMaintenanceMode + + Request to put the specific node into maintenance mode. + + + + + + + + + + + + + Exit-OVClusterNodeMaintenanceMode + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/cluster/enter-ovclusternodemaintenancemode + + + + + + + + Exit-OVClusterNodeMaintenanceMode + + Request a cluster node member to exit maintenance mode. + + Exit + OVClusterNodeMaintenanceMode + + + A cluster in an active state runs a shared workload, like virtual machines within a Hypervisor Cluster. When you place a cluster node into maintenance mode, the workload running on the cluster member is migrated to other available cluster member. While in maintenance state the server administrator can perform updates on the host software, server hardware, or both, preventing business downtime. + +After the maintenance operation on the cluster member completes, you must release it from maintenance mode to resume hosting the shared workload. + +Minimum required privileges: Infrastructure administrator, Server administrator, Server Profile administrator, Server Profile architect, or Server Profile operator + + + + + Exit-OVClusterNodeMaintenanceMode + + InputObject + + The cluster member from Get-OVClusterNode + + Object + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + WhatIf + + + + SwitchParameter + + + Confirm + + Use to override the confirmation prompt. + + SwitchParameter + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + SwitchParameter + + False + + + Confirm + + Use to override the confirmation prompt. + + SwitchParameter + + SwitchParameter + + + + + InputObject + + The cluster member from Get-OVClusterNode + + Object + + Object + + + + + WhatIf + + + + SwitchParameter + + SwitchParameter + + + + + + + + + HPEOneView.Cluster.ClusterNode [System.Management.Automation.PSCustomObject] + + + Cluster node member from Get-OVClusterNode. + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + Asynchronous task resource to monitor. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVClusterNode -Name Cluster1-Node1 | Exit-OVClusterNodeMaintenanceMode + + Request to the specific node exit maintenance mode. + + + + + + + + + + + + + Enter-OVClusterNodeMaintenanceMode + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/cluster/exit-ovclusternodemaintenancemode + + + + + + + + Get-OVAddressPool + + Retrieve address pool information. + + Get + OVAddressPool + + + An ID pool is a collection of one or more ranges that you can be randomly generate or specify to provide large address spaces. By default, one virtual ID pool each of contiguous MAC addresses, WWNs, and serial numbers are created automatically when you initialize the appliance. The pools are composed of address and ID ranges. You can individually enable or disable a range, or delete any unused ranges. ID pool ranges do not conflict with physical IDs, provided the virtual ranges you create exclude the physical ID ranges. + +This Cmdlet will get the available and configured address pools, and their associated Ranges from the appliance. Currently, the appliance supports the following address pools: + + * VMAC + * VWWN + * VSN + * IPv6 + * IPv4 + +You can specify one, some or all of the Pool types. A Range switch is provided to include the associated Range objects. A report switch is provided to display a report of each address pool type. + +Minimum required privileges: Network administrator (virtual MAC addresses and virtual WWNs), Infrastructure administrator (all ID types) + + + + + Get-OVAddressPool + + Type + + The address pool type. Accepted values are VMAC, VWWN, VSN, IPv4, IPv6, or All. + + String[] + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Type + + The address pool type. Accepted values are VMAC, VWWN, VSN, IPv4, IPv6, or All. + + String[] + + String[] + + all + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + HPEOneView.Appliance.AddressPool [System.Management.Automation.PSCustomObject] + + + + Single address pool and its contents. + + + + + System.Collections.ArrayList <HPEOneView.Appliance.AddressPool> + + + + Collection of address pools and their contents. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVAddressPool + + Get the address pools. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Get-OVAddressPool -type vmac + + Get the vmac address pool. + + + + + + + + + + + + + Get-OVAddressPoolRange + + + + Get-OVAddressPoolSubnet + + + + New-OVAddressPoolRange + + + + New-OVAddressPoolSubnet + + + + Remove-OVAddressPoolRange + + + + Remove-OVAddressPoolSubnet + + + + Set-OVAddressPoolSubnet + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/get-ovaddresspool + + + + + + + + Get-OVAddressPoolRange + + Retrieve address pool range information. + + Get + OVAddressPoolRange + + + An ID pool is a collection of one or more ranges that you can be randomly generate or specify to provide large address spaces. By default, one virtual ID pool each of contiguous MAC addresses, WWNs, and serial numbers are created automatically when you initialize the appliance. The pools are composed of address and ID ranges. You can individually enable or disable a range, or delete any unused ranges. ID pool ranges do not conflict with physical IDs, provided the virtual ranges you create exclude the physical ID ranges. + +This Cmdlet will display configured address pool ranges defined on an HPE OneView appliance. Currently, the appliance supports the following address pool ranges: + + * VMAC + * VWWN + * VSN + * IPv6 + * IPv4 + +You can specify one, some or all of the pool types. + +Minimum required privileges: Network administrator (virtual MAC addresses and virtual WWNs), Infrastructure administrator (all ID types) + + + + + Get-OVAddressPoolRange + + Type + + Specify the type of address pool. Allowed values are: + + * IPv4 + * IPv6 + * VMAC + * VWWN + * VSN + * All + + String[] + + + Name + + Filter address ranges based on the name. + + String + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + Get-OVAddressPoolRange + + InputObject + + Specify the address pool object from Get-OVAddressPool. + + Object + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + InputObject + + Specify the address pool object from Get-OVAddressPool. + + Object + + Object + + + + + Name + + Filter address ranges based on the name. + + String + + String + + + + + Type + + Specify the type of address pool. Allowed values are: + + * IPv4 + * IPv6 + * VMAC + * VWWN + * VSN + * All + + String[] + + String[] + + all + + + + + + + HPEOneView.Appliance.AddressPool [System.Management.Automation.PSCustomObject] + + + Address pool resource object. + + + + + + + + HPEOneView.Appliance.AddressPoolRange [System.Management.Automation.PSCustomObject] + + + + Address pool range object. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + [PS] C:\> Get-OVAddressPoolRange + +Name Enabled Category Total Allocated Available Reserved Start End +---- ------- -------- ----- --------- --------- -------- ----- --- +VMAC True Generated 1048576 2 1048574 0 62:79:84:50:00:00 62:79:84:5F:FF:FF +VWWN True Generated 1048576 0 1048576 0 10:00:92:5a:1f:b0:00:00 10:00:92:5a:1f:bf:ff:ff +VSN True Generated 46656 1 46655 0 VCGBWAB000 VCGBWABZZZ +VMAC True Generated 1048576 0 1048576 0 F6:38:E6:90:00:00 F6:38:E6:9F:FF:FF +VWWN True Generated 1048576 0 1048576 0 10:00:ce:58:fa:50:00:00 10:00:ce:58:fa:5f:ff:ff +VSN True Generated 46656 0 46656 0 VCGA290000 VCGA290ZZZ + + Get all configured address pool ranges from all connected appliances. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + [PS] C:\> Get-OVAddressPoolRange -Type vmac + +Name Enabled Category Total Allocated Available Reserved Start End +---- ------- -------- ----- --------- --------- -------- ----- --- +VMAC True Generated 1048576 2 1048574 0 62:79:84:50:00:00 62:79:84:5F:FF:FF +VMAC True Generated 1048576 0 1048576 0 F6:38:E6:90:00:00 F6:38:E6:9F:FF:FF + + Get a specific address pool range type (VMAC) from all connected appliances. + + + + + + + + + + + + + New-OVAddressPoolRange + + + + Remove-OVAddressPoolRange + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/get-ovaddresspoolrange + + + + + + + + Get-OVAddressPoolSubnet + + Retrieve address pool subnet information. + + Get + OVAddressPoolSubnet + + + An ID pool is a collection of one or more ranges that you can be randomly generate or specify to provide large address spaces. By default, one virtual ID pool each of contiguous MAC addresses, WWNs, and serial numbers are created automatically when you initialize the appliance. The pools are composed of address and ID ranges. You can individually enable or disable a range, or delete any unused ranges. ID pool ranges do not conflict with physical IDs, provided the virtual ranges you create exclude the physical ID ranges. + +IPv4 or IPv6 address pools can be used in a variety of application. Create an IPv4 or IPv6 subnet with one or more IPv4 or IPv6 address ranges you define. To assign static IP addresses to device bays, associate these IP ranges with an enclosure group, in which case IP addresses are assigned to the iLOs of server hardware populating these bays. IP ranges are also associated with interconnect bays, in which case IP addresses are assigned to the interconnect modules. Interconnects and iLOs share the same IP address pool. + +Associate an IPv4 or IPv6 subnet with an Ethernet network. If this is an iSCSI network used as a deployment network, Image Streamer appliances can consume an IP address from one of the ranges for management of the appliance. + +Use this Cmdlet to retrieve the configured IPv4 or IPv6 address pool subnets. + +Minimum required privileges: Network administrator, Infrastructure administrator + + + + + Get-OVAddressPoolSubnet + + NetworkId + + Specify the Network ID of the subnet in order to filter the results. + + String + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + NetworkId + + Specify the Network ID of the subnet in order to filter the results. + + String + + String + + + + + + + + + None. This Cmdlet does not support pipeline operations. + + + + + + + + + + + HPEOneView.Appliance.IPAddressSubnet [System.Management.Automation.PSCustomObject] + + + + Single IPv4 Subnet address pool range. + + + + + System.Collections.ArrayList <HPEOneView.Appliance.IPAddressSubnet> + + + + Collection of IPv4 Subnet address pool range(s). + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVAddressPoolSubnet + + Get the configured IPv4 and IPv6 address pools. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Get-OVAddressPoolSubnet -NetworkId 192.168.20.0 + + Get the specified IPv4 address pool. + + + + + + + + + + + + + New-OVAddressPoolSubnet + + + + Remove-OVAddressPoolSubnet + + + + Set-OVAddressPoolSubnet + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/get-ovaddresspoolsubnet + + + + + + + + Get-OVAlert + + Get an alert. + + Get + OVAlert + + + The appliance uses alert messages to report issues with the resources it manages and monitors. The resources generate alerts to notify you that some meaningful event occurred and that an action might be required. + +An event describes a single problem or change that occurred on a resource. For example, an event might be an SNMP trap received from a server's (iLO) management processor. + +Each alert includes the following information about the event it reports: severity, state, description, and urgency. You can clear alerts, assign owners to alerts, and add notes to alerts. + +While alerts have an active or locked state, they contribute to the overall displayed status for a resource. After you change their state to Cleared, they no longer affect the displayed status. + +You can filter the display of the activity list to help you locate and view specific activities. However, you cannot customize filters to otherwise manage the display of the activities. + +This Cmdlet allows the administrator to get an alert. Alerts can be filtered by using the -State parameter. If a resource object is supplied using the -InputObject parameter, all associated alerts will be returned. This Cmdlet also supports additional filtering by state, assigned to user, severity, count and date range. + +Minimum required privileges: Network administrator, Server administrator, Infrastructure administrator, Backup administrator, Read only + + + + + Get-OVAlert + + InputObject + + Alerts for the specified resource will be returned. + + Object + + + Severity + + Alerts with given severity will be returned. Allowed severity values are: + + * Unknown + * Ok + * Disabled + * Warning + * Critical + + String + + + HealthCategory + + Alerts with given health category will be returned. Allowed health category values are: + + * Appliance + * DeviceBay + * Enclosure + * Fan + * Firmware + * Host + * Instance + * InterconnectBay + * LogicalSwitch + * Logs + * ManagementProcessor + * Memory + * Network + * Operational + * Power + * Processor + * RemoteSupport + * Storage + * Thermal + * Unknown + + String + + + AssignedToUser + + Alerts assigned to the given user will be returned. + + String + + + AlertState + + Alerts with given alert state will be returned. State values include Active and Cleared + + String + + + Count + + Return only the number of alerts from the appliance. Can be combined with other parameters to return a pruned list of alerts. + + String + + + TimeSpan + + Return the number of alerts created from today to the defined number of days. + + Timespan + + + Start + + Return alerts that were created starting from the specified date. Hour, Min and Seconds will not be used, only Month, Day and Year of the DateTime value. + + DateTime + + + End + + Return alerts that were created on the specified date. Hour, Min and Seconds will not be used, only Month, Day and Year of the DateTime value. + + DateTime + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + + + + + + AlertState + + Alerts with given alert state will be returned. State values include Active and Cleared + + String + + String + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + AssignedToUser + + Alerts assigned to the given user will be returned. + + String + + String + + + + + Count + + Return only the number of alerts from the appliance. Can be combined with other parameters to return a pruned list of alerts. + + String + + String + + + + + End + + Return alerts that were created on the specified date. Hour, Min and Seconds will not be used, only Month, Day and Year of the DateTime value. + + DateTime + + DateTime + + + + + HealthCategory + + Alerts with given health category will be returned. Allowed health category values are: + + * Appliance + * DeviceBay + * Enclosure + * Fan + * Firmware + * Host + * Instance + * InterconnectBay + * LogicalSwitch + * Logs + * ManagementProcessor + * Memory + * Network + * Operational + * Power + * Processor + * RemoteSupport + * Storage + * Thermal + * Unknown + + String + + String + + + + + InputObject + + Alerts for the specified resource will be returned. + + Object + + Object + + + + + Severity + + Alerts with given severity will be returned. Allowed severity values are: + + * Unknown + * Ok + * Disabled + * Warning + * Critical + + String + + String + + + + + Start + + Return alerts that were created starting from the specified date. Hour, Min and Seconds will not be used, only Month, Day and Year of the DateTime value. + + DateTime + + DateTime + + + + + TimeSpan + + Return the number of alerts created from today to the defined number of days. + + Timespan + + Timespan + + + + + + + + + System.Management.Automation.PSCustomObject + + + Resource object (i.e. Get-OVServer). + + + + + + + + HPEOneView.Alert [System.Management.Automation.PSCustomObject] + + + + HPE OneView alert. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + $alerts = Get-OVAlert -severity CRITICAL + + Return all the critical alerts. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Get-OVServer -Name "Encl1, Bay 2" | Get-OVAlert -severity CRITICAL + + Return all the critical alerts for server "Encl1, Bay 2". + + + + + + + + + + -------------------------- EXAMPLE 3 -------------------------- + + + + Get-OVServerProfile -Name "Profile 1" | Get-OVAlert + + Return all the alerts for server profile "Profile 1". + + + + + + + + + + -------------------------- EXAMPLE 4 -------------------------- + + + + Get-OVInterconnect -Name "Encl1, interconnect 2" | Get-OVAlert + + Get all alerts for "Encl1, interconnect 2" interconnect module. + + + + + + + + + + -------------------------- EXAMPLE 5 -------------------------- + + + + Get-OVInterconnect -Name "Encl1, interconnect 2" | Get-OVAlert -severity Critical + + Get "critical" severity alerts for "Encl1, interconnect 2" interconnect module. + + + + + + + + + + -------------------------- EXAMPLE 6 -------------------------- + + + + Get-OVAlert -severity Critical -Count 5 + + Return the first 5 "critical" severity alerts. + + + + + + + + + + -------------------------- EXAMPLE 7 -------------------------- + + + + Get-OVAlert -severity Critical -Timespan (New-TimeSpan -Days 8) + + Return "critical" severity alerts for the past 8 days. + + + + + + + + + + -------------------------- EXAMPLE 8 -------------------------- + + + + Get-OVAlert -severity Critical -Start "2016-12-01" + + Return "critical" severity alerts Starting at 2016-12-01 to now. + + + + + + + + + + -------------------------- EXAMPLE 9 -------------------------- + + + + Get-OVAlert -Start "2016-12-01" -End "2016-12-09 + + Return all alerts Starting at 2016-12-01 to 2016-12-09. + + + + + + + + + + + + + Clear-OVAlert + + + + Remove-OVAlert + + + + Set-OVAlert + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/get-ovalert + + + + + + + + Get-OVApplianceAuditLogForwarding + + Get the appliance remote Syslog audit log forwarding configuration. + + Get + OVApplianceAuditLogForwarding + + + Audit log forwarding enables the Infrastructure administrator to forward audit logs to remote Security Information and Event Management (SIEM) systems. Such systems enable centralized audit compliance, monitoring, log analysis, and controlled retention policies. + +The forwarding protocol used is the standard UDP-based syslog protocol described in RFC5424 and RFC5426. The syslog protocol is supported by all common syslog servers such as rsyslog, syslog-ng and SIEM products. + +NOTE: Ensure that any firewalls between HPE OneView and the remote syslog server allow UDP traffic. The default UDP port used is 514. + +As audit log entries are forwarded over UDP, the entries are not encrypted and delivery is not guaranteed. Even when you have HPE OneView and all managed devices on a dedicated, isolated management LAN, forwarding audit log entries to external systems can pose a security risk. In an environment where encryption is required, use the REST API /rest/audit-logs to schedule a job to download the appliance audit logs. + +This Cmdlet will return the current status, remote Syslog destination and port currently configured on the appliance. + +Minimum required privileges: Infrastructure administrator. + + + + + Get-OVApplianceAuditLogForwarding + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + HPEOneView.Appliance.AuditLogForwardingConfig + + + + The appliance audit log forwarding configuration. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVApplianceAuditLogForwarding + + Get the appliance audit log configuration. + + + + + + + + + + + + + Set-OVApplianceAuditLogForwarding + + + + Test-OVApplianceAuditLogForwarding + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/get-ovapplianceauditlogforwarding + + + + + + + + Get-OVApplianceAvailableSecurityMode + + Get appliance available security cryptography modes. + + Get + OVApplianceAvailableSecurityMode + + + HPE OneView allows you to change the Cryptography Settings of a specific appliance. These setting modes change the available cryptography algorithms, allowed ciphers and disabling unsecure protocols. Available cryptography modes include: + + * Legacy - This is the default cryptography mode. In the legacy mode all TLS protocol versions (1.0, 1.1, and 1.2) and associated cipher suites for those versions are supported. TLS certificates are not required to have FIPS or CNSA minimum key lengths nor strong digital signatures. + * FIPS - Federal Information Processing Standard (FIPS) Publication 140-2 is a U.S. government computer security standard for products performing cryptography. The FIPS 140-2 Cryptographic Module Validation Program has validated the cryptography libraries of HPE OneView. When in the FIPS mode: + * The cryptographic modules of the appliance are configured to operate in accordance with the FIPS 140-2 level 1 specification. This setting ensures that the required FIPS self-tests are run while loading these cryptographic modules. + * The ciphers and algorithms used for cryptographic operations by the appliance are restricted to only those approved by FIPS. + * The appliance allows only TLS1.1 and TLS 1.2 protocols for all TLS communications + * All SSH and SNMPv3 communication use only cipher suites and algorithms approved by FIPS. + * For additional information, see the FIPS-140 site. + * CNSA - The Commercial National Security Algorithm (CNSA) cryptography mode restricts HPE OneView to use only those algorithms included in the CNSA suite. The CNSA suite is a subset of the general FIPS support and includes a set of algorithms used to protect national security systems, including information classified as 'top secret.' In the CNSA mode, the appliance uses only TLS 1.2 protocol and a CNSA-strength subset of the TLS 1.2 ciphers. Similarly, SSH and SNMP communication uses CNSA-compliant ciphers and algorithms. + +For additional information, see the CNSA standards site (https://www.iad.gov/iad/programs/iad-initiatives/cnsa-suite.cfm). This website uses a US Government Certificate Authority-signed certificate which is not present, by default, in most browser trust stores. See Establishing Site Trust (https://www.iad.gov/NSCAP/warnings.cfm) for more information on establishing trust with this website. + +NOTE: In HPE OneView releases prior to version 4.0, local user passwords are hashed using SHA256. Starting with release version 4.0, the first time the user logs in, irrespective of the appliance cryptography mode, the password gets rehashed and stored as SHA384. + +When the iLO of a managed server is in the CNSA mode, the iLO user interface or console is not accessible from HPE OneView console user interface. + +For a complete list of ciphers and algorithms supported in the legacy, FIPS and CNSA modes, see Algorithm and ciphers for securing the appliance in the HPE OneView User Guide available on the Hewlett Packard Enterprise Information Library. + +The installation scenarios and the default behavior during a mode switch are: + + * Fresh installation - The appliance defaults to the legacy mode. + * Upgrade - Cryptography mode of the appliance prior to upgrade is retained after the upgrade. For an appliance upgraded from a release that did not support cryptography modes, the appliance is configured to be in legacy mode after the upgrade. + * Factory reset - A factory reset or the Preserve network settings option does not change the cryptography mode. The cryptography mode of the appliance prior to the reset is retained. Verify that the Cryptography setting is set to required mode in the Security settings panel. + * Backup and restore - A restore operation restores the appliance to the same cryptography mode as the backed up appliance. + +For HPE OneView to operate in FIPS or CNSA mode, it is not required that all systems or devices that are managed or monitored by HPE OneView (for example, blade ILO) or the external servers that communicate with HPE OneView (for example, MicroSoft Active Directory Server) also operate in FIPS or CNSA-approved mode only. However, HPE OneView must be abl +e to communicate with these managed or monitored devices and external servers with the protocols and cipher suites supported by the chosen mode. For example, as long as a device supports FIPS-compliant TLS protocols, ciphers and certificates, HPE OneView in FIPS or CNSA modes can manage that device. + +For information on the support for various devices and supported cryptography modes, see the HPE OneView Support Matrix on the Hewlett Packard Enterprise Information Library. +Additionally, using a higher mode of cryptography requires that you use stronger certificates for all TLS communications. For example, in the CNSA mode, managed devices using RSA certificates need a minimum key length of 3072 bits and a digital signature using SHA-384 or greater. + +Not all devices that HPE OneView manages or monitors support these stronger cryptography modes. Some examples are: + + * ProLiant Gen 6 systems have iLO versions that only support TLS 1.0. These servers are not supported when the appliance is in the FIPS or CNSA modes. + * Gen7 systems have iLO versions that only support TLS 1.0 and 1.1. These servers are not supported when the appliance is in the CNSA mode. + * ProLiant Gen8 systems have iLO versions that support TLS 1.1 and 1.2, and are compatible with both FIPS and CNSAmodes. + +When opting for a higher security mode, use the Show-OVApplianceSecurityModeCompatibilityReport Cmdlet to generate a Compatibility report to get a complete report of any currently managed or monitored devices that are not compatible with the target mode. + +NOTE: Changing the cryptography mode might regenerate the web server or RabbitMQ certificates. The newly generated RabbitMQ client certificate, along with the CA and key pair, must be applied to the RabbitMQ client. When using CA-signed certificates you might need to issue a new certificate signing request (CSR), obtain a stronger certificate and re-import the certificate into your appliance. Check the compatibility report for details. The appliance automatically reboots as part of configuring the appliance in a different cryptographic mode. + +Minimum required privileges: Infrastructure administrator + + + + + Get-OVApplianceAvailableSecurityMode + + ModeName + + The name of the mode to return. Allowed values: + + * Legacy + * FIPS + * CNSA + +Default: Return all available security modes. + + String[] + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + Array + + (${Global:ConnectedSessions} | ? Default) + + + ModeName + + The name of the mode to return. Allowed values: + + * Legacy + * FIPS + * CNSA + +Default: Return all available security modes. + + String[] + + String[] + + + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + HPEOneView.Appliance.SecurityMode + + + + The available appliance security mode, including which mode is set as the current value. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVApplianceAvailableSecurityMode + + Return all available security modes on the appliance. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Get-OVApplianceAvailableSecurityMode -ModeName CNSA + + Return the CNSA available security mode on the appliance. + + + + + + + + + + + + + Get-OVApplianceCurrentSecurityMode + + + + Set-OVApplianceCurrentSecurityMode + + + + Show-OVApplianceSecurityModeCompatibilityReport + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/get-ovapplianceavailablesecuritymode + + + + + + + + Get-OVApplianceCertificateStatus + + Get the appliance SSL certificate status. + + Get + OVApplianceCertificateStatus + + + HPE OneView uses HTTPS to communicate with managed devices and remote servers. HTTPS is based on Transport Layer Security (TLS). HTTPS and TLS offer the following benefits: + + * Confidentiality: Data is encrypted on the wire using symmetric key cryptography. + * Message integrity: Secure hash functions guarantee integrity. + * Authentication: HPE OneView authenticates the remote end point of the HTTPS connection. Public key cryptography is used to authenticate HTTPS and TLS. + +The certificate that gets generated by default on a newly installed appliance is an RSA certificate. Currently, only RSA certificates are supported for the appliance certificate. + +Public key cryptography uses public and private key pairs to encrypt and decrypt data. In a public key system, digital certificates certify the ownership of the public key. Digital certificates also certify the allowed usage of that key (for example, digital signatures, certificate signing, encryption). + +HPE OneView supports the use of both self signed certificates and certificate authority issued (CA) certificates in a formal public key infrastructure (PKI). + +This Cmdlet will return the appliance HTTPS certificate. The certificate can then be examined for validity, or to import the public certificate into a certificate trust store. + +Minimum required privileges: No minimum required + + + + + Get-OVApplianceCertificateStatus + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + HPEOneView.Appliance.ApplianceSslCertificateStatus [System.Management.Automation.PSCustomObject] + + + + Formatted table display of the SSL Certificate object. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVApplianceCertificateStatus + + + + + + + + + + + + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/get-ovappliancecertificatestatus + + + + + + + + Get-OVApplianceCurrentSecurityMode + + Get the appliance current security mode. + + Get + OVApplianceCurrentSecurityMode + + + HPE OneView allows you to change the Cryptography Settings of a specific appliance. These setting modes change the available cryptography algorithms, allowed ciphers and disabling unsecure protocols. Available cryptography modes include: + + * Legacy - This is the default cryptography mode. In the legacy mode all TLS protocol versions (1.0, 1.1, and 1.2) and associated cipher suites for those versions are supported. TLS certificates are not required to have FIPS or CNSA minimum key lengths nor strong digital signatures. + * FIPS - Federal Information Processing Standard (FIPS) Publication 140-2 is a U.S. government computer security standard for products performing cryptography. The FIPS 140-2 Cryptographic Module Validation Program has validated the cryptography libraries of HPE OneView. When in the FIPS mode: + * The cryptographic modules of the appliance are configured to operate in accordance with the FIPS 140-2 level 1 specification. This setting ensures that the required FIPS self-tests are run while loading these cryptographic modules. + * The ciphers and algorithms used for cryptographic operations by the appliance are restricted to only those approved by FIPS. + * The appliance allows only TLS1.1 and TLS 1.2 protocols for all TLS communications + * All SSH and SNMPv3 communication use only cipher suites and algorithms approved by FIPS. + * For additional information, see the FIPS-140 site. + * CNSA - The Commercial National Security Algorithm (CNSA) cryptography mode restricts HPE OneView to use only those algorithms included in the CNSA suite. The CNSA suite is a subset of the general FIPS support and includes a set of algorithms used to protect national security systems, including information classified as 'top secret.' In the CNSA mode, the appliance uses only TLS 1.2 protocol and a CNSA-strength subset of the TLS 1.2 ciphers. Similarly, SSH and SNMP communication uses CNSA-compliant ciphers and algorithms. + +For additional information, see the CNSA standards site (https://www.iad.gov/iad/programs/iad-initiatives/cnsa-suite.cfm). This website uses a US Government Certificate Authority-signed certificate which is not present, by default, in most browser trust stores. See Establishing Site Trust (https://www.iad.gov/NSCAP/warnings.cfm) for more information on establishing trust with this website. + +NOTE: In HPE OneView releases prior to version 4.0, local user passwords are hashed using SHA256. Starting with release version 4.0, the first time the user logs in, irrespective of the appliance cryptography mode, the password gets rehashed and stored as SHA384. + +When the iLO of a managed server is in the CNSA mode, the iLO user interface or console is not accessible from HPE OneView console user interface. + +For a complete list of ciphers and algorithms supported in the legacy, FIPS and CNSA modes, see Algorithm and ciphers for securing the appliance in the HPE OneView User Guide available on the Hewlett Packard Enterprise Information Library. + +The installation scenarios and the default behavior during a mode switch are: + + * Fresh installation - The appliance defaults to the legacy mode. + * Upgrade - Cryptography mode of the appliance prior to upgrade is retained after the upgrade. For an appliance upgraded from a release that did not support cryptography modes, the appliance is configured to be in legacy mode after the upgrade. + * Factory reset - A factory reset or the Preserve network settings option does not change the cryptography mode. The cryptography mode of the appliance prior to the reset is retained. Verify that the Cryptography setting is set to required mode in the Security settings panel. + * Backup and restore - A restore operation restores the appliance to the same cryptography mode as the backed up appliance. + +For HPE OneView to operate in FIPS or CNSA mode, it is not required that all systems or devices that are managed or monitored by HPE OneView (for example, blade ILO) or the external servers that communicate with HPE OneView (for example, MicroSoft Active Directory Server) also operate in FIPS or CNSA-approved mode only. However, HPE OneView must be abl +e to communicate with these managed or monitored devices and external servers with the protocols and cipher suites supported by the chosen mode. For example, as long as a device supports FIPS-compliant TLS protocols, ciphers and certificates, HPE OneView in FIPS or CNSA modes can manage that device. + +For information on the support for various devices and supported cryptography modes, see the HPE OneView Support Matrix on the Hewlett Packard Enterprise Information Library. +Additionally, using a higher mode of cryptography requires that you use stronger certificates for all TLS communications. For example, in the CNSA mode, managed devices using RSA certificates need a minimum key length of 3072 bits and a digital signature using SHA-384 or greater. + +Not all devices that HPE OneView manages or monitors support these stronger cryptography modes. Some examples are: + + * ProLiant Gen 6 systems have iLO versions that only support TLS 1.0. These servers are not supported when the appliance is in the FIPS or CNSA modes. + * Gen7 systems have iLO versions that only support TLS 1.0 and 1.1. These servers are not supported when the appliance is in the CNSA mode. + * ProLiant Gen8 systems have iLO versions that support TLS 1.1 and 1.2, and are compatible with both FIPS and CNSAmodes. + +When opting for a higher security mode, use the Show-OVApplianceSecurityModeCompatibilityReport Cmdlet to generate a Compatibility report to get a complete report of any currently managed or monitored devices that are not compatible with the target mode. + +NOTE: Changing the cryptography mode might regenerate the web server or RabbitMQ certificates. The newly generated RabbitMQ client certificate, along with the CA and key pair, must be applied to the RabbitMQ client. When using CA-signed certificates you might need to issue a new certificate signing request (CSR), obtain a stronger certificate and re-import the certificate into your appliance. Check the compatibility report for details. The appliance automatically reboots as part of configuring the appliance in a different cryptographic mode. + +Minimum required privileges: Infrastructure administrator + + + + + Get-OVApplianceCurrentSecurityMode + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + Array + + (${Global:ConnectedSessions} | ? Default) + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + HPEOneView.Appliance.SecurityMode + + + + The current appliance security mode. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVApplianceCurrentSecurityMode + + Get the appliances current security mode. + + + + + + + + + + + + + Get-OVApplianceAvailableSecurityMode + + + + Set-OVApplianceCurrentSecurityMode + + + + Show-OVApplianceSecurityModeCompatibilityReport + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/get-ovappliancecurrentsecuritymode + + + + + + + + Get-OVApplianceDataAtRestEncryption + + Get the appliance configured data at rest encryption state. + + Get + OVApplianceDataAtRestEncryption + + + HPE OneView encrypts sensitive data, such as managed device credentials, when it is stored on-disk in the appliance. The HPE OneView appliance encryption key (AEK) is used internally to encrypt the credentials for managed devices (such as, iLO, onboard administrator, frame link module). By default, the AEK is stored on the HPE Synergy Composer disk and also included in the appliance backup. This could pose a security risk in case the disk is stolen. + +The secure data-at-rest option, when enabled, stores the AEK off-disk in Composer NVRAM, and does not include the keyin the appliance backup. Enabling this option requires the administrator to save a copy of the AEK (recovery AEK) for use in the following circumstances: + + * When restoring a backup taken when a different AEK was in effect. + * To successfully boot the system in the unlikely event that the system copy of the key is corrupted. + * A backup is being restored to a different new Composer or to the same Composer that has been factory reset. + +The administrator must store the recovery AEK in a secure location, where it can be only accessed by authorized personnel. In the rare circumstance where the key cannot be read from the Composer NVRAM or the key gets corrupted, the administrator must use the appliance maintenance console to upload the AEK recovery copy, based on the error resolution message displayed. In the rare circumstance where the Composer NVRAM itself becomes inaccessible, users can choose to disable secure-data-at-rest option until the hardware issue itself is resolved. + +If the downloaded recovery key and the AEK stored in the Composer NVRAM are both lost, the appliance data cannot be recovered. + +Using this Cmdlet will get the data at rest encryption current configuration from supported HPE Synergy Composer appliances. + +Minimum required privileges: Infrastructure administrator. + + + + + Get-OVApplianceDataAtRestEncryption + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + System.Management.Automation.PSCustomObject + + + + THe data at rest encryption configuration state of the appliance. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVApplianceDataAtRestEncryption + + Get the appliance data at rest encryption state. + + + + + + + + + + + + + Disable-OVApplianceDataAtRestEncryption + + + + Enable-OVApplianceDataAtRestEncryption + + + + New-OVApplianceDataAtRestEncryptionKey + + + + Save-OVApplianceDataAtRestEncryptionKey + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/security/get-ovappliancedataatrestencryption + + + + + + + + Get-OVApplianceDateTime + + Get Appliance Date/Time Configuration. + + Get + OVApplianceDateTime + + + This Cmdlet displays the appliance or connected appliances Date and Time configuration. Part of this is the actual Date and Time of the appliance, Time Zone, NTP Servers, NTP polling, and Locale. + +When querying a Virtual Machine Appliance and the NTPServersproperty or field is Null, the appliance will retrieve its Date and Time from the Hypervisor Host. + +When querying a Synergy Composer appliance and the NTPServersproperty or field is Null, the appliance will retrieve its Date and Time from the System ROM. + +Minimum required privileges: Read-only + + + + + Get-OVApplianceDateTime + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + +Default Value: ${Global:ConnectSessions} | ? Default + + Object + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + +Default Value: ${Global:ConnectSessions} | ? Default + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + HPEOneView.Appliance.ApplianceServerDateTime [System.Management.Automation.PSCustomObject] + + + + Date/Time object. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVApplianceDateTime +Appliance Time Time Zone NTP Servers NTP Polling +--------- ---- --------- ----------- ----------- +hpov1.domain.com 2/11/2016 2:12:46 PM UTC {10.55.1.1,10.54.1.1} +hpov2.domain.com 2/11/2016 2:12:45 PM UTC {} + + This example passes in updated values to set for the appliance networking configuration. + + + + + + + + + + + + + Set-OVApplianceDateTime + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/get-ovappliancedatetime + + + + + + + + Get-OVApplianceGlobalSetting + + (Reserved for future use) Retrieve appliance global settings. + + Get + OVApplianceGlobalSetting + + + (Reserved for future use) + +Retrieves the list of global settings or a specific global setting by name. + + + + + Get-OVApplianceGlobalSetting + + name + + Name of the global setting to be retrieved. + + String + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + +Default Value: ${Global:ConnectSessions} + + Object + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + +Default Value: ${Global:ConnectSessions} + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + name + + Name of the global setting to be retrieved. + + String + + String + + + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + System.Collections.ArrayList + + + + Name, value, description, and uri for the global setting(s) + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVApplianceGlobalSetting + + Return appliance Global Settings and their values. + + + + + + + + + + + + + Set-OVApplianceGlobalSetting + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/get-ovapplianceglobalsetting + + + + + + + + Get-OVApplianceIPAddress + + Display the configured NICs of an appliance, or Synergy Composer cluster. + + Get + OVApplianceIPAddress + + + The HPE OneView appliance can be configured with static IPv4 and/or IPv6 addresses. This address is used for all IP communication between monitored/managed resources, external services (i.e. authentication directory, HPE web services like OneView Remote Support) and for administrator client management operations from the web UI and/or REST API. This Cmdlet will return the configured IP address(es). + + + + + Get-OVApplianceIPAddress + + ApplianceConnection + + Specify one or more HPEOneView.Appliance.Connection object(s) or Name property value(s). + +Default Value: ${Global:ConnectedSessions} | ? Default + + Object + + + + + + + ApplianceConnection + + Specify one or more HPEOneView.Appliance.Connection object(s) or Name property value(s). + +Default Value: ${Global:ConnectedSessions} | ? Default + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + + + + + None. You cannot pipe objects to this cmdlet. + + + + + + + + + + + HPEOneView.Appliance.NetworkInterface + + + + Network interface configured for virtual machine appliance. + + + + + + HPEOneView.Appliance.ComposerNetworkInterface + + + + Network interface(s) configured for HPE Synergy Composer appliance(s). + + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVApplianceIPAddress + + + Display configured appliance NICs. + + + + + + + + + + + + + New-OVApplianceStaticRoute + + + + Get-OVApplianceStaticRoute + + + + Set-OVApplianceStaticRoute + + + + Remove-OVApplianceStaticRoute + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/get-ovapplianceipaddress + + + + + + + + Get-OVApplianceNetworkConfig + + Retrieves the configuration of the primary NIC of the appliance + + Get + OVApplianceNetworkConfig + + + This Cmdlet will return the appliance network settings configuration parameters of the primary network interface on the appliance, which can be captured into a customer object for further operation, or captured to a text file in JSON format. + +NOTE: Any time the IP address or hostname of the appliance changes, any CA-signed appliance certificate associated with the appliance is erased, and a new self signed appliance certificate is generated. In this case, you must generate a new Certificate Signing Request (CSR), have it signed by a CA, and import it into the appliance. + +Minimum required privileges: Read-only + + + + + Get-OVApplianceNetworkConfig + + Location + + Directory to where the appliance network configuration will be exported to. +Exported file name will be "{$ApplianceConnection.Name}_ApplianceNetConf.json". + + String + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Location + + Directory to where the appliance network configuration will be exported to. +Exported file name will be "{$ApplianceConnection.Name}_ApplianceNetConf.json". + + String + + String + + + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + HPEOneView.Appliance.ApplianceServerConfiguration [System.Management.Automation.PSCustomObject] + + + + A collection object containing the properties and values of the primary network interface of the appliance. + + + + + HPEOneView.Appliance.ApplianceServerConfiguration.ApplianceNetworks [System.Management.Automation.PSCustomObject] + + + + The applianceNetworks property will display the appliance Networking in either a Format-Table (default) or Format-List view. + + + + + System.IO.FileSystemInfo + + + + If exporting the appliance network configuration, the file object created will be returned. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVApplianceNetworkConfig +Hostname IPv4Type IPv4Address IPv4DNS IPv6Type IPv6Address IPv6DNS +-------- -------- ----------- ------- -------- ----------- ------- +hpov1.domain.com STATIC 172.20.51.4\24 {172.20.10.41, 172.20.10.42} UNCONFIGURE {} +hpov2.domain.com STATIC 172.20.52.4\24 {172.20.10.41, 172.20.10.42} UNCONFIGURE {} + + Outputs the configuration of the primary network interface to standard output. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Get-OVApplianceNetworkConfig -Appliance hpov1.domain.com | fl +Hostname : hpov1.domain.com +IPv4Type : STATIC +IPv4Address : 172.20.51.4 +IPv4Mask : 255.255.255.0 +IPv4Gateway : 172.20.51.1 +IPv4DNS : {172.20.10.41, 172.20.10.42} +IPv6Type : UNCONFIGURE +IPv6Address : +IPv6Mask : +IPv6Gateway : +IPv6DNS : {} + + Outputs the configuration of the primary network interface and pipe to Format-List for more information about the network configuration. + + + + + + + + + + -------------------------- EXAMPLE 3 -------------------------- + + + + $myAppNetConfig = Get-OVApplianceNetworkConfig -Appliance hpov1.domain.com + + Outputs the configuration of the primary network interface of the appliance to the object variable $myAppNetConfig + + + + + + + + + + -------------------------- EXAMPLE 4 -------------------------- + + + + Get-OVApplianceNetworkConfig -Location . + + Outputs the configuration of the primary network interface of the appliance to the current directory. + + + + + + + + + + + + + Set-OVApplianceNetworkConfig + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/get-ovappliancenetworkconfig + + + + + + + + Get-OVApplianceProxy + + Get appliance configured HTTP proxy. + + Get + OVApplianceProxy + + + The setting an appliance proxy allows you to set the HTTP/HTTPS proxy, port number for client connections, and whether authentication requires a username and a password. The appliance HTTP or HTTPS proxy configuration is used for HPE OneView Remote Support, and HPE OneView Remote Technician. + +This Cmdlet will return the configured appliance HTTP/HTTPS proxy configuration. + +Minimum required privileges: Read only + + + + + Get-OVApplianceProxy + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + Array + + (${Global:ConnectedSessions} | ? Default) + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + HPEOneView.Appliance.ProxyServer + + + + Appliance proxy server settings. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVApplianceProxy + + Get the appliance configured HTTP/HTTPS proxy configuration. + + + + + + + + + + + + + Remove-OVApplianceProxy + + + + Set-OVApplianceProxy + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/get-ovapplianceproxy + + + + + + + + Get-OVApplianceSecurityProtocol + + Get appliance supported security protocols and ciphers. + + Get + OVApplianceSecurityProtocol + + + Get the appliance available security protocols, and their active state. By default the appliance current security mode will return the available security protocols and their configuration state. Use the -SecurityMode parameter to specify one or more modes. Use the -TlsVersion to specify one or more security protocols to return. + +Minimum required privileges: Read only + + + + + Get-OVApplianceSecurityProtocol + + TlsVersion + + Filter for specific TLS version(s). By default, will return all TLS Versions. Allowed values: + + * TLSv1 + TLSv1.1 + TLSv1.2 + + String[] + + + SecurityMode + + Specify the Security Mode to return supported security protocols and encryption ciphers. By default, will return the current appliance security mode. Allowed values: + + * Legacy + * FIPS + *CNSA + + String[] + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + Array + + (${Global:ConnectedSessions} | ? Default) + + + SecurityMode + + Specify the Security Mode to return supported security protocols and encryption ciphers. By default, will return the current appliance security mode. Allowed values: + + * Legacy + * FIPS + *CNSA + + String[] + + String[] + + + + + TlsVersion + + Filter for specific TLS version(s). By default, will return all TLS Versions. Allowed values: + + * TLSv1 + TLSv1.1 + TLSv1.2 + + String[] + + String[] + + + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + HPEOneView.Appliance.SecurityProtocol + + + + Available appliance security protocol, mode enabled and associated encryption ciphers.n + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVApplianceSecurityProtocol + + Get the appliance FIPS security mode and associated security protocols. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Get-OVApplianceSecurityProtocol -SecurityMode FIPS, CNSA -TlsVersion TLSv1.1, TLSv1.2 + + Get the appliance FIPS security mode and TLSv1.1 and TLSv1.2 security protocols. + + + + + + + + + + + + + Set-OVApplianceSecurityProtocol + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/get-ovappliancesecurityprotocol + + + + + + + + Get-OVApplianceServiceConsoleAccess + + Get the appliance service console access configuration. + + Get + OVApplianceServiceConsoleAccess + + + HPE OneView contains a technical feature that you can use to allow an authorized technical support to access your system, through the system console, to assess and troubleshoot problems that you have reported. This access is controlled by a password generated and provided by you to the authorized technical support. You can disable the access at any time while the system is running. Hewlett Packard Enterprise recommends that you enable service console access so that an authorized technical support can diagnose your system in the event of a system failure. + +This Cmdlet will return the existing configuration state of the appliance service console. + +Minimum required privileges: Read only + + + + + Get-OVApplianceServiceConsoleAccess + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + HPEOneView.Appliance.ServiceConsoleAccess + + + + The current service console configuration status. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVApplianceServiceConsoleAccess + + Get the service console access status. + + + + + + + + + + + + + Disable-OVApplianceServiceConsoleAccess + + + + Enable-OVApplianceServiceConsoleAccess + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/get-ovapplianceserviceconsoleaccess + + + + + + + + Get-OVApplianceSnmpV3EngineId + + Get appliance SNMPv3 Engine ID. + + Get + OVApplianceSnmpV3EngineId + + + HPE OneView can be used as a proxy to forward device traps from servers, enclosures, and Synergy compute modules to other SNMP-enabled applications on the network. HPE OneView can forward traps, as SNMPv3 or SNMPv1 traps, to configured destinations. Additionally, HPE OneView will also send alerts received from a Synergy Frame Link Module (FLM) as SNMPv1 or SNMPv3 traps to the configured destinations. + +Use this Cmdlet to get the appliance SNMPv3 Engine ID that is automatically generated upon first time boot of the appliance, or configured by an Infrastructure Administrator. + +Minimum required privileges: Read only + + + + + Get-OVApplianceSnmpV3EngineId + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + Array + + (${Global:ConnectedSessions} | ? Default) + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + HPEOneView.Appliance.SnmpV3EngineId + + + + Appliance SNMPv3 Engine ID. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVApplianceSnmpV3EngineId + + Get the SNMPv3 Engine ID of the connected appliance. + + + + + + + + + + + + + Set-OVApplianceSnmpV3EngineId + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/get-ovappliancesnmpv3engineid + + + + + + + + Get-OVApplianceSshAccess + + Get the current SSH console access state. + + Get + OVApplianceSshAccess + + + HPE OneView supports Secure Shell (SSH) to remotely access the appliance to perform maintenance and recovery operations. Without SSH access, you must access the virtual machine system console. To avoid requiring a console access, SSH access is enabled by default. However, remote access to maintenance and recovery operations is considered a security risk by some users. Therefore, HPE OneView provides the option to disable remote access to the appliance via SSH. + +Use this Cmdlet to enable appliance SSH access. + +Minimum required privileges: Read only + + + + + Get-OVApplianceSshAccess + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + HPEOneView.Appliance.SshAccess + + + + The configured state of the appliance SSH console. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVApplianceSshAccess + + Get the current state of the appliance SSH console. + + + + + + + + + + + + + Disable-OVApplianceSshAccess + + + + Enable-OVApplianceSshAccess + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/get-ovappliancesshaccess + + + + + + + + Get-OVApplianceStaticRoute + + Display configured static routes on the appliance. + + Get + OVApplianceStaticRoute + + + When configuring a second NIC on a virtual machine appliance, static routes can be configured as only a single appliance NIC can be configured with a default gateway. Both IPv4 and IPv6 static routes are supported. Use Get-OVApplianceIPAddress to display the configured NIC interfaces, and supply the interface name with the -Interface parameter. + +Minimum required privileges: Infrastructure administrator + + + + + Get-OVApplianceStaticRoute + + Destination + + The static route defined on the appliance. IP address format should be {destination_subnet}/{subnetmask_short_bit}. + +Example: 10.55.74.0/24 + + String + + + Interface + + Interface name to filter. Use Get-OVApplianceIPAddress to display the configured NIC interfaces. + + String + + + ApplianceConnection + + Specify one or more HPEOneView.Appliance.Connection object(s) or Name property value(s). + +Default Value: ${Global:ConnectedSessions} | ? Default + + Object + + + + + + + ApplianceConnection + + Specify one or more HPEOneView.Appliance.Connection object(s) or Name property value(s). + +Default Value: ${Global:ConnectedSessions} | ? Default + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Destination + + The static route defined on the appliance. IP address format should be {destination_subnet}/{subnetmask_short_bit}. + +Example: 10.55.74.0/24 + + String + + String + + + + + Interface + + Interface name to filter. Use Get-OVApplianceIPAddress to display the configured NIC interfaces. + + String + + String + + + + + + + + + None. You cannot pipe objects to this cmdlet. + + + + + + + + + + + HPEOneView.Appliance.StaticRoute + + + + IP static route object. + + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVApplianceStaticRoute + + + Get all configured static routes. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Get-OVApplianceStaticRoute -Interface Appliance + + + Get all configured static routes for the default "Appliance" NIC. + + + + + + + + + + + + + New-OVApplianceStaticRoute + + + + Set-OVApplianceStaticRoute + + + + Remove-OVApplianceStaticRoute + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/get-ovappliancestaticroute + + + + + + + + Get-OVApplianceStatus + + Get the appliance status. + + Get + OVApplianceStatus + + + This Cmdlet returns appliance resource status information. Specifically: + + * Installed memory. + * CPU frequency + * NIC link speed + * Appliance uptime + * Appliance last startup date + * Error status messages for these resources. + +If the appliance is part of an HPE Synergy Composer cluster pair, the the standby appliance uptime and startup date are added as additional note properties to the returned object. By default, only the active appliance values are returned. + + + + + Get-OVApplianceStatus + + ApplianceConnection + + Specify one or more HPEOneView.Appliance.Connection object(s) or Name property value(s). + +Default Value: ${Global:ConnectedSessions} | ? Default + + Object + + + + + + + ApplianceConnection + + Specify one or more HPEOneView.Appliance.Connection object(s) or Name property value(s). + +Default Value: ${Global:ConnectedSessions} | ? Default + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + + + + + None. You cannot pipe objects to this cmdlet. + + + + + + + + + + + HPEOneView.Appliance.ApplianceStatus + + + + Appliance status object, contining appliance memory, CPU, network link details, including any resource error status messages. + + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVApplianceStatus + + + Default example + + + + + + + + + + + + + Online: + https://hpe-docs.gitbook.io/posh-hpeoneview/cmdlets/v9.00/appliance/get-ovappliancestatus + + + + + + + + Get-OVApplianceTrapDestination + + Get configured appliance SNMP trap destinations. + + Get + OVApplianceTrapDestination + + + HPE OneView can be used as a proxy to forward device traps from servers, enclosures, and Synergy compute modules to other SNMP-enabled applications on the network. HPE OneView can forward traps, as SNMPv3 or SNMPv1 traps, to configured destinations. Additionally, HPE OneView will also send alerts received from a Synergy Frame Link Module (FLM) as SNMPv1 or SNMPv3 traps to the configured destinations. + +Use this Cmdlet to retrieve configured SNMPv1 and/or SNMPv3 appliance trap destinations, configured by an Infrastructure Administrator. + +Minimum required privileges: Read only + + + + + Get-OVApplianceTrapDestination + + Destination + + Filter trap destinations by the destination value. Supports wildcard. + + String + + + Type + + Filter based on SNMP version. Supported values: + + * SNMPv1 + *SNMPv3 + + String[] + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + Array + + (${Global:ConnectedSessions} | ? Default) + + + Destination + + Filter trap destinations by the destination value. Supports wildcard. + + String + + String + + + + + Type + + Filter based on SNMP version. Supported values: + + * SNMPv1 + *SNMPv3 + + String[] + + String[] + + + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + HPEOneView.Appliance.SnmpV1TrapDestination + + + + Appliance SNMPv1 trap destination, including trap community and target. + + + + + HPEOneView.Appliance.SnmpV3TrapDestination + + + + Appliance SNMPv3 trap destination, including type, SNMPv3 user and target. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVApplianceTrapDestination + + Get trap destinations from the appliance. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Get-OVApplianceTrapDestination -Destination 172.17.8.8 + + Get the specific appliance trap destination. + + + + + + + + + + + + + New-OVApplianceTrapDestination + + + + Remove-OVApplianceTrapDestination + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/get-ovappliancetrapdestination + + + + + + + + Get-OVApplianceTrustedCertificate + + Get X.509 SSL certificates from the appliace trusted store. + + Get + OVApplianceTrustedCertificate + + + HPE OneView uses HTTPS to communicate with managed devices and remote servers. HTTPS is based on Transport Layer Security (TLS). HTTPS and TLS offer the following benefits: + + * Confidentiality: Data is encrypted on the wire using symmetric key cryptography. + * Message integrity: Secure hash functions guarantee integrity. + * Authentication: HPE OneView authenticates the remote end point of the HTTPS connection. Public key cryptography is used to authenticate HTTPS and TLS. + +The certificate that gets generated by default on a newly installed appliance is an RSA certificate. Currently, only RSA certificates are supported for the appliance certificate. + +Public key cryptography uses public and private key pairs to encrypt and decrypt data. In a public key system, digital certificates certify the ownership of the public key. Digital certificates also certify the allowed usage of that key (for example, digital signatures, certificate signing, encryption). + +HPE OneView supports the use of both self signed certificates and certificate authority issued (CA) certificates in a formal public key infrastructure (PKI). + +This Cmdlet will get X.509 compliant certificates and/or certificate authority trusted certificates an Infrastructure Administrator or other administrator who has added a trusted device from the appliance trusted store. + +Minimum required privileges: Read only + + + + + Get-OVApplianceTrustedCertificate + + Name + + The Alias Name of the certificate. Please know that wildcard is not supported. + + String + + + CertificateAuthoritiesOnly + + This parameter will filter for trusted certificate authorities only. + + SwitchParameter + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] objects or Name property values. + + Object + + + + Get-OVApplianceTrustedCertificate + + InputObject + + Provide an HPEOneView.ServerHardware or HPEOneView.Enclosure resource to return associated appliance trusted certificate(s). + + Object + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] objects or Name property values. + + Object + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] objects or Name property values. + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + CertificateAuthoritiesOnly + + This parameter will filter for trusted certificate authorities only. + + SwitchParameter + + SwitchParameter + + + + + InputObject + + Provide an HPEOneView.ServerHardware or HPEOneView.Enclosure resource to return associated appliance trusted certificate(s). + + Object + + Object + + + + + Name + + The Alias Name of the certificate. Please know that wildcard is not supported. + + String + + String + + + + + + + + + HPEOneView.ServerHardware + + + Server hardware resource from Get-OVServer. + + + + + HPEOneView.Enclosure + + + Enclosure resource from Get-OVEnclosure. + + + + + + + + HPEOneView.Appliance.TrustedCertificate + + + + Appliance trusted certificate object. + + + + + HPEOneView.Appliance.TrustedCertificateAuthority + + + + Appliance trusted certificate authority object. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVApplianceTrustedCertificate + + Return all trusted certificates from the appliance trusted store. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Get-OVServer -Name MyServer.domain.com -ErrorAction SilentlyContinue | Get-OVApplianceTrustedCertificate + + Return the trusted certificate of the provided server hardware resource in the appliance trusted store. + + + + + + + + + + + + + Add-OVApplianceTrustedCertificate + + + + Remove-OVApplianceTrustedCertificate + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/get-ovappliancetrustedcertificate + + + + + + + + Get-OVApplianceTwoFactorAuthentication + + Get appliance two-factor configuration. + + Get + OVApplianceTwoFactorAuthentication + + + Enabling two-factor authentication allows you to use smart cards - for example, Common Access Cards (CAC), or Personal Identity Verification (PIV) cards - to authenticate within HPE OneView. The client certificate embedded in the smart card is presented to HPE OneView by the library. The client certificate must be signed by a root or intermediate Certificate Authority (CA) that has been previously imported into the HPE OneView appliance. The appliance authenticates the client certificate to validate that the user name specified in the certificate is that of a valid user recognized by the directory server configuration in HPE OneView. + +When two-factor authentication is enabled, HPE OneView uses a Microsoft Active Directory service account set up and owned by the user to access an Active Directory entry for the user, rather than using an account associated with the user name received during first time login. + +Use this Cmdlet to get two factor authentication state of the connected appliance. Infrastructure administrator role is required. + +Minimum required privileges: Read only + + + + + Get-OVApplianceTwoFactorAuthentication + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + Array + + (${Global:ConnectedSessions} | ? Default) + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + HPEOneView.Appliance.Security.TwoFactorAuthConfiguration + + + + Appliance two-factor security settings. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVApplianceTwoFactorAuthentication + + Get the appliance two-factor authentication configuration. + + + + + + + + + + + + + Disable-OVApplianceTwoFactorAuthentication + + + + Set-OVApplianceTwoFactorAuthentication + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/get-ovappliancetwofactorauthentication + + + + + + + + Get-OVAuditLog + + Get appliance audit log entries. + + Get + OVAuditLog + + + The audit log contains a record of actions performed on the appliance, which you can use for individual accountability. Because the logs are rolled over periodically to prevent them from getting too large, Hewlett Packard Enterprise recommends downloading the audit logs to monitor the actions being performed. You can also download the audit logs periodically to maintain a long-term audit history. + +Each user has a unique logging ID per session, enabling you to follow a user?s trail in the audit log. Some actions are performed by the appliance and might not have a logging ID. + +A breakdown of an audit entry follows: + + * Date/time - The date and time of the event + * Internal component ID - The unique identifier of an internal component + * Reserved - The organization ID. Reserved for internal use + * User domain - The login domain name of the user + * User name/ID - The user name + * Session ID - The user session ID associated with the message + * Task ID - The URI of the task resource associated with the message + * Client host/IP - The client (browser) IP address identifies the client machine that initiated the request + * Result - The result of the action, which can be one of the following values: + * SUCCESS + * FAILURE + * SOME_FAILURES + * CANCELED + * KILLED + * Action - A description of the action, which can be one of the following values: + * ADD + * MODIFY + * DELETE + * ACCESS + * RUN + * LIST + * ENABLE + * DISABLE + * SAVE + * SETUP + * UNSETUP + * DEPLOY + * START + * DONE + * KILLED + * CANCELED + * LOGIN + * LOGOUT + * DOWNLOAD_START + * Severity - A description of the severity of the event, which can be one of the following values, listed in descending order of importance: + * INFO + * NOTICE + * WARNING + * ERROR + * ALERT + * CRITICAL + * Resource category - For REST API category information, see the HPE OneView API Reference. + * Resource URI/name - The resource URI/name associated with the task + * Message - The output message that appears in the audit log + +The audit log includes entries for all Maintenance console events except for viewing. + +Use this Cmdlet to retrieve appliance audit log entries. Audit log entries can be filtered based on number of entries to return, and a date range. + +Minimum required privileges: Infrastructure administrator + + + + + Get-OVAuditLog + + + Get-OVAuditLog + + Count + + Specify the number of audit log entries to return. + + Int + + + TimeSpan + + Specify the time span of to filter results on. Cannot be combined with Start or End. + + Timespan + + + Start + + Specify the Start datetime object to begin the search. Can be combined with End parameter. + + DateTime + + + End + + Specify the End datetime object to begin the search. Should be combined with Start parameter. + + DateTime + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Count + + Specify the number of audit log entries to return. + + Int + + Int + + + + + End + + Specify the End datetime object to begin the search. Should be combined with Start parameter. + + DateTime + + DateTime + + [DateTime]::Now + + + Start + + Specify the Start datetime object to begin the search. Can be combined with End parameter. + + DateTime + + DateTime + + + + + TimeSpan + + Specify the time span of to filter results on. Cannot be combined with Start or End. + + Timespan + + Timespan + + + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + HPEOneView.Appliance.AuditLogEntry [System.Management.Automation.PSCustomObject] + + + + Single Appliance Audit Log Entry + + + + + System.Collections.ArrayList + + + + Multiple Appliance Audit Log Entries + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVAuditLog +Appliance : hpov.mydomain.com +Date : 2015-10-05 18:14:17.679 UTC +Source : AUTHENTICATION +Action : LOGIN +Result : SUCCESS +Severity : INFO +Details : Login Message Acknowledgment is "false". +Source IP : 172.20.253.1 + +Appliance : hpov.mydomain.com +Date : 2015-10-05 18:14:17.761 UTC +Source : AUTHENTICATION +Action : LOGIN +Result : SUCCESS +Severity : INFO +Details : Authentication SUCCESS. User "Administrator" logged in successfully from client "172.20.253.1" and + directory "LOCAL" on server "". [logID:LTY4ODgyMTcyMTMz] +Source IP : 172.20.253.1 + +Appliance : hpov.mydomain.com +Date : 2015-10-05 20:51:45.754 UTC +Source : firmware-drivers +Action : ADD +Result : SUCCESS +Severity : INFO +Details : Add firmware bundle /rest/firmware-drivers/CP026527 + + Return the audit logs from the appliance. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Get-OVAuditLog -Start ([DateTime]::Now).AddDays("-5") + + Return the audit logs from the appliance from 5 days ago from today. + + + + + + + + + + + + + Get-OVAuditLogArchive + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/get-ovauditlog + + + + + + + + Get-OVAuditLogArchive + + Download archive of appliance audit logs. + + Get + OVAuditLogArchive + + + The audit log contains a record of actions performed on the appliance, which you can use for individual accountability. Because the logs are rolled over periodically to prevent them from getting too large, Hewlett Packard Enterprise recommends downloading the audit logs to monitor the actions being performed. You can also download the audit logs periodically to maintain a long-term audit history. + +Each user has a unique logging ID per session, enabling you to follow a user?s trail in the audit log. Some actions are performed by the appliance and might not have a logging ID. + +A breakdown of an audit entry follows: + + * Date/time - The date and time of the event + * Internal component ID - The unique identifier of an internal component + * Reserved - The organization ID. Reserved for internal use + * User domain - The login domain name of the user + * User name/ID - The user name + * Session ID - The user session ID associated with the message + * Task ID - The URI of the task resource associated with the message + * Client host/IP - The client (browser) IP address identifies the client machine that initiated the request + * Result - The result of the action, which can be one of the following values: + * SUCCESS + * FAILURE + * SOME_FAILURES + * CANCELED + * KILLED + * Action - A description of the action, which can be one of the following values: + * ADD + * MODIFY + * DELETE + * ACCESS + * RUN + * LIST + * ENABLE + * DISABLE + * SAVE + * SETUP + * UNSETUP + * DEPLOY + * START + * DONE + * KILLED + * CANCELED + * LOGIN + * LOGOUT + * DOWNLOAD_START + * Severity - A description of the severity of the event, which can be one of the following values, listed in descending order of importance: + * INFO + * NOTICE + * WARNING + * ERROR + * ALERT + * CRITICAL + * Resource category - For REST API category information, see the HPE OneView API Reference. + * Resource URI/name - The resource URI/name associated with the task + * Message - The output message that appears in the audit log + +The audit log includes entries for all Maintenance console events except for viewing. + +Use this Cmdlet to retrieve appliance audit log archive, which contains all available audit log entries, in ZIP format. + +Minimum required privileges: Infrastructure administrator + + + + + Get-OVAuditLogArchive + + Location + + The full path to where the audit log will be saved to. If omitted, current directory location will be used. + + System.IO.DirectoryInfo + + + ApplianceConnection + + One or more Appliance Connection Objects, Connection ID, or Connection Name. If omitted, all connected appliances will be processed. + + Object + + + + + + + ApplianceConnection + + One or more Appliance Connection Objects, Connection ID, or Connection Name. If omitted, all connected appliances will be processed. + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Location + + The full path to where the audit log will be saved to. If omitted, current directory location will be used. + + System.IO.DirectoryInfo + + System.IO.DirectoryInfo + + (get-location).Path + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + System.IO.FileInfo + + + + The generated audit log File + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVAuditLogArchive -Location C:\Temp + + Save the Appliance audit log archive to C:\Temp + + + + + + + + + + + + + Get-OVAuditLog + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/get-ovauditlogarchive + + + + + + + + Get-OVAutomaticBackupConfig + + Retrieve automatic appliance backup configuration. + + Get + OVAutomaticBackupConfig + + + HPE OneView provides the ability to save your configuration settings and management data to a backup file and enables you to use that backup to restore a corrupted appliance in the event of a catastrophic failure. + +The backup process involves creating a backup file and then downloading that file so that you can store it to a safe and secure (off-appliance) location for future use. You can schedule automatic backup operations and designate a remote location for the backup file. + +This Cmdlet will get the automatic backup configuration from the connected appliance(s). Use Set-OVAutomaticBackupConfig to set a new automatic backup policy for the appliance(s). + +Minimum required privileges: Read only + + + + + Get-OVAutomaticBackupConfig + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Array + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Array + + Array + + (${Global:ConnectedSessions} | ? Default) + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + HPEOneView.Appliance.AutomaticBackupConfig [System.Management.Automation.PSCustomObject] + + + + Appliance automatic backup configuration object. + + + + + System.Collections.Arraylist <HPEOneView.Appliance.AutomaticBackupConfig> + + + + Multiple appliance automatic backup configuration objects. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVAutomaticBackupConfig + +Appliance Enabled Server Protocol Directory Interval Days Time +--------- ------- ------ -------- --------- -------- ---- ---- +Appliance True scphost.domain.com SCP WEEKLY {MO, WE, FR} 18:00 + + Get the configured automatic backup setting of the appliance. + + + + + + + + + + + + + Set-OVAutomaticBackupConfig + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/get-ovautomaticbackupconfig + + + + + + + + Get-OVAvailableDriveType + + Return a collection of available D3940 disks. + + Get + OVAvailableDriveType + + + This helper Cmdlet will return a collection of available disk drives from a specified SAS Logical Interconnect or Drive Enclosure. The returned value will contain available quantity of drives based on interface, media type and capacity, organized by SAS Logical Interconnect. The object can then be used to define the drive selection criteria for New-OVServerProfileLogicalDisk using the -AvailableDriveType parameter. + +Minimum required privileges: Read only + + + + + Get-OVAvailableDriveType + + InputObject + + A SAS Logical Interconnect or D3940 Drive Enclosure resource. If providing a SAS Logical Interconnect, the Cmdlet will automatically locate the available drive enclosures. + + Object + + + ApplianceConnection + + The name of the appliance or list of appliances to execute the command against. + + Object + + + + + + + ApplianceConnection + + The name of the appliance or list of appliances to execute the command against. + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + InputObject + + A SAS Logical Interconnect or D3940 Drive Enclosure resource. If providing a SAS Logical Interconnect, the Cmdlet will automatically locate the available drive enclosures. + + Object + + Object + + + + + + + + + HPEOneView.Storage.SASLogicalInterconnect + + + A SAS Logical Interconnect resource from Get-OVSasLogicalInterconnect Cmdlet. + + + + + HPEOneView.Storage.DiskEnclosure + + + A D3940 Drive Enclosure from Get-OVSasLogicalInterconnect Cmdlet. + + + + + + + + HPEOneView.Storage.AvailableDriveType + + + + A disk type object that defines available quantity of drives based on interface, media type and capacity, organized by SAS Logical Interconnect. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVSasLogicalInterconnect | Get-OVAvailableDriveType + + Return all available disk drives from all SAS Logical Interconnects. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Get-OVSasLogicalInterconnect -Name "LE1-Default SAS Synergy LIG-3" -ErrorAction Stop | Get-OVAvailableDriveType + + Return all available disk drives from the specific SAS Logical Interconnect. + + + + + + + + + + -------------------------- EXAMPLE 3 -------------------------- + + + + Get-OVDriveEnclosure -Name "EnclosureName, Bay 1" -ErrorAction Stop | Get-OVAvailableDriveType + + Return all available disk drives from the specific D3940 Drive Enclosure. + + + + + + + + + + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/storage/get-ovavailabledrivetype + + + + + + + + Get-OVBackup + + List appliance backups. + + Get + OVBackup + + + HPE OneView provides the ability to save your configuration settings and management data to a backup file and enables you to use that backup to restore a corrupted appliance in the event of a catastrophic failure. + +The backup process involves creating a backup file and then downloading that file so that you can store it to a safe and secure (off-appliance) location for future use. You can schedule automatic backup operations and designate a remote location for the backup file. + +Use this Cmdlet to return any existing backups that have not been downloaded or offloaded on the appliance. + +Minimum required privileges: Read only + + + + + Get-OVBackup + + Before + + Specify the DateTime object of when to locate backups created before. + + DateTime + + + After + + Specify the DateTime object of when to locate backups created after. + + DateTime + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + + + + + + After + + Specify the DateTime object of when to locate backups created after. + + DateTime + + DateTime + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + Array + + (${Global:ConnectedSessions} | ? Default) + + + Before + + Specify the DateTime object of when to locate backups created before. + + DateTime + + DateTime + + + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + The generated backup File if appliance is not setup for remote storage or the Force parameter is used. + + + + + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVBackup + + This command will return any appliance backs present on the appliance. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Get-OVBackup -Before [datetime]"2017/01/01" + + This command will return appliance backups that were created before 2017/01/01. + + + + + + + + + + + + + New-OVBackup + + + + Save-OVBackup + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/get-ovbackup + + + + + + + + Get-OVBaseline + + Retrieve available SPP baseline and hotfix information. + + Get + OVBaseline + + + The appliance provides reliable and simplified firmware management across the data center. Using the firmware management features built in to the appliance, you can define firmware baselines and perform firmware updates across many resources. When you add a resource to the appliance, the appliance automatically updates the resource firmware to the minimum version required to be managed by the appliance or version defined to be a baseline. + +A firmware bundle, also known as an HPE Service Pack for ProLiant (SPP), is a comprehensive collection of firmware and system software components, all tested together as a single solution stack that includes drivers, agents, utilities, and firmware packages. Firmware bundles enable you to update firmware on HPE ProLiant servers, controllers, storage, servers, interconnects, and enclosures. + +Retrieve the list of SPPs or hotfixes which have been uploaded to the appliance, and their detail. You can examine the included components and their versions reported by the baseline. + +Please note that any file name that contains the . (period, CHAR46) character will be replaced with _ (underscore, CHAR95). + +Example: My.Spp.To.Upload.201605.iso will become My_Spp_To_Upload_201605.iso. + +Minimum required privileges: Read only + + + + + Get-OVBaseline + + File + + The file name of an SPP or hotfix component + + String + + + Scope + + Filter resources based on provided Scope membership. By default, all resources for the accounts Active Permissions will be displayed. Allowed values: + + * AllResources + * AllResourcesInScope + * HPEOneView.Appliance.ScopeCollection + * HPEOneView.Appliance.ConnectionPermission + + Object + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + + + Get-OVBaseline + + SppName + + The SPP/Baseline or hotfix name. + + String + + + Version + + If multiple SPP/Baselines with the same name exist, use the Version parameter to filter to the specific SPP/Baseline version. + + String + + + Scope + + Filter resources based on provided Scope membership. By default, all resources for the accounts Active Permissions will be displayed. Allowed values: + + * AllResources + * AllResourcesInScope + * HPEOneView.Appliance.ScopeCollection + * HPEOneView.Appliance.ConnectionPermission + + Object + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + + + Get-OVBaseline + + HotfixesOnly + + Display only the available hotfixes present with in the repository. + + SwitchParameter + + + Scope + + Filter resources based on provided Scope membership. By default, all resources for the accounts Active Permissions will be displayed. Allowed values: + + * AllResources + * AllResourcesInScope + * HPEOneView.Appliance.ScopeCollection + * HPEOneView.Appliance.ConnectionPermission + + Object + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + Array + + (${Global:ConnectedSessions} | ? Default) + + + File + + The file name of an SPP or hotfix component + + String + + String + + + + + HotfixesOnly + + Display only the available hotfixes present with in the repository. + + SwitchParameter + + SwitchParameter + + False + + + Scope + + Filter resources based on provided Scope membership. By default, all resources for the accounts Active Permissions will be displayed. Allowed values: + + * AllResources + * AllResourcesInScope + * HPEOneView.Appliance.ScopeCollection + * HPEOneView.Appliance.ConnectionPermission + + Object + + Object + + AllResourcesInScope + + + SppName + + The SPP/Baseline or hotfix name. + + String + + String + + + + + Version + + If multiple SPP/Baselines with the same name exist, use the Version parameter to filter to the specific SPP/Baseline version. + + String + + String + + + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + HPEOneView.Appliance.Baseline + + + + SPP baseline resource object. + + + + + HPEOneView.Appliance.BaselineHotfix : HPEOneView.Appliance.Baseline + + + + Baseline hotfix resource. Class derived from HPEOneView.Appliance.Baseline base class. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + $sppCollection = Get-OVBaseline + + Retrieves all baseline objects from the appliance and stores them in the sppCollection variable. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + $sppObject = Get-OVBaseline -Filename SPP2012060B.2012_0525.1.iso + + Retrieves an baseline object with the filename SPP2012060B.2012_0525.1.iso + + + + + + + + + + -------------------------- EXAMPLE 3 -------------------------- + + + + $sppObject = Get-OVBaseline -SppName "HPE Service Pack for ProLiant" + + Retrieves an baseline object with the SPP Name "HPE Service Pack for ProLiant". + + + + + + + + + + + + + Add-OVBaseline + + + + Get-OVBaselineRepository + + + + Remove-OVBaseline + + + + Show-OVBaselineRepositorySize + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/get-ovbaseline + + + + + + + + Get-OVBaselineRepository + + Retrieve available baseline repository information. + + Get + OVBaselineRepository + + + A firmware repository enables you to store firmware file and deploy them across your environment. Selecting a firmware file from the repository displays its release date, supported languages and operating systems, and the file components. The screen also displays the amount of storage space available for additional firmware file on the appliance. You cannot add a firmware file that is larger than the amount of space available in the repository. + +Two types of repositories are supported: + + * Internal Repository: The internal embedded firmware repository in an HPE Synergy Composer has a maximum size limit of 12 GB to store and upload firmware files for use by components managed by HPE OneView. + + NOTE: You cannot add, edit, or remove the internal repository. + + * External Repository: An additional externally managed HTTP/HTTPS web server can be added to the appliance as a repository. It is a user-maintained HTTP/HTTPS web server. You can upload firmware file in a specific directory and then register the HTTP/HTTPS server with HPE OneView. This functionality is supported for Linux and Windows systems. + +The Cmdlet will get the appliance repositories. + +Minimum required privileges: Read only + + + + + Get-OVBaselineRepository + + Name + + Return the repository with the name or matching name. + + String + + + Type + + Specify "Internal" or "External" to filter the repository type. + + String + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + Array + + (${Global:ConnectedSessions} | ? Default) + + + Name + + Return the repository with the name or matching name. + + String + + String + + + + + Type + + Specify "Internal" or "External" to filter the repository type. + + String + + String + + + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + HPEOneView.Appliance.BaselineRepository [System.Management.Automation.PSCustomObject] + + + + Either and Internal or External repository object. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + $Repositories = Get-OVBaselineRepository + + Retrieves all repository objects from the appliance. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Get-OVBaselineRepository -Type External + + Retrieves only the configured external repository on the appliance. + + + + + + + + + + + + + Show-OVBaselineRepositorySize + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/get-ovbaselinerepository + + + + + + + + Get-OVClusterManager + + Get configured hypervisor managers. + + Get + OVClusterManager + + + A hypervisor is software deployed on a server node that creates and runs virtual machines. Hypervisors are clustered to ensure high availability, to optimize resource utilization, and to be fault tolerant. A hypervisor cluster profile enables you to deploy and manage a cluster of hypervisors running on servers managed by HPE OneView and orchestrates consistent configuration on cluster of server nodes to share the same workload. + +A hypervisor cluster profile and the associated server profile template are used to define a consistent configuration from server nodes to hypervisors in the cluster. The server profiles define physical server configurations for server nodes in the cluster, which are derived from hypervisor cluster profile and the associated server profile template. The hypervisor profiles define network and storage configurations for hypervisors in the cluster, which are derived from hypervisor cluster profile. Hypervisor network and storage configurations in the hypervisor cluster profile are defined based on physical server configuration to ensure consistent configuration from server node to hypervisor. + +You can register a hypervisor manager with HPE OneView by using Add-OVClusterManager. The registered hypervisor manager contains preferences, which are used as default hypervisor or cluster settings during hypervisor cluster profile creation. You can modify the hypervisor manager preferences when adding, or using Set-OVClusterManager. You can override these values when creating a hypervisor cluster profile. + +This Cmdlet will get the configured hypervisor cluster manager on the appliance. + +Minimum required privileges: Read only + + + + + Get-OVClusterManager + + Name + + Filter for vCenter name. + + String + + + Version + + Filter for specific vCenter version. + + String + + + Label + + Specify the label associated with resources. + + String + + + Scope + + Filter resources based on provided Scope membership. By default, all resources for the accounts Active Permissions will be displayed. Allowed values: + + * AllResources + *AllResourcesInScope + * HPEOneView.Appliance.ScopeCollection + * HPEOneView.Appliance.ConnectionPermission + + Object + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + Array + + (${Global:ConnectedSessions} | ? Default) + + + Label + + Specify the label associated with resources. + + String + + String + + + + + Name + + Filter for vCenter name. + + String + + String + + + + + Scope + + Filter resources based on provided Scope membership. By default, all resources for the accounts Active Permissions will be displayed. Allowed values: + + * AllResources + *AllResourcesInScope + * HPEOneView.Appliance.ScopeCollection + * HPEOneView.Appliance.ConnectionPermission + + Object + + Object + + AllResourcesInScope + + + Version + + Filter for specific vCenter version. + + String + + String + + + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + HPEOneView.Cluster.HypervisorManager + + + + The configured hypervisor cluster manager and its properties + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVClusterManager -Name vcenter.domain.com + + Get the specified hypervisor manager by resource name. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Get-OVClusterManager -Version 5.5.0 + + Get all of the configured hypervisor managers that are vSphere 5.5.0. + + + + + + + + + + + + + Add-OVClusterManager + + + + Remove-OVClusterManager + + + + Set-OVClusterManager + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/cluster/get-ovclustermanager + + + + + + + + Get-OVClusterNode + + Default content + + Get + OVClusterNode + + + Default content + + + + + Get-OVClusterNode + + Name + + + + String + + + Label + + Specify the label associated with resources. + + String + + + Scope + + Filter resources based on provided Scope membership. By default, all resources for the accounts Active Permissions will be displayed. Allowed values: + + * AllResources + *AllResourcesInScope + * HPEOneView.Appliance.ScopeCollection + * HPEOneView.Appliance.ConnectionPermission + + Object + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Label + + Specify the label associated with resources. + + String + + String + + + + + Name + + + + String + + String + + + + + Scope + + Filter resources based on provided Scope membership. By default, all resources for the accounts Active Permissions will be displayed. Allowed values: + + * AllResources + *AllResourcesInScope + * HPEOneView.Appliance.ScopeCollection + * HPEOneView.Appliance.ConnectionPermission + + Object + + Object + + AllResourcesInScope + + + + + + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVClusterNode + + Default example + + + + + + + + + + + + + Add-OVClusterNode + + + + Add-OVClusterNodeToCluster + + + + Enter-OVClusterNodeMaintenanceMode + + + + Exit-OVClusterNodeMaintenanceMode + + + + Update-OVClusterNode + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/cluster/get-ovclusternode + + + + + + + + Get-OVClusterProfile + + Get a deployed cluster profile. + + Get + OVClusterProfile + + + A cluster profile enables you to deploy and manage a cluster of servers (nodes) managed by HPE OneView and orchestrates consistent configuration on cluster of server nodes to share the same workload. A cluster profile and the associated server profile template are used to define a consistent configuration from server nodes to members in the cluster. The associated server profiles define physical server configurations for server nodes in the cluster, which are derived from parent cluster profile and its associated server profile template. + +NOTE: The server profile template must have a configured connection to the hypervisor management network for the template to be valid for use by a hypervisor cluster profile. + +The cluster profile helps you manage life cycle operations, such as growing or shrinking the cluster, modifying configurations based on needs, consistency checks, and nondisruptive firmware updates on the member nodes. For example, you can grow or shrink a cluster by adding or removing members from the cluster profile. Any change in the configuration of the cluster profile will be reported as an inconsistency. When inconsistencies are remediated, the changed configurations can be applied on cluster and member nodes. + +A cluster profile can manage VMware ESXi-based hypervisor clusters by leveraging VMware vCenter server. A hypervisor cluster must be managed by one instance of HPE OneView to avoid inconsistencies. + +Use this Cmdlet to get created cluster profiles within OneView. + +Minimum required privileges: Read only + + + + + Get-OVClusterProfile + + Name + + Specify a string value to filter for the specific resource + + String + + + NonCompliant + + Filter resources based on their non-compliant state. + + SwitchParameter + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Name + + Specify a string value to filter for the specific resource + + String + + String + + + + + NonCompliant + + Filter resources based on their non-compliant state. + + SwitchParameter + + SwitchParameter + + + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + HPEOneView.Cluster.ClusterProfile [System.Management.Automation.PSCustomObject] + + + + The returned cluster profile resource. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVClusterProfile + + Get the available and managed cluster profiles. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Get-OVClusterProfile -NonCompliant + + Get the non compliant and managed cluster profiles. + + + + + + + + + + + + + New-OVClusterProfile + + + + New-OVClusterProfileMember + + + + Remove-OVClusterProfile + + + + Update-OVClusterProfile + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/cluster/get-ovclusterprofile + + + + + + + + Get-OVCommandTrace + + Start an OV Library Verbose Trace. + + Get + OVCommandTrace + + + This Cmdlet will assist the user in setting up the PowerShell environment to generate and capture Verbose output from OV Library Cmdlets. Once this Cmdlet has been executed, the prior OV Cmdlets can be executed, without the need of using the `-Cerbose` switch. + +Cmdlet output will be captured using the built-in Microsoft PowerShell Start-Transcript provider. A transcript trace file will be saved in either the current working directory, or specified using the `-Location` parameter. + +Please know that this Cmdlet is currently not supported in the Windows PowerShell ISE, unless using PowerShell v5 or newer. + + + + + Get-OVCommandTrace + + ScriptBlock + + One or more HPOneView library Cmdlets. The Cmdlet will execute the contents of the ScriptBlock, ensuring that the commands will generate verbose output and be captured to a log file. + + ScriptBlock + + + Location + + Specify the directory where the output file will be created. A file with the following format will be created: + + "{Date}_HPOV_transcript.log", where date is derived from `Get-Date -UFormat %y%m%d%H%M` + +Default Value: (PWD).Path + + String + + + Passthru + + When you use the PassThru parameter, Get-OVCommandTrace returns the processed output from the provided scriptblock, while still capturing to file. + + SwitchParameter + + + + + + + Location + + Specify the directory where the output file will be created. A file with the following format will be created: + + "{Date}_HPOV_transcript.log", where date is derived from `Get-Date -UFormat %y%m%d%H%M` + +Default Value: (PWD).Path + + String + + String + + (pwd).path + + + Passthru + + When you use the PassThru parameter, Get-OVCommandTrace returns the processed output from the provided scriptblock, while still capturing to file. + + SwitchParameter + + SwitchParameter + + + + + ScriptBlock + + One or more HPOneView library Cmdlets. The Cmdlet will execute the contents of the ScriptBlock, ensuring that the commands will generate verbose output and be captured to a log file. + + ScriptBlock + + ScriptBlock + + + + + + + + + System.Management.Automation.ScriptBlock + + + ScriptBlock of the command or commands to generate verbose output for. + + + + + + + + System.IO.FileInfo + + + + FileInfo object where the "{Date}_HPOV_transcript.log" file is generated. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVCommandTrace -ScriptBlock { Get-OVNetwork -Name MyNet } -Location C:\Temp + + Start a new library trace, which will create a file in the `C:\Temp` directory. + + + + + + + + + + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/library/get-ovcommandtrace + + + + + + + + Get-OVComposerIloStatus + + Retrieve the HPE Synergy Composer iLO configuration. + + Get + OVComposerIloStatus + + + You can configure the HPE Synergy Composer2 for remote access through its embedded management processor (iLO). This configuration enables you to manage the Composer2 remotely and perform specific Composer2 management operations that previously required accessing the Composer console locally in the data center. + +After remote access to a Composer2 iLO is configured, you can: + + * Use the iLO Integrated Remote Console (iLO IRC) to access the Composer2 physical console. The physical console provides access to the HPE OneView maintenance console. The Composer2 iLO has an independent IPaddress and is accessible even when the Composer2 is not available. + * Mount a virtual USB drive on the Composer2 through iLO and perform critical operations such as reimage,restore, backup, and create support dump without physically accessing the appliance. + * Power on or off the appliance. + +You can configure the iLO of the HPE Synergy Composer2 for remote access using this Cmdlet. All the Composer2 nodes that are present in the enclosures managed by HPE OneView can be configured, including standby or standalone Composer2 nodes. The following are the settings that you can configure for the Composer2 iLO in HPE OneView: + + * The iLO user account and password that are required to log in to the Composer2 iLO. + * Network parameters that allow you to access the Composer2 iLO from an external browser. The network parameters include iLO hostname, iLO IP address, subnet mask, gateway, and DNS server names. Both IPv4 and IPv6 addresses are supported. + +Supported operations on the Composer2 through the iLO Integrated Remote Console + +You can perform the following operations when using the HPE Synergy Composer2 iLO Integrated Remote Console (iLO IRC): + + * Switch between the graphical console or the Composer2 maintenance console. By default, the Composer2 console displays a graphical browser interface. Use Ctrl+Alt+F1 and Ctrl+Alt+F2 to switch between the graphical interface and the maintenance console. + * For the first-time setup, Hewlett Packard Enterprise recommends that you configure the appliance network before the hardware discovery process starts. + * Power on and off the appliance using the integrated power control options on the iLO remote console. + * Use the Composer2 iLO virtual media feature to have a USB drive on your local workstation mounted as a virtual USB drive on the Composer2. + +Virtually mounting the USB drive allows you to: + + * Reimage the Composer2 from a DD image on the virtual USB drive. + * Create a support dump file on the virtual USB drive. + + NOTE: If both virtual USB drive and local USB drive are plugged into the Composer2, by default the virtual USB drive is selected. To choose the USB drive that is plugged into the Composer2, unmount the virtual USB drive. In the iLO IRC, select Virtual Drives and clear the virtual drive selection to unmount the virtual USB drive. You can also unmount the virtual USB drive from the maintenance console of HPE OneView. + + * Restore the Composer2 from a backup image on the virtual USB drive. + +Requirements + + * A single iLO user account is supported. Creating a user account replaces any existing user account. + * The iLO username cannot be Administrator or start with an _. + +NOTE: The iLO user account is assigned a predefined set of privileges that allows the user to perform a restricted set of iLO operations. Specifically, the iLO account has permissions to control power, use the iLO Integrated Remote Console (iLO IRC), and use the iLO Virtual Media. + +Use this Cmdlet to retrieve the iLO configuration of the support HPE Synergy Composer. This will return an object detailing if the iLO is remotely accessible, configured iLO username and configured IP address(es). The object will not contain the configued iLO username's password. + +Minimum required privileges: Read-only + + + + + + Get-OVComposerIloStatus + + ApplianceConnection + + Specify one or more HPEOneView.Appliance.Connection object(s) or Name property value(s). + +Default Value: ${Global:ConnectedSessions} | ? Default + + Object + + + + + + + ApplianceConnection + + Specify one or more HPEOneView.Appliance.Connection object(s) or Name property value(s). + +Default Value: ${Global:ConnectedSessions} | ? Default + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + + + + + None. You cannot pipe objects to this cmdlet. + + + + + + + + + + + HPEOneView.Appliance.HardwareConfig [System.Management.Automation.PSCustomObject] + + + + The existing iLO configuration of an HPE Synergy Composer. + + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVComposerIloStatus + + + Get the avialable HPE Synergy Composers and their iLO configuration. + + + + + + + + + + + + + Disable-OVComposerIlo + + + + Enable-OVComposerIlo + + + + Set-OVComposerIlo + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/get-ovcomposerilostatus + + + + + + + + Get-OVComposerNode + + Retrieve Synergy Composer node information. + + Get + OVComposerNode + + + The Composer is an appliance that runs HPE OneView and manages the group of Synergy frames cabled together. You select the initial, active Composer during hardware setup by connecting the Synergy monitor port to a frame link module in the same bay number as the Composer you want to configure. A second Composer is automatically selected to create a high-availability (HA) cluster for managing the Synergy frame in a standby role. If the active Composer fails, the standby Composer automatically becomes the active Composer. + +This Cmdlet will report the installed and configured Synergy Composer nodes. This includes status, state, model, firmware version, and role. + +Minimum required privileges: Read only + + + + + Get-OVComposerNode + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + HPEOneView.ComposerNode [System.Management.Automation.PSCustomObject] + + + + Synergy Compose node. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVComposerNode + +Appliance Name State Status Model Version Role +--------- ---- ----- ------ ----- ------- ---- +zpo-s18r18s3-ov.vse.rdlabs.hpecorp.net CN75160607 appliance bay 1 OK OK Synergy Composer 3.00.00-0251673 Active +zpo-s18r18s3-ov.vse.rdlabs.hpecorp.net CN75140CPW appliance bay 1 OK OK Synergy Composer 3.00.00-0251673 Standby + + Return all Synergy Composer nodes + + + + + + + + + + + + + Get-OVEnclosure + + + + Reset-OVEnclosureDevice + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/servers/get-ovcomposernode + + + + + + + + Get-OVComputeOpsManagement + + Get the appliance Compute Ops Management configuration. + + Get + OVComputeOpsManagement + + + HPE GreenLake for Compute Ops Management is a cloud-based as-a-Service application that manages various operations of HPE OneView appliances. By integrating HPE OneView with HPE GreenLake for Compute Ops Management will unify server inventory and centralize management to a single console. To enable the cloud management service for HPE OneView, you must onboard the appliance in the Compute Ops Management application in HPE GreenLake by using this Cmdlet to first generate the appliance ID. Once the Cmdlet completes successfully, use the Get-OVComputeOpsManagement Cmdlet to retreive the appliance ID needed in the HPE GreenLake for Compute Ops Management to generate an activation key. You can use this same Cmdlet with the -ActivationKey parameter, or Set-OVComputeOpsManagement Cmdlet to set the activation key for the appliance. + +Minimum required privileges: Infrastructure administrator + + + + + Get-OVComputeOpsManagement + + ApplianceConnection + + Specify one or more HPEOneView.Appliance.Connection object(s) or Name property value(s). + +Default Value: ${Global:ConnectedSessions} | ? Default + + Object + + + + + + + ApplianceConnection + + Specify one or more HPEOneView.Appliance.Connection object(s) or Name property value(s). + +Default Value: ${Global:ConnectedSessions} | ? Default + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + + + + + None. You cannot pipe objects to this cmdlet. + + + + + + + + + + + HPEOneView.Appliance.CloudSettings + + + + Object that represents the current configuration + + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVComputeOpsManagement + + + Show the connected status of the appliance to HPE GreenLake for Compute Ops Management - OneView Edition service. + + + + + + + + + + + + + Connect-OVComputeOpsManagement + + + + Disable-OVComputeOpsManagement + + + + Enable-OVComputeOpsmanagement + + + + Set-OVComputeOpsManagement + + + + Set-OVApplianceProxy + + + + Online: + https://hpe-docs.gitbook.io/posh-hpeoneview/cmdlets/v9.00/appliance/get-ovcomputeopsmanagement + + + + + + + + Get-OVDataCenter + + Retrieve a defined DataCenter. + + Get + OVDataCenter + + + A data center represents a physically contiguous area in which racks containing IT equipment are located. For example, you have IT equipment in two rooms or on separate floors. You could create a data center for each of these areas. Each server, enclosure, or power distribution device in your data center can report its power requirements, but it can be difficult to understand the power and cooling requirements for your data center as a whole. The appliance enables you to bring power and cooling management of your servers, enclosures, and power delivery devices together in a single management system. When you initialize the appliance for the first time, it creates a data center named Datacenter 1. The appliance provides this data center as a place to visualize your racks. You can rename or edit this data center to match the values and layout of your data center, you can use it as the basis for a planned data center model, or you can delete this data center without adverse effects. + +This Cmdlet will retrieve all or a specific DataCenter resource object. If Remote Support has been enabled on the appliance, the DataCenter object will contain a RemoteSupportLocation property that contains the site location (if different from the Default DataCenter), and both the Primary and Secondary contacts. + +Minimum required privileges: Read only + + + + + Get-OVDataCenter + + Name + + DataCenter name. Supports wildcard (*) character. + + String + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Name + + DataCenter name. Supports wildcard (*) character. + + String + + String + + + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + HPEOneView.Facilities.DataCenter + + + + A DataCenter resource object. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVDataCenter + + Retrieve all defined DataCenters on the appliance. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Get-OVDataCenter -Name DC* + + Locate all DataCenter objects that begin with "DC". + + + + + + + + + + -------------------------- EXAMPLE 3 -------------------------- + + + + Get-OVDataCenter | Select -ExpandProperty RemoteSupportLocation + + Retrieve the Remote Support Location property from the found DataCenter resource objects. + + + + + + + + + + + + + New-OVDataCenter + + + + Remove-OVDataCenter + + + + Set-OVDataCenter + + + + Set-OVDataCenterRemoteSupport + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/facilities/get-ovdatacenter + + + + + + + + Get-OVDriveEnclosure + + List Synergy DAS Enclosures. + + Get + OVDriveEnclosure + + + Drive enclosures are hardware devices that contain a set of drive bays. A drive enclosure is installed in a device bay of an enclosure, and provides composable storage to servers. Composable storage is a group of physical drives that you can dynamically define as virtual drives. These virtual drives are called logical JBODs. A JBOD (just a bunch of disks) is a group of physical disk drives that are assigned to server hardware. Unlike a RAID configuration, a JBOD is a not redundant configuration. You can specify a RAID configuration when you create a logical JBOD. + +Logical JBODs are created and assigned to server hardware from server profiles or server profile templates. + +This Cmdlet will help display the available Synergy DAS Enclosures, and their associated inventory data. + +Minimum required privileges: Read only + + + + + Get-OVDriveEnclosure + + Name + + The name of the Synergy DAS enclosure. Omit to return all devices. + + String + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + Array + + (${Global:ConnectedSessions} | ? Default) + + + Name + + The name of the Synergy DAS enclosure. Omit to return all devices. + + String + + String + + + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + HPEOneView.Storage.DriveEnclosure [System.Management.Automation.PSCustomObject] + + + + DAS enclosure resource object. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVDriveEnclosure +Appliance Name State Status Serial Number Drive Bays I/O Adapters +--------- ---- ----- ------ ------------- ---------- ------------ +appliance 0000A66101, bay 1 On Monitored SN123100 40/40 2 +appliance 0000A66102, bay 1 On Monitored SN123101 40/40 2 +appliance 0000A66103, bay 1 On Monitored SN123102 40/40 2 + + Get all available Synergy Drive Enclosures. + + + + + + + + + + + + + Get-OVAvailableDriveType + + + + Get-OVDriveEnclosureInventory + + + + Get-OVEnclosure + + + + Get-OVLogicalJBOD + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/storage/get-ovdriveenclosure + + + + + + + + Get-OVDriveEnclosureInventory + + Get the HPE Synergy D3940 drive enclosure inventory. + + Get + OVDriveEnclosureInventory + + + Drive enclosures are hardware devices that contain a set of drive bays. A drive enclosure is installed in a device bay of an enclosure, and provides composable storage to servers. Composable storage is a group of physical drives that you can dynamically define as virtual drives. These virtual drives are called logical JBODs. A JBOD (just a bunch of disks) is a group of physical disk drives that are assigned to server hardware. Unlike a RAID configuration, a JBOD is a not redundant configuration. You can specify a RAID configuration when you create a logical JBOD. + +Using this Cmdlet will get the drive inventory from the connected appliance. Inventory can be filtered on SAS logical interconnects and SAS drive enclosures. + +Minimum required privileges: Infrastructure administrator, server administrator, server profile architect, server profile administrator + + + + + Get-OVDriveEnclosureInventory + + Name + + Specify a drive name, or wild card value. + + String + + + DriveEnclosure + + Provide a drive enclosure from Get-OVDriveEnclosure to filter for associated drives. + + Object + + + SasLogicalInterconnect + + Provide a SAS Logical Interconnect from Get-OVSasLogicalInterconnect to filter for associated drives. + + Object + + + Count + + Return a specific number of drives. Will return in order from system inventory. + + Int + + + Available + + Return drives that are available for assignment. + + SwitchParameter + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + Get-OVDriveEnclosureInventory + + Name + + Specify a drive name, or wild card value. + + String + + + DriveEnclosure + + Provide a drive enclosure from Get-OVDriveEnclosure to filter for associated drives. + + Object + + + SasLogicalInterconnect + + Provide a SAS Logical Interconnect from Get-OVSasLogicalInterconnect to filter for associated drives. + + Object + + + Assigned + + Return only drives that are assigned to a Logical JBOD. + + SwitchParameter + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Assigned + + Return only drives that are assigned to a Logical JBOD. + + SwitchParameter + + SwitchParameter + + + + + Available + + Return drives that are available for assignment. + + SwitchParameter + + SwitchParameter + + + + + Count + + Return a specific number of drives. Will return in order from system inventory. + + Int + + Int + + + + + DriveEnclosure + + Provide a drive enclosure from Get-OVDriveEnclosure to filter for associated drives. + + Object + + Object + + + + + Name + + Specify a drive name, or wild card value. + + String + + String + + + + + SasLogicalInterconnect + + Provide a SAS Logical Interconnect from Get-OVSasLogicalInterconnect to filter for associated drives. + + Object + + Object + + + + + + + + + HPEOneView.Storage.DriveEnclosure [System.Management.Automation.PSCustomObject] + + + Drive enclosure resource from Get-OVDriveEnclosure Cmdlet. + + + + + + + + HPEOneView.Storage.Drive + + + + The drive class object from the API. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVDriveEnclosureInventory + + Get all drive enclosure inventory. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Get-OVDriveEnclosureInventory -Assigned + + Get inventory of drives that are assigned. + + + + + + + + + + -------------------------- EXAMPLE 3 -------------------------- + + + + $DriveEnclosure = Get-OVDriveEnclosure -Name "Enclosure1, bay 1" +Get-OVDriveEnclosureInventory -DriveEnclosure $DriveEnclosure + + Get the drive enventory from the specified drive enclosure. + + + + + + + + + + -------------------------- EXAMPLE 4 -------------------------- + + + + $SasLogicalInterconnect = Get-SasLogicalInterconnect -Name "LE1-SAS Synergy LIG-1" +Get-OVDriveEnclosureInventory -SasLogicalInterconnect $SasLogicalInterconnect -Available + + Get the drive enventory from the specified SAS logical interconnect. + + + + + + + + + + + + + Get-OVDriveEnclosure + + + + Get-OVLogicalJBOD + + + + New-OVLogicalJBOD + + + + Remove-OVLogicalJBOD + + + + Set-OVLogicalJBOD + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/storage/get-ovdriveenclosureinventory + + + + + + + + Get-OVEnclosure + + Retrieve Enclosure resource(s). + + Get + OVEnclosure + + + An enclosure (HPE c-Class BladeSystem enclosure or Synergy frame) is a physical structure with device bays supporting compute, networking, and storage building blocks. These building blocks share the enclosure's common power, cooling, and management infrastructure. + +This Cmdlet will get the managed and/or monitored enclosure resources from an appliance. This can include HPE BladeSystem c7000, HPE Synergy or HPE Superdome X enclosure resources. + +Minimum required privileges: Read only + + + + + Get-OVEnclosure + + Name + + The name of the enclosure hardware resource to be returned. All enclosure hardware resources will be returned if omitted. + + String + + + Scope + + Filter resources based on provided Scope membership. By default, all resources for the accounts Active Permissions will be displayed. Allowed values: + + * AllResources + * AllResourcesInScope + * HPEOneView.Appliance.ScopeCollection + * HPEOneView.Appliance.ConnectionPermission + + Object + + + Label + + Specify the label associated with resources. + + String + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + + + Get-OVEnclosure + + Name + + The name of the enclosure hardware resource to be returned. All enclosure hardware resources will be returned if omitted. + + String + + + Scope + + Filter resources based on provided Scope membership. By default, all resources for the accounts Active Permissions will be displayed. Allowed values: + + * AllResources + * AllResourcesInScope + * HPEOneView.Appliance.ScopeCollection + * HPEOneView.Appliance.ConnectionPermission + + Object + + + Label + + Specify the label associated with resources. + + String + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + + Report + + Generate report of enclosure, including device bays, interconnect bays, and reported firmware for components. + + SwitchParameter + + + + Get-OVEnclosure + + Name + + The name of the enclosure hardware resource to be returned. All enclosure hardware resources will be returned if omitted. + + String + + + Scope + + Filter resources based on provided Scope membership. By default, all resources for the accounts Active Permissions will be displayed. Allowed values: + + * AllResources + * AllResourcesInScope + * HPEOneView.Appliance.ScopeCollection + * HPEOneView.Appliance.ConnectionPermission + + Object + + + Label + + Specify the label associated with resources. + + String + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + + exportFile + + Full path and file name to save the output . + + String + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + Array + + (${Global:ConnectedSessions} | ? Default) + + + Label + + Specify the label associated with resources. + + String + + String + + False + + + Name + + The name of the enclosure hardware resource to be returned. All enclosure hardware resources will be returned if omitted. + + String + + String + + + + + Report + + Generate report of enclosure, including device bays, interconnect bays, and reported firmware for components. + + SwitchParameter + + SwitchParameter + + False + + + Scope + + Filter resources based on provided Scope membership. By default, all resources for the accounts Active Permissions will be displayed. Allowed values: + + * AllResources + * AllResourcesInScope + * HPEOneView.Appliance.ScopeCollection + * HPEOneView.Appliance.ConnectionPermission + + Object + + Object + + AllResourcesInScope + + + exportFile + + Full path and file name to save the output . + + String + + String + + + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + System.Object + + + + Enclosure Report + + + + + HPEOneView.Enclosure [System.Management.Automation.PSCustomObject] + + + + The matching enclosure hardware resources. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + $enclosures = Get-OVEnclosure + + Return all the enclosure hardware managed by this appliance. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + $enclosure = Get-OVEnclosure -Name "A" + + Return the enclosure hardware resource with name "A". + + + + + + + + + + -------------------------- EXAMPLE 3 -------------------------- + + + + Get-OVEnclosure + +Enclosure Name Serial Number Enclosure Model Rack Name State EG Populated Bays +-------------- ------------- --------------- --------- ----- -- -------------- +Encl1 SGH100X6J1 BladeSystem c7000 Enclosure G2 Rack-173 Monitored Default EG1 16/16 +Encl2 SGH102X6J1 BladeSystem c7000 Enclosure G2 Rack-173 Monitored Default EG1 9/16 + + Display a brief list of the enclosures managed or monitored by the appliance. + + + + + + + + + + -------------------------- EXAMPLE 4 -------------------------- + + + + Get-OVEnclosure -Name Encl1 -report + +Enclosure Name Serial Number Enclosure Model Rack Name FW Managed Baseline Name +-------------- ------------- --------------- --------- ---------- ------------- +Encl1 SGH100X6J1 BladeSystem c7000 Enclosure G2 Rack-173 False + +Licensing +--------- +OneView + +OA Bay Role IP Address Firmware Version +------ ---- ---------- ---------------- + 1 Active 172.18.1.11 4.01 April 01 2013 + 2 Standby 172.18.1.12 4.01 April 01 2013 + +Server Name Serial Number Model System ROM iLO Firmware Version Server Profile Licensing +----------- ------------- ----- ---------- -------------------- -------------- --------- +Encl1, bay 1 SGH100X5RN BL660c Gen8 I32 05/30/2012 iLO4 1.30 Jul 02 2013 No Profile OneView +Encl1, bay 11 SGH106X8RN BL460c Gen8 I27 09/30/2011 iLO4 1.30 Jul 02 2013 Profile 11 OneView +Encl1, bay 12 SGH107X8RN BL460c Gen8 I27 09/30/2011 iLO4 1.30 Jul 02 2013 Profile 12 OneView +Encl1, bay 13 SGH108X8RN BL460c Gen8 I27 09/30/2011 iLO4 1.30 Jul 02 2013 Profile 13 OneView +Encl1, bay 14 SGH109X8RN BL460c Gen8 I27 09/30/2011 iLO4 1.30 Jul 02 2013 Profile 14 OneView +Encl1, bay 15 SGH110X8RN BL460c Gen8 I27 09/30/2011 iLO4 1.30 Jul 02 2013 Profile 15 OneView +Encl1, bay 16 SGH111X8RN BL460c Gen8 I27 09/30/2011 iLO4 1.30 Jul 02 2013 Profile 16 OneView +Encl1, bay 2 SGH101X5RN BL660c Gen8 I32 05/30/2012 iLO4 1.30 Jul 02 2013 No Profile OneView +Encl1, bay 3 SGH100X8RN BL460c Gen8 I27 09/30/2011 iLO4 1.30 Jul 02 2013 test 2 OneView +Encl1, bay 4 SGH101X8RN BL460c Gen8 I27 09/30/2011 iLO4 1.30 Jul 02 2013 No Profile OneView +Encl1, bay 5 SGH102X8RN BL460c Gen8 I27 09/30/2011 iLO4 1.30 Jul 02 2013 No Profile OneView +Encl1, bay 6 SGH103X8RN BL460c Gen8 I27 09/30/2011 iLO4 1.30 Jul 02 2013 No Profile OneView +Encl1, bay 7 SGH104X8RN BL460c Gen8 I27 09/30/2011 iLO4 1.30 Jul 02 2013 No Profile OneView +Encl1, bay 8 SGH105X8RN BL460c Gen8 I27 09/30/2011 iLO4 1.30 Jul 02 2013 No Profile OneView + +Interconnect Name Module Serial Number Firmware Version +----------------- ------ ------------- ---------------- +Encl1, interconnect 1 HP VC FlexFabric 10Gb/24-Port Module WECFSED100 4.10 +Encl1, interconnect 2 HP VC FlexFabric 10Gb/24-Port Module WECFSED101 4.10 + + Interconnect Name Logical Interconnect State Status Consistency state +----- ----------------- -------------------- ----- ------ ----------------- + Encl1, interconnect 1 Encl1-LI Configured OK Consistent + Encl1, interconnect 2 Encl1-LI Configured OK Consistent + + + + Generate a report of Encl1. + + + + + + + + + + + + + Add-OVEnclosure + + + + Get-OVEnclosureGroup + + + + New-OVEnclosureGroup + + + + Remove-OVEnclosure + + + + Remove-OVEnclosureGroup + + + + Reset-OVEnclosureDevice + + + + Set-OVEnclosure + + + + Set-OVEnclosureActiveFLM + + + + Set-OVEnclosureGroup + + + + Update-OVEnclosure + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/servers/get-ovenclosure + + + + + + + + Get-OVEnclosureGroup + + Retrieve Enclosure Group resource(s). + + Get + OVEnclosureGroup + + + An enclosure group is a logical resource that defines a consistent configuration for an enclosure or a set of enclosures making up a logical enclosure. The network connectivity for an enclosure group is defined by the logical interconnect groups associated with the enclosure group. + +This Cmdlet will get all available enclosure group resources configured on an appliance. + +Minimum required privileges: Read only + + + + + Get-OVEnclosureGroup + + Name + + The name of the Enclosure Group resource to be returned. All enclosure group resources will be returned if omitted. + + String + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + + exportFile + + Full path and file name to save the output of Get-OVEnclosureGroup + + String + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + Array + + ${Global:ConnectedSessions} + + + Name + + The name of the Enclosure Group resource to be returned. All enclosure group resources will be returned if omitted. + + String + + String + + + + + exportFile + + Full path and file name to save the output of Get-OVEnclosureGroup + + String + + String + + + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + HPEOneView.EnclosureGroup [System.Management.Automation.PSCustomObject] + + + + Enclosure Group resource. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + $enclosures = Get-OVEnclosureGroup + + Return all the enclosure groups managed by this appliance. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + $enclosure = Get-OVEnclosureGroup "A" + + Return the enclosure group resource with name "A". + + + + + + + + + + + + + Add-OVEnclosure + + + + Get-OVEnclosure + + + + Get-OVLogicalEnclosure + + + + New-OVLogicalEnclosure + + + + New-OVEnclosureGroup + + + + Remove-OVEnclosure + + + + Remove-OVEnclosureGroup + + + + Set-OVEnclosureGroup + + + + Update-OVLogicalEnclosure + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/servers/get-ovenclosuregroup + + + + + + + + Get-OVEulaStatus + + Get the appliance end user license agreement (EULA) status. + + Get + OVEulaStatus + + + The appliance has a EULA (End-User License agreement) that you must accept before using the appliance for the first time. + +This Cmdlet supports an unauthenticated request. If attempting to get the EULA status of an appliance not yet configured, provide the IP Address or FQDN of the appliance. A temporary ApplianceConnection will be created then removed in the ${Global:ConnectedSessions} tracker. + +Minimum required privileges: None + + + + + Get-OVEulaStatus + + Appliance + + The FQDN, IP Address or HPEOneView.Appliance.Connection of an HPE OneView appliance must be provided. + + Object + + + + + + + Appliance + + The FQDN, IP Address or HPEOneView.Appliance.Connection of an HPE OneView appliance must be provided. + + Object + + Object + + + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + HPEOneView.Appliance.EulaStatus + + + + Object that returns the Appliance Name and if the EULA has been accepted with a boolean "Accepted" property. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVEulaStatus -Appliance myappliance.domain.com + +Appliance Accepted +--------- -------- +myappliance.domain.com False + + Get the EULA status from myappliance.domain.com + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + $Connection = Connect-OVMgmt -Appliance myappliance.domain.com -Username Administrator -Password MyPassw0rd +Get-OVEulaStatus -Appliance $Connection + +Appliance Accepted +--------- -------- +myappliance.domain.com False + + Connect to an appliance, then get the EULA status from myappliance.domain.com + + + + + + + + + + + + + Set-OVEulaStatus + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/get-oveulastatus + + + + + + + + Get-OVFabricManager + + Get configured fabric manager(s). + + Get + OVFabricManager + + + Fabric Managers is a resource manager in HPE OneView that enables integration of a Cisco ACI fabric (an external entity) with HPE Synergy. A fabric manager aligns HPE OneView resources as defined by Cisco Application Policy Infrastructure Controller (APIC) policies. It represents a remote Cisco APIC or an APIC cluster that manages a Cisco ACI fabric. + +You can operate a fabric manager after adding it in HPE OneView and configure a list of tenants to cover policies necessary for HPE Synergy and Cisco APIC integration. + +Remediation of networks, network sets, and logical interconnects Remediation is a process to convert a noncompliant health state of an HPE OneView resource to a compliant health state with respect to APIC policy definitions. + +The following conditions cause the fabric manager to be unable to synchronize with network policies: + + * One or more networks connected across uplink sets in a logical interconnect within HPE Synergy have the same VLAN tag + * The two networks are shared across tenants + +When a fabric manager is non compliant with APIC network policies, a software remediation enables a fabric manager to synchronize with network policies. A compliance report is generated immediately after adding a fabric manager and is updated again after remediation. The compliance report details actions that you can perform to remediate inconsistencies. There are indicators for compliant, noncompliant, and compliance-check progress for each resource. Every tenant has a list of consistent and inconsistent reports based on the compliance records generated for a tenant. An inconsistency appears in the form of an alert, which contains an action choice: auto-remediate or manual. If you choose to auto-remediate, an automatic update of the selected HPE OneView resource will initiate. + +Minimum required privileges: Read-only + + + + + Get-OVFabricManager + + Name + + Specify the fabric manager name to filter for. + + String + + + Label + + Specify the label associated with resources. + + String + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + Array + + (${Global:ConnectedSessions} | ? Default) + + + Label + + Specify the label associated with resources. + + String + + String + + + + + Name + + Specify the fabric manager name to filter for. + + String + + String + + + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + HPEOneView.Networking.FabricManager + + + + Configured fabric manager resource object. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVFabricManager + + Get all defined fabric managers. + + + + + + + + + + + + + Add-OVFabricManager + + + + Remove-OVFabricManager + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/networking/get-ovfabricmanager + + + + + + + + Get-OVFirmwareBundleUpdate + + Get available SPP/SSP updates from connected service. + + Get + OVFirmwareBundleUpdate + + + You can enable HPE OneView to automatically check for new service pack updates and notify you when they are available. A connected notification alert is generated when a scheduled or manual check for updates is run and a new service pack update is available from the HPE software depot. Enable the Check for updates setting using Set-OVFirmwareBundleUpdateSchedule to receive these connected notifications. + +This Cmdlet will return a list of available updates from the connected service. In order to download a new available baseline, the supportURL attribute of the update object can be used to open in your browser. + +Example: Get-OVApplianceUpdate | Select -First 1 | % { Start-Process $_.supportURL } + + + + + Get-OVFirmwareBundleUpdate + + GetLatestUpdates + + Use this switch to request the appliance pull down the latest available updates and return an updated list. + + SwitchParameter + + + ApplianceConnection + + Specify one or more HPEOneView.Appliance.Connection object(s) or Name property value(s). + +Default Value: ${Global:ConnectedSessions} | ? Default + + Object + + + + + + + ApplianceConnection + + Specify one or more HPEOneView.Appliance.Connection object(s) or Name property value(s). + +Default Value: ${Global:ConnectedSessions} | ? Default + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + GetLatestUpdates + + Use this switch to request the appliance pull down the latest available updates and return an updated list. + + SwitchParameter + + SwitchParameter + + + + + + + + + None. You cannot pipe objects to this cmdlet. + + + + + + + + + + + HPEOneView.Appliance.FirmwareBundleUpdate [System.Management.Automation.PSCustomObject] + + + + Object that represents the available update. + + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVFirmwareBundleUpdate + + + Return the list of available updates. + + + + + + + + + + + + + Get-OVFirmwareBundleUpdateSchedule + + + + Set-OVFirmwareBundleUpdateSchedule + + + + Online: + https://hpe-docs.gitbook.io/posh-hpeoneview/cmdlets/v9.00/appliance/get-ovfirmwarebundleupdate + + + + + + + + Get-OVFirmwareBundleUpdateSchedule + + Get the appliance update configuration and schedule state. + + Get + OVFirmwareBundleUpdateSchedule + + + You can enable HPE OneView to automatically check for new service pack updates and notify you when they are available. A connected notification alert is generated when a scheduled or manual check for updates is run and a new service pack update is available from the HPE software depot. Enable the Check for updates setting using Set-OVFirmwareBundleUpdateSchedule to receive these connected notifications. + +This Cmdlet will return the current schedule configuration of the appliance. If set to manual, use the Get-OVApplianceUpdate and the -GetLatestUpdates switch to instruct the appliance to connect to the HPE software depot for available updates. + + + + + Get-OVFirmwareBundleUpdateSchedule + + ApplianceConnection + + Specify one or more HPEOneView.Appliance.Connection object(s) or Name property value(s). + +Default Value: ${Global:ConnectedSessions} | ? Default + + Object + + + + + + + ApplianceConnection + + Specify one or more HPEOneView.Appliance.Connection object(s) or Name property value(s). + +Default Value: ${Global:ConnectedSessions} | ? Default + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + + + + + None. You cannot pipe objects to this cmdlet. + + + + + + + + + + + HPEOneView.Appliance.FirmwareBundleUpdateSchedule + + + + Class object with the appliance update schedule configuration and current status. + + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVFirmwareBundleUpdateSchedule + + + Get the appliance configured update method and applicable schedule. + + + + + + + + + + + + + Get-OVFirmwareBundleUpdate + + + + Set-OVFirmwareBundleUpdateSchedule + + + + Online: + https://hpe-docs.gitbook.io/posh-hpeoneview/cmdlets/v9.00/appliance/get-ovfirmwarebundleupdateschedule + + + + + + + + Get-OVFixMeInstallationLog + + Get fixme installation log file. + + Get + OVFixMeInstallationLog + + + This Cmdlet will Retrieve any fixme patch installation log files needed by HPE Support to analyze for installation completion or errors. + +Minimum required privileges: Infrastructure Administrator + + + + + Get-OVFixMeInstallationLog + + Location + + The directory location where to save the generated file to. If omitted, will use the current working directory. + + System.IO.DirectoryInfo + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Location + + The directory location where to save the generated file to. If omitted, will use the current working directory. + + System.IO.DirectoryInfo + + System.IO.DirectoryInfo + + + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + System.IO.FileInfo + + + + The downloaded log file. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVFixMeInstallationLog + + Get the fixme installation logs for the connected appliance. + + + + + + + + + + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/get-ovfixmeinstallationlog + + + + + + + + Get-OVHealthStatus + + Display appliance health. + + Get + OVHealthStatus + + + Display the HPE OneView appliance health status. This includes CPU, Memory and Disk Space. + +Minimum required privileges: Read-only + + + + + Get-OVHealthStatus + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + HPEOneView.Appliance.HealthStatus [System.Management.Automation.PSCustomObject] + + + + Appliance health report in table format. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVHealthStatus + + Get the HPE OneView appliance health. + + + + + + + + + + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/get-ovhealthstatus + + + + + + + + Get-OVIloSso + + Generate iLO SSO Token. + + Get + OVIloSso + + + Obtain an iLO SSO Token URL to authenticate to an iLO. If the server hardware is unsupported, the resulting URL will not use SSO and the iLO web interface will prompt for credentials. + +Note: this is not supported on G7 or earlier servers. + +The generated SSO object or URL can be used with other HPE libraries that support iLO session tokens. + +Minimum required privileges: Read-only. Know that your user account role within OneView will be mapped to a specific iLO role. Please review the HPE OneView online help for more information, searching for "Mapping of SSO roles". + + + + + Get-OVIloSso + + InputObject + + The Server Hardware or Server Profile resource object from Get-OVServer or Get-OVServerProfile. + + Object + + + RemoteConsoleOnly + + Generate an SSO URL Token for accessing the Remote Console. + + SwitchParameter + + + IloRestSession + + Generate an HPRESTCmdlets compliant IloSession object. + + SwitchParameter + + + SkipCertificateCheck + + Skips certificate validation checks that include all validations such as expiration, revocation, trusted root authority, etc. + +[WARNING]: Using this parameter is not secure and is not recommended. This switch is only intended to be used against known hosts using a self-signed certificate for testing purposes. Use at your own risk. + + SwitchParameter + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + + + Get-OVIloSso + + InputObject + + The Server Hardware or Server Profile resource object from Get-OVServer or Get-OVServerProfile. + + Object + + + IloRestSession + + Generate an HPRESTCmdlets compliant IloSession object. + + SwitchParameter + + + SkipCertificateCheck + + Skips certificate validation checks that include all validations such as expiration, revocation, trusted root authority, etc. + +[WARNING]: Using this parameter is not secure and is not recommended. This switch is only intended to be used against known hosts using a self-signed certificate for testing purposes. Use at your own risk. + + SwitchParameter + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + Array + + (${Global:ConnectedSessions} | ? Default) + + + IloRestSession + + Generate an HPRESTCmdlets compliant IloSession object. + + SwitchParameter + + SwitchParameter + + False + + + InputObject + + The Server Hardware or Server Profile resource object from Get-OVServer or Get-OVServerProfile. + + Object + + Object + + + + + RemoteConsoleOnly + + Generate an SSO URL Token for accessing the Remote Console. + + SwitchParameter + + SwitchParameter + + False + + + SkipCertificateCheck + + Skips certificate validation checks that include all validations such as expiration, revocation, trusted root authority, etc. + +[WARNING]: Using this parameter is not secure and is not recommended. This switch is only intended to be used against known hosts using a self-signed certificate for testing purposes. Use at your own risk. + + SwitchParameter + + SwitchParameter + + False + + + + + + + HPEOneView.ServerHardware [System.Management.Automation.PSCustomObject] + + + Server Hardware resource object. + + + + + HPEOneView.ServerProfile [System.Management.Automation.PSCustomObject] + + + Server Profile resource object. + + + + + + + + System.Management.Automation.PSCustomObject + + + + SSO Url Object + + + + + System.Array + + + + Multiple SSO URL objects. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + $SSOObjects = Get-OVServer | Get-OVIloSso + + Generate iLO SSO Objects for all managed server resources. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + $SSOObject = Get-OVServer -Name "Enc1, bay 1" | Get-OVIloSso + + Generate iLO SSO Object for the specified managed server resource. + + + + + + + + + + -------------------------- EXAMPLE 3 -------------------------- + + + + $SSOObject = Get-OVServerProfile -Name "My Server Profile" | Get-OVIloSso + + Generate iLO SSO Object for the specified managed server resource. + + + + + + + + + + -------------------------- EXAMPLE 4 -------------------------- + + + + $IloSession = Get-OVServer -Name "Enc1, bay 1" | Get-OVIloSso -IloRestSession + + Generate iLO SSO Object that can then be used with the HPRESTCmdlets. + + + + + + + + + + + + + Get-OVServer + + + + Get-OVServerProfile + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/servers/get-ovilosso + + + + + + + + Get-OVImageStreamerAppliance + + Retrieve HPE Synergy Image Streamer appliances. + + Get + OVImageStreamerAppliance + + + An Image Streamer appliance is an HPE Synergy add-on solution that forms an OS Deployment Server. An OS deployment server is a resource that enables you to deploy (install and configure) operating systems for use by servers. HPE OneView connects to an OS deployment server and configures it for deploying operating systems. +The default selection is HPE Synergy Image Streamer, when an Image Streamer is discovered in an HPE Synergy configuration. You can add only a single Image Streamer deployment server. The Image Streamer OS deployment server supports the deployment of plans that define the operating system artifacts necessary for server hardware operation. +Adding a deployment server causes Image Streamer appliances to be clustered and configured to manage OS deployment artifacts. +This Cmdlet will retrieve populated and discovered HPE Synergy Image Streamer appliances within the Synergy Management fabric. Image Streamer appliances can be in either a Claimed or Unclaimed state. Appliances will only belong in a single redundant High Availability (H/A) Pair, and all H/A pairs will participate within the same HPE Synergy OS Deployment Server. Redundant H/A pairs will automatically be created during the Create Logical Enclosure task. +Minimum required privileges: Read-only. + + + + + Get-OVImageStreamerAppliance + + Name + + Image Streamer resource name. Supported the * (asterisk) wildcard character. + + String + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Name + + Image Streamer resource name. Supported the * (asterisk) wildcard character. + + String + + String + + + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + System.Management.Automation.PSCustomObject [HPEOneView.Appliance.ImageStreamerAppliance] + + + + An HPE Synergy Image Streamer appliance object. + + + + + System.Collections.ArrayList<HPEOneView.Appliance.ImageStreamerAppliance> + + + + A collection of HPE Synergy Image Streamer appliance objects. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVImageStreamerAppliance + + List all HPE Synergy Image Streamer appliances. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Get-OVImageStreamerAppliance -Name "0000A66102, appliance 2" + + Retrieve the Image Streamer Appliance "0000A66102, appliance 2". + + + + + + + + + + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/servers/get-ovimagestreamerappliance + + + + + + + + Get-OVInterconnect + + Retrieve Interconnect resource(s). + + Get + OVInterconnect + + + Interconnects enable communication between the server hardware in the enclosure and the data center networks. Interconnects that are managed are put in a Configured state when the Synergy frame is configured by creating a logical enclosure. An unmanaged interconnect remains in the Monitored state when the Synergy frame is configured by creating a logical enclosure. +Retrieves a list of all Interconnects (Ethernet, FC, Converged Network, and/or SAS) or just specific ones via a query if the name parameter is provided. The output can be sent to a file using the Export parameter. +Minimum required privileges: Read-only + + + + + Get-OVInterconnect + + Name + + The name of the interconnect to retrieve. + + String + + + Scope + + Filter resources based on provided Scope membership. By default, all resources for the accounts Active Permissions will be displayed. Allowed values: + + * AllResources + * AllResourcesInScope + * HPEOneView.Appliance.ScopeCollection + * HPEOneView.Appliance.ConnectionPermission + + Object + + + Label + + Specify the label associated with resources. + + String + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + Export + + The full path and file name to export the contents retrieved from the call to Get-OVInterconnect. + + String + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Export + + The full path and file name to export the contents retrieved from the call to Get-OVInterconnect. + + String + + String + + + + + Label + + Specify the label associated with resources. + + String + + String + + False + + + Name + + The name of the interconnect to retrieve. + + String + + String + + + + + Scope + + Filter resources based on provided Scope membership. By default, all resources for the accounts Active Permissions will be displayed. Allowed values: + + * AllResources + * AllResourcesInScope + * HPEOneView.Appliance.ScopeCollection + * HPEOneView.Appliance.ConnectionPermission + + Object + + Object + + AllResourcesInScope + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + HPEOneView.Networking.Interconnect [System.Management.Automation.PSCustomObject] + + + + Single Interconnect object. + + + + + HPEOneView.Networking.SasInterconnect [System.Management.Automation.PSCustomObject] + + + + Single SAS Interconnect object. + + + + + System.Collections.ArrayList + + + + Multiple Interconnect objects. + + + + + An Interconnect or collection of Interconnects + + + + + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVInterconnect + + Returns all Interconnects managed by all connected appliances to standard output. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Get-OVInterconnect -Name "Encl1, Interconnect 1" + + Returns just the Encl1, Interconnect 1 Interconnect object to standard output. + + + + + + + + + + -------------------------- EXAMPLE 3 -------------------------- + + + + Get-OVInterconnect -exportFile "c:\myApplianceConfig\ICs.json" + + Returns the Get-OVInterconnect query results to the file c:\myApplianceConfig\ICs.json + + + + + + + + + + + + + Get-OVInterconnectType + + + + Reset-OVInterconnectNetOpPassword + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/networking/get-ovinterconnect + + + + + + + + Get-OVInterconnectNTPConfiguration + + Get the default time source policy for HPE Synergy interconnects. + + Get + OVInterconnectNTPConfiguration + + + When HPE OneView manages interconnect resources, it will automatically by default set the management processor NTP settings to external NTP servers applied within the logical interconnect group resource. Using this Cmdlet, you can get the current time synchronize policy of supported interconnects managed by the appliance. When the global policy is set to sync with external NTP servers, a property is added to the returned object called NTPServers. The array contains the appliance configured NTP server(s). + +Minimum required privileges: + + * Read-Only + + + + + Get-OVInterconnectNTPConfiguration + + ApplianceConnection + + Specify one or more HPEOneView.Appliance.Connection object(s) or Name property value(s). + +Default Value: ${Global:ConnectedSessions} | ? Default + + Object + + + + + + + ApplianceConnection + + Specify one or more HPEOneView.Appliance.Connection object(s) or Name property value(s). + +Default Value: ${Global:ConnectedSessions} | ? Default + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + + + + + None. You cannot pipe objects to this cmdlet. + + + + + + + + + + + HPEOneView.Appliance.GlobalSetting + + + + Object resource with the global setting value + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVInterconnectNTPConfiguration + + + Get the current intreconnect time source global policy setting. + + + + + + + + + + + + + Set-OVInterconnectNTPConfiguration + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/get-ovinterconnectntpconfiguration + + + + + + + + Get-OVInterconnectType + + Retrieve Interconnect Type resource(s). + + Get + OVInterconnectType + + + Interconnects enable communication between the server hardware in the enclosure and the data center networks. Interconnects and their configuration are derived from either a Logical Switch Group or Logical Interconnect Group. When configuring either resource, you will need to specify an interconnect type that is supported by the appliance. + +This Cmdlet will retrieve a list of all supported interconnect types (Ethernet, FC, Converged Network, and/or SAS) or specific ones via a query if the name parameter is provided. The output can be sent to a file using the Export parameter. + +Minimum required privileges: Read-only + + + + + Get-OVInterconnectType + + Name + + The name of the interconnect type model name to retrieve. + + String + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + Get-OVInterconnectType + + PartNumber + + The Part Number of an Interconnect Type to search for. + + String + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Name + + The name of the interconnect type model name to retrieve. + + String + + String + + + + + PartNumber + + The Part Number of an Interconnect Type to search for. + + String + + String + + + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + HPEOneView.Networking.InterconnectType [System.Management.Automation.PSCustomObject] + + + + Single Interconnect Type resource. + + + + + System.Collections.ArrayList <HPEOneView.Networking.InterconnectType> + + + + Multiple Interconnect Type resources or formatted table dispalying basic Interconnect Type information. + + + + + An Interconnect Type or collection of Interconnect Types. + + + + + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVInterconnectType + + Returns all Interconnect Types available from all connected appliances to standard output. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Get-OVInterconnect -Name "HP VC FlexFabric 10Gb/24-Port Module" + + Returns just the "HP VC FlexFabric 10Gb/24-Port Module" Interconnect Type object to standard output. + + + + + + + + + + -------------------------- EXAMPLE 3 -------------------------- + + + + Get-OVInterconnect -Partnumber "571956-B21" + + Returns just the partnumber "571956-B21" Interconnect Type object to standard output. + + + + + + + + + + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/networking/get-ovinterconnecttype + + + + + + + + Get-OVLabel + + Return created label resources. + + Get + OVLabel + + + Labels identify resources so you can organize them into groups. For example, you might want to identify the servers that are used primarily by the Finance team, or identify the storage systems assigned to the Asia/Pacific division. + +This Cmdlet will return all of the created labels on the specifed appliance. + + + + + Get-OVLabel + + Name + + The name of the Label to associate resources to. If Label does not exist, a new one will be created. + + String + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Name + + The name of the Label to associate resources to. If Label does not exist, a new one will be created. + + String + + String + + + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + HPEOneView.Appliance.Label + + + + Label resource. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVLabel + + Return all labels from the appliance. + + + + + + + + + + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/get-ovlabel + + + + + + + + Get-OVLdap + + List Global Authentication Directory settings. + + Get + OVLdap + + + You can configure HPE OneView to use an external enterprise directory service for user authentication. HPE OneView supports the following enterprise directory services: + + * Active Directory + * OpenLDAP + +When you use a directory service, directory users are granted HPE OneView permissions using their group membership in the directory. After defining a directory service, use the User and Groups screen to define permissions for directory groups. Directory groups are assigned one or more HPE OneView permissions. A directory user is assigned the HPE OneView permissions that represent the union of the permissions for all the directory groups that the user is a member of. Only after permissions are defined for directory groups, directory users are authenticated into the appliance. + +This Cmdlet will display the global authentication directory settings configured on the appliance. It will show if local logins are enabled, default authentication directory name, and configured authentication directory names. + +Minimum required privileges: Read-only + + + + + Get-OVLdap + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + Get-OVLdap + + Export + + Export the configured directories to individual files. + + SwitchParameter + + + Save + + Directory where the exported configured directories will be saved to. A filename of "{appliance_name}_globalSettings.json" will be created. + + String + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Export + + Export the configured directories to individual files. + + SwitchParameter + + SwitchParameter + + False + + + Save + + Directory where the exported configured directories will be saved to. A filename of "{appliance_name}_globalSettings.json" will be created. + + String + + String + + + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + HPEOneView.Appliance.AuthGlobalDirectoryConfiguration [System.Management.Automation.PSCustomObject] + + + + Global Authentication Settings object + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVLdap +Allow Local Login Default Directory Configured Directories +----------------- ----------------- ---------------------- +True domain1 {domain1, domain2} +True domain2 {domain1, domain2} + + View the Global Authentication Directory configuration for all connected appliances. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Get-OVLdap -export -save c:\directory + + Export the Global Authentication Directory configuration settings. + + + + + + + + + + + + + Add-OVLdapServer + + + + Disable-OVLdapLocalLogin + + + + Enable-OVLdapLocalLogin + + + + Get-OVLdapDirectory + + + + Get-OVLdapGroup + + + + New-OVLdapDirectory + + + + New-OVLdapGroup + + + + New-OVLdapServer + + + + Remove-OVLdapDirectory + + + + Remove-OVLdapGroup + + + + Remove-OVLdapServer + + + + Set-OVLdapDefaultDirectory + + + + Set-OVLdapGroupRole + + + + Show-OVLdapGroups + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/security/get-ovldap + + + + + + + + Get-OVLdapDirectory + + Get configured Authentication Directories + + Get + OVLdapDirectory + + + You can configure HPE OneView to use an external enterprise directory service for user authentication. HPE OneView supports the following enterprise directory services: + + * Active Directory + * OpenLDAP + +When you use a directory service, directory users are granted HPE OneView permissions using their group membership in the directory. After defining a directory service, use the User and Groups screen to define permissions for directory groups. Directory groups are assigned one or more HPE OneView permissions. A directory user is assigned the HPE OneView permissions that represent the union of the permissions for all the directory groups that the user is a member of. Only after permissions are defined for directory groups, directory users are authenticated into the appliance. + +This Cmdlet will retrieve the configured authentication directory(ies) configured on the appliance. + +Minimum required privileges: Read-only + + + + + Get-OVLdapDirectory + + Name + + The specific authentication directory name. + + String + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + +Default Value: ${Global:ConnectSessions} + + Object + + + + Get-OVLdapDirectory + + Export + + Export the configured directories to individual files. + + String + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + +Default Value: ${Global:ConnectSessions} + + Object + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + +Default Value: ${Global:ConnectSessions} + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Export + + Export the configured directories to individual files. + + String + + String + + + + + Name + + The specific authentication directory name. + + String + + String + + + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + HPEOneView.Appliance.AuthDirectory [System.Management.Automation.PSCustomObject] + + + + Authentication Directory settings object + + + + + System.Collections.ArrayList + + + + Multiple Authentication Directory settings objects + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVLdapDirectory + +Appliance Name Type Root Search Context Directory Servers +--------- ---- ---- ---- -------------- ----------------- +MyAppliance1 domain1 AD dc=domain1,dc=com ou=Admins,ou=domain1.. {dc1.domain1.com:636, dc2.domain1.com:636} +MyAppliance1 domain2 AD dc=domain2,dc=com ou=Admins,ou=domain2.. {dc1.domain2.com:636, 10.1.2.1:636} +MyAppliance2 domain1 AD dc=domain1,dc=com ou=Admins,ou=domain1.. {dc1.domain1.com:636, dc2.domain1.com:636} +MyAppliance2 domain2 AD dc=domain2,dc=com ou=Admins,ou=domain2.. {dc1.domain2.com:636, 10.1.2.1:636} + + View the configured authentication directories, for all connected appliances. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Get-OVLdap -export -save c:\directory + + Export the Global Directory Configuration settings. + + + + + + + + + + + + + New-OVLdapDirectory + + + + Remove-OVLdapDirectory + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/security/get-ovldapdirectory + + + + + + + + Get-OVLdapGroup + + List Directory Group role assignment. + + Get + OVLdapGroup + + + You can configure HPE OneView to use an external enterprise directory service for user authentication. HPE OneView supports the following enterprise directory services: + + * Active Directory + * OpenLDAP + +When you use a directory service, directory users are granted HPE OneView permissions using their group membership in the directory. After defining a directory service, use the User and Groups screen to define permissions for directory groups. Directory groups are assigned one or more HPE OneView permissions. A directory user is assigned the HPE OneView permissions that represent the union of the permissions for all the directory groups that the user is a member of. Only after permissions are defined for directory groups, directory users are authenticated into the appliance. + +This Cmdlet will display the configured directory groups on the appliance, and display their assigned role(s). + +Minimum required privileges: Read-only + + + + + Get-OVLdapGroup + + Name + + Configured Directory Group Name. If omitted, all configured Directory Groups will be displayed. + + String + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + Get-OVLdapGroup + + Export + + Export JSON content to file + + String + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Export + + Export JSON content to file + + String + + String + + + + + Name + + Configured Directory Group Name. If omitted, all configured Directory Groups will be displayed. + + String + + String + + + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + HPEOneView.Appliance.AuthDirectoryGroupRoleMapping [System.Management.Automation.PSCustomObject] + + + + Configured Directory Group role mapping + + + + + System.Collections.ArrayList + + + + Multiple configured Directory Group role mappings + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVLdapGroup + +Name Directory Roles +---- --------- ----- +My Directory Group1 domain1 {Storage administrator} +My Directory Group2 domain1 {Network administrator} + + Get list of configured Directory Groups. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Get-OVLdapGroup -Name "My Directory Group1" + +Name Directory Roles +---- --------- ----- +My Directory Group1 domain1 {Storage administrator} + + Display "My Directroy Group1" and the assigned roles. + + + + + + + + + + -------------------------- EXAMPLE 3 -------------------------- + + + + Get-OVLdapGroup -export C:\dir\directorygroups.json + + Export configured Directory Groups to c:\dir\directorygroups.json + + + + + + + + + + + + + New-OVLdapGroup + + + + Remove-OVLdapGroup + + + + Set-OVLdapGroupRole + + + + Show-OVLdapGroups + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/security/get-ovldapgroup + + + + + + + + Get-OVLicense + + Gets the installed licenses on the appliance. + + Get + OVLicense + + + HPE OneView requires a license for all server hardware that it manages or monitors. HPE Synergy requires fibre channel license for the Virtual Connect SE 40Gb F8 Module for Synergy. + +The following HPE OneView Advanced licenses provide support as listed below, and in addition, enable integration with other products. + + * HPE OneView Advanced + * Provides an HPE OneView Advanced license and an iLO Advanced license. + * This license is intended for server hardware and enclosures you want to manage with HPE OneView. + + * HPE OneView Advanced w/o iLO + * Provides an HPE OneView Advanced license only. + + This license is intended for server hardware you want to manage with HPE OneView. This license is for servers with iLOs that are already licensed, or server hardware for which you do not require an iLO license. + + An HPE OneView Advanced w/o iLO license provides support for all server hardware features on the appliance, with the following exceptions: + * Server hardware without an iLO Advanced license does not display utilization data. + * Rack mount servers without an iLO Advanced license cannot access the remote console. + + * HPE OneView Standard + * Provides an HPE OneView Standard license for all monitored server hardware. + + * This license is automatically selected: + * for the enclosure when adding a monitored enclosure + * for the server when adding a monitored server + * for all ProLiant G6 server blades or G7 BL680c server blades when adding a managed enclosure + +HPE OneView does not manage the hardware running with an HPE OneView Standard license. + +When you add an enclosure or rack mount server to the appliance, you must specify one of these licenses. + +When you add a rack manager, either the HPE OneView Standard license or the HPE OneView Advanced license is automatically applied based on the firmware version installed on the rack manager. + +If you purchase HPE OneView Advanced and HPE OneView Advanced w/o iLO licenses separately from the hardware (standalone, nonintegrated), you must add them to the HPE OneView license pool in order for them to be available to assign to your server hardware. + +This Cmdlet will retrieve licenses installed on the appliance. You can use this to get an inventory of what's installed and what licenses are consumed. + +Minimum required privileges: Read-only + + + + + Get-OVLicense + + Type + + Specify the type of License to retrieve. Valid options are "HP_ONE_VIEW" or "HP_ONE_VIEW_WO_ILO". + + String + + + State + + Specify the license state to retrieve. Valid options are "Unlicensed" or "Permanent". + + String + + + Summary + + Display a condensed summary view of the installed or required licenses. This does not return a License object that can be used with Remove-OVLicense. + + SwitchParameter + + + Report + + PARAMETER IS DEPRECATED. + +Generate a report of installed or required licenses, their type and assigned Nodes. + + SwitchParameter + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Report + + PARAMETER IS DEPRECATED. + +Generate a report of installed or required licenses, their type and assigned Nodes. + + SwitchParameter + + SwitchParameter + + False + + + State + + Specify the license state to retrieve. Valid options are "Unlicensed" or "Permanent". + + String + + String + + + + + Summary + + Display a condensed summary view of the installed or required licenses. This does not return a License object that can be used with Remove-OVLicense. + + SwitchParameter + + SwitchParameter + + False + + + Type + + Specify the type of License to retrieve. Valid options are "HP_ONE_VIEW" or "HP_ONE_VIEW_WO_ILO". + + String + + String + + + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + HPEOneView.Appliance.License + + + + HPE OneView License + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVLicense + +Product : HPE OneView Advanced +Type : Permanent +Capacity : 64 +Allocated : 30 +Available : 34 +Nodes : {Encl2, bay 7, Encl2, bay 4, Encl2, bay 13, Encl1, bay 8..} + + Retrieve all installed license objects on the connected appliance(s). + + + + + + + + + + + + + New-OVLicense + + + + Remove-OVLicense + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/get-ovlicense + + + + + + + + Get-OVLogicalEnclosure + + Retrieve Logical Enclosure resource(s). + + Get + OVLogicalEnclosure + + + A logical enclosure contains the configuration intended for a set of physical enclosures. Its initial values are taken from an enclosure group and applied to the physical enclosures. If the intended configuration in the logical enclosure does not match the actual configuration on the enclosures, the logical enclosure becomes inconsistent. Use the Logical Enclosures screen to manage firmware, create a support dump, and to apply updates made from the Enclosure Groups screen to the enclosures in the logical enclosure. + +A logical enclosure is automatically created when a c7000 enclosure is added. + +After Synergy frames are discovered automatically during hardware setup, you must manually create a logical enclosure. The logical enclosure must contain the number of Synergy frames that are connected together with interconnect link cables. For example, if you have three Synergy frames cabled together, create a logical enclosure that contains all three Synergy frames. + +This Cmdlet will retrieve a collection of Logical Enclosure resources, or a single Logical Enclosure with the specified name. + +Minimum required privileges: Read-only + + + + + Get-OVLogicalEnclosure + + Name + + The name of the Logical Enclosure resource to be returned. All Logical Enclosure resources will be returned if omitted. + + String + + + EnclosureGroup + + Filter resources based on provided EnclosureGroup association. + + Object + + + NonCompliant + + Filter resources based on their non-compliant state. + + SwitchParameter + + + Scope + + Filter resources based on provided Scope membership. By default, all resources for the accounts Active Permissions will be displayed. Allowed values: + + * AllResources + * AllResourcesInScope + * HPEOneView.Appliance.ScopeCollection + * HPEOneView.Appliance.ConnectionPermission + + Object + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + Array + + (${Global:ConnectedSessions} | ? Default) + + + EnclosureGroup + + Filter resources based on provided EnclosureGroup association. + + Object + + Object + + + + + Name + + The name of the Logical Enclosure resource to be returned. All Logical Enclosure resources will be returned if omitted. + + String + + String + + + + + NonCompliant + + Filter resources based on their non-compliant state. + + SwitchParameter + + SwitchParameter + + + + + Scope + + Filter resources based on provided Scope membership. By default, all resources for the accounts Active Permissions will be displayed. Allowed values: + + * AllResources + * AllResourcesInScope + * HPEOneView.Appliance.ScopeCollection + * HPEOneView.Appliance.ConnectionPermission + + Object + + Object + + AllResourcesInScope + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + HPEOneView.EnclosureGroup [System.Management.Automation.PSCustomObject] + + + + Single Enclosure Group + + + + + System.Collections.ArrayList + + + + Multiple Enclosure Groups + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVLogicalEnclosure + + Return all the Logical Enclosure resources managed by all appliances. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + $EnclosureGroup = Get-OVEnclosureGroup -Name CorpEG1 +Get-OVLogicalEnclosure -EnclosureGroup $EnclosureGroup + + Return the associated logical enclosures that were created from the specific enclosure group. + + + + + + + + + + + + + New-OVLogicalEnclosure + + + + Remove-OVLogicalEnclosure + + + + Set-OVLogicalEnclosure + + + + Update-OVLogicalEnclosure + + + + Update-OVLogicalEnclosureFirmware + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/servers/get-ovlogicalenclosure + + + + + + + + Get-OVLogicalInterconnect + + Retrieve Logical Interconnect resource(s). + + Get + OVLogicalInterconnect + + + A logical interconnect is a single administrative entity that consists of the configuration for a set of interconnects in a single enclosure or an HPE Synergy frame link topology, and includes: + + * The uplink sets, which connect to data center networks. + * The mapping of networks to physical uplink ports, which is defined by the uplink sets for a logical interconnect. + * The internal networks, which are used for server-to-server communications without traffic egressing any uplinks. + * The downlink ports, which connect through the enclosure midplane to the servers in the enclosure. + * The connections between interconnects, which are called stacking links. + * Stacking links can be internal cables (through the enclosure) or external cables between the external ports of interconnects. + +See the appropriate support or compatibility matrix on the Hewlett Packard Enterprise Information Library for the maximum number of networks that can be provisioned on a logical interconnect. + +A logical interconnect derives its configuration from a logical interconnect group, which serves as a template to ensure that the logical interconnects being created are configured consistently. + +For a server administrator, a logical interconnect represents the available networks through the interconnect uplinks and the interconnect downlink capabilities through a physical server?s interfaces. For a network administrator, a logical interconnect represents an Ethernet stacking configuration, aggregation layer connectivity, stacking topology, network reachability, statistics, and troubleshooting tools. + +This Cmdlet retrieves a list of all Logical Interconnect or just specific ones via a query if the name parameter is provided. The output can be sent to a file using the exportFile parameter. + +Minimum required privileges: Read-only + + + + + Get-OVLogicalInterconnect + + Name + + The name of the Logical Interconnect to retrieve. + + String + + + NonCompliant + + Filter resources based on their non-compliant state. + + SwitchParameter + + + Scope + + Filter resources based on provided Scope membership. By default, all resources for the accounts Active Permissions will be displayed. Allowed values: + + * AllResources + * AllResourcesInScope + * HPEOneView.Appliance.ScopeCollection + * HPEOneView.Appliance.ConnectionPermission + + Object + + + Label + + Specify the label associated with resources. + + String + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + Export + + The full path and file name to export the contents retrieved from the call to Get-OVLogicalInterconnect. + + String + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Export + + The full path and file name to export the contents retrieved from the call to Get-OVLogicalInterconnect. + + String + + String + + + + + Label + + Specify the label associated with resources. + + String + + String + + False + + + Name + + The name of the Logical Interconnect to retrieve. + + String + + String + + + + + NonCompliant + + Filter resources based on their non-compliant state. + + SwitchParameter + + SwitchParameter + + + + + Scope + + Filter resources based on provided Scope membership. By default, all resources for the accounts Active Permissions will be displayed. Allowed values: + + * AllResources + * AllResourcesInScope + * HPEOneView.Appliance.ScopeCollection + * HPEOneView.Appliance.ConnectionPermission + + Object + + Object + + AllResourcesInScope + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + HPEOneView.Networking.LogicalInterconnect [System.Management.Automation.PSCustomObject] + + + + Logical Interconnect resource object from Get-OVLogicalInterconnect + + + + + System.Collections.ArrayList <HPEOneView.Networking.LogicalInterconnect> + + + + Multiple Logical Interconnects + + + + + A Logical Interconnect or collection of Logical Interconnects + + + + + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVLogicalInterconnect + + Returns all Logical Interconnect defined on the appliance to standard output. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Get-OVLogicalInterconnect -Name "Production" + + Returns just the Production Logical Interconnect object to standard output. + + + + + + + + + + -------------------------- EXAMPLE 3 -------------------------- + + + + $myLogicalICs = Get-OVLogicalInterconnect -NonCompliant + + Returns non-compliant logical interconnect resources. + + + + + + + + + + -------------------------- EXAMPLE 4 -------------------------- + + + + Get-OVLogicalInterconnect -Export "c:\myApplianceConfig\LogicalInterconnects.json" + + Returns the query results to the file c:\myApplianceConfig\LogicalInterconnects.json + + + + + + + + + + + + + Disable-OVLogicalInterconnectPortMonitoring + + + + Enable-OVLogicalInterconnectPortMonitoring + + + + Get-OVLogicalInterconnectGroup + + + + Get-OVLogicalInterconnectPortMonitoring + + + + Install-OVLogicalInterconnectFirmware + + + + New-OVLogicalInterconnectGroup + + + + Remove-OVLogicalInterconnectGroup + + + + Show-OVLogicalInterconnectMacTable + + + + Update-OVLogicalInterconnect + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/networking/get-ovlogicalinterconnect + + + + + + + + Get-OVLogicalInterconnectGroup + + Retrieve Logical Interconnect Group resource(s). + + Get + OVLogicalInterconnectGroup + + + A logical interconnect group acts as a recipe for creating a logical interconnect representing the available networks, uplink sets, and interconnect settings for a set of physical interconnects in a set of enclosures. One or more logical interconnect groups are associated with an enclosure group and are used to define the logical interconnect configuration for every enclosure that is using that enclosure group. + +There are different kinds of logical interconnect groups: + + * A multiple-enclosure logical interconnect group must match the interconnect link topology within the set of linked enclosures. All bays must be properly populated in all enclosures in the interconnect link topology. A multiple-enclosure logical interconnect group must include a Virtual Connect SE 40Gb F8 Module for Synergy and/or a HPE Virtual Connect SE 100Gb F32 Module for HPE Synergy and the Interconnect Link Module configuration. + * Single-enclosure logical interconnect groups, such as an HPE Synergy Serial Attached SCSI (SAS) or HPE BladeSystem c7000 logical interconnect group, pertain only to the enclosure in which they are applied. A single-enclosure logical interconnect group can be applied to individual fabric module bays in individual enclosures in the HPE Synergy interconnect link topology or HPE BladeSystem c7000 enclosure. Virtual Connect SE Fibre Channel modules support single-enclosure logical interconnect groups. + +All references to a logical interconnect group by an enclosure group or logical interconnect must be removed before you can delete the logical interconnect group. + +This Cmdlet retrieves a list of all Logical Interconnect Group or just specific ones via a query if the name parameter is provided. The output can be sent to a file using the exportFile parameter. + +Minimum required privileges: Read-only + + + + + Get-OVLogicalInterconnectGroup + + Name + + The name of the Logical Interconnect Group to retrieve. + + String + + + Type + + Provide the type of Logical Interconnect Group to return. Omit to return all Logical Interconnect Group resources. + + String + + + Scope + + Filter resources based on provided Scope membership. By default, all resources for the accounts Active Permissions will be displayed. Allowed values: + + * AllResources + * AllResourcesInScope + * HPEOneView.Appliance.ScopeCollection + * HPEOneView.Appliance.ConnectionPermission + + Object + + + Label + + Specify the label associated with resources. + + String + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + + exportFile + + The full path and file name to export the contents retrieved from the call to Get-OVLogicalInterconnectGroup. + + String + + + + Get-OVLogicalInterconnectGroup + + InputObject + + Pipeline input resource generated from Wait-OVTaskComplete, or successfully completed Async Task resource object. + + Object + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + InputObject + + Pipeline input resource generated from Wait-OVTaskComplete, or successfully completed Async Task resource object. + + Object + + Object + + + + + Label + + Specify the label associated with resources. + + String + + String + + False + + + Name + + The name of the Logical Interconnect Group to retrieve. + + String + + String + + + + + Scope + + Filter resources based on provided Scope membership. By default, all resources for the accounts Active Permissions will be displayed. Allowed values: + + * AllResources + * AllResourcesInScope + * HPEOneView.Appliance.ScopeCollection + * HPEOneView.Appliance.ConnectionPermission + + Object + + Object + + AllResourcesInScope + + + Type + + Provide the type of Logical Interconnect Group to return. Omit to return all Logical Interconnect Group resources. + + String + + String + + + + + exportFile + + The full path and file name to export the contents retrieved from the call to Get-OVLogicalInterconnectGroup. + + String + + String + + + + + + + + + HPEOneView.Networking.LogicalInterconnectGroup [System.Management.Automation.PSCustomObject] + + + A logical interconnect resource. + + + + + + + + System.Collections.ArrayList + + + + A Logical Interconnect Group or collection of Logical Interconnect Groups + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVLogicalInterconnectGroup + + Returns all Logical Interconnect Groups defined on the appliance to standard output. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Get-OVLogicalInterconnectGroup -Name "Production" + + Returns just the Production Logical Interconnect Group object to standard output. + + + + + + + + + + -------------------------- EXAMPLE 3 -------------------------- + + + + $LigName = "VC FF Virt Prod" +$CreatedLig = New-OVLogicalInterconnectGroup -Name $LigName -bays @{1 = "FlexFabric";2 = "FlexFabric"} -EnableIgmpSnooping $True -InternalNetworks "VMMigration Network" | Wait-OVTaskComplete | Get-OVLogicalInterconnectGroup +$CreatedLig + +Name Enclosure Groups +---- ---------------- +VC FF Virt Prod + + Create a new Logical Interconnect Group resource, wait for the task to complete, then retrieve the created resource. + + + + + + + + + + -------------------------- EXAMPLE 4 -------------------------- + + + + Get-OVLogicalInterconnectGroup -exportFile "c:\myApplianceConfig\LogicaICGs.json" + + Returns the Get-OVLogicalInterconnectGroup query results to the file c:\myApplianceConfig\LogicaICGs.json + + + + + + + + + + + + + New-OVLogicalInterconnectGroup + + + + Remove-OVLogicalInterconnectGroup + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/networking/get-ovlogicalinterconnectgroup + + + + + + + + Get-OVLogicalInterconnectPortMonitoring + + Get port monitoring configuration from provided logical interconnect. + + Get + OVLogicalInterconnectPortMonitoring + + + Port monitoring enables you to send a copy of every Ethernet or Fibre Channel frame coming in and going out of a downlink (server-facing) port to another port. To evaluate network traffic between ports, you can connect debugging equipment, such as a network analyzer. This capability is important in a server environment where there is limited physical access to the network interfaces on the servers. + +Use this Cmdlet to get the current port monitoring configuration from a specified logical interconnect resource. + +NOTE: + + * You cannot use Virtual Connect to forward captured traffic to a server. For more information, see the HPE Virtual Connect for c-Class BladeSystem User Guide in the Hewlett Packard Enterprise Information Library. + * You can configure one network analyzer port (the uplink port) for up to 16 downlink server ports within a logical interconnect. + * The HPE Virtual Connect 16Gb 24-Port Fibre Channel Module monitors 1 downlink server port. + * HPE Virtual Connect 16Gb 24-Port Fibre Channel Module firmware must be 4.00 or later + +Minimum required privileges: Network administrator + + + + + Get-OVLogicalInterconnectPortMonitoring + + InputObject + + HPEOneView.Networking.LogicalInterconnect from Get-OVLogicalInterconnect. + + Object + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + Array + + (${Global:ConnectedSessions} | ? Default) + + + InputObject + + HPEOneView.Networking.LogicalInterconnect from Get-OVLogicalInterconnect. + + Object + + Object + + + + + + + + + HPEOneView.Networking.LogicalInterconnect [System.Management.Automation.PSCustomObject] + + + Logical Interconnect resource object from Get-OVLogicalInterconnect + + + + + + + + HPEOneView.Networking.LogicalInterconnect+PortMonitoringConfig + + + + The current port monitor configuration of the provided logical interconnect(s). + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVLogicalInterconnect -Name "Encl1-Default VC FF LIG" -ErrorAction Stop | Get-OVLogicalInterconnectPortMonitoring + + Get the port monitoring configuration from the specified Logical Interconnect. + + + + + + + + + + + + + Disable-OVLogicalInterconnectPortMonitoring + + + + Enable-OVLogicalInterconnectPortMonitoring + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/networking/get-ovlogicalinterconnectportmonitoring + + + + + + + + Get-OVLogicalJBOD + + Get defined logical JBODs. + + Get + OVLogicalJBOD + + + A logical JBOD is a group of physical drives that are dynamically defined as virtual drives. Logical JBOD uses the drives from the drive enclosures that are installed in the device bays of the enclosure and are associated with a SAS logical interconnect. You can assign or unassign a logical JBOD to a server hardware through the server profile. + +If the logical drive settings in the server profile indicate that the data in the logical JBOD is to be retained when you delete the server profile, then the data is retained and you can assign this logical JBOD to a different server profile. + +Using this Cmdlet will return defined logical JBOD resources from the connected appliance. + + + + + Get-OVLogicalJBOD + + Name + + Specify to filter resources by the specific name or wildcard search. + + String + + + Scope + + Filter resources based on provided Scope membership. By default, all resources for the accounts Active Permissions will be displayed. Allowed values: + + * AllResources + *AllResourcesInScope + * HPEOneView.Appliance.ScopeCollection + * HPEOneView.Appliance.ConnectionPermission + + Object + + + Label + + Specify the label associated with resources. + + String + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Label + + Specify the label associated with resources. + + String + + String + + + + + Name + + Specify to filter resources by the specific name or wildcard search. + + String + + String + + + + + Scope + + Filter resources based on provided Scope membership. By default, all resources for the accounts Active Permissions will be displayed. Allowed values: + + * AllResources + *AllResourcesInScope + * HPEOneView.Appliance.ScopeCollection + * HPEOneView.Appliance.ConnectionPermission + + Object + + Object + + AllResourcesInScope + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + HPEOneView.Storage.LogicalJBOD + + + + The defined logical JBOD resource from the appliance. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVLogicalJBOD + + Get the defined logical JBOD resources from an appliance. + + + + + + + + + + + + + Get-OVDriveEnclosure + + + + New-OVLogicalJBOD + + + + Remove-OVLogicalJBOD + + + + Set-OVLogicalJBOD + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/storage/get-ovlogicaljbod + + + + + + + + Get-OVLogicalSwitch + + Retrieve Logical Switch resources. + + Get + OVLogicalSwitch + + + A logical switch is added into HPE OneView as a managed or monitored logical switch. The logical switch can consist of a maximum of two physical top-of-rack switches (external to the HPE Synergy frame) configured in a single stacking domain. + +There is a connectivity limitation of one logical interconnect to one logical switch. Interconnects within a logical interconnect cannot be connected to more than one logical switch. + +A logical switch is based on a logical switch group configuration. If the logical switch transitions to an Inconsistent with group state (due to the changes in either the logical switch or the logical switch group), update the logical switch configuration based on the logical switch group to return to a consistent state. + +About assigning Arista switches to a logical switch (HPE Synergy only) + +You can create a logical switch with a maximum of two Arista switches. When there are two Arista switches in a logical switch, they must be in a multichassis link aggregation (MLAG) environment. MLAG must be configured on both the switches, and they must belong to the same MLAG domain. + +About assigning Cisco Nexus switches to a logical switch (HPE BladeSystem only) + +You can create a logical switch with a maximum of two Cisco Nexus switches. When there are two Cisco Nexus switches in a logical switch, they must be in a virtual PortChannel (vPC) environment. vPC must be configured on both the switches, and they must belong to the same vPC domain. + +A virtual PortChannel (vPC) allows links that are physically connected to two different switches to appear as a single port channel to a third switch. vPC domain ID, vPC primary MAC address, vPC member ID, vPC role in a vPC domain can be configured for Cisco Nexus switches. + +Stacking links can be set from the originating peer or the destination peer when two switches are participating in the vPC environment. Also, stacking links can be set to the destination end of the peer link between two vPC switches. + +About assigning rack connectivity modules to a logical switch + +You can create a logical switch that pairs two rack connectivity modules. You can assign rack servers and server profiles to the two rack connectivity modules that are associated with the logical switch. + +When rack servers are assigned to the rack connectivity modules that are associated with the logical switch, the following configurations are checked: + + * The rack servers are consistently connected with the two rack connectivity modules. + * The rack server is connected to the same port on both rack connectivity modules. + +If there are issues during the initial server profile assignment, validation errors are displayed during server profile creation. + +If the cabling configuration is changed after the server profile assignment, alerts are displayed on the Logical Switches, Server Profiles, and Switches screens as applicable. + +Stacking links can be set from the originating peer or from the destination peer when two switches are participating in the MLAG environment. + +Minimum required privileges: Read-only + + + + + Get-OVLogicalSwitch + + Name + + Name of the Logical Switch resource. Supports wildcard * character. + + String + + + Scope + + Filter resources based on provided Scope membership. By default, all resources for the accounts Active Permissions will be displayed. Allowed values: + + * AllResources + * AllResourcesInScope + * HPEOneView.Appliance.ScopeCollection + * HPEOneView.Appliance.ConnectionPermission + + Object + + + Label + + Specify the label associated with resources. + + String + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + + exportFile + + Save the Logical Switch resource(s) to the specified JSON file. + + String + + + + Get-OVLogicalSwitch + + InputObject + + Provide an HPEOneView.Appliance.TaskResource object and the Cmdlet will return the associated Logical Switch resource created from the New-OVLogicalSwitch Cmdlet. + + Object + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + InputObject + + Provide an HPEOneView.Appliance.TaskResource object and the Cmdlet will return the associated Logical Switch resource created from the New-OVLogicalSwitch Cmdlet. + + Object + + Object + + + + + Label + + Specify the label associated with resources. + + String + + String + + False + + + Name + + Name of the Logical Switch resource. Supports wildcard * character. + + String + + String + + + + + Scope + + Filter resources based on provided Scope membership. By default, all resources for the accounts Active Permissions will be displayed. Allowed values: + + * AllResources + * AllResourcesInScope + * HPEOneView.Appliance.ScopeCollection + * HPEOneView.Appliance.ConnectionPermission + + Object + + Object + + AllResourcesInScope + + + exportFile + + Save the Logical Switch resource(s) to the specified JSON file. + + String + + String + + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + Async Task resource object, from New-OVLogicalSwitch. + + + + + + + + HPEOneView.Networking.LogicalSwitch [System.Management.Automation.PSCustomObject] + + + + Single Logical Switch resource. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVLogicalSwitch + + Retrieve all Logical Switch resources from the default appliance connection. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Get-OVLogicalSwitch -Name MyLogicalSwitch1 + + Retrieve the specified MyLogicalSwitch1 resource from the default appliance connection. + + + + + + + + + + + + + Get-OVLogicalSwitchGroup + + + + New-OVLogicalSwitch + + + + New-OVLogicalSwitchGroup + + + + Remove-OVLogicalSwitch + + + + Remove-OVLogicalSwitchGroup + + + + Update-OVLogicalSwitch + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/networking/get-ovlogicalswitch + + + + + + + + Get-OVLogicalSwitchGroup + + Retrieve Logical Switch Group resources. + + Get + OVLogicalSwitchGroup + + + The logical switch group is a template for creating logical switches. Logical switches are an aggregation of up to two physical top-of-rack switches. + +Once constructed from a logical switch group, a logical switch continues to be associated with its logical switch group. Any change in consistency between the logical switch group and its associated logical switches is monitored and made visible on the associated logical switch screen in HPE OneView. + +A logical switch is added into HPE OneView as a managed or monitored logical switch. The logical switch can consist of a maximum of two physical top-of-rack switches (external to the HPE Synergy frame) configured in a single stacking domain. + +There is a connectivity limitation of one logical interconnect to one logical switch. Interconnects within a logical interconnect cannot be connected to more than one logical switch. + +A logical switch is based on a logical switch group configuration. If the logical switch transitions to an Inconsistent with group state (due to the changes in either the logical switch or the logical switch group), update the logical switch configuration based on the logical switch group to return to a consistent state. + +About assigning Arista switches to a logical switch (HPE Synergy only) + +You can create a logical switch with a maximum of two Arista switches. When there are two Arista switches in a logical switch, they must be in a multichassis link aggregation (MLAG) environment. MLAG must be configured on both the switches, and they must belong to the same MLAG domain. + +About assigning Cisco Nexus switches to a logical switch (HPE BladeSystem only) + +You can create a logical switch with a maximum of two Cisco Nexus switches. When there are two Cisco Nexus switches in a logical switch, they must be in a virtual PortChannel (vPC) environment. vPC must be configured on both the switches, and they must belong to the same vPC domain. + +A virtual PortChannel (vPC) allows links that are physically connected to two different switches to appear as a single port channel to a third switch. vPC domain ID, vPC primary MAC address, vPC member ID, vPC role in a vPC domain can be configured for Cisco Nexus switches. + +Stacking links can be set from the originating peer or the destination peer when two switches are participating in the vPC environment. Also, stacking links can be set to the destination end of the peer link between two vPC switches. + +About assigning rack connectivity modules to a logical switch + +You can create a logical switch that pairs two rack connectivity modules. You can assign rack servers and server profiles to the two rack connectivity modules that are associated with the logical switch. + +When rack servers are assigned to the rack connectivity modules that are associated with the logical switch, the following configurations are checked: + + * The rack servers are consistently connected with the two rack connectivity modules. + * The rack server is connected to the same port on both rack connectivity modules. + +If there are issues during the initial server profile assignment, validation errors are displayed during server profile creation. + +If the cabling configuration is changed after the server profile assignment, alerts are displayed on the Logical Switches, Server Profiles, and Switches screens as applicable. + +Stacking links can be set from the originating peer or from the destination peer when two switches are participating in the MLAG environment. + +This Cmdlet retrieves a list of all Logical Switch Groups or just specific ones via a query if the name parameter is provided. The output can be sent to a file using the exportFile parameter. + +Minimum required privileges: Read-only + + + + + Get-OVLogicalSwitchGroup + + Name + + The Logical Switch Group resource Name. Supports the * wildcard character. + + String + + + Scope + + Filter resources based on provided Scope membership. By default, all resources for the accounts Active Permissions will be displayed. Allowed values: + + * AllResources + * AllResourcesInScope + * HPEOneView.Appliance.ScopeCollection + * HPEOneView.Appliance.ConnectionPermission + + Object + + + Label + + Specify the label associated with resources. + + String + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + + exportFile + + Export the Logical Switch Group resource(s) to the specified JSON file. + + SwitchParameter + + + + Get-OVLogicalSwitchGroup + + InputObject + + The Async task object after a Logical Switch Group resource is created, the Cmdlet will return the associated object. + + Object + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + InputObject + + The Async task object after a Logical Switch Group resource is created, the Cmdlet will return the associated object. + + Object + + Object + + + + + Label + + Specify the label associated with resources. + + String + + String + + False + + + Name + + The Logical Switch Group resource Name. Supports the * wildcard character. + + String + + String + + + + + Scope + + Filter resources based on provided Scope membership. By default, all resources for the accounts Active Permissions will be displayed. Allowed values: + + * AllResources + * AllResourcesInScope + * HPEOneView.Appliance.ScopeCollection + * HPEOneView.Appliance.ConnectionPermission + + Object + + Object + + AllResourcesInScope + + + exportFile + + Export the Logical Switch Group resource(s) to the specified JSON file. + + SwitchParameter + + SwitchParameter + + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + Async task resource after a Logical Switch Group has been created. + + + + + + + + HPEOneView.Networking.LogicalSwitchGroup [System.Management.Automation.PSCustomObject] + + + + The async task resource object to monitor (if -Async was used) or results. + + + + + System.Collections.ArrayList <HPEOneView.Networking.LogicalSwitchGroup> + + + + Collection of Logical Switch Group resources. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVLogicalSwitchGroup + + Get all logical switch group resources found on the default appliance connection. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Get-OVLogicalSwitchGroup -Name "My Logical Switch Group Policy 1" + + Get the "My Logical Switch Group Policy 1" resource. + + + + + + + + + + + + + New-OVLogicalSwitchGroup + + + + Remove-OVLogicalSwitchGroup + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/networking/get-ovlogicalswitchgroup + + + + + + + + Get-OVLoginMessage + + Get appliance configured login message. + + Get + OVLoginMessage + + + Retrieve the current Login Message for the connected appliance(s). + + + + + Get-OVLoginMessage + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + HPEOneView.Appliance.LoginMessage + + + + If successful, returns a resource + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVLoginMessage +Appliance : hpov1.domain.com +Message : ************************************ + ***** WARNING ******** + ************************************ + This management appliance is a company owned asset and provided for the exclusive use of authorized personnel. Unauthorized use or + abuse of this system may lead to corrective action including termination, civil and/or criminal penalties. +Acknowledge : True + + +Appliance : hpov2.domain.com +Message : ************************************ + ***** WARNING ******** + ************************************ + This management appliance is a company owned asset and provided for the exclusive use of authorized personnel. Unauthorized use or + abuse of this system may lead to corrective action including termination, civil and/or criminal penalties. +Acknowledge : False + + Get the Login Message from all connected appliances. + + + + + + + + + + + + + Set-OVLoginMessage + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/get-ovloginmessage + + + + + + + + Get-OVManagedSan + + Retrieve Managed SAN resource(s). + + Get + OVManagedSan + + + SANs are Fibre Channel (FC) or Fibre Channel over Ethernet (FCoE) storage area networks that connect servers to storage systems. The possible states for SANs are: + + * Discovered - A SAN that is not associated with a network. SANs are automatically discovered when a SAN manager is added to HPE OneView. + * Managed - A SAN that is associated with one or more networks in HPE OneView. Only managed SANs can be configured to be automatically zoned by HPE OneView. + +Direct attach SANs + +HPE OneView creates a direct attach SAN (flat SAN) automatically when you configure an enclosure with a logical interconnect that contains a direct attach uplink set. HPE OneView names the direct attach SAN using the format <interconnect><uplink set>. The created SAN is a Fibre Channel (FC) direct attach SAN that is not zoned, and cannot be edited. + +NOTE: HPE OneView creates a SAN for each interconnect module that is connected to a direct attach Fibre Channel network. + +Zoning policy + +A SAN zone enables communication between devices connected to the SAN. SAN zoning policies determine how zoning should be configured on a SAN. SAN zoning policies define whether or not zoning is automated as well as the naming format of zones and aliases. In HPE OneView, you can specify the name format of the zones and aliases that will be created when you associate a storage volume to a server profile via a volume attachment. By specifying zone name and alias formats using text strings and server profile objects, you can create names that are meaningful and conform with your naming conventions. + +NOTE: HPE OneView performs zoning only when you add a connection to a server profile and attach a SAN storage volume to it. When you do this, HPE OneView will determine if the current zoning allows connectivity. If current zoning does not allow connectivity, HPE OneView will create the necessary zoning based on the specified zoning policy. + +Automate zoning + +Automated zoning enables HPE OneView to automatically create, edit, and delete zones on a zoned SAN when you attach storage volumes to servers through a volume attachment in a server profile. + + * Yes/True - Zoning is automated. HPE OneView takes full control of the zone naming and contents based on the zoning policy for the SAN. Use automated zoning when you want HPE OneView to configure new zones for volume attachments to server profiles. Existing zones are not modified unless the SAN storage attributes defined in a server profile change. + * No/False - Zoning is not modified by HPE OneView. You must manually manage zoning. + +This Cmdlet is used to display or list the discovered and available Managed SAN resources in the appliance once a supported SAN manager has been added to the appliance. + +Minimum required privileges: Read-only + + + + + Get-OVManagedSan + + Name + + Managed SAN Name to retrieve. + + String + + + Label + + Specify the label associated with resources. + + String + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + Array + + (${Global:ConnectedSessions} | ? Default) + + + Label + + Specify the label associated with resources. + + String + + String + + False + + + Name + + Managed SAN Name to retrieve. + + String + + String + + + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + HPEOneView.Storage.ManagedSan [System.Management.Automation.PSCustomObject] + + + + Single Resource + + + + + System.Collections.ArrayList + + + + Multiple Resources + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVManagedSan + +Name State Status Network Zoned Automated Zoning +---- ----- ------ ------- ----- ---------------- +Fabric A Ready OK BNA Managed Fabric A Zoned True + + Return all managed SAN resources. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Get-OVManagedSan -Name "Fabric A" + + Show the "Fabric A" Managed SAN resource object. + + + + + + + + + + + + + Get-OVSanZone + + + + Set-OVManagedSan + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/storage/get-ovmanagedsan + + + + + + + + Get-OVMigratableServer + + Establish connection to source appliance and retrieve a list of servers that are available to migrate. + + Get + OVMigratableServer + + + Migration transfers the management of rackmount servers along with their associated profiles, and copies dependent resources from one HPE OneView appliance to another appliance. This migration process does not impact the applications or workloads that are running on the server. + +You can consolidate one or more rackmount servers from multiple appliances into a single appliance to increase the server scale support. + +Supported migration paths + +You can use the migration utility that is available with the HPE OneView 7.0 appliance to migrate servers from: + + * HPE OneView 6.6, which is a long-term support (LTS) version, and + * other HPE OneView 7.0 or newer appliances + +Please see the HPE OneView online help "Migrating server hardware" help topic for more information and best practices. + +This Cmdlet will connect to the source appliance, in order to retrieve a list of supported and migratable servers. Use the returned list to then initiate the server migration process with the Invoke-OVMigrateServer Cmdlet. If there are no available servers to migrate, a non-trappable error is generated, which can be overridden using the -ErrorAction common switch parameter. + +Minimum required privileges: Infrastructure administrator and Server administrator + + + + + Get-OVMigratableServer + + Hostname + + IP Address or FQDN of the source appliance to migrate servers from. + + Object + + + Credential + + Parameter to provide credentials in order to authenticate to the source appliance. + + PSCredential + + + ApplianceConnection + + Specify one or more HPEOneView.Appliance.Connection object(s) or Name property value(s). + +Default Value: ${Global:ConnectedSessions} | ? Default + + Object + + + + + + + ApplianceConnection + + Specify one or more HPEOneView.Appliance.Connection object(s) or Name property value(s). + +Default Value: ${Global:ConnectedSessions} | ? Default + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Credential + + Parameter to provide credentials in order to authenticate to the source appliance. + + PSCredential + + PSCredential + + + + + Hostname + + IP Address or FQDN of the source appliance to migrate servers from. + + Object + + Object + + + + + + + + + None. You cannot pipe objects to this cmdlet. + + + + + + + + + + + HPEOneView.Servers.MigratableServer + + + + Class object of migratable server resources from Get-OVMigratableServer. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + $SourceServerMigrationHost = "appliance1.domain.com" + +$Credential = Get-Credential -Username myadminaccount + +# Get the list of migratable servers from the source appliance +$MigratableServers = Get-OVMigratableServer -Hostname $SourceServerMigrationHost -Credential $Credential + + +Name Model Status ServerProfileName +---- ----- ------ ----------------- +Server-33.domain.com ProLiant XL270d Gen10 OK NoProfile +Server-39.domain.com ProLiant DL560 Gen10 OK NoProfile + + Connect ot the specified appliance and return a list of migratable servers. + + + + + + + + + + + + + Invoke-OVMigrateServer + + + + Online: + https://hpe-docs.gitbook.io/posh-hpeoneview/cmdlets/v9.00/servers/get-ovmigratableserver + + + + + + + + Get-OVNetwork + + Retrieve Network resource(s). + + Get + OVNetwork + + + A virtual connect interconnect in an enclosure supports the following types of data center networks: + + * Fibre Channel for storage networks, including fabric-attach (SAN) Fibre Channel (FC) connections and direct-attach (Flat SAN) Fibre Channel connections. + * Ethernet for data networks, including tagged, untagged, or tunnel networks. + * Fibre Channel over Ethernet (FCoE) for storage networks where storage traffic is carried over a dedicated Ethernet VLAN. + +NOTE: The networking features described here apply to enclosures and servers only. The appliance does not monitor or manage the network features and hardware for rack mount servers or networking equipment outside the enclosures without using a supported logical switch or fabric manager. + +NOTE: You can associate a network to both an IPv4 subnet. + +The details of your networks and any alerts associated with them appear on the Networks screen. If no resources are listed, you must add a resource. See Create networks. + +About creating networks + +Before creating networks, be aware of the networking maximums. See the HPE OneView Support Matrix for more information. + +You can create networks before you add an enclosure, which is known as preprovisioning. + +About provisioning networks + +An Ethernet network is provisioned to an interconnect when the network is associated with an uplink set or internal networks in a logical interconnect. + +An FC or FCoE network is provisioned to an interconnect when the network is associated with an uplink set in a logical interconnect. + +An Ethernet and FCoE network must be provisioned to a logical interconnect and be consistent with the logical interconnect group to be deployed in a server profile connection. + +This Cmdlet is used to retrieve a collection of network resources which have the specified type and/or name. The default connection information is included in the returned network resources. + +Minimum required privileges: Read-only + + + + + Get-OVNetwork + + Name + + The name of the network resource to be returned. All network resources will be returned if omitted. Supports "*" wildcard character. + + String + + + Type + + The type of the network resource to be returned. Valid types are "Ethernet" for Ethernet networks, "FC" or "FibreChannel" for Fibre Channel networks. All network resources will be returned if omitted. + + String + + + Purpose + + Specify the Ethernet Purpose value to filter on. + +Supported Values: + + * General + * Management + * VMMigration + * FaultTolerance + * ISCSI + + Note: When using this parameter, only Ethernet networks will be returned. + + String + + + Scope + + Filter resources based on provided Scope membership. By default, all resources for the accounts Active Permissions will be displayed. Allowed values: + + * AllResources + * AllResourcesInScope + * HPEOneView.Appliance.ScopeCollection + * HPEOneView.Appliance.ConnectionPermission + + Object + + + Label + + Specify the label name the network resource is associated with. Cannot be combined with Name. + + String + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + exportFile + + The full path and file name to export the JSON formatted definition of the networks to a file. The directory for the file is validated prior to execution and the function returns an error is the directory does not exist. + + String + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Label + + Specify the label name the network resource is associated with. Cannot be combined with Name. + + String + + String + + + + + Name + + The name of the network resource to be returned. All network resources will be returned if omitted. Supports "*" wildcard character. + + String + + String + + + + + Purpose + + Specify the Ethernet Purpose value to filter on. + +Supported Values: + + * General + * Management + * VMMigration + * FaultTolerance + * ISCSI + + Note: When using this parameter, only Ethernet networks will be returned. + + String + + String + + + + + Scope + + Filter resources based on provided Scope membership. By default, all resources for the accounts Active Permissions will be displayed. Allowed values: + + * AllResources + * AllResourcesInScope + * HPEOneView.Appliance.ScopeCollection + * HPEOneView.Appliance.ConnectionPermission + + Object + + Object + + AllResourcesInScope + + + Type + + The type of the network resource to be returned. Valid types are "Ethernet" for Ethernet networks, "FC" or "FibreChannel" for Fibre Channel networks. All network resources will be returned if omitted. + + String + + String + + + + + exportFile + + The full path and file name to export the JSON formatted definition of the networks to a file. The directory for the file is validated prior to execution and the function returns an error is the directory does not exist. + + String + + String + + + + + + + + + System.String + + + Network Resource Name(s) + + + + + + + + HPEOneView.Networking.EthernetNetwork + + + + Single Ethernet Network resource + + + + + HPEOneView.Networking.FibreChannelNetwork + + + + Single Fibre Channel Network resource + + + + + HPEOneView.Networking.FCoENetwork + + + + Single FCoE Network resource + + + + + System.Collections.ArrayList + + + + Multiple Network Object resources + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + $net41 = Get-OVNetwork -name "Net-41" + + Return the network resource with the name "Net-41" + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + $ethNets = Get-OVNetwork -type Ethernet + + Return all the Ethernet network resources + + + + + + + + + + -------------------------- EXAMPLE 3 -------------------------- + + + + $ethNets = Get-OVNetwork -Name VLAN_19* + + Return all Ethernet Networks that match "VLAN_19*". + + + + + + + + + + -------------------------- EXAMPLE 4 -------------------------- + + + + $ethNets = "Net1","Net2","Net3" | Get-OVNetwork -Type Ethernet + + Return Net1, Net2, and Net3 Ethernet Networks from the specified appliance connection. + + + + + + + + + + -------------------------- EXAMPLE 5 -------------------------- + + + + Get-OVNetwork -exportFile "c:\myApplianceConfig\myNets.json" + + Exports all networks to the file myNets.json in JSON format. + + + + + + + + + + -------------------------- EXAMPLE 6 -------------------------- + + + + Get-OVNetwork -x "c:\myApplianceConfig\myNets.json" -type Ethernet + + Exports only the ethernet networks to the file myNets.json. + + + + + + + + + + -------------------------- EXAMPLE 7 -------------------------- + + + + Get-OVNetwork +Type: Ethernet + + +Name Type VLAN ID Purpose Smartlink Private Network Status Preferred Bandwidth Max Bandwidth +---- ---- ------- ------- --------- --------------- ------ ------------------- ------------- +VLAN 1-A Tagged 1 Management True False OK 2500 10000 +VLAN 1-B Tagged 1 Management True False OK 2500 10000 +VLAN 10-A Tagged 10 VMMigration True False OK 2500 10000 +VLAN 10-B Tagged 10 VMMigration True False OK 2500 10000 +VLAN 101-A Tagged 101 General True False OK 2500 10000 +VLAN 101-B Tagged 101 General True False OK 2500 10000 +VLAN 102-A Tagged 102 General True False OK 2500 10000 +VLAN 102-B Tagged 102 General True False OK 2500 10000 +VLAN 103-A Tagged 103 General True False OK 2500 10000 +VLAN 103-B Tagged 103 General True False OK 2500 10000 +VLAN 104-A Tagged 104 General True False OK 2500 10000 +VLAN 104-B Tagged 104 General True False OK 2500 10000 +VLAN 105-A Tagged 105 General True False OK 2500 10000 +VLAN 105-B Tagged 105 General True False OK 2500 10000 +VLAN 20-A Tagged 20 General True False OK 2500 10000 +VLAN 20-B Tagged 20 General True False OK 2500 10000 +VLAN 201-A Tagged 201 General True False OK 2500 10000 +VLAN 201-B Tagged 201 General True False OK 2500 10000 +VLAN 30-A Tagged 30 General True False OK 2500 10000 +VLAN 30-B Tagged 30 General True False OK 2500 10000 +VLAN 301-A Tagged 301 General True False OK 2500 10000 +VLAN 301-B Tagged 301 General True False OK 2500 10000 +VLAN 40-A Tagged 40 General True False OK 2500 10000 +VLAN 40-B Tagged 40 General True False OK 2500 10000 +VLAN 401-A Tagged 401 General True False OK 2500 10000 +VLAN 401-B Tagged 401 General True False OK 2500 10000 +VLAN 50-A Tagged 50 General True False OK 2500 10000 +VLAN 50-B Tagged 50 General True False OK 2500 10000 +VLAN 501-A Tagged 501 General True False OK 2500 10000 +VLAN 501-B Tagged 501 General True False OK 2500 10000 + + + Type: Fibre Channel + + +Name Status Type Typical Bandwidth Max Bandwidth Auto Login Redistribution Link Stability Interval +---- ------ ---- ----------------- ------------- ------------------------- ----------------------- +3PAR SAN DA A OK DirectAttach 4000 8000 False 0 +3PAR SAN DA B OK DirectAttach 4000 8000 False 0 +3PAR SAN Fabric A OK FabricAttach 4000 8000 True 30 +3PAR SAN Fabric B OK FabricAttach 4000 8000 True 30 + + + Type: FCoE + + +Name Status vlanId Typical Bandwidth Max Bandwidth Associated SAN +---- ------ ------ ----------------- ------------- -------------- +fcoe1 OK 134 2500 20000 +FCOE3 OK 11 2500 10000 +FCOE2 OK 10 2500 10000 +FCOE12 OK 12 2500 10000 + + Get all available networks. + + + + + + + + + + + + + Get-OVNetworkSet + + + + New-OVNetwork + + + + New-OVNetworkSet + + + + Remove-OVNetwork + + + + Remove-OVNetworkSet + + + + Set-OVNetwork + + + + Set-OVNetworkSet + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/networking/get-ovnetwork + + + + + + + + Get-OVNetworkSet + + Retrieve Network Set resource(s). + + Get + OVNetworkSet + + + A network set is a collection of tagged Ethernet networks that form a named group to simplify server profile creation. Network sets are useful in virtual environments where each server profile connection needs to access multiple networks. Use network sets in server profile connections to make all networks on a connection's downlink port available. Network sets define how packets will be delivered to the server when a server Ethernet connection is associated with the network set. Network sets also enable you to define a VLAN trunk and associate it with a server connection. + +Instead of assigning a single network to a connection in a server profile, you can assign a network set to that connection. + + * Using network sets, you can quickly deploy changes to the network environment to multiple servers. For example, you have 16 servers connected to a network set. To add a new network to all 16 servers, you only need to add it to the network set instead of each server individually. + * You can create a network set for your production networks and one for your development networks. + * You can configure a hypervisor with a vSwitch to access multiple VLANs by creating a network set as a trunk that includes these networks. + +Network set prerequisites + + * All networks in a network set must be Ethernet networks and must have unique external VLAN IDs. Untagged and tunnel networks are single networks and do not use network sets. + * All networks in a network set must be configured in the same appliance. + * A network can be a member of multiple network sets. + * All networks in a network set must be added to uplink sets or internal networks in the logical interconnect group (and its logical interconnects) to be used in server profiles with connections to the logical interconnect. + * A network set can be empty (contain no networks) or can contain one or more of the networks configured in the logical interconnect group and logical interconnect. Empty network sets enable you to create network sets in the configuration before you create the member networks, or to remove all the member networks before you add their replacements. However, if a server profile adds a connection to an empty network set, the server cannot connect to any data center networks using that connection. + +Network set types + +You can select either a Regular or Large network set type. You can deploy Large network sets on rack servers or using the HPE Virtual Connect SE 100Gb F32 Module for HPE Synergy. You cannot deploy Large network sets on blade servers. If the network set type is selected for blade server profiles or server profile templates, you cannot convert the network set type from Regular to Large. + +For rack or blade servers: Regular network sets can contain up to 162 networks. Large network sets can contain up to a maximum of 4,000 networks. Network sets with more than 4,000 networks are not supported on rack servers. VLANs with VLAN IDs above 4,000 are reserved for use by the HPE Composable Fabric Manager. +For HPE Synergy: Regular network sets can contain up to 1,000 networks. Large network sets can contain up to 4,094 networks minus the number of networks that are in the reserved VLAN range, which can range from 60 to 128 networks. The default is 128 networks. Generally, the maximum number of networks is 3,966 networks. A maximum of 60 distinct large network sets can be simultaneously deployed per logical interconnect. + +This Cmdlet is used to retrieve a collection of network set resources which have the specified type and/or name. The default connection information is included in the returned network resources. + +Minimum required privileges: Read-only + + + + + Get-OVNetworkSet + + Name + + The name of the Network Set to retrieve. + + String + + + Scope + + Filter resources based on provided Scope membership. By default, all resources for the accounts Active Permissions will be displayed. Allowed values: + + * AllResources + * AllResourcesInScope + * HPEOneView.Appliance.ScopeCollection + * HPEOneView.Appliance.ConnectionPermission + + Object + + + Label + + Specify the label associated with resources. + + String + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + Get-OVNetworkSet + + Name + + The name of the Network Set to retrieve. + + String + + + Scope + + Filter resources based on provided Scope membership. By default, all resources for the accounts Active Permissions will be displayed. Allowed values: + + * AllResources + * AllResourcesInScope + * HPEOneView.Appliance.ScopeCollection + * HPEOneView.Appliance.ConnectionPermission + + Object + + + Label + + Specify the label associated with resources. + + String + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + ExportFile + + The full path and file name to export the contents retrieved from the call to Get-OVNetworkSet. + + String + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + ExportFile + + The full path and file name to export the contents retrieved from the call to Get-OVNetworkSet. + + String + + String + + + + + Label + + Specify the label associated with resources. + + String + + String + + False + + + Name + + The name of the Network Set to retrieve. + + String + + String + + + + + Scope + + Filter resources based on provided Scope membership. By default, all resources for the accounts Active Permissions will be displayed. Allowed values: + + * AllResources + * AllResourcesInScope + * HPEOneView.Appliance.ScopeCollection + * HPEOneView.Appliance.ConnectionPermission + + Object + + Object + + AllResourcesInScope + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + HPEOneView.Networking.NetworkSet [System.Management.Automation.PSCustomObject] + + + + Single Network Set + + + + + System.Collections.ArrayList <HPEOneView.Networking.NetworkSet> + + + + Multiple Network Sets + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVNetworkSet + + Returns all Network Sets defined on the appliance to standard output. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Get-OVNetworkSet -Name "Production" + + Returns just the Production Network Set object to standard output. + + + + + + + + + + -------------------------- EXAMPLE 3 -------------------------- + + + + $myNetSets = Get-OVNetworkSet + + Returns the Get-OVNetworkSet query and stores it in the object $myNetSets + + + + + + + + + + -------------------------- EXAMPLE 4 -------------------------- + + + + Get-OVNetworkSet -exportFile "c:\myApplianceConfig\Network-Sets.json" + + Returns the Get-OVNetworkSet query results to the file c:\myApplianceConfig\Network-Sets.json + + + + + + + + + + + + + New-OVNetworkSet + + + + Remove-OVNetworkSet + + + + Set-OVNetworkSet + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/networking/get-ovnetworkset + + + + + + + + Get-OVOSDeploymentPlan + + Retrieve OS deployment server deployment plan. + + Get + OVOSDeploymentPlan + + + An OS Deployment Plan is a recipe on how to deploy and configure an operating system, which has been created and is managed from on the associated OS deployment server. It will contain custom attributes that are necessary to personalize the OS deployment plan. The supported OS deployment server is HPE Image Streamer for Synergy. + +Use this Cmdlet to return defined OS Deployment Plans on an HPE Synergy Image Streamer appliance. The resource object will also provide the custom attributes allowed. Use the Get-OVOSDeploymentPlanAttribute to return the collection object of attributes. + +Minimum required privileges: Read-only + + + + + Get-OVOSDeploymentPlan + + Name + + OS Deployment Plan name. Supports wildcard (*) character. + + String + + + Scope + + Filter resources based on provided Scope membership. By default, all resources for the accounts Active Permissions will be displayed. Allowed values: + + * AllResources + * AllResourcesInScope + * HPEOneView.Appliance.ScopeCollection + * HPEOneView.Appliance.ConnectionPermission + + Object + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Name + + OS Deployment Plan name. Supports wildcard (*) character. + + String + + String + + + + + Scope + + Filter resources based on provided Scope membership. By default, all resources for the accounts Active Permissions will be displayed. Allowed values: + + * AllResources + * AllResourcesInScope + * HPEOneView.Appliance.ScopeCollection + * HPEOneView.Appliance.ConnectionPermission + + Object + + Object + + AllResourcesInScope + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + HPEOneView.Appliance.OSDeploymentPlan + + + + An HPE Synergy Image Streamer OS Deployment plan object. + + + + + System.Collections.ArrayList<HPEOneView.Appliance.OSDeploymentPlan> + + + + A collection or HPE Synergy Image Streamer OS Deployment plan objects. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVOSDeploymentPlan + + Retrieve all defined OS Deployment Plans found on the appliance. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Get-OVOSDeploymentPlan -Name "My OS Deployment Plan" + + Retrieve the specified OS Deployment Plan on the appliance. + + + + + + + + + + + + + Get-OVOSDeploymentPlanAttribute + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/servers/get-ovosdeploymentplan + + + + + + + + Get-OVOSDeploymentPlanAttribute + + Get OS deployment plan parameters and attributes. + + Get + OVOSDeploymentPlanAttribute + + + An OS Deployment Plan is a recipe on how to deploy and configure an operating system, which has been created and is managed from on the associated OS deployment server. It will contain custom attributes that are necessary to personalize the OS deployment plan. The supported OS deployment server is HPE Image Streamer for Synergy. + +Use this Cmdlet to return defined OS deployment plan custom attributes from a specified OS deployment plan. + +Minimum required privileges: Read-only + + + + + Get-OVOSDeploymentPlanAttribute + + InputObject + + The OS Deployment Plan from Get-OVOSDeploymentPlan. + + Object + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + InputObject + + The OS Deployment Plan from Get-OVOSDeploymentPlan. + + Object + + Object + + + + + + + + + HPEOneView.Appliance.OSDeploymentPlan [System.Management.Automation.PSCustomObject] + + + The OS Deployment Plan from Get-OVOSDeploymentPlan. + + + + + + + + HPEOneView.ServerProfile.OSDeployment.OSDeploymentParameter + + + + The object contained the Name of the parameter, and its default Value. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVOSDeploymentPlan -Name "RHEL 7.2 OS" -ErrorAction Stop | Get-OVOSDeploymentPlanAttribute + + Return OS Deployment Plan parameters from the "RHEL 7.2 OS" deployment plan. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + $OSDeploymentAttributes = Get-OVOSDeploymentPlanAttributes -InputObject $MyDeploymentPlan +$OSDeploymentAttributes = $OSDeploymentAttributes | Where-Object name -NotMatch 'dns|gateway|ipaddress|netmask' +($OSDeploymentAttributes | Where-Object name -eq "NIC1.connectionid").value = 3 +($OSDeploymentAttributes | Where-Object name -eq "NIC1.networkuri").value = $I3SCon3.networkUri +($OSDeploymentAttributes | Where-Object name -eq "NIC1.constraint").value = 'dhcp' +($OSDeploymentAttributes | Where-Object name -eq "NIC1.dhcp").value = $true +($OSDeploymentAttributes | Where-Object name -eq "NIC2.connectionid").value = 4 +($OSDeploymentAttributes | Where-Object name -eq "NIC2.networkuri").value = $I3SCon4.networkUri +($OSDeploymentAttributes | Where-Object name -eq "NIC2.constraint").value = 'dhcp' +($OSDeploymentAttributes | Where-Object name -eq "NIC2.dhcp").value = $true + + Get OS deployment plan attributes, and set DHCP for the two network connections. + + + + + + + + + + + + + Get-OVOSDeploymentPlan + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/servers/get-ovosdeploymentplanattribute + + + + + + + + Get-OVOSDeploymentServer + + Retrieve HPE Synergy OS Deployment Server. + + Get + OVOSDeploymentServer + + + An OS deployment server is a resource that enables you to deploy (install and configure) operating systems for use by servers. HPE OneView connects to an OS deployment server and configures it for deploying operating systems. + +The default selection is HPE Synergy Image Streamer, when an Image Streamer is discovered in an HPE Synergy configuration. + +The HPE OneView Infrastructure administrator can add an OS deployment server. HPE OneView manages the OS deployment server after it is configured and displays the list of attributes, management settings, the OS deployment plans, and the server profiles that reference the available OS deployment plans. + +This Cmdlet will return the discovered OS deployment servers. + +Minimum required privileges: Read-only + + + + + Get-OVOSDeploymentServer + + Name + + OS deployment server resource name. Supported the * (asterisk) wildcard character. + + String + + + Label + + Specify the label associated with resources. + + String + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Label + + Specify the label associated with resources. + + String + + String + + False + + + Name + + OS deployment server resource name. Supported the * (asterisk) wildcard character. + + String + + String + + + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + HPEOneView.Appliance.OSDeploymentServer + + + + An HPE Synergy Image Streamer appliance object. + + + + + System.Collections.ArrayList<HPEOneView.Appliance.OSDeploymentServer> + + + + A collection of HPE Synergy Image Streamer appliance objects. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVOSDeploymentServer + + List all HPE Synergy OS Deployment servers. + + + + + + + + + + + + + New-OVOSDeploymentServer + + + + Remove-OVOSDeploymentServer + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/servers/get-ovosdeploymentserver + + + + + + + + Get-OVPendingUpdate + + Verify pending appliance update has been staged. + + Get + OVPendingUpdate + + + The appliance runs a combination of software and firmware. Maintaining up-to-date appliance software and firmware fixes problems, improves performance, and adds new features to the appliance. The appliance does not automatically notify you when an update is available. You must determine if an appliance update file has been released. + +To view the installed version of appliance firmware, use Get-OVVersion Cmdlet. + +Verify if a newer version of an appliance update file is available for download at www.hpe.com/info/hpeoneview/updates. + +Before you update the appliance, examine the HPE OneView Release Notes to learn about supported upgrade paths, new features delivered in the update, limitations, troubleshooting hints and tips, and if you must restart the appliance after it is updated. + +NOTE: When you download the appliance update file, a link to the HPE OneView Release Notes appears in the download dialog box. Hewlett Packard Enterprise recommends that you click the link to read, save, and print the information for future reference. Once the download starts, you cannot access the link again. + +When you install an appliance update, the appliance restarts and goes offline. When the appliance is offline, it does not affect the managed resources. The managed resources continue to operate while the appliance is offline. + +Minimum required privileges: Infrastructure administrator or Software administrator + + + + + Get-OVPendingUpdate + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + HPEOneView.Appliance.Update.Pending [System.Management.Automation.PSCustomObject] + + + + Pending appliance update + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVPendingUpdate + + Retrieve pending update from all connected appliance sessions. + + + + + + + + + + + + + Get-OVVersion + + + + Install-OVUpdate + + + + Remove-OVPendingUpdate + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/get-ovpendingupdate + + + + + + + + Get-OVPowerDevice + + Retrieve Power Device (iPDU) resource(s). + + Get + OVPowerDevice + + + Power delivery devices provide power to IT hardware. A typical power topology in a data center includes power delivery devices such as power feeds, breaker panels, branch circuits, and power distribution units (PDUs), as well as the load segments, outlet bars, and outlet components of these devices. Adding your power delivery devices to the appliance enables power management using thermal limits, rated capacity, and derated capacity. + +This Cmdlet will retrieve the following classes of devices: + + * Intelligent Power Distribution Units (iPDUs), which the appliance can automatically discover and control. + * Other power delivery devices that the appliance cannot discover. By manually adding these devices to the appliance, they become available for tracking, inventory, and power management purposes. + +Regardless of how power delivery devices are added to the appliance, the appliance automatically generates the same types of analysis (capacity, redundancy, and configuration). For iPDUs, the appliance gathers statistical data and reports errors. + +Connectivity and synchronization with the appliance + +The appliance monitors the connectivity status of iPDUs. If the appliance loses connectivity with an iPDU, an alert displays until connectivity is restored. The appliance will try to resolve connectivity issues and clear the alert automatically, but if it cannot, you must resolve the issue and manually refresh the iPDU to bring it in synchronization with the appliance. + +The appliance also monitors iPDU to remain synchronized with changes to hardware and power connections. However, some changes to devices made outside of the control of the appliance (from iLO or the OA, for example) may cause them to become out of synchronization with the appliance. You may have to manually refresh devices that lose synchronization with the appliance. + +NOTE: Hewlett Packard Enterprise recommends that you do not use iLO or the OA to make changes to a device. Making changes to a device from its iLO or OA could cause it to lose synchronization with the appliance. + +Minimum required privileges: Read-only + + + + + Get-OVPowerDevice + + Name + + The name of the power device resource to be returned. All power device resources will be returned if omitted. + + String + + + Type + + Filter the Power Delivery Device type. Allowed values: + + * HPIpduCore + * HPIpduAcModule + * LoadSegment + * HPIpduOutletBar + * HPIpduOutlet. + + String + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Name + + The name of the power device resource to be returned. All power device resources will be returned if omitted. + + String + + String + + + + + Type + + Filter the Power Delivery Device type. Allowed values: + + * HPIpduCore + * HPIpduAcModule + * LoadSegment + * HPIpduOutletBar + * HPIpduOutlet. + + String + + String + + + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + HPEOneView.PowerDeliveryDevice [System.Management.Automation.PSCustomObject] + + + + The matching power device resources + + + + + System.Collections.ArrayList <HPEOneView.PowerDeliveryDevice> + + + + The matching power device resources + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + $powerDevices = Get-OVPowerDevice + + Return all the power devices managed by this appliance. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + $powerDeviceA = Get-OVPowerDevice -Name "iPDU_A" + + Return the power device resource with name "iPDU_A". + + + + + + + + + + + + + Add-OVPowerDevice + + + + Add-OVPowerDeviceConnection + + + + New-OVPowerDevice + + + + Remove-OVPowerDevice + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/facilities/get-ovpowerdevice + + + + + + + + Get-OVPowerPotentialDeviceConnection + + Retrieve power device (mPDU/Rack PDU) potential connections. + + Get + OVPowerPotentialDeviceConnection + + + Obtain a collection of potential managed and unmanaged device power connections for the provided power device resource. The returned value(s) will include the potential power connections that can be manually associated when not using iPDU devices. + + + + + Get-OVPowerPotentialDeviceConnection + + PowerDevice + + The name of the power device resource. Can provide Name, URI or Object. + + Object + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + + + + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + PowerDevice + + The name of the power device resource. Can provide Name, URI or Object. + + Object + + Object + + + + + + + + + System.Management.Automation.PSCustomObject + + + Potential managed/unmanaged device Power Delivery Device connection object + + + + + + + + System.Collections.ArrayList + + + + Collection of matching potential power device connection objects + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVPowerDevice "iPDU_A" | Get-OVPowerPotentialDeviceConnection + + Return the potential power device connections for the "iPDU_A" power delivery device. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Get-OVPowerPotentialDeviceConnection "iPDU_A" + + Return the potential power device connections for the "iPDU_A" power delivery device. + + + + + + + + + + + + + Get-OVPowerDevice + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/facilities/get-ovpowerpotentialdeviceconnection + + + + + + + + Get-OVRack + + Retrieve a defined Rack. + + Get + OVRack + + + A rack is a physical structure that contains IT equipment such as enclosures, servers, power delivery devices, and unmanaged devices (an unmanaged device uses slots in the rack and consumes power or exhausts heat, but it is not managed by the appliance). You can manage your racks and the equipment in them by adding them to the appliance. Having your racks managed by the appliance enables you to use the appliance for space and power planning. The appliance also gathers statistical data and monitors the power and temperature of the racks it manages. When you add an enclosure to the appliance, it automatically creates a rack and places the enclosure in it. The appliance places into the rack all enclosures connected by management link cables. When enclosures are added, the appliance places them in the rack from top to bottom. When an enclosure is placed in an Intelligent Series Rack, the enclosure slots are automatically detected. For other racks, to accurately depict the layout of your enclosures within the rack you must edit the rack to place the enclosure in the proper slots. + +You can use the appliance to view and manage your rack configuration and power delivery topology. You can specify the physical dimensions of the rack (width, height, and depth), the number of U slots, and the location of each piece of equipment in the rack. You can specify the rack PDUs that provide power to the rack, and their physical position in the rack or on either side. You can also describe how the devices in the rack are connected to those PDUs. + +The appliance automatically discovers the rack height and rack model for a ProLiant server with Location Discovery Services and updates the physical locations of devices when they are relocated within and between racks for c7000 enclosures. + +This Cmdlet will retrieve all or a specific Rack resource object. + +Minimum required privileges: Read only + + + + + Get-OVRack + + Name + + Rack name. Supports wildcard (*) character. + + String + + + Datacenter + + Filter racks that are a member of a data center. Provide the data center object from Get-HPOVDatacenter Cmdlet. + + Object + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Datacenter + + Filter racks that are a member of a data center. Provide the data center object from Get-HPOVDatacenter Cmdlet. + + Object + + Object + + + + + Name + + Rack name. Supports wildcard (*) character. + + String + + String + + + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + HPEOneView.Facilities.Rack + + + + A Rack resource object. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVRack + + Retrieve all defined DataCenters on the appliance. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Get-OVRack -Name Rack22* + + Locate all racks objects that begin with "Rack22". + + + + + + + + + + + + + Add-OVRackToDataCenter + + + + Add-OVResourceToRack + + + + Get-OVRackMember + + + + New-OVRack + + + + Remove-OVRack + + + + Remove-OVRackMember + + + + Set-OVRackMemberLocation + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/facilities/get-ovrack + + + + + + + + Get-OVRackManager + + Get claimed rack manage resource. + + Get + OVRackManager + + + A rack manager platform is a multinode system. The nodes are housed within a rack or across racks, and are centrally managed by a management controller. The Rack Managers screen enables you to manage and visualize the physical location of rack manager platforms within a rack. + +A rack manager platform consists of the following: + + * One or more chassis - The chassis are individual nodes that are used to build logical components such as systems or partitions. Each chassis is a physical container for system components like the compute, storage, or network nodes. + + In an HPE Superdome Flex Server, the chassis are 5U nodes that represent the compute nodes with CPU, memory, I/O, power supplies, and fans. + + * One or more systems or partitions - The system is a logical entity that functions as a server, and runs a single instance of an operating system to host services. In HPE OneView, the partition is modeled as a server hardware resource. + + In an HPE Superdome Flex Server, the systems are also called partitions. A partition consists of one or more compute chassis that are interconnected through an ultra-fast fabric. Each partition starts with a base chassis and can be extended using expansion chassis to form a large system. + + * One or more managers - The manager component manages the rack manager platform, and hosts the management controller function. HPE OneView communicates with the rack manager through this management controller enabling system administration, control, and platform management of the rack manager platform. Some platforms have multiple manager components to support redundancy. + + In an HPE Superdome Flex Server, the manager component is called the Rack Management Controller (RMC). The RMC hosts the DMTF Redfish APIs. + + * One or more racks - The racks physically contain all the rack manager platform components. + +This Cmdlet will retrieve available rack managers added to the appliance. + +Minimum required privileges: Read-only + + + + + Get-OVRackManager + + Name + + Specify a resource name to filter for. + + String + + + Label + + Specify the label associated with resources. + + String + + + Scope + + Filter resources based on provided Scope membership. By default, all resources for the accounts Active Permissions will be displayed. Allowed values: + + * AllResources + *AllResourcesInScope + * HPEOneView.Appliance.ScopeCollection + * HPEOneView.Appliance.ConnectionPermission + + Object + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + Array + + (${Global:ConnectedSessions} | ? Default) + + + Label + + Specify the label associated with resources. + + String + + String + + + + + Name + + Specify a resource name to filter for. + + String + + String + + + + + Scope + + Filter resources based on provided Scope membership. By default, all resources for the accounts Active Permissions will be displayed. Allowed values: + + * AllResources + *AllResourcesInScope + * HPEOneView.Appliance.ScopeCollection + * HPEOneView.Appliance.ConnectionPermission + + Object + + Object + + AllResourcesInScope + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + HPEOneView.Servers.RackManager + + + + Rack manager resource object, with associated sub components like managers, chassis and rack. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVRackManager + + Get all added rack manager resources. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Get-OVRackManager -Name manager1.domain.com -ErrorAction Stop + + Get the specified rack manager resource. + + + + + + + + + + + + + Add-OVRackManager + + + + Remove-OVRackManager + + + + Update-OVRackManager + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/servers/get-ovrackmanager + + + + + + + + Get-OVRackMember + + Get a member device from a defined Rack. + + Get + OVRackMember + + + A rack is a physical structure that contains IT equipment such as enclosures, servers, power delivery devices, and unmanaged devices (an unmanaged device uses slots in the rack and consumes power or exhausts heat, but it is not managed by the appliance). You can manage your racks and the equipment in them by adding them to the appliance. Having your racks managed by the appliance enables you to use the appliance for space and power planning. The appliance also gathers statistical data and monitors the power and temperature of the racks it manages. When you add an enclosure to the appliance, it automatically creates a rack and places the enclosure in it. The appliance places into the rack all enclosures connected by management link cables. When enclosures are added, the appliance places them in the rack from top to bottom. When an enclosure is placed in an Intelligent Series Rack, the enclosure slots are automatically detected. For other racks, to accurately depict the layout of your enclosures within the rack you must edit the rack to place the enclosure in the proper slots. + +You can use the appliance to view and manage your rack configuration and power delivery topology. You can specify the physical dimensions of the rack (width, height, and depth), the number of U slots, and the location of each piece of equipment in the rack. You can specify the rack PDUs that provide power to the rack, and their physical position in the rack or on either side. You can also describe how the devices in the rack are connected to those PDUs. + +The appliance automatically discovers the rack height and rack model for a ProLiant server with Location Discovery Services and updates the physical locations of devices when they are relocated within and between racks for c7000 enclosures. + +This Cmdlet will return members within a specified rack. + +Minimum required privileges: Read only + + + + + Get-OVRackMember + + InputObject + + Rack resource from Get-OVRack. + + String + + + Name + + Name of a member within the Rack. Supports (*) wildcard character. + + String + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + InputObject + + Rack resource from Get-OVRack. + + String + + String + + + + + Name + + Name of a member within the Rack. Supports (*) wildcard character. + + String + + String + + + + + + + + + HPEOneView.Facilities.Rack + + + Rack resource object from Get-OVRack. + + + + + + + + HPEOneView.Facilities.RackMember + + + + The individual rack member resource object. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVRack -Name Rack-221 | Get-OVRackMember + + Retrieve all rack members from the specified rack. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + $Rack = Get-OVRack -Name Rack-221 +Get-OVRackMember -InputObject $Rack -Name ProdDL380* + + Retrieve rack members that begin with "ProdDL380" within the "Rack-221" rack resource. + + + + + + + + + + + + + Get-OVRack + + + + Remove-OVRackMember + + + + Set-OVRackMemberLocation + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/facilities/get-ovrackmember + + + + + + + + Get-OVRemoteSupport + + Retrieve appliance Remote Support configuration. + + Get + OVRemoteSupport + + + Register with Hewlett Packard Enterprise to allow automatic case creation for hardware failures on servers and enclosures and to enable Proactive Care. Once enabled, all eligible devices added in the future will be automatically enabled for remote support. + +Eligible devices are Gen8 and newer blades and enclosures. + +WARNING: Servers must be at iLO 2.1 firmware level or above to be enabled for remote support + +Hewlett Packard Enterprise will contact you to ship a replacement part or send an engineer for devices that are under warranty or support contract. + +Remote support enables Proactive Care services including Proactive Scan reports and Firmware/Software Analysis reports with recommendations that are based on collected configuration data. + +Remote support is secure. No business data is collected, only device-specific configuration and fault data. All communications are outbound only and use industry standard TLS encryption ensuring confidentiality and integrity of the information. + +Once the appliance is configured, it cannot be unauthorized or disabled. + +Use this Cmdlet to get the appliance"s current Remote Support configuration. This Cmdlet does not return device collection data or schedules. + +Minimum required privileges: Read-only + + + + + Get-OVRemoteSupport + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + Array + + (${Global:ConnectedSessions} | ? Default) + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + HPEOneView.Appliance.RemoteSupport.Configuration + + + + The setting object with updated parameters. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVRemoteSupport + +Appliance Enabled Company AutoEnableDevices MarketingOptIn InsightOnlineEnabled +--------- ------- ------- ----------------- -------------- -------------------- +myappliance.domain.com True MyCompany False False False + + Returns the existing Remote Support configuration of the appliance. + + + + + + + + + + + + + Disable-OVRemoteSupport + + + + Enable-OVRemoteSupport + + + + Get-OVRemoteSupportContact + + + + Get-OVRemoteSupportDataCollectionSchedule + + + + Get-OVRemoteSupportDefaultSite + + + + Get-OVRemoteSupportEntitlementStatus + + + + Get-OVRemoteSupportPartner + + + + Get-OVRemoteSupportSetting + + + + New-OVRemoteSupportContact + + + + New-OVRemoteSupportPartner + + + + Remove-OVRemoteSupportContact + + + + Remove-OVRemoteSupportPartner + + + + Set-OVRemoteSupport + + + + Set-OVRemoteSupportDataCollectionSchedule + + + + Set-OVRemoteSupportDefaultSite + + + + Set-OVRemoteSupportPrimaryContact + + + + Set-OVRemoteSupportSetting + + + + Start-OVRemoteSupportCollection + + + + Update-OVRemoteSupportEntitlement + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/get-ovremotesupport + + + + + + + + Get-OVRemoteSupportContact + + Retrieve configured Remote Support contacts. + + Get + OVRemoteSupportContact + + + Register with Hewlett Packard Enterprise to allow automatic case creation for hardware failures on servers and enclosures and to enable Proactive Care. Once enabled, all eligible devices added in the future will be automatically enabled for remote support. HPE OneView automatically checks if your hardware has a valid entitlement to Hewlett Packard Enterprise support. A valid entitlement is a Hewlett Packard Enterprise warranty or an active contract. If a valid entitlement to support is found, HPE OneView Remote Support opens a support case for a hardware failure. + +Eligible devices are Gen8 and newer blades and enclosures. + +WARNING: Servers must be at iLO 2.1 firmware level or above to be enabled for remote support + +Hewlett Packard Enterprise will contact you to ship a replacement part or send an engineer for devices that are under warranty or support contract. Hewlett Packard Enterprise uses contact information when a support case is created. + +You can add, remove, and specify primary and secondary contacts. Primary and secondary contacts are applied to the devices by default. + +Remote support enables Proactive Care services including Proactive Scan reports and Firmware/Software Analysis reports with recommendations that are based on collected configuration data. + +Remote support is secure. No business data is collected, only device-specific configuration and fault data. All communications are outbound only and use industry standard TLS encryption ensuring confidentiality and integrity of the information. + +Once the appliance is configured, it cannot be unauthorized or disabled. + +Use this Cmdlet to get the configured Remote Support contacts defined on the appliance. + +Minimum required privileges: Read-only + + + + + Get-OVRemoteSupportContact + + Name + + Full ("Bob Smith") or partial ("Bob*") name of the contact. When using partial names, please include the * (asterisk) wildcard character. + + String + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Name + + Full ("Bob Smith") or partial ("Bob*") name of the contact. When using partial names, please include the * (asterisk) wildcard character. + + String + + String + + + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + System.Management.Automation.PSCustomObject + + + + The configured Remote Support Contact. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVRemoteSupportContact + + List all configured Remote Support Contacts. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Get-OVRemoteSupportContact -Name "Bob*" + + List all contacts with the name Bob, using the * wildcard character. + + + + + + + + + + + + + Disable-OVRemoteSupport + + + + Enable-OVRemoteSupport + + + + New-OVRemoteSupportContact + + + + Remove-OVRemoteSupportContact + + + + Set-OVRemoteSupportPrimaryContact + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/get-ovremotesupportcontact + + + + + + + + Get-OVRemoteSupportDataCollectionSchedule + + Retrieve Remote Support Schedule settings on an appliance. + + Get + OVRemoteSupportDataCollectionSchedule + + + Remote support collects hardware diagnostic and system configuration information. It also stores administrator contact information. This information can be sent to Hewlett Packard Enterprise and used to troubleshoot and resolve system issues. + +Basic collection sends configuration information to Hewlett Packard Enterprise for analysis and proactive services in accordance with your warranty and service agreements. This data is transmitted every 30 days. + +Active health sends information about the server?s health, configuration, and run-time telemetry to Hewlett Packard Enterprise. This information is used to troubleshoot issues and closed-loop quality analysis. This data is transmitted every 7 days. + +To perform basic device monitoring, configuration and diagnostic collections, and to maintain the health of the remote support solution, on a periodic and event driven basis remote support sends certain information to Hewlett Packard Enterprise. This information is used in accordance with the Software License Documents (https://www.hpe.com/us/en/software/licensing) and the HPE Online Privacy Statement (https://www.hpe.com/us/en/privacy/ww-privacy-statement.html). + +To ensure that Hewlett Packard Enterprise can respond effectively to a required repair and to provide services and recommendations to reduce downtime, remote support collects service delivery information which includes device administrator contact details such as name, phone number, and email address, and site location information such as postal address. + +To properly identify monitored devices and to synchronize the local remote support software with the Hewlett Packard Enterprise support automation services, remote support sends periodic data to Hewlett Packard Enterprise which includes service delivery information as well as basic device identification information such as IP addresses, MAC addresses, hostname and FQDN. + +To automate service delivery when a failure is detected on a monitored device, remote support sends information about the failure event which includes diagnostic sense data, firmware information, model number, serial number, failure details, as well as service delivery information and basic device identifiers as mentioned above. + +Remote support sends detailed configuration, telemetry and diagnostic information to Hewlett Packard Enterprise. This information can be used by Hewlett Packard Enterprise for troubleshooting, repair and internal closed loop quality purposes. Configuration collections may be required to deliver additional services. Information sent to Hewlett Packard Enterprise varies by device type, but in addition to data noted above it can include component configuration, firmware versions, OS type and version, DNS configuration, Windows domain, and diagnostic information. Configuration, telemetry and diagnostic information can also be utilized by Hewlett Packard Enterprise or its affiliates to provide recommendations to optimize your environment and minimize downtime. You must provide permission to use this information in this manner by choosing to do so in the remote support. If you choose to 'Opt-In' to be contacted by Hewlett Packard Enterprise or your Hewlett Packard Enterprise authorized reseller to optimize your IT environment, Hewlett Packard Enterprise or Hewlett Packard Enterprise authorized resellers may use the collected configuration data to provide you with recommendations, and sell or deliver solutions, to optimize your IT environment. These providers may be located in countries other than your Hewlett Packard Enterprise IT hardware locations. Hewlett Packard Enterprise's providers are required to keep confidential information received from Hewlett Packard Enterprise and may use it only for the purpose of providing advisories and recommendations on behalf of Hewlett Packard Enterprise. You will have the option to specify your Hewlett Packard Enterprise authorized reseller(s) or support provider(s) during setup of remote support software. Only the Hewlett Packard Enterprise authorized resellers and support providers you associate with your devices can receive your configuration data to individually contact you for making IT environment recommendations, sell, or deliver solutions. + +Some of the information collected is also used for optional display in Insight Online. This information can be associated with your HPE Passport credentials and viewable by you in Insight Online. + +For more details on the data items transmitted, see the security white paper in the Insight Remote Support (http://www.hpe.com/info/insightremotesupport/docs) section. + +Use this Cmdlet to retrieve configured schedules to collect Remote Support logs. + +Minimum required privileges: Read-only + + + + + Get-OVRemoteSupportDataCollectionSchedule + + Type + + Specify the schedule type to modify. Allowed value is: + * AHS + *Basic +If no value is provided, both schedules will be returned. + + String + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Type + + Specify the schedule type to modify. Allowed value is: + * AHS + *Basic +If no value is provided, both schedules will be returned. + + String + + String + + + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + HPEOneView.Appliance.RemtoeSupport.Schedule [System.Management.Automation.PSCustomObject] + + + + The configured Remote Support data collection schedule. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVRemoteSupportDataCollectionSchedule + + Get the Remote Support data collection schedules. + + + + + + + + + + + + + Get-OVRemoteSupport + + + + Set-OVRemoteSupportDataCollectionSchedule + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/get-ovremotesupportdatacollectionschedule + + + + + + + + Get-OVRemoteSupportDefaultSite + + Retrieve Remote Support Default Site. + + Get + OVRemoteSupportDefaultSite + + + Register with Hewlett Packard Enterprise to allow automatic case creation for hardware failures on servers and enclosures and to enable Proactive Care. Once enabled, all eligible devices added in the future will be automatically enabled for remote support. + +Hewlett Packard Enterprise recommends enabling all features and benefits provided by HPE OneView Remote Support so you can receive fast, accurate 'phone home' support and service per your contractual terms with Hewlett Packard Enterprise. Hewlett Packard Enterprise securely collects your HPE IT hardware diagnostics, configuration and telemetry information to provide you with remote support and services. The data is handled and managed to respect your privacy. For more information, Hewlett Packard Enterprise's Privacy Statement can be found at http://privacy.hpe.com. + +Enabling Remote Support configures your devices being remotely supported to securely send support or service events, IT configuration information, diagnostic, and telemetry information to Hewlett Packard Enterprise, together with your support contact information. No other business information is collected and the data is managed according to the Hewlett Packard Enterprise's Privacy Statement. + +This Cmdlet will get the address of the data center where the devices are located for support. + +Minimum required privileges: Read-only + + + + + Get-OVRemoteSupportDefaultSite + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + System.Management.Automation.PSCustomObject + + + + Configured Remote Support default site. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVRemoteSupportDefaultSite + + Get the configured Remote Support default site. + + + + + + + + + + + + + Get-OVRemoteSupport + + + + Set-OVRemoteSupportDefaultSite + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/get-ovremotesupportdefaultsite + + + + + + + + Get-OVRemoteSupportEntitlementStatus + + Get Remote Support for a supported resource. + + Get + OVRemoteSupportEntitlementStatus + + + Remote support collects hardware diagnostic and system configuration information. It also stores administrator contact information. This information can be sent to Hewlett Packard Enterprise and used to troubleshoot and resolve system issues. + +Basic collection sends configuration information to Hewlett Packard Enterprise for analysis and proactive services in accordance with your warranty and service agreements. This data is transmitted every 30 days. + +Active health sends information about the server?s health, configuration, and run-time telemetry to Hewlett Packard Enterprise. This information is used to troubleshoot issues and closed-loop quality analysis. This data is transmitted every 7 days. + +To perform basic device monitoring, configuration and diagnostic collections, and to maintain the health of the remote support solution, on a periodic and event driven basis remote support sends certain information to Hewlett Packard Enterprise. This information is used in accordance with the Software License Documents (https://www.hpe.com/us/en/software/licensing) and the HPE Online Privacy Statement (https://www.hpe.com/us/en/privacy/ww-privacy-statement.html). + +To ensure that Hewlett Packard Enterprise can respond effectively to a required repair and to provide services and recommendations to reduce downtime, remote support collects service delivery information which includes device administrator contact details such as name, phone number, and email address, and site location information such as postal address. + +To properly identify monitored devices and to synchronize the local remote support software with the Hewlett Packard Enterprise support automation services, remote support sends periodic data to Hewlett Packard Enterprise which includes service delivery information as well as basic device identification information such as IP addresses, MAC addresses, hostname and FQDN. + +To automate service delivery when a failure is detected on a monitored device, remote support sends information about the failure event which includes diagnostic sense data, firmware information, model number, serial number, failure details, as well as service delivery information and basic device identifiers as mentioned above. + +Remote support sends detailed configuration, telemetry and diagnostic information to Hewlett Packard Enterprise. This information can be used by Hewlett Packard Enterprise for troubleshooting, repair and internal closed loop quality purposes. Configuration collections may be required to deliver additional services. Information sent to Hewlett Packard Enterprise varies by device type, but in addition to data noted above it can include component configuration, firmware versions, OS type and version, DNS configuration, Windows domain, and diagnostic information. Configuration, telemetry and diagnostic information can also be utilized by Hewlett Packard Enterprise or its affiliates to provide recommendations to optimize your environment and minimize downtime. You must provide permission to use this information in this manner by choosing to do so in the remote support. If you choose to 'Opt-In' to be contacted by Hewlett Packard Enterprise or your Hewlett Packard Enterprise authorized reseller to optimize your IT environment, Hewlett Packard Enterprise or Hewlett Packard Enterprise authorized resellers may use the collected configuration data to provide you with recommendations, and sell or deliver solutions, to optimize your IT environment. These providers may be located in countries other than your Hewlett Packard Enterprise IT hardware locations. Hewlett Packard Enterprise's providers are required to keep confidential information received from Hewlett Packard Enterprise and may use it only for the purpose of providing advisories and recommendations on behalf of Hewlett Packard Enterprise. You will have the option to specify your Hewlett Packard Enterprise authorized reseller(s) or support provider(s) during setup of remote support software. Only the Hewlett Packard Enterprise authorized resellers and support providers you associate with your devices can receive your configuration data to individually contact you for making IT environment recommendations, sell, or deliver solutions. + +Some of the information collected is also used for optional display in Insight Online. This information can be associated with your HPE Passport credentials and viewable by you in Insight Online. + +For more details on the data items transmitted, see the security white paper in the Insight Remote Support (http://www.hpe.com/info/insightremotesupport/docs) section. + +This Cmdlet will return the Remote Support entitlement status for a compute or enclosure resource. If remote support has not been globally enabled and configured on the appliance, this Cmdlet will fail. + +Minimum required privileges: Read-only + + + + + Get-OVRemoteSupportEntitlementStatus + + InputObject + + The compute or enclosure resource to enable Remote Support for. + + Object + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + InputObject + + The compute or enclosure resource to enable Remote Support for. + + Object + + Object + + + + + + + + + HPEOneView.ServerHardware [System.Management.Automation.PSCustomObject] + + + A Gen8 or newer generation server hardware resource object from Get-OVServer. + + + + + HPEOneView.Enclosure [System.Management.Automation.PSCustomObject] + + + A Gen8 or newer generation server hardware resource object from Get-OVServer. + + + + + + + + HPEOneView.RemoteSupport.ContractAndWarrantyStatus + + + + The object with the current contract and warranty status. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVServer -Name Prod* | Get-OVRemoteSupportEntitlementStatus + + Get the servers with their name matching "Prod" and get their Remote Support entitlement status. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + $Enclosure = Get-OVEnclosure -Name Enclosure-1A +Get-OVRemoteSupportEntitlementStatus -InputObject $Enclusre + + Get the specific enclosure resource and get Remote Support entitlement status. + + + + + + + + + + + + + Get-OVEnclosure + + + + Get-OVRemoteSupport + + + + Get-OVServer + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/get-ovremotesupportentitlementstatus + + + + + + + + Get-OVRemoteSupportPartner + + Retrieve defined Support and Reseller partners. + + Get + OVRemoteSupportPartner + + + The Partner ID uniquely identifies a partner as an HPE Authorized Partner. Hewlett Packard Enterprise is the default channel partner if no other channel partner is assigned. + +HPE Authorized Resellers + +By enabling remote support, you enable the reseller to access configuration reports and contract warranty reports in Insight Online in the HPE Support Center, as well as configuration details and some contract and warranty details. + +HPE Authorized Service Partners + +In addition to the above information provided to Authorized Resellers, the Service Partner has access to service event status and reports, with links into the HPE Channel Services Network portal. + +Use this Cmdlet to Retrieve defined Remote Support partners that are authorized HPE Resellers and/or Support. + +Minimum required privileges: Read-only + + + + + Get-OVRemoteSupportPartner + + Name + + Name of the HPE Partner. + + String + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Name + + Name of the HPE Partner. + + String + + String + + + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + HPEOneView.Appliance.RemoteSupport.Partner [System.Management.Automation.PSCustomObject] + + + + Defined HPE authorized reseller and/or support partners. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVRemoteSupportPartner + + Get all configured report support partners. + + + + + + + + + + + + + Get-OVRemoteSupport + + + + New-OVRemoteSupportPartner + + + + Remove-OVRemoteSupportPartner + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/get-ovremotesupportpartner + + + + + + + + Get-OVRemoteSupportPortalConnectionStatus + + Get appliance connection status to HPE Support Center + + Get + OVRemoteSupportPortalConnectionStatus + + + The Hewlett Packard Enterprise Support Center (HPESC) integration enables you to securely register the HPE OneView Remote Support client with your HPESC group. It can be a private or shared group. Registering remote support with HPESC improves case visibility for the cases originating from the client. After registration, all the group members can view the cases originating from the client. + +This feature provides an improvement over the existing contact-based access. It does not require explicit contact matching and allows you to share case content with all the HPESC group members. + +Use this Cmdlet to get the current portal registration status. To establish a secure connection, you use Register-OVRemoteSupportPortalConnection Cmdlet. To disconnect the appliance connection to the HPE Support Center, use the Unregister-OVRemoteSupportPortalConnection Cmdlet. + +You can also view the connection details on the My Remote Support Connections page in HPESC. + +If the appliance has not completed registration, you can retrieve the token with the -GetGeneratedToken switch parameter. + + + + + Get-OVRemoteSupportPortalConnectionStatus + + GetGeneratedToken + + Use to return the current token used to onboard the appliance to the HPE Support Center. + + SwitchParameter + + + ApplianceConnection + + Specify one or more HPEOneView.Appliance.Connection object(s) or Name property value(s). + +Default Value: ${Global:ConnectedSessions} | ? Default + + Object + + + + + + + ApplianceConnection + + Specify one or more HPEOneView.Appliance.Connection object(s) or Name property value(s). + +Default Value: ${Global:ConnectedSessions} | ? Default + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + GetGeneratedToken + + Use to return the current token used to onboard the appliance to the HPE Support Center. + + SwitchParameter + + SwitchParameter + + + + + + + + + None. You cannot pipe objects to this cmdlet. + + + + + + + + + + + HPEOneView.Appliance.RemoteSupport.PortalConnectionToken + + + + If the -GetGeneratedToken switch parameter is used, return the generated token class. + + + + + + HPEOneView.Appliance.RemoteSupport.PortalConnection + + + + The current appliance secure connection status to the HPE Support Center. + + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVRemoteSupportPortalConnectionStatus + + + Get the appliances current connection status to the HPE Support Center. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Get-OVRemoteSupportPortalConnectionStatus -GetGeneratedToken + + + Get the appliances generated token. If still valid, can be used to complet appliance registration in the HPE Support Center. + + + + + + + + + + + + + Online: + https://hpe-docs.gitbook.io/posh-hpeoneview/cmdlets/v9.00//get-ovremotesupportportalconnectionstatus + + + + + + + + Get-OVRemoteSupportSetting + + Get supported resource Remote Support settings. + + Get + OVRemoteSupportSetting + + + Register with Hewlett Packard Enterprise to allow automatic case creation for hardware failures on servers and enclosures and to enable Proactive Care. Once enabled, all eligible devices added in the future will be automatically enabled for remote support. + +Eligible devices are Gen8 and newer blades and enclosures. + +WARNING: Servers must be at iLO 2.1 firmware level or above to be enabled for remote support + +Hewlett Packard Enterprise will contact you to ship a replacement part or send an engineer for devices that are under warranty or support contract. + +Remote support enables Proactive Care services including Proactive Scan reports and Firmware/Software Analysis reports with recommendations that are based on collected configuration data. + +Remote support is secure. No business data is collected, only device-specific configuration and fault data. All communications are outbound only and use industry standard TLS encryption ensuring confidentiality and integrity of the information. + +Once the appliance is configured, it cannot be unauthorized or disabled. + +Use this Cmdlet to retrieve a supported resources Remote Support settings of an enabled resource (compute or enclosure), defined Parimary and Secondary contact, and authorized reseller or support partners. + +Minimum required privileges: Read-only + + + + + Get-OVRemoteSupportSetting + + InputObject + + Either a Server Hardware or Enclosure resource to get the configured Remote Support collection settings. + + Object + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + InputObject + + Either a Server Hardware or Enclosure resource to get the configured Remote Support collection settings. + + Object + + Object + + + + + + + + + HPEOneView.ServerHardware [System.Management.Automation.PSCustomObject] + + + Server hardware resource object. + + + + + HPEOneView.Enclosure [System.Management.Automation.PSCustomObject] + + + Enclosure resource object. + + + + + + + + HPEOneView.Appliance.RemoteSupport.ResourceSetting [System.Management.Automation.PSCustomObject] + + + + Remote Support Settings object. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVEnclosure -Name Encl1 | Get-OVRemoteSupportSetting + +Appliance ResourceName SalesChannelPartner SupportChannelPartner PrimaryContact SecondaryContact +--------- ------------ ------------------- --------------------- -------------- ---------------- +MyAppliance.domain.com Encl1 Hewlett Packard Enterprise Hewlett Packard Enterprise Mark Jones + + Get the configured Remote Support collection settings for "Encl1" Enclosure resource. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Get-OVServer -Name PROD* | Get-OVRemoteSupportSetting | ? supportEnabled -eq $false + + Return all PROD servers, and return only those where remote support is not enabled. + + + + + + + + + + + + + Get-OVEnclosure + + + + Get-OVRemoteSupport + + + + Get-OVRemoteSupportEntitlementStatus + + + + Get-OVServer + + + + Set-OVRemoteSupportSetting + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/get-ovremotesupportsetting + + + + + + + + Get-OVRemoteSyslog + + Get the configured remote syslog settings. + + Get + OVRemoteSyslog + + + The remoteSyslog API provides the ability to configure remote logging on devices managed by OneView. This Cmdlet handles disabling the remote syslog configuration. Only a single destination can be set. When configured, the HPE OneView appliance will deploy the SysLog settings to managed resources automatically. + +Minimum required privileges: Read-only + + + + + Get-OVRemoteSyslog + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + HPEOneView.RemoteSyslog [System.Management.Automation.PSCustomObject] + + + + If successful, returns Appliance Syslog settings + + + + + System.Collections.ArrayList <HPEOneView.RemoteSyslog> + + + + Collection of Appliance Syslog settings + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVRemoteSyslog +Appliance Destination Port Enabled + +--------- ----------- ---- ------- +appliance1.domain.com False +appliance2.domain.com 10.150.20.1 514 True + + Get the current configuration from all connected appliances. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Get-OVRemoteSyslog -ApplianceConnection appliance1.domain.com + +Appliance Destination Port Enabled +--------- ----------- ---- ------- +appliance1.domain.com False + + Get the current configuration from specified connected appliance. + + + + + + + + + + + + + Disable-OVRemoteSyslog + + + + Enable-OVRemoteSyslog + + + + Set-OVRemoteSyslog + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/get-ovremotesyslog + + + + + + + + Get-OVReservedVlanRange + + Get the reserved VLAN range for HPE Synergy. + + Get + OVReservedVlanRange + + + A reserved VLAN pool is a range of VLANs used for allocation of non-tagged networks: + + * Tunnel + * Untagged + * Fibre Channel (FC) + +Tagged networks and FCoE networks use VLANs outside of the reserved pool. You cannot use a reserved VLAN for tagged or FCoE networks. + +The VLAN pool allows the number of available VLANs to be segregated between tagged and non-tagged networks. Because non-tagged networks use VLANs for internal translation resources, a reserved VLAN pool can provide a sufficient number of VLANs available for allocation of those internal VLANs. In addition, the reserved pool range removes the need for translation resources to be used on tagged networks. + +For the maximum number of VLANs per physical downlink port, see the HPE OneView Support Matrix for HPE Synergy (https://www.hpe.com/info/synergy-docs). + +Use this Cmdlet to get the configured reserved VLAN range pool. + +Minimum required privileges: Read-only + + + + + Get-OVReservedVlanRange + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + HPEOneView.Networking.ReservedVlanRange + + + + The reserved VLAN range object + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVReservedVlanRange + + Get the defined reserved VLAN range on the connected HPE Synergy appliance. + + + + + + + + + + + + + Set-OVReservedVlanRange + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/networking/get-ovreservedvlanrange + + + + + + + + Get-OVRole + + Get role of user. + + Get + OVRole + + + Deprecated Cmdlet as of v2.0. Please use the Get-OVUser Cmdlet to retrieve User Roles. + + + + + Get-OVRole + + + + + + + + + + None. + + + + + + + + + + + None. + + + + + + + + + + + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/security/get-ovrole + + + + + + + + Get-OVRotateMPPasswordPolicy + + Get the appliance management processor password policy configuration. + + Get + OVRotateMPPasswordPolicy + + + You can enable and set up a schedule for automatic rotation of passwords for HPE OneView administrator accounts on managed devices. Based on the security policy of the organization, you can set the timeframe for the password rotation from 1-365 days. This security practice of setting a timeframe for enforcing password change reduces password-based attacks. + +You can schedule password rotation for the following accounts: + + * HPE iLO: hpOneViewAdmin + * HPE Compute Scale-up Server 3200: HPEOneViewMonitor + * HPE Superdome Flex Servers Family: HPEOneViewMonitor + +Considerations + +If devices have accounts set up with LDAP or Microsoft Active Directory, the password cannot be rotated. + +If a server is engaged in another task, password rotation is skipped for the server, and rotation is done in the next schedule. + +Only non-HPE Synergy Servers are supported. + +Use this Cmdlet to get the current password rotation policy configuration. + +Minimum required privileges: + + * Read-only + + + + + Get-OVRotateMPPasswordPolicy + + ApplianceConnection + + Specify one or more HPEOneView.Appliance.Connection object(s) or Name property value(s). + +Default Value: ${Global:ConnectedSessions} | ? Default + + Object + + + + + + + ApplianceConnection + + Specify one or more HPEOneView.Appliance.Connection object(s) or Name property value(s). + +Default Value: ${Global:ConnectedSessions} | ? Default + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + + + + + None. You cannot pipe objects to this cmdlet. + + + + + + + + + + + HPEOneView.Appliance.RotateMPPasswordPolicy + + + + Appliance RotateMPPasswordPolicy class. This defines the device embedded management process (e.g. iLO) privileged account password rotation policy and how it is configured on the appliance. + + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVRotateMPPasswordPolicy + + + Get the password rotation policy configuration. + + + + + + + + + + + + + Get-OVRotateMPPasswordPolicyReport + + + + Set-OVRotateMPPasswordPolicy + + + + Online: + https://hpe-docs.gitbook.io/posh-hpeoneview/cmdlets/v9.00/appliance/get-ovrotatemppasswordpolicy + + + + + + + + Get-OVRotateMPPasswordPolicyReport + + Generate management processor password report. + + Get + OVRotateMPPasswordPolicyReport + + + You can enable and set up a schedule for automatic rotation of passwords for HPE OneView administrator accounts on managed server devices. Based on the security policy of the organization, you can set the timeframe for the password rotation from 1-365 days. This security practice of setting a timeframe for enforcing password change reduces password-based attacks. + +You can schedule password rotation for the following accounts: + + * HPE iLO: hpOneViewAdmin account + * HPE Compute Scale-up Server 3200: HPEOneViewMonitor account + * HPE Superdome Flex Servers Family: HPEOneViewMonitor account + +Considerations + +If devices have accounts set up with LDAP or Microsoft Active Directory, the password cannot be rotated. + +If a server is engaged in another task, password rotation is skipped for the server, and rotation is done in the next schedule. + +Only non-HPE Synergy Servers are supported. + +Use this Cmdlet to generate a report of the last executed task. To get all previous and current password rotation task results, use the -GetAllReports switch parameter. + +Minimum required privileges: + + * Read-only + + + + + Get-OVRotateMPPasswordPolicyReport + + GetAllReports + + Get all available password rotation results. + + SwitchParameter + + + ApplianceConnection + + Specify one or more HPEOneView.Appliance.Connection object(s) or Name property value(s). + +Default Value: ${Global:ConnectedSessions} | ? Default + + Object + + + + + + + ApplianceConnection + + Specify one or more HPEOneView.Appliance.Connection object(s) or Name property value(s). + +Default Value: ${Global:ConnectedSessions} | ? Default + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + GetAllReports + + Get all available password rotation results. + + SwitchParameter + + SwitchParameter + + False + + + + + + + None. You cannot pipe objects to this cmdlet. + + + + + + + + + + + HPEOneView.Appliance.RotateMPPasswordPolicyReport[] + + + + Class object that contains the report. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVRotateMPPasswordPolicyReport + + + Return the most current password rotation report and servers that successfully or failed to rotate the password. + + + + + + + + + + + + + Get-OVRotateMPPasswordPolicy + + + + Set-OVRotateMPPasswordPolicy + + + + Online: + https://hpe-docs.gitbook.io/posh-hpeoneview/cmdlets/v9.00/appliance/get-ovrotatemppasswordpolicyreport + + + + + + + + Get-OVSanManager + + Retrieve SAN Manager resource(s). + + Get + OVSanManager + + + SAN managers are a resource in HPE OneView that represent a connection to an external entity through which SANs are discovered and managed. The external entity can be vendor-specific management software or a physical switch. + +SANs are created outside of HPE OneView in the SAN manager vendor?s management interface. Once created, SANs can be discovered and managed in HPE OneView using the SAN Manager resource. + +When managing SAN managers, HPE OneView does not permit a SAN to be managed through more than one SAN manager. When associating an HPE OneView network to the SAN, the choice of which SAN to associate determines which SAN manager will be used to manage the SAN. Any subsequent change to a new SAN manager application requires to go through a phased migration process. + +HPE OneView supports SAN managers from different vendors. See the HPE OneView Support Matrix (http://www.hpe.com/info/oneview/docs) for a list of supported SAN managers. + +This Cmdlet will return the configured SAN Manager(s). + +Minimum required privileges: Read-only + + + + + Get-OVSanManager + + Name + + Provide the name of the SAN Manager to display. + + String + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + Array + + (${Global:ConnectedSessions} | ? Default) + + + Name + + Provide the name of the SAN Manager to display. + + String + + String + + + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + HPEOneView.Storage.SanManager [System.Management.Automation.PSCustomObject] + + + + Single SAN Manager resource + + + + + System.Collections.ArrayList <HPEOneView.Storage.SanManager> + + + + Multiple SAN Manager resources + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVSanManager + +Name Status State Type Version Managed SANs +---- ------ ----- ---- ------- ------------ +bna1.domain.com OK Managed Brocade Network Advisor 12.3.4.5 {Fabric_A, Fabric_B} +bna2.domain.com OK Managed Brocade Network Advisor 12.3.4.5 {Fabric_C, Fabric_D} + + Display all SAN Managers. + + + + + + + + + + + + + Add-OVSanManager + + + + Remove-OVSanManager + + + + Set-OVSanManager + + + + Update-OVSanManager + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/storage/get-ovsanmanager + + + + + + + + Get-OVSanZone + + View Managed SAN Zones. + + Get + OVSanZone + + + SANs are Fibre Channel (FC) or Fibre Channel over Ethernet (FCoE) storage area networks that connect servers to storage systems. The possible states for SANs are: + + * Discovered - A SAN that is not associated with a network. SANs are automatically discovered when a SAN manager is added to HPE OneView. + * Managed - A SAN that is associated with one or more networks in HPE OneView. Only managed SANs can be configured to be automatically zoned by HPE OneView. + +The SAN Endpoints, or SAN zones, contain all device ports actively logged into or configured to log in to a SAN. + +This Cmdlet will display the Managed SAN Zone details, which include Zone Name, state, status, Managed SAN and Alias members with their WWN(s). By default, all SAN Zones will be returned. You can filter the results based on Managed SAN resource. + +Minimum required privileges: Read-only + + + + + Get-OVSanZone + + ManagedSan + + The Managed SAN Resource Object. + + Object + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Array + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Array + + Array + + (${Global:ConnectedSessions} | ? Default) + + + ManagedSan + + The Managed SAN Resource Object. + + Object + + Object + + + + + + + + + HPEOneView.Storage.ManagedSan [System.Management.Automation.PSCustomObject] + + + Managed SAN resource from Get-OVManagedSan + + + + + + + + HPEOneView.Storage.ManagedSan.Zone [System.Management.Automation.PSCustomObject] + + + + Managed SAN Zone resource object + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVSanZone +Appliance SAN Name State Status Members + +--------- --- ---- ----- ------ ------- +appliance SAN1_1 dummy_zone Managed OK +appliance SAN1_0 dummy_zone Managed OK +appliance SAN1_1 Node_1_8 Managed OK {Target_ThreePAR72004506_0_2_2, Initiator_Node_1_8, Target_ThreePAR72004506_1_2_2} +appliance SAN1_0 Node_1_7 Managed OK {Initiator_Node_1_7, Target_ThreePAR72004506_0_2_1, Target_ThreePAR72004506_1_2_1} + + Return all SAN Zones from the appliance(s). + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Get-OVManagedSan -Name SAN1_0 | Get-OVSanZone + +Appliance SAN Name State Status Members +--------- --- ---- ----- ------ ------- +appliance SAN1_0 dummy_zone Managed OK +appliance SAN1_0 Node_1_7 Managed OK {Initiator_Node_1_7, Target_ThreePAR72004506_0_2_1, Target_ThreePAR72004506_1_2_1} + + Return the specific SAN Zone for the specified Managed SAN resource from the appliance. + + + + + + + + + + -------------------------- EXAMPLE 3 -------------------------- + + + + $Zones = Get-OVManagedSan -Name SAN1_0 | Get-OVSanZone +$Zones | ? Name -eq "Node_1_7" + +Appliance SAN Name State Status Members +--------- --- ---- ----- ------ ------- +hpov-tot2 SAN1_0 Node_1_7 Managed OK {Initiator_Node_1_7, Target_ThreePAR72004506_0_2_1, Target_ThreePAR72004506_1_2_1} + +($Zones | ? Name -eq "Node_1_7").members + +Name WWN +---- --- +Initiator_Node_1_7 {10:00:F6:9F:5F:70:00:00} +Target_ThreePAR72004506_0_2_1 {20:00:00:02:AC:00:08:DE} +Target_ThreePAR72004506_1_2_1 {20:00:00:02:AC:00:08:E2} + + Get the Zone information from the specific Managed SAN, then display the associated aliases including their WWNs. + + + + + + + + + + + + + Get-OVManagedSan + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/storage/get-ovsanzone + + + + + + + + Get-OVSasInterconnectType + + Retrieve SAS Interconnect Type resource(s). + + Get + OVSasInterconnectType + + + Interconnects enable communication between the server hardware in the enclosure and the data center networks. Interconnects and their configuration are derived from either a Logical Switch Group or Logical Interconnect Group. When configuring either resource, you will need to specify an interconnect type that is supported by the appliance. + +This Cmdlet will retrieve a list of supported SAS interconnect type or specific ones via a query if the name parameter is provided. + +Minimum required privileges: Read-only + + + + + Get-OVSasInterconnectType + + Name + + The name of the interconnect type model name to retrieve. + + String + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + Get-OVSasInterconnectType + + PartNumber + + The Part Number of an Interconnect Type to search for. + + String + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Name + + The name of the interconnect type model name to retrieve. + + String + + String + + + + + PartNumber + + The Part Number of an Interconnect Type to search for. + + String + + String + + + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + HPEOneView.Networking.SasInterconnectType [System.Management.Automation.PSCustomObject] + + + + Single SAS Interconnect Type resource + + + + + System.Collections.ArrayList <HPEOneView.Networking.SasInterconnectType> + + + + Multiple SAS Interconnect Type resources or formatted table dispalying basic Interconnect Type information + + + + + A SAS Interconnect Type or collection of SAS Interconnect Types. + + + + + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVSasInterconnectType + + Returns all SAS Interconnect Types available from all connected appliances to standard output. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Get-OVSasInterconnectType -Name "Synergy 12Gb SAS Connection Module" + + Returns just the "Synergy 12Gb SAS Connection Module" SAS Interconnect Type object to standard output. + + + + + + + + + + + + + Get-OVInterconnectType + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/networking/get-ovsasinterconnecttype + + + + + + + + Get-OVSasLogicalInterconnect + + Retrieve SAS Logical Interconnect resource(s). + + Get + OVSasLogicalInterconnect + + + A logical interconnect is a single administrative entity that consists of the configuration for a set of interconnects in a single enclosure or an HPE Synergy frame link topology. + +A logical interconnect derives its configuration from a logical interconnect group, which serves as a template to ensure that the logical interconnects being created are configured consistently. + +A SAS Logical Interconnect represents a single SAS fabric local to the physical HPE Synergy Frame (Enclosure). Which compute modules can be assigned one or more physical drives as a Logical JBOD, or RAID configuration. + +This Cmdlet retrieves a list of all SAS Logical Interconnect or just specific ones via a query if the name parameter is provided. The output can be sent to a file using the exportFile parameter. + +Minimum required privileges: Read-only + + + + + Get-OVSasLogicalInterconnect + + Name + + The name of the SAS Logical Interconnect to retrieve. + + String + + + Label + + Specify the label associated with resources. + + String + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + Export + + The full path and file name to export the contents retrieved from the call to Get-OVLogicalInterconnect. + + String + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Export + + The full path and file name to export the contents retrieved from the call to Get-OVLogicalInterconnect. + + String + + String + + + + + Label + + Specify the label associated with resources. + + String + + String + + False + + + Name + + The name of the SAS Logical Interconnect to retrieve. + + String + + String + + + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + HPEOneView.Storage.SasLogicalInterconnect [System.Management.Automation.PSCustomObject] + + + + Logical Interconnect resource object from Get-OVLogicalInterconnect + + + + + System.Collections.ArrayList <HPEOneView.Storage.SasLogicalInterconnect> + + + + Multiple Logical Interconnects + + + + + A SAS Logical Interconnect or collection of SAS Logical Interconnects + + + + + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVSasLogicalInterconnect + + Returns all SAS Logical Interconnect defined on the appliance to standard output. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Get-OVSasLogicalInterconnect -Name "LE1-SasProduction" -ErrorAction Stop + + Returns just the specific SAS Logical Interconnect object to standard output. + + + + + + + + + + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/networking/get-ovsaslogicalinterconnect + + + Install-OVLogicalInterconnectFirmware + + + + + + + + + Get-OVScmbCertificates + + Get State Change Message Bus certificates. + + Get + OVScmbCertificates + + + HPE OneView uses a state change message bus (SCMB) for internal components to notify each other of resource state changes. External users can connect and consume these same messages for monitoring purposes. The HPE OneView SCMB is built upon the RabbitMQ provider. + +In order to connect to connect to the HPE OneView SCMB, a proper message queue client is needed, in which it must support certificate authentication. The HPE OneView SCMB does not support standard username and password authentication. + +This Cmdlet will retrieve and store the certificates necessary to register with the State Change Message Bus. If the SCMB certificate has not been created, a new one will be generated. The generated certificate is mapped to a private, internal user account with Read-Only permissions. In order to write changes, a REST API bind-back is necessary. + +The generated and/or downloaded SCMB certificate can also be exported to PFX format for secure storage, using the -ConvertToPFx parameter. + +Minimum required privileges: Infrastructure Administrator + + + + + Get-OVScmbCertificates + + Location + + Directory to store the SSL certificates. If the directory doesn"t exist, it will be created. + + String + + + InstallApplianceRootCA + + hoose to install the appliance root certificate to the current users Trusted Root Authorities store. + + SwitchParameter + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + + + Get-OVScmbCertificates + + Password + + Password that will be used to encrypt the PFX client certificate. + + SecureString + + + Location + + Directory to store the SSL certificates. If the directory doesn"t exist, it will be created. + + String + + + ConvertToPFx + + Aliases [-pfx] +Convert rabbitmq_readonly client certificate to PFX format for .Net consumption. + + SwitchParameter + + + InstallApplianceRootCA + + hoose to install the appliance root certificate to the current users Trusted Root Authorities store. + + SwitchParameter + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + Array + + (${Global:ConnectedSessions} | ? Default) + + + ConvertToPFx + + Aliases [-pfx] +Convert rabbitmq_readonly client certificate to PFX format for .Net consumption. + + SwitchParameter + + SwitchParameter + + False + + + InstallApplianceRootCA + + hoose to install the appliance root certificate to the current users Trusted Root Authorities store. + + SwitchParameter + + SwitchParameter + + + + + Location + + Directory to store the SSL certificates. If the directory doesn"t exist, it will be created. + + String + + String + + ($pwd).path + + + Password + + Password that will be used to encrypt the PFX client certificate. + + SecureString + + SecureString + + + + + + + + + System.Security.SecureString + + + Password for PFX file + + + + + + + + 3 files will be created: + + + + * {ApplianceConnection_Name}_ca.cer - Appliance internal Root Certificate Authority * {ApplianceConnection_Name}_cert.cer - Appliance managed rabbitmq_readonly user Public Key * {ApplianceConnection_Name}_privateKey.key - Appliance managed rabbitmq_readonly user Client Certificate + + + + + Pkcs12/PFX certificate file + + + + If ConvertToPfX is used, the Pkcs12/PFX compliant certificate file is created, {ApplianceConnection_Name}_privateKey.pfx + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVScmbCertificates + + Get the HPE OneView appliance SCMB SSL certificates, and save them in the current directory. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Read-hHst "Password" -AsSecureString | Get-OVScmbCertificates -Location C:\scmbcerts -ConvertToPFx + + Prompt for secure password input and pipe the value to convert the cert.pem to PFX format. + + + + + + + + + + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/get-ovscmbcertificates + + + + + + + + Get-OVScope + + Get Scope resource(s) + + Get + OVScope + + + A scope is a grouping of resources that can be used to restrict the range of an operation or action. For example, you can create scopes based on: + + * Organizations (Marketing, Research and Development, Finance) + * Usage (Production, Development, Testing) + * Skills (Linux, Windows) + +The resources are arranged by categories. All the resources in these categories can be added to or removed from a scope: + + * Enclosures + * Server Hardware + * Networks (Ethernet, FC, and FCoE) + * Network Sets + * Interconnects, excluding SAS resources + * Logical Interconnects, excluding SAS resources + * Logical Interconnect Groups, excluding SAS resources + * OS Deployment Plans + * Switches + * Logical Switches + * Logical Switch Groups + * Rack Managers + * Storage Pools + * Volumes + * Volume Templates + * Volume Sets + +NOTE: Resources in other categories are considered to be included in all scopes, and they cannot be removed. + +WARNING: For email notification of alerts, resources that are not categorized here are included in any scope. An email notification filter that specifies one or more scopes does not eliminate alerts generated by resources that are not currently categorized here. Inhibiting alerts from non-scope resources requires the use of associated resource categories, which is described in "Edit an email recipient and filter entry" online help chapter. + +When scopes are defined and resources assigned to them, you can: + + * Restrict the resources displayed in the user interface (UI) to those assigned to the scope. + * Restrict user permissions to grant access only to the resources in a scope. + * Configure filtered email notifications for alerts based on previously-defined scopes. + +Returned Scope object(s) will contain a collection of associated resources. + +Minimum Minimum required privileges: Read-Only + + + + + Get-OVScope + + Name + + Name of the scope to return. + + String + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Name + + Name of the scope to return. + + String + + String + + + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + HPEOneView.Appliance.ScopeCollection + + + + Collection of Appliance Scope resource objects. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVScope + + List all available scopes on the connected default appliance. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Get-OVScope -Name MyFinanceScope + + Return the "MyFinanceScope" scope resource from the conncted default appliance. + + + + + + + + + + -------------------------- EXAMPLE 3 -------------------------- + + + + Get-OVScope -Name My* -ApplianceConnection $ConnectedSessions + + Use wildcard search for a specific scope on all connected appliances. + + + + + + + + + + + + + Add-OVResourceToScope + + + + Remove-OVResourceFromScope + + + + New-OVScope + + + + Remove-OVScope + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/get-ovscope + + + + + + + + Get-OVServer + + Retrieve Server Hardware resource(s). + + Get + OVServer + + + Obtain a collection of server hardware resources, a specific server with the specified name, or server hardware resources without an assigned Server Profile. Returned resources will display: + + * Device Name + * Serial Number + * Model + * System ROM + * iLO and its firmware + * Server Profile + * Status + * Licensing + + + + + Get-OVServer + + Name + + The name of the server hardware resource to be returned. All server hardware resources will be returned if omitted. Supports * wildcard character. + + String + + + SerialNumber + + Specify the server hardware serial number to locate. This parameter does not support wildcard chatacters. + + String + + + ServerName + + Specify the Server OS Name that is reported by the iLO. + + String + + + Status + + Filter resources based on their current status. Allowed values: + + * Ok + * Warning + * Critical + * Unknown + * Disabled + + String[] + + + NoProfile + + Optional parameter that can be used with the report parameter to display Servers without a Server Profile assigned. + + SwitchParameter + + + InputObject + + Aliases [-ServerHardwareType, -ServerProfileTemplate] +Provide the Server Hardware Type or Server Profile Template Object to filter for available server hardware. + + Object + + + MaintenanceMode + + Optional parameter that can be used to filter for specific servers that are in maintenance mode or note based on the boolean value provided. + + Boolean + + + Label + + Specify the label associated with resources. + + String + + + Query + + Provide an API-compatible query to filter the results. + + String + + + Count + + Return no more than the provided value. Combining other parameters to filter may not return the requested count value. + + Int + + + Scope + + Filter resources based on provided Scope membership. By default, all resources for the accounts Active Permissions will be displayed. Allowed values: + + * AllResources + * AllResourcesInScope + * HPEOneView.Appliance.ScopeCollection + * HPEOneView.Appliance.ConnectionPermission + + Object + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Count + + Return no more than the provided value. Combining other parameters to filter may not return the requested count value. + + Int + + Int + + + + + InputObject + + Aliases [-ServerHardwareType, -ServerProfileTemplate] +Provide the Server Hardware Type or Server Profile Template Object to filter for available server hardware. + + Object + + Object + + + + + Label + + Specify the label associated with resources. + + String + + String + + False + + + MaintenanceMode + + Optional parameter that can be used to filter for specific servers that are in maintenance mode or note based on the boolean value provided. + + Boolean + + Boolean + + False + + + Name + + The name of the server hardware resource to be returned. All server hardware resources will be returned if omitted. Supports * wildcard character. + + String + + String + + + + + NoProfile + + Optional parameter that can be used with the report parameter to display Servers without a Server Profile assigned. + + SwitchParameter + + SwitchParameter + + False + + + Query + + Provide an API-compatible query to filter the results. + + String + + String + + + + + Scope + + Filter resources based on provided Scope membership. By default, all resources for the accounts Active Permissions will be displayed. Allowed values: + + * AllResources + * AllResourcesInScope + * HPEOneView.Appliance.ScopeCollection + * HPEOneView.Appliance.ConnectionPermission + + Object + + Object + + AllResourcesInScope + + + SerialNumber + + Specify the server hardware serial number to locate. This parameter does not support wildcard chatacters. + + String + + String + + + + + ServerName + + Specify the Server OS Name that is reported by the iLO. + + String + + String + + + + + Status + + Filter resources based on their current status. Allowed values: + + * Ok + * Warning + * Critical + * Unknown + * Disabled + + String[] + + String[] + + + + + + + + + HPEOneView.ServerHardwareType [System.Management.Automation.PSCustomObject] + + + Server Hardware Type resource object. + + + + + HPEOneView.ServerProfileTemplate [System.Management.Automation.PSCustomObject] + + + Server Profile Template resource object. + + + + + + + + HPEOneView.ServerHardware [System.Management.Automation.PSCustomObject] + + + + Single Server Hardware resource + + + + + System.Collections.ArrayList + + + + Multiple Server Hardware resources + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVServer +Name Status Power Serial Number Model ROM iLO Server Profile License +---- ------ ----- ------------- ----- --- --- -------------- ------- +172.18.6.15 Disabled Off MXQ1000207 DL360p Gen8 P71 02/10/2014 iLO4 2.03 No Profile OneViewNoiLO +172.18.6.16 Unknown Unknown MXQ1000307 DL380p Gen8 No Profile OneViewNoiLO +172.18.6.31 Disabled Off MXQ1000208 DL360 Gen9 P89 07/11/2014 iLO4 2.03 No Profile OneViewNoiLO +172.18.6.32 Unknown Unknown MXQ1020307 DL380p Gen8 No Profile OneViewNoiLO +Encl1, bay 1 OK Off SGH100X7RN BL660c Gen9 I32 08/03/2014 iLO4 2.03 Server Profile 1 OneView +Encl1, bay 11 OK Off SGH100X5RN BL460c Gen9 I36 08/26/2014 iLO4 2.03 Server Profile 2 OneView +Encl1, bay 12 Disabled Off SGH101X5RN BL460c Gen9 I36 08/26/2014 iLO4 2.03 No Profile OneView +Encl1, bay 13 Disabled Off SGH102X5RN BL460c Gen9 I36 08/26/2014 iLO4 2.03 No Profile OneView +Encl1, bay 14 Disabled Off SGH103X5RN BL460c Gen9 I36 08/26/2014 iLO4 2.03 No Profile OneView +Encl1, bay 15 Disabled Off SGH104X5RN BL460c Gen9 I36 08/26/2014 iLO4 2.03 No Profile OneView +Encl1, bay 16 Disabled Off SGH105X5RN BL460c Gen9 I36 08/26/2014 iLO4 2.03 No Profile OneView +Encl1, bay 2 OK Off SGH101X7RN BL660c Gen9 I32 08/03/2014 iLO4 2.03 My Profile OneView +Encl1, bay 3 OK Off SGH100X8RN BL460c Gen8 I31 08/02/2014 iLO4 2.03 Server Profile 3 OneView +Encl1, bay 4 OK Off SGH101X8RN BL460c Gen8 I31 08/02/2014 iLO4 2.03 Server Profile 4 OneView +Encl1, bay 5 OK Off SGH102X8RN BL460c Gen8 I31 08/02/2014 iLO4 2.03 Server Profile 5 OneView +Encl1, bay 6 Disabled Off SGH103X8RN BL460c Gen8 I31 08/02/2014 iLO4 2.03 No Profile OneView +Encl1, bay 7 Disabled Off SGH104X8RN BL460c Gen8 I31 08/02/2014 iLO4 2.03 No Profile OneView +Encl1, bay 8 Disabled Off SGH105X8RN BL460c Gen8 I31 08/02/2014 iLO4 2.03 No Profile OneView +Encl2, bay 1 Disabled Off SGH102X7RN BL660c Gen9 I32 08/03/2014 iLO4 2.03 No Profile OneView +Encl2, bay 11 Disabled Off SGH106X5RN BL460c Gen9 I36 08/26/2014 iLO4 2.03 No Profile OneView +Encl2, bay 12 Disabled Off SGH107X5RN BL460c Gen9 I36 08/26/2014 iLO4 2.03 No Profile OneView +Encl2, bay 13 Disabled Off SGH108X5RN BL460c Gen9 I36 08/26/2014 iLO4 2.03 No Profile OneView +Encl2, bay 14 Disabled Off SGH109X5RN BL460c Gen9 I36 08/26/2014 iLO4 2.03 No Profile OneView +Encl2, bay 15 Disabled Off SGH110X5RN BL460c Gen9 I36 08/26/2014 iLO4 2.03 No Profile OneView +Encl2, bay 16 Disabled Off SGH111X5RN BL460c Gen9 I36 08/26/2014 iLO4 2.03 No Profile OneView +Encl2, bay 2 Disabled Off SGH103X7RN BL660c Gen9 I32 08/03/2014 iLO4 2.03 No Profile OneView +Encl2, bay 3 Disabled Off SGH106X8RN BL460c Gen8 I31 08/02/2014 iLO4 2.03 No Profile OneView +Encl2, bay 4 Disabled Off SGH107X8RN BL460c Gen8 I31 08/02/2014 iLO4 2.03 No Profile OneView +Encl2, bay 5 Disabled Off SGH108X8RN BL460c Gen8 I31 08/02/2014 iLO4 2.03 No Profile OneView +Encl2, bay 6 Disabled Off SGH109X8RN BL460c Gen8 I31 08/02/2014 iLO4 2.03 No Profile OneView +Encl2, bay 7 Disabled Off SGH110X8RN BL460c Gen8 I31 08/02/2014 iLO4 2.03 No Profile OneView +Encl2, bay 8 Disabled Off SGH111X8RN BL460c Gen8 I31 08/02/2014 iLO4 2.03 No Profile OneView + + Return all the server hardware managed by this appliance. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + $bay1 = Get-OVServer -Name "Encl1, bay 1" + + Return the server hardware resource with name "Encl1, bay 1". + + + + + + + + + + -------------------------- EXAMPLE 3 -------------------------- + + + + Get-OVServer -NoProfile +Name Status Power Serial Number Model ROM iLO Server Profile License +---- ------ ----- ------------- ----- --- --- -------------- ------- +172.18.6.15 Disabled Off MXQ1000207 DL360p Gen8 P71 02/10/2014 iLO4 2.03 No Profile OneViewNoiLO +172.18.6.16 Unknown Unknown MXQ1000307 DL380p Gen8 No Profile OneViewNoiLO +172.18.6.31 Disabled Off MXQ1000208 DL360 Gen9 P89 07/11/2014 iLO4 2.03 No Profile OneViewNoiLO +172.18.6.32 Unknown Unknown MXQ1020307 DL380p Gen8 No Profile OneViewNoiLO +Encl1, bay 12 Disabled Off SGH101X5RN BL460c Gen9 I36 08/26/2014 iLO4 2.03 No Profile OneView +Encl1, bay 13 Disabled Off SGH102X5RN BL460c Gen9 I36 08/26/2014 iLO4 2.03 No Profile OneView +Encl1, bay 14 Disabled Off SGH103X5RN BL460c Gen9 I36 08/26/2014 iLO4 2.03 No Profile OneView +Encl1, bay 15 Disabled Off SGH104X5RN BL460c Gen9 I36 08/26/2014 iLO4 2.03 No Profile OneView +Encl1, bay 16 Disabled Off SGH105X5RN BL460c Gen9 I36 08/26/2014 iLO4 2.03 No Profile OneView +Encl1, bay 6 Disabled Off SGH103X8RN BL460c Gen8 I31 08/02/2014 iLO4 2.03 No Profile OneView +Encl1, bay 7 Disabled Off SGH104X8RN BL460c Gen8 I31 08/02/2014 iLO4 2.03 No Profile OneView +Encl1, bay 8 Disabled Off SGH105X8RN BL460c Gen8 I31 08/02/2014 iLO4 2.03 No Profile OneView +Encl2, bay 1 Disabled Off SGH102X7RN BL660c Gen9 I32 08/03/2014 iLO4 2.03 No Profile OneView +Encl2, bay 11 Disabled Off SGH106X5RN BL460c Gen9 I36 08/26/2014 iLO4 2.03 No Profile OneView +Encl2, bay 12 Disabled Off SGH107X5RN BL460c Gen9 I36 08/26/2014 iLO4 2.03 No Profile OneView +Encl2, bay 13 Disabled Off SGH108X5RN BL460c Gen9 I36 08/26/2014 iLO4 2.03 No Profile OneView +Encl2, bay 14 Disabled Off SGH109X5RN BL460c Gen9 I36 08/26/2014 iLO4 2.03 No Profile OneView +Encl2, bay 15 Disabled Off SGH110X5RN BL460c Gen9 I36 08/26/2014 iLO4 2.03 No Profile OneView +Encl2, bay 16 Disabled Off SGH111X5RN BL460c Gen9 I36 08/26/2014 iLO4 2.03 No Profile OneView +Encl2, bay 2 Disabled Off SGH103X7RN BL660c Gen9 I32 08/03/2014 iLO4 2.03 No Profile OneView +Encl2, bay 3 Disabled Off SGH106X8RN BL460c Gen8 I31 08/02/2014 iLO4 2.03 No Profile OneView +Encl2, bay 4 Disabled Off SGH107X8RN BL460c Gen8 I31 08/02/2014 iLO4 2.03 No Profile OneView +Encl2, bay 5 Disabled Off SGH108X8RN BL460c Gen8 I31 08/02/2014 iLO4 2.03 No Profile OneView +Encl2, bay 6 Disabled Off SGH109X8RN BL460c Gen8 I31 08/02/2014 iLO4 2.03 No Profile OneView +Encl2, bay 7 Disabled Off SGH110X8RN BL460c Gen8 I31 08/02/2014 iLO4 2.03 No Profile OneView +Encl2, bay 8 Disabled Off SGH111X8RN BL460c Gen8 I31 08/02/2014 iLO4 2.03 No Profile OneView + + Display all server hardware resources without an assigned Server Profile. + + + + + + + + + + -------------------------- EXAMPLE 4 -------------------------- + + + + $sht = Get-OVServerHardwareType -Name "BL460c Gen9 1" +$AvailableServer = Get-OVServer -NoProfile -ServerHardwareType $sht | Select -first 1 + + Return the first available server hardware of the Server Hardware Type requested. + + + + + + + + + + -------------------------- EXAMPLE 5 -------------------------- + + + + $AvailableServer = Get-OVServerProfileTemplate -Name "My Template 1" | Get-OVServer -NoProfile | Select -first 1 + + Return the first available server hardware designed for the specific Server Profile Template. + + + + + + + + + + -------------------------- EXAMPLE 6 -------------------------- + + + + Get-OVServer -Status Warning, Critical + + Return only servers that are currently reporting Warning or Critical status. + + + + + + + + + + -------------------------- EXAMPLE 7 -------------------------- + + + + # Get all Gen11 servers from inventory +Get-OVServer -Query "generation:11" + +# Get all DL380 Gen11 servers from inventory +Get-OVServer -Query "shortModel:'DL380 Gen11'" + +# Get the server with the MAC address 02:23:13:25:23:96 +Get-OVServer -Query "macAddrs:'02:23:13:25:23:96'" + + Various uses of the -Query parameter. + + + + + + + + + + + + + Add-OVServer + + + + Convert-OVServerProfile + + + + Convert-OVServerProfileTemplate + + + + ConvertTo-OVServerProfileTemplate + + + + Copy-OVServerProfile + + + + Disable-OVMaintenanceMode + + + + Enable-OVMaintenanceMode + + + + Get-OVServerHardwareType + + + + Get-OVServerProfile + + + + Get-OVServerProfileConnectionList + + + + Get-OVServerProfileMessage + + + + Get-OVServerProfileTemplate + + + + Join-OVServerProfileToTemplate + + + + New-OVServerProfile + + + + New-OVServerProfileAssign + + + + New-OVServerProfileAttachVolume + + + + New-OVServerProfileConnection + + + + New-OVServerProfileLogicalDisk + + + + New-OVServerProfileLogicalDiskController + + + + New-OVServerProfileTemplate + + + + Remove-OVServer + + + + Remove-OVServerProfile + + + + Remove-OVServerProfileTemplate + + + + Restart-OVServer + + + + Save-OVServerProfile + + + + Save-OVServerProfileTemplate + + + + Set-OVServerHardwareType + + + + Set-OVServerPower + + + + Set-OVServerProfile + + + + Set-OVServerProfileTemplate + + + + Update-OVServer + + + + Update-OVServerHardwareLicenseIntent + + + + Update-OVServerProfile + + + + Get-OVServerOneTimeBoot + + + + Set-OVServerOneTimeBoot + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/servers/get-ovserver + + + + + + + + Get-OVServerHardwareAvailableController + + Get a collection of inventoried storage controllers. + + Get + OVServerHardwareAvailableController + + + Storage Controllers can be managed by HPE OneView for various platforms taht are defined within a server profile template or server profile resource. Administrators can choose to import an existing configuration (to reduce data loss) if local storage controllers already have an existing policy, or to deploy a new policy. Configuring logical drives, HPE OneView can automatically assign drives based on defined characteristics that must match available drives within the server. Drives that are already allocated will result in a server profile apply error. Administrators can also specify specific drives to assign for Server Profiles and Gen10 or newer only. + +To identify installed drives, use this help Cmdlet, and provide a server resource with Get-OVServer Cmdlet. Available controller objects are returned, with a collection of installed drives. Additionally, supported "default" controller families will be returned, which will provide supported modes, drive technologies, and controller cache policies. + +If you configure new logical drives in your server profile or import the existing logical drives from the server hardware, HPE OneView stores a unique identifier for each logical drive in the server profile configuration when the server profile is applied. + +On subsequent server profile apply operations, HPE OneView checks for the existence of the identifier on the physical drives of the assigned server hardware. If the identifier is missing, the apply operation fails in order to ensure that if the server profile is re-assigned to new server hardware and that the physical drives are inserted correctly. + +NOTE: HPE OneView also uses the logical drive name (label) as a unique identifier. Do not modify the label of logical drives that are managed by HPE OneView. Do not create logical drives with non-unique labels. + +RAID levels and number of physical drives + +The HPE OneView Support Matrix provides information on the number of drives supported by specific server hardware. + + * RAID 0 - Minimum of 1 drive, increments of 1. + * RAID 1 - Requires 2 drives. + * RAID 1 ADM - Requires 3 drives. + * RAID 10 - Requires 4 drives, increments of 2. + * RAID 10 ADM - Minimum of 6 drives, increments of 3. + * RAID 5 - Minimum of 3 drives, increments of 1. + * RAID 6 - Minimum of 4 drives, increments of 1. + +After you create a logical drive and apply it to a server hardware, you can no longer modify those logical drives. + +NOTE: For controllers that support mixed mode (Gen10 servers), creating a logical drive uses the physical drives that are currently visible to the operating system. To preserve any data, back up the server drives before creating a logical drive. + +Only for Gen11 servers that contain storage controllers, you can configure logical drives that are related to the following Logical Drive Configuration options, using server profiles: + + * IOPerformanceMode + * ReadCachePolicy + * WriteCachePolicy + + + + + + Get-OVServerHardwareAvailableController + + InputObject + + Server hardware resource from Get-OVServer. + + Object + + + ApplianceConnection + + Specify one or more HPEOneView.Appliance.Connection object(s) or Name property value(s). + +Default Value: ${Global:ConnectedSessions} | ? Default + + Object + + + + + + + ApplianceConnection + + Specify one or more HPEOneView.Appliance.Connection object(s) or Name property value(s). + +Default Value: ${Global:ConnectedSessions} | ? Default + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + InputObject + + Server hardware resource from Get-OVServer. + + Object + + Object + + + + + + + + + HPEOneView.ServerHardware [System.Management.Automation.PSCustomObject] + + + Server hardware resource from Get-OVServer. + + + + + + + + HPEOneView.Servers.StorageController + + + + Storage controller object that provide specific information about available controllers available from a server resources inventory. Will include Controller Mode capabilities, and drives attached to each controller. The "Default" Type can be used to identify what controller families and base capabilities supplied by either SmartRAID (SR) or MegaRAID (MR) controller models. + +If the server generation is Gen10 or newer and no controllers in specific DeviceSlot have been identified, ensure the server has powered on at least once and successfully completed POST. + + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + # Get the specific server. Server must have been powered on at least 1 time to complete POST in order for server inventory to be updated +$Server = Get-OVServer -Name MyGen11Server + +# Get the available controllers and drives from the specific server +$AvailableControllers = Get-OVServerHardwareAvailableController -InputObject $Server + +# Review installed controllers +$AvailableControllers | ? { -not [String]::IsNullOrEmpty($_.DeviceSlot) } + +DeviceSlot : Slot 1 +Family : SmartRAID +Type : Standup +Model : HPE SR308i-p Gen11 +Firmware : 5.29-256 +ControllerMode : HPEOneView.Servers.ControllerModes +RaidModes : HPEOneView.Servers.RaidModes +DriveTechnologies : HPEOneView.Servers.DriveTechnologies +ReadCachePolicy : HPEOneView.Servers.ReadCachePolicy +WriteCachePolicy : HPEOneView.Servers.WriteCachePolicy +Capabilities : {RedfishConfig, RedfishDedicatedSpare} +Drives : {1I:1:41 147 GB (NvmeSsd), 1I:1:42 147 GB (NvmeSsd), 1I:1:43 147 GB (NvmeSsd), 1I:1:44 147 GB (NvmeSsd)ΓǪ} +MaximumLogicalDrives : 256 +MaximumDrives : 256 +ApplianceConnection : MyAppliance + + View Slot 1 controller from the specified volume server. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + # View the available storage controllers and supported controller type for the follow HPE Synergy Compute Node +Get-OVServer | Select -first 1 | Get-OVServerHardwareAvailableController + +DeviceSlot : Slot 0 +Family : SmartRAID +Type : Embedded +Model : Embedded Controller +Firmware : +ControllerMode : HPEOneView.Servers.ControllerModes +RaidModes : HPEOneView.Servers.RaidModes +DriveTechnologies : HPEOneView.Servers.DriveTechnologies +ReadCachePolicy : HPEOneView.Servers.ReadCachePolicy +WriteCachePolicy : HPEOneView.Servers.WriteCachePolicy +Capabilities : {RedfishConfig} +Drives : {1I:1:1 147 GB (SasHdd), 1I:1:2 147 GB (SasHdd), 1I:1:3 147 GB (SasHdd), 1I:1:4 147 GB (SasHdd)ΓǪ} +MaximumLogicalDrives : 256 +MaximumDrives : 256 +ApplianceConnection : MyAppliance + +DeviceSlot : Mezz 1 +Family : SmartRAID +Type : SAS Adapter +Model : HPE Smart Array P416ie-m SR Gen10 Controller +Firmware : 2.65 +ControllerMode : HPEOneView.Servers.ControllerModes +RaidModes : HPEOneView.Servers.RaidModes +DriveTechnologies : HPEOneView.Servers.DriveTechnologies +ReadCachePolicy : HPEOneView.Servers.ReadCachePolicy +WriteCachePolicy : HPEOneView.Servers.WriteCachePolicy +Capabilities : {RedfishConfig, RedfishConfig, RedfishConfig} +Drives : {} +MaximumLogicalDrives : 256 +MaximumDrives : 256 +ApplianceConnection : MyAppliance + +DeviceSlot : +Family : SmartRAID +Type : Default +Model : +Firmware : +ControllerMode : HPEOneView.Servers.ControllerModes +RaidModes : HPEOneView.Servers.RaidModes +DriveTechnologies : HPEOneView.Servers.DriveTechnologies +ReadCachePolicy : HPEOneView.Servers.ReadCachePolicy +WriteCachePolicy : HPEOneView.Servers.WriteCachePolicy +Capabilities : {RedfishConfig} +Drives : {} +MaximumLogicalDrives : 256 +MaximumDrives : 256 +ApplianceConnection : MyAppliance + + View available storage controllers, their location and any available drives for the specific HPE Synergy Compute Node. + + + + + + + + + + + + + New-OVServerProfileLogicalDisk + + + + New-OVServerProfileLogicalDiskController + + + + Online: + https://hpe-docs.gitbook.io/posh-hpeoneview/cmdlets/v9.00/servers/get-ovserverhardwareavailablecontroller + + + + + + + + Get-OVServerHardwareType + + Retrieve Server Hardware Type resource(s). + + Get + OVServerHardwareType + + + Obtain a collection of server hardware types. This includes information about the type of server, adapter layout and features, and possible server BIOS settings. This Cmdlet is also used with the New-OVServerProfile Cmdlet to retrieve the list of BIOS settings and adapters to configure. + + + + + Get-OVServerHardwareType + + Name + + The name of the server hardware type resource to be returned. All server hardware type resources will be returned if omitted. + + String + + + Model + + Filter based on Model name. Supports wildcard search. + + String + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + +Default Value: ${Global:ConnectSessions} + + Array + + + exportFile + + The path where the resource will be exported to, in JSON text format. + + String + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + +Default Value: ${Global:ConnectSessions} + + Array + + Array + + (${Global:ConnectedSessions} | ? Default) + + + Model + + Filter based on Model name. Supports wildcard search. + + String + + String + + + + + Name + + The name of the server hardware type resource to be returned. All server hardware type resources will be returned if omitted. + + String + + String + + + + + exportFile + + The path where the resource will be exported to, in JSON text format. + + String + + String + + + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + HPEOneView.ServerHardwareType [System.Management.Automation.PSCustomObject] + + + + Single Server Hardware type + + + + + System.Collections.ArrayList + + + + Multiple Server Hardware types + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + $sht = Get-OVServerHardwareType + + Return all the server hardware types on the appliance. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + $shtBL460Gen81 = Get-OVServerHardwareType -name "BL460 Gen8 1" + + Return the "BL460 Gen8 1" server hardware type on the appliance. + + + + + + + + + + + + + Set-OVServerHardwareType + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/servers/get-ovserverhardwaretype + + + + + + + + Get-OVServerNTPConfiguration + + Get the default time source policy for servers. + + Get + OVServerNTPConfiguration + + + When HPE OneView manages or monitors server or compute resources, it will automatically by default set the management processor NTP settings to the appliance's IP Address. Using this Cmdlet, you can get the current time synchronize policy of the managed and monitored server hardware on the appliance. When the global policy is set to sync with external NTP servers, a property is added to the returned object called NTPServers. The array contains the appliance configured NTP server(s). + +Minimum required privileges: + + * Read-Only + + + + + Get-OVServerNTPConfiguration + + ApplianceConnection + + Specify one or more HPEOneView.Appliance.Connection object(s) or Name property value(s). + +Default Value: ${Global:ConnectedSessions} | ? Default + + Object + + + + + + + ApplianceConnection + + Specify one or more HPEOneView.Appliance.Connection object(s) or Name property value(s). + +Default Value: ${Global:ConnectedSessions} | ? Default + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + + + + + None. You cannot pipe objects to this cmdlet. + + + + + + + + + + + HPEOneView.Appliance.GlobalSetting + + + + Object resource with the global setting value + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVServerNTPConfiguration + + + Get the current server time source global policy setting. + + + + + + + + + + + + + Set-OVServerNTPConfiguration + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/get-ovserverntpconfiguration + + + + + + + + Get-OVServerOneTimeBoot + + Get a servers current One Time Boot setting. + + Get + OVServerOneTimeBoot + + + HPE OneView allows you to set a one-time boot option for the server hardware. You can set the one-time boot option to any of the following: + + * Keep current settings—Keeps the previously chosen settings. + * No one-time boot—Normal boot is used when this option is selected. + * PXE—Boots from the PXE server on the network. + * Hard disk—Boots from the first local disk. + * CD—Boots from a local or virtual optical drive. + * USB—Boots from a physical or virtual USB drive. + +Other one-time boot options are available through the HPE iLO interface; however, HPE OneView offers only a common subset of one-time boot options. The one-time boot option requires the server hardware to be powered off and powered back on. If you set the one-time boot option while the server power is on, the one-time boot value is remembered until the server is powered off and then powered back on. HPE OneView does not support setting of the one-time boot option while the server is in power-on self-test (POST). + +After setting the one-time boot option, when the server hardware is powered off and powered on, HPE iLO attempts to boot the server using the selected boot option. If the selected boot option is not available, HPE iLO attempts to boot the server using the boot order defined in the server profile. After using or attempting to use the one-time boot value, the one-time boot value is reset to No one-time boot and the server boots using the boot order defined in its server profile or through HPE iLO. + +Minimum required privileges: Server administrator + + + + + Get-OVServerOneTimeBoot + + InputObject + + The server hardware or server profile resource object from Get-OVServer or Get-OVServerProfile. If providing a server profile resource, it must be assigned to a server in order for one time boot settings to be returned. + + Object + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + InputObject + + The server hardware or server profile resource object from Get-OVServer or Get-OVServerProfile. If providing a server profile resource, it must be assigned to a server in order for one time boot settings to be returned. + + Object + + Object + + + + + + + + + HPEOneView.ServerHardware [System.Management.Automation.PSCustomObject] + + + Server hardware resource object from Get-OVServer. + + + + + HPEOneView.ServerProfile [System.Management.Automation.PSCustomObject] + + + Server profile resource object from Get-OVServerProfile. + + + + + + + + HPEOneView.ServerHardware+OneTimeBoot + + + + The current One Time Boot setting of the server hardware resource. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVServer -Name MyServer1 | Get-OVServerOneTimeBoot + + Get the one time boot setting from the provided server hardware resource. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Get-OVServerProfile -Name 'My Prod Node 1' | Get-OVServerOneTimeBoot + + Get the one time boot setting from the provided server profile resource. + + + + + + + + + + + + + Get-OVServer + + + + Get-OVServerProfile + + + + Set-OVServerOneTimeBoot + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/servers/get-ovserveronetimeboot + + + + + + + + Get-OVServerProfile + + Retrieve Server Profile resource(s). + + Get + OVServerProfile + + + This Cmdlet will obtain a collection of Server Profile resources, or a specific Server Profile the specified name. It returns all aspects of the Server Profile. + +This will also provide the ability to export Server Profile objects to their own JSON encoded file. All appliance unique properties (minus the Server Hardware Type, Enclosure Group, and Connection Network assignment) are removed. Connection layout, assigned addresses, networks, bandwidth, BIOS, Boot Order, Firmware settings will all be retained. Assigned Address types will change from Virtual to UserDefined in order to retain their assignment. + + + + + Get-OVServerProfile + + Name + + The name of the server profile resource to be returned. All server profile resources will be returned if omitted. Supports * wildcard character. + + String + + + NonCompliant + + Return collection of Server Profiles that are not compliant with their template. Will not return Server Profiles that have no Template association. + + SwitchParameter + + + Unassigned + + Optional parameter that can be included with the List switch parameter to only display unassigned Server Profiles. Can also be combined with the name parameter for Server Profile wildcard name search. + + SwitchParameter + + + InputObject + + Profile a Server Hardware or Server Profile Template resource, and the associated Server Hardware will be returned. + + Object + + + Label + + Specify the label associated with resources. + + String + + + Scope + + Filter resources based on provided Scope membership. By default, all resources for the accounts Active Permissions will be displayed. Allowed values: + + * AllResources + * AllResourcesInScope + * HPEOneView.Appliance.ScopeCollection + * HPEOneView.Appliance.ConnectionPermission + + Object + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + Get-OVServerProfile + + export + + Switch used to export Server Profile object to JSON encoded file. + + SwitchParameter + + + location + + Location where to save the Server Profile + + String + + + Name + + The name of the server profile resource to be returned. All server profile resources will be returned if omitted. Supports * wildcard character. + + String + + + Unassigned + + Optional parameter that can be included with the List switch parameter to only display unassigned Server Profiles. Can also be combined with the name parameter for Server Profile wildcard name search. + + SwitchParameter + + + InputObject + + Profile a Server Hardware or Server Profile Template resource, and the associated Server Hardware will be returned. + + Object + + + Label + + Specify the label associated with resources. + + String + + + Scope + + Filter resources based on provided Scope membership. By default, all resources for the accounts Active Permissions will be displayed. Allowed values: + + * AllResources + * AllResourcesInScope + * HPEOneView.Appliance.ScopeCollection + * HPEOneView.Appliance.ConnectionPermission + + Object + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + Get-OVServerProfile + + Detailed + + Display detailed report list of Server Profiles + + SwitchParameter + + + Name + + The name of the server profile resource to be returned. All server profile resources will be returned if omitted. Supports * wildcard character. + + String + + + Label + + Specify the label associated with resources. + + String + + + Scope + + Filter resources based on provided Scope membership. By default, all resources for the accounts Active Permissions will be displayed. Allowed values: + + * AllResources + * AllResourcesInScope + * HPEOneView.Appliance.ScopeCollection + * HPEOneView.Appliance.ConnectionPermission + + Object + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Detailed + + Display detailed report list of Server Profiles + + SwitchParameter + + SwitchParameter + + False + + + InputObject + + Profile a Server Hardware or Server Profile Template resource, and the associated Server Hardware will be returned. + + Object + + Object + + + + + Label + + Specify the label associated with resources. + + String + + String + + False + + + Name + + The name of the server profile resource to be returned. All server profile resources will be returned if omitted. Supports * wildcard character. + + String + + String + + + + + NonCompliant + + Return collection of Server Profiles that are not compliant with their template. Will not return Server Profiles that have no Template association. + + SwitchParameter + + SwitchParameter + + False + + + Scope + + Filter resources based on provided Scope membership. By default, all resources for the accounts Active Permissions will be displayed. Allowed values: + + * AllResources + * AllResourcesInScope + * HPEOneView.Appliance.ScopeCollection + * HPEOneView.Appliance.ConnectionPermission + + Object + + Object + + AllResourcesInScope + + + Unassigned + + Optional parameter that can be included with the List switch parameter to only display unassigned Server Profiles. Can also be combined with the name parameter for Server Profile wildcard name search. + + SwitchParameter + + SwitchParameter + + False + + + export + + Switch used to export Server Profile object to JSON encoded file. + + SwitchParameter + + SwitchParameter + + False + + + location + + Location where to save the Server Profile + + String + + String + + + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + System.Management.Automation.PSCustomObject + + + + + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVServerProfile +Profile Name Managing BIOS Managing Firmware Assigned State +------------ ------------- ----------------- -------- ----- +Copy of test 2 False False Unassigned Normal +Profile 11 True True Encl1, bay 11 Normal +Profile 12 False False Encl1, bay 12 Normal +Profile 13 False False Encl1, bay 13 Normal +Profile 14 False False Encl1, bay 14 Normal +Profile 15 False False Encl1, bay 15 Normal +Profile 16 False False Encl1, bay 16 Normal +Test 1 False False Unassigned Normal +test 2 False False Encl1, bay 3 Normal +test 3 False False Unassigned Normal + + Generate a list of all server profiles. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + $profile = Get-OVServerProfile -Name "SA" + + Return the server profile resource with name "SA". + + + + + + + + + + -------------------------- EXAMPLE 3 -------------------------- + + + + $profiles = Get-OVServerProfile -Name profile* + + Return server profile resources that match "profile*". + + + + + + + + + + -------------------------- EXAMPLE 4 -------------------------- + + + + Get-OVServerProfile -name "test 1" -list +Profile Name Managing BIOS Managing Firmware Assigned State +------------ ------------- ----------------- -------- ----- +Test 1 False False Unassigned Normal + + Generate a report of a specific server profile. + + + + + + + + + + -------------------------- EXAMPLE 5 -------------------------- + + + + Get-OVServerProfile -unassigned +Profile Name Managing BIOS Managing Firmware Assigned State +------------ ------------- ----------------- -------- ----- +Copy of test 2 False False Unassigned Normal +Test 1 False False Unassigned Normal +test 3 False False Unassigned Normal + + Generate a list of all Unassigned server profiles. + + + + + + + + + + -------------------------- EXAMPLE 6 -------------------------- + + + + Get-OVServerProfile -export -location c:\profiles + + Save all Server Profile objects to their own backup file to C:\profiles. + + + + + + + + + + -------------------------- EXAMPLE 7 -------------------------- + + + + Get-OVServerProfile -name Profile1 -export -location c:\profiles + + Save Profile1 Server Profile object to its own backup file in C:\profiles. + + + + + + + + + + + + + Convert-OVServerProfile + + + + Convert-OVServerProfileTemplate + + + + ConvertTo-OVServerProfileTemplate + + + + Copy-OVServerProfile + + + + Disable-OVMaintenanceMode + + + + Enable-OVMaintenanceMode + + + + Get-OVServerProfileConnectionList + + + + Get-OVServerProfileMessage + + + + Get-OVServerProfileTemplate + + + + Join-OVServerProfileToTemplate + + + + New-OVServerProfile + + + + New-OVServerProfileAssign + + + + New-OVServerProfileAttachVolume + + + + New-OVServerProfileConnection + + + + New-OVServerProfileLogicalDisk + + + + New-OVServerProfileLogicalDiskController + + + + New-OVServerProfileTemplate + + + + Remove-OVServerProfile + + + + Remove-OVServerProfileTemplate + + + + Save-OVServerProfile + + + + Save-OVServerProfileTemplate + + + + Set-OVServerProfile + + + + Set-OVServerProfileTemplate + + + + Update-OVServerProfile + + + + Get-OVServerOneTimeBoot + + + + Set-OVServerOneTimeBoot + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/servers/get-ovserverprofile + + + + + + + + Get-OVServerProfileConnectionList + + Retrieve Server Profile Connections + + Get + OVServerProfileConnectionList + + + Obtain a formatted list of server profile connection IDs, include hardware address, device mapping, and boot settings. + + + + + Get-OVServerProfileConnectionList + + Name + + The name of the server profile resource to be returned. All server profile resources will be returned if name is omitted. + + String + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. + + Object + + + + + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Name + + The name of the server profile resource to be returned. All server profile resources will be returned if name is omitted. + + String + + String + + + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + System.Collections.ArrayList + + + + Formatted table of Server Profile Connections + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVServerProfileConnectionList "test" +serverProfile portId cid networkType macAddress wwpn boot arrayTarget lun +------------- -------- --- ----------- ---------- ---- ---- ----------- --- +test Flb 1:1-a 1 Ethernet 36:37:6B:90:00:08 1000378079e00011 Primary +test Flb 1:1-b 2 Ethernet 36:37:6B:90:00:06 1000378079e0000d Secondary + + List Server Profile connections for Test. + + + + + + + + + + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/servers/get-ovserverprofileconnectionlist + + + + + + + + Get-OVServerProfileMessage + + Display Server Profile alert messages. + + Get + OVServerProfileMessage + + + Use this Cmdlet to display alert or other activity messages that are not tracked as Alerts or Tasks. For instance, failed Connection will be reported as a Server Profile Message. Firmware update status (using HPSUT) wil be displayed as messages. + + + + + Get-OVServerProfileMessage + + InputObject + + The Server Profile resource object. + + Object + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + InputObject + + The Server Profile resource object. + + Object + + Object + + + + + + + + + HPEOneView.ServerProfile [System.Management.Automation.PSCustomObject] + + + Server Profile resource object from Get-OVServerProfile + + + + + + + + HPEOneView.ServerProfileMessage [System.Management.Automation.PSCustomObject] + + + + Server Profile message object. + + + + + System.Collections.ArrayList <HPEOneView.ServerProfileMessage> + + + + Server Profile message object. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVServerProfile MyProfile | Get-OVServerProfileMessage + + Display the Server Profile messages for the provided resource. + + + + + + + + + + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/servers/get-ovserverprofilemessage + + + + + + + + Get-OVServerProfileTemplate + + Retrieve Server Profile Template resource(s). + + Get + OVServerProfileTemplate + + + This Cmdlet will obtain a collection of Server Profile Template resources, or a specific Server Profile Template with the specified name. It +returns all aspects of the Server Profile Template. + +This will also provide the ability to export Server Profile Template objects to their own JSON encoded file. All appliance unique properties (minus the Server Hardware Type, Enclosure Group, and Connection Network assignment) are removed. Connection layout, assigned addresses, networks, bandwidth, BIOS, Boot Order, Firmware settings will all be retained. Assigned Address types will change from Virtual to UserDefined in order to retain their assignment. + + + + + Get-OVServerProfileTemplate + + Name + + The name of the specific Server Profile Template resource to retrieve + + String + + + ServerHardwareType + + Provide the Server Hardware Type resource object or name to return Server Profile Templates designed for it. + + String + + + Label + + Specify the label associated with resources. + + String + + + Scope + + Filter resources based on provided Scope membership. By default, all resources for the accounts Active Permissions will be displayed. Allowed values: + + * AllResources + * AllResourcesInScope + * HPEOneView.Appliance.ScopeCollection + * HPEOneView.Appliance.ConnectionPermission + + Object + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + Get-OVServerProfileTemplate + + Export + + Switch used to export Server Profile Template object to JSON encoded file. + + SwitchParameter + + + Location + + Location where to save the Server Profile Template file. + + String + + + Name + + The name of the specific Server Profile Template resource to retrieve + + String + + + ServerHardwareType + + Provide the Server Hardware Type resource object or name to return Server Profile Templates designed for it. + + String + + + Label + + Specify the label associated with resources. + + String + + + Scope + + Filter resources based on provided Scope membership. By default, all resources for the accounts Active Permissions will be displayed. Allowed values: + + * AllResources + * AllResourcesInScope + * HPEOneView.Appliance.ScopeCollection + * HPEOneView.Appliance.ConnectionPermission + + Object + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + Get-OVServerProfileTemplate + + Detailed + + Displays detailed information about the Server Profile Template in tabular format + + SwitchParameter + + + Name + + The name of the specific Server Profile Template resource to retrieve + + String + + + ServerHardwareType + + Provide the Server Hardware Type resource object or name to return Server Profile Templates designed for it. + + String + + + Label + + Specify the label associated with resources. + + String + + + Scope + + Filter resources based on provided Scope membership. By default, all resources for the accounts Active Permissions will be displayed. Allowed values: + + * AllResources + * AllResourcesInScope + * HPEOneView.Appliance.ScopeCollection + * HPEOneView.Appliance.ConnectionPermission + + Object + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Detailed + + Displays detailed information about the Server Profile Template in tabular format + + SwitchParameter + + SwitchParameter + + False + + + Export + + Switch used to export Server Profile Template object to JSON encoded file. + + SwitchParameter + + SwitchParameter + + False + + + Label + + Specify the label associated with resources. + + String + + String + + False + + + Location + + Location where to save the Server Profile Template file. + + String + + String + + + + + Name + + The name of the specific Server Profile Template resource to retrieve + + String + + String + + + + + Scope + + Filter resources based on provided Scope membership. By default, all resources for the accounts Active Permissions will be displayed. Allowed values: + + * AllResources + * AllResourcesInScope + * HPEOneView.Appliance.ScopeCollection + * HPEOneView.Appliance.ConnectionPermission + + Object + + Object + + AllResourcesInScope + + + ServerHardwareType + + Provide the Server Hardware Type resource object or name to return Server Profile Templates designed for it. + + String + + String + + + + + + + + + None + + + + + + + + + + + HPEOneView.ServerProfileTemplate [System.Management.Automation.PSCustomObject] + + + + Server Profile template resource + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + $templates = Get-OVServerProfileTemplate + + Return all the server profile templates managed by the appliance. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + $template = Get-OVServerProfileTemplate "SA" + + Return the server profile template resource with name "SA". + + + + + + + + + + -------------------------- EXAMPLE 3 -------------------------- + + + + $profiletemplates = Get-OVServerProfileTemplate profile* + + Return server profile template resources that match "profile*". + + + + + + + + + + -------------------------- EXAMPLE 4 -------------------------- + + + + Get-OVServerProfileTemplate +Profile Name Managing BIOS Managing Firmware Assigned State +------------ ------------- ----------------- -------- ----- +Copy of test 2 False False Unassigned Normal +Test 1 False False Unassigned Normal +test 3 False False Unassigned Normal + + Generate a list of all server profiles. + + + + + + + + + + -------------------------- EXAMPLE 5 -------------------------- + + + + Get-OVServerProfileTemplate -name "test 1" +Profile Name Managing BIOS Managing Firmware Assigned State +------------ ------------- ----------------- -------- ----- +Test 1 False False Unassigned Normal + + Show a specific Server Profile Template, "test 1". + + + + + + + + + + -------------------------- EXAMPLE 6 -------------------------- + + + + Get-OVServerProfileTemplate -export -location c:\profiles + + Save all Server Profile Template objects to their own backup file to C:\profiles. + + + + + + + + + + -------------------------- EXAMPLE 7 -------------------------- + + + + Get-OVServerProfileTemplate -name Profile1 -export -location c:\profiles + + Save Profile1 Server Profile template object to its own backup file in C:\pro + + + + + + + + + + + + + Convert-OVServerProfileTemplate + + + + ConvertTo-OVServerProfileTemplate + + + + New-OVServerProfileTemplate + + + + Remove-OVServerProfileTemplate + + + + Save-OVServerProfileTemplate + + + + Set-OVServerProfileTemplate + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/servers/get-ovserverprofiletemplate + + + + + + + + Get-OVServiceAlert + + Generate report of HPE OneView Remote Support service events. + + Get + OVServiceAlert + + + HPE OneView automatically checks if your hardware has a valid entitlement to Hewlett Packard Enterprise support. A valid entitlement is a Hewlett Packard Enterprise warranty or an active contract. If a valid entitlement to support is found, HPE OneView Remote Support opens a support case for a hardware failure. This Cmdlet allows administrators to display and/or export service events logged by the HPE OneView appliance. + + + + + Get-OVServiceAlert + + InputObject + + Use to filter for the supported hardware resource object. Enclosures, Server Hardware and Server Profile objects are supported. If an Enclosure resource is provided, only the Enclosure service events are queried. Associated Server Hardare within the enclosure is not. If providing a Server Profile object, it must be assigned to a supported hardware platform. If the Server Profile has moved between hardware resources, only the currently assigned server hardware resource object will be used to query for service events. + + Object + + + State + + Specify the state of the Service Alert. The state is not correlated to the associated Alert. + + * Closed - The state of Service event when the service call is closed. + * Error - The Service request has some error None This is a default state. + * Open - The state of Service event when the service call is open. + * Pending - The state of Service event when the service call is pending. + * Received - The state of Service event when the service call is received. + * Submitted - The state of Service event when the service call is submitted. + + String + + + Count + + Specify the number of service alerts to return. + + Int + + + TimeSpan + + Specify a TimeSpan object in number of days. Cannot be combined with -Start and -End parameters. + + TimeSpan + + + Start + + DateTime object of the start date and time to being query. + + DateTime + + + End + + DateTime object of the end date and time accompanied with the -Start parameter. If omitted, the current time of the PC is used. + + DateTime + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + Array + + (${Global:ConnectedSessions} | ? Default) + + + Count + + Specify the number of service alerts to return. + + Int + + Int + + + + + End + + DateTime object of the end date and time accompanied with the -Start parameter. If omitted, the current time of the PC is used. + + DateTime + + DateTime + + + + + InputObject + + Use to filter for the supported hardware resource object. Enclosures, Server Hardware and Server Profile objects are supported. If an Enclosure resource is provided, only the Enclosure service events are queried. Associated Server Hardare within the enclosure is not. If providing a Server Profile object, it must be assigned to a supported hardware platform. If the Server Profile has moved between hardware resources, only the currently assigned server hardware resource object will be used to query for service events. + + Object + + Object + + + + + Start + + DateTime object of the start date and time to being query. + + DateTime + + DateTime + + + + + State + + Specify the state of the Service Alert. The state is not correlated to the associated Alert. + + * Closed - The state of Service event when the service call is closed. + * Error - The Service request has some error None This is a default state. + * Open - The state of Service event when the service call is open. + * Pending - The state of Service event when the service call is pending. + * Received - The state of Service event when the service call is received. + * Submitted - The state of Service event when the service call is submitted. + + String + + String + + + + + TimeSpan + + Specify a TimeSpan object in number of days. Cannot be combined with -Start and -End parameters. + + TimeSpan + + TimeSpan + + + + + + + + + HPEOneView.ServerHardware + + + A Server Hardware resource object from Get-OVServer. + + + + + HPEOneView.ServerProfile + + + A Server Profile resource object from Get-OVServerProfile. If the Server Profile is not associated with a server hardware resource, an excpetion is thrown. If the Server Profile has moved from one server hardware resource to another, only the currently assigned server hardware resource will be queried. + + + + + HPEOneView.Enclosure + + + An Enclosure resource object from Get-OVEnclosure. + + + + + + + + HPEOneView.Appliance.ServiceAlert + + + + The Service Alert object that contains the CaseID, associated resource name, URI and serial number, and description of the service event. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVServiceAlert + + Get all Service Alerts from the connected appliance. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Get-OVServiceAlert -Count 10 + + Get the first 10 Service Alerts from the connected appliance. + + + + + + + + + + -------------------------- EXAMPLE 3 -------------------------- + + + + $TimeSpan = New-TimeSpan -Days 30 +Get-OVServiceAlert -Count 10 -TimeSpan $TimeSpan + + Get the first 10 Service Alerts within the last 30 days from the connected appliance. + + + + + + + + + + -------------------------- EXAMPLE 4 -------------------------- + + + + Get-OVServiceAlert -Start ([DateTime]"2018-01-05") -End ([DateTime]"2018-01-30") + + Get the Service Alerts within the specified date range from the connected appliance. + + + + + + + + + + -------------------------- EXAMPLE 5 -------------------------- + + + + Get-OVServer -Name "Encl1, Bay 1" -ErrorAction Stop | Get-OVServiceAlert -Start ([DateTime]"2018-01-05") -End ([DateTime]"2018-01-30") + + Get the Service Alerts within the specified date range for the specified server hardware resource from the connected appliance. + + + + + + + + + + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/get-ovservicealert + + + + + + + + Get-OVSmtpAlertEmailFilter + + Retrieve SMTP email alert filter(s) configured on the appliance. + + Get + OVSmtpAlertEmailFilter + + + Email alerting feature notifies specified recipients when a certain alert occurs. When this feature is configured and enabled, the appliance performs these steps in addition to posting the alert: + + * The appliance compares the alert to configured search criteria. + * If the alert matches, it creates an email message containing the text of the alert. + * The appliance sends the email message to designated recipients in both plain text and HTML MIME types. Sending in both types allows the recipient?s mail application to determine the display. + +You can enable or disable this email notification feature, or you can enable or disable individual filter notifications, as required. + +The appliance provides for as many as 100 recipient and filter combinations, and allows as many as 50 recipients in a single email message. This flexibility lets you fine-tune which alert messages are sent and to whom. For example, you can configure the appliance to send Warning alerts to one recipient and Critical alerts to another. + +This Cmdlet will help get the configured email alert filter(s) configured on the appliance. + +Minimum required privileges: Infrastructure administrator. + + + + + Get-OVSmtpAlertEmailFilter + + Name + + Name of the Filter to return. Supports wildcard. To return the remote support email filter configuration, specify "Remote Support" as the filter name. + + String + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Name + + Name of the Filter to return. Supports wildcard. To return the remote support email filter configuration, specify "Remote Support" as the filter name. + + String + + String + + + + + + + + + None. You cannot pipe objects to this cmdlet. + + + + + + + + + + + HPEOneView.Appliance.AlertEmailFilter [System.Management.Automation.PSCustomObject] + + + + The configured email alert filter on the appliance. + + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVSmtpAlertEmailFilter -Name "Monitor CPU Error and Warning conditions" + + Get the specified email alert filter. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Get-OVSmtpAlertEmailFilter -Name "Remote Support" + + Get the remote support email filter. + + + + + + + + + + + + + Get-OVSMTPConfig + + + + Set-OVSMTPConfig + + + + Test-OVEmailAlert + + + + Add-OVSmtpAlertEmailFilter + + + + Set-OVSmtpAlertEmailFilter + + + + Remove-OVSmtpAlertEmailFilter + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/get-ovsmtpalertemailfilter + + + + + + + + Get-OVSMTPConfig + + Configure appliance SMTP Reporting settings. + + Get + OVSMTPConfig + + + This Cmdlet will retrieve the SMTP settings for the appliance. + + + + + Get-OVSMTPConfig + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + None. You cannot pipe objects to this Cmdlet + + + + + + + + System.Management.Automation.PSCustomObject + + + + Returns SMTP Email Configurtion object from the specified appliance(s). + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVSMTPConfig + + Get SMTP Email Alert configuration from the default appliance connection. + + + + + + + + + + + + + Set-OVSMTPConfig + + + + Add-OVSmtpAlertEmailFilter + + + + Get-OVSmtpAlertEmailFilter + + + + Set-OVSmtpAlertEmailFilter + + + + Remove-OVSmtpAlertEmailFilter + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/get-ovsmtpconfig + + + + + + + + Get-OVSnmpReadCommunity + + GRetrieve Appliance SNMP Read Community. + + Get + OVSnmpReadCommunity + + + Get the configured appliance SNMP Read Community string. + + + + + Get-OVSnmpReadCommunity + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + System.Management.Automation.PSCustomObject + + + + The SNMP Read Community + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVSnmpReadCommunity + + Retrieve the SNMP Read Community string the appliance is configured to use from all connected sessions. + + + + + + + + + + + + + Set-OVSnmpReadCommunity + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/get-ovsnmpreadcommunity + + + + + + + + Get-OVSnmpV3User + + Get defined SNMPv3 user from appliance. + + Get + OVSnmpV3User + + + HPE OneView can be used as a proxy to forward device traps from servers and enclosures (OA) to other SNMP-enabled applications on the network. HPE OneView can forward traps, as SNMPv3 or SNMPv1 traps, to configured destinations. + +Appliance SNMP settings allow you to add destinations to which the traps need to be forwarded. You can configure each destination as an SNMPv1 or SNMPv3 destination, depending on whether the traps are sent in SNMPv1 or SNMPv3 formats. + +Additionally, if you have Gen6 or Gen7 servers being monitored by HPE OneView in your environment, you can configure the read community string that HPE OneView uses for monitoring these servers with SNMPv1. + +NOTE: To configure SNMP trap forwarding for network devices (interconnects and switches), use the New-OVSnmpV3User and include it within the New-OVSnmpTrapDestination Cmdlet. + +Minimum required privileges: Infrastructure administrator + + + + + Get-OVSnmpV3User + + Name + + Filter for the SNMPv3 user. Supports wildcard characters. + + String + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + Array + + (${Global:ConnectedSessions} | ? Default) + + + Name + + Filter for the SNMPv3 user. Supports wildcard characters. + + String + + String + + + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + HPEOneView.Appliance.SnmpV3User + + + + Appliance SNMPv3 user object. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVSnmpV3User + + Get the defined SNMPv3 users on the appliance. + + + + + + + + + + + + + New-OVSnmpV3User + + + + Remove-OVSnmpV3User + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/get-ovsnmpv3user + + + + + + + + Get-OVStoragePool + + Retrieve Storage Pool resource(s). + + Get + OVStoragePool + + + Obtain a collection of storage pools (i.e. CPG"s) from discovered and managed storage systems. + + + + + Get-OVStoragePool + + Name + + The name of the specific storage pool resource to be returned. All storage pool resources will be returned if omitted. + + String + + + StorageSystem + + The name or Storage System object of the specific storage system to return storage pool resource from. Can be combined with the PoolName parameter to single out a specific storage pool in a specific storage system. + + Object + + + Label + + Specify the Label to filter on. + + Object + + + Scope + + Filter resources based on provided Scope membership. By default, all resources for the accounts Active Permissions will be displayed. Allowed values: + + * AllResources + * AllResourcesInScope + * HPEOneView.Appliance.ScopeCollection + * HPEOneView.Appliance.ConnectionPermission + + Object + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Array + + + Managed + + Only returned storage pools that are managed. + + SwitchParameter + + + Unmanaged + + Only returned storage pools that are unmanaged. + + SwitchParameter + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Array + + Array + + (${Global:ConnectedSessions} | ? Default) + + + Label + + Specify the Label to filter on. + + Object + + Object + + + + + Managed + + Only returned storage pools that are managed. + + SwitchParameter + + SwitchParameter + + + + + Name + + The name of the specific storage pool resource to be returned. All storage pool resources will be returned if omitted. + + String + + String + + + + + Scope + + Filter resources based on provided Scope membership. By default, all resources for the accounts Active Permissions will be displayed. Allowed values: + + * AllResources + * AllResourcesInScope + * HPEOneView.Appliance.ScopeCollection + * HPEOneView.Appliance.ConnectionPermission + + Object + + Object + + AllResourcesInScope + + + StorageSystem + + The name or Storage System object of the specific storage system to return storage pool resource from. Can be combined with the PoolName parameter to single out a specific storage pool in a specific storage system. + + Object + + Object + + + + + Unmanaged + + Only returned storage pools that are unmanaged. + + SwitchParameter + + SwitchParameter + + + + + + + + + HPEOneView.Storage.System + + + Managed Storage System from Get-OVStorageSystem. + + + + + + + + HPEOneView.Storage.Pool [System.Management.Automation.PSCustomObject] + + + + Single Storage Pool resource + + + + + System.Collections.ArrayList + + + + Multiple Storage Pool resources + + + + + The matching storage pool resources. + + + + + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVStoragePool +Status Name Storage System Storage Domain Drive Type RAID Total Allocated Free +------ ---- -------------- -------------- ---------- ---- -------- ----------- ------- +OK FC_NO_DN ThreePAR7200-5706 NoDomain FC RAID5 1,048,576.00GB 22.13GB 1,048,553.88GB +OK FC_NO_DN ThreePAR7200-2870 NoDomain FC RAID5 1,048,576.00GB 22.13GB 1,048,553.88GB + + Get all available storage pools. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Get-OVStoragePool | format-list +Name : FC_NO_DN +Status : OK +Storage System : ThreePAR7200-5706 +Domain : NoDomain +Drive Type : FC +RAID : RAID5 +Total : 1,048,576.00 GB +Allocated : 22.13 GB +Free : 1,048,553.88 GB +Volumes : 0 +Volume Templates : 0 + +Name : FC_NO_DN +Status : OK +Storage System : ThreePAR7200-2870 +Domain : NoDomain +Drive Type : FC +RAID : RAID5 +Total : 1,048,576.00 GB +Allocated : 22.13 GB +Free : 1,048,553.88 GB +Volumes : 0 +Volume Templates : 0 + + Get all available storage pools, display using Format-List to see extended information. + + + + + + + + + + -------------------------- EXAMPLE 3 -------------------------- + + + + $myPool = Get-OVStoragePool -name "HP_CPG1" + + Return the storage pool resource(s) with the name "HP_CPG1" + + + + + + + + + + -------------------------- EXAMPLE 4 -------------------------- + + + + $myPools = Get-OVStoragePool + + Return all the storage pool resources + + + + + + + + + + -------------------------- EXAMPLE 5 -------------------------- + + + + Get-OVStoragePool -StorageSystem "HP_3PAR_1" + + Returns all managed storage pool resources on the storage system "HP_3PAR_1" + + + + + + + + + + -------------------------- EXAMPLE 6 -------------------------- + + + + Get-OVStoragePool -poolName "HP_CPG1" -systemName "HP_3PAR_1" + + Returns the storage pool resource "HP_CPG1" on the storage system "HP_3PAR_1" + + + + + + + + + + + + + Add-OVStoragePool + + + + Remove-OVStoragePool + + + + Set-OVStoragePool + + + + Update-OVStoragePool + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/storage/get-ovstoragepool + + + + + + + + Get-OVStorageSystem + + Retrieve Storage System resource(s). + + Get + OVStorageSystem + + + This Cmdlet will display all or a specific storage system configured on the HPE OneView appliance. A specific Storage System can be searched for by using the System Name (not FQDN) or Serial Number. Use the List switch to display a report of the requested storage system(s). + + + + + Get-OVStorageSystem + + Name + + Display the specific Storage System by its system name. + + String + + + Hostname + + Display the specific Storage System by its hostname (IP Address or FQDN). + + String + + + Family + + Specify the type of Storage System to add: Nimble, StorageVirtual, StoreServ or Primera. + + String + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + + List + + Generate a report of the specific or all storage systems. + + SwitchParameter + + + + Get-OVStorageSystem + + SerialNumber + + Search for the Storage System based on the resource serial number instead of the name. + + String + + + Family + + Specify the type of Storage System to add: Nimble, StorageVirtual, StoreServ or Primera. + + String + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + + List + + Generate a report of the specific or all storage systems. + + SwitchParameter + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + Array + + (${Global:ConnectedSessions} | ? Default) + + + Family + + Specify the type of Storage System to add: Nimble, StorageVirtual, StoreServ or Primera. + + String + + String + + + + + Hostname + + Display the specific Storage System by its hostname (IP Address or FQDN). + + String + + String + + + + + List + + Generate a report of the specific or all storage systems. + + SwitchParameter + + SwitchParameter + + False + + + Name + + Display the specific Storage System by its system name. + + String + + String + + + + + SerialNumber + + Search for the Storage System based on the resource serial number instead of the name. + + String + + String + + + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + HPEOneView.Storage.System [System.Management.Automation.PSCustomObject] + + + + Single Storage System + + + + + System.Collections.ArrayList <HPEOneView.Storage.System> + + + + Multiple Storage Systems + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVStorageSystem + + Get all storage system resource objects managed by the appliance. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Get-OVStorageSystem HP3Par_1 +Status Name Serial Number Model Storage Domain WWN Firmware +------ ---- ------------- ----- -------------- --- -------- +Ok HP3Par_1 TXQ1020307 HP_3PAR 7200 NoDomain 28:11:00:02:AC:00:08:7D 3.1.3 + + Get "HP3Par_1" storage system resource object managed by the appliance. + + + + + + + + + + -------------------------- EXAMPLE 3 -------------------------- + + + + Get-OVStorageSystem HP3Par_1 -report +Status Name Serial Number Model Storage Domain WWN Firmware +------ ---- ------------- ----- -------------- --- -------- +Ok HP3Par_1 TXQ1020307 HP_3PAR 7200 NoDomain 28:11:00:02:AC:00:08:7D 3.1.3 + + + +[Credentials] Username Address +------------- -------- ------- + 3paradm 172.18.11.13 + + + +[Capacity] Status Total Allocated Free +---------- ------ -------- ----------- ------- + Ok 90.00TB 0.01TB 90.00TB + + + +[Storage Pools] Status Name Drive Type RAID Total Allocated Free +--------------- ------ ------- ---------- ---- -------- ----------- ------- + OK FC_NO_DN FC RAID5 1,048,576.00GB 22.13GB 1,048,553.88GB + + + +[Host Ports] Status Port WWPN Expected Network Actual Network Port Group Name +------------ ------ ------- ----------------------- ---------------- -------------- --------------- + Ok 0:1:1 01:00:4A:2B:21:E1:00:11 Fabric A (DA) Fabric A (DA) Auto + Ok 0:2:2 01:02:4A:2B:21:E1:00:12 Fabric A (DA) Fabric A (DA) Auto + + Show a report of the managed storage system(s). + + + + + + + + + + + + + Add-OVStorageSystem + + + + Remove-OVStorageSystem + + + + Show-OVStorageSystemPerformancePolicy + + + + Update-OVStorageSystem + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/storage/get-ovstoragesystem + + + + + + + + Get-OVStorageVolume + + Retrieve Storage Volume resource(s). + + Get + OVStorageVolume + + + This Cmdlet will display all or a specific storage volume(s) created on the HPE OneView appliance. A specific storage volume can be searched for by using the Name. Use the List switch to display a report of the requested volume(s), including any assignments to Server Profiles. + + + + + Get-OVStorageVolume + + Name + + Specify the name of the Storage Volume to display. + + String + + + StorageVolumeTemplate + + Return a list of provisioned Storage Volumes by their associated Storage Volume Template. + + Object + + + Available + + Use to display Storage Volumes that are available for attachment. + + SwitchParameter + + + Label + + Specify the label associated with resources. + + String + + + Scope + + Filter resources based on provided Scope membership. By default, all resources for the accounts Active Permissions will be displayed. Allowed values: + + * AllResources + * AllResourcesInScope + * HPEOneView.Appliance.ScopeCollection + * HPEOneView.Appliance.ConnectionPermission + + Object + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + + + Get-OVStorageVolume + + InputObject + + Provide a Server Profile object and all associated Storage Volumes will be returned. + + Object + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + Array + + (${Global:ConnectedSessions} | ? Default) + + + Available + + Use to display Storage Volumes that are available for attachment. + + SwitchParameter + + SwitchParameter + + False + + + InputObject + + Provide a Server Profile object and all associated Storage Volumes will be returned. + + Object + + Object + + + + + Label + + Specify the label associated with resources. + + String + + String + + False + + + Name + + Specify the name of the Storage Volume to display. + + String + + String + + + + + Scope + + Filter resources based on provided Scope membership. By default, all resources for the accounts Active Permissions will be displayed. Allowed values: + + * AllResources + * AllResourcesInScope + * HPEOneView.Appliance.ScopeCollection + * HPEOneView.Appliance.ConnectionPermission + + Object + + Object + + AllResourcesInScope + + + StorageVolumeTemplate + + Return a list of provisioned Storage Volumes by their associated Storage Volume Template. + + Object + + Object + + + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + System.Collections.ArrayList <HPEOneView.Storage.Volume> + + + + Multiple storage volume resources + + + + + HPEOneView.Storage.Volume [System.Management.Automation.PSCustomObject] + + + + Formatted table view of storage volume resources + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVStorageVolume + + Return all storage volume resource objects. + + + + + + + + + + + + + Add-OVStorageVolume + + + + ConvertTo-OVStorageVolume + + + + Get-OVStorageVolumeSet + + + + Get-OVStorageVolumeSnapShot + + + + Get-OVStorageVolumeTemplate + + + + Get-OVStorageVolumeTemplatePolicy + + + + New-OVStorageVolume + + + + New-OVStorageVolumeSnapshot + + + + New-OVStorageVolumeTemplate + + + + Remove-OVStorageVolume + + + + Remove-OVStorageVolumeSnapshot + + + + Remove-OVStorageVolumeTemplate + + + + Set-OVStorageVolume + + + + Set-OVStorageVolumeTemplate + + + + Set-OVStorageVolumeTemplatePolicy + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/storage/get-ovstoragevolume + + + + + + + + Get-OVStorageVolumeSet + + Get available storage volume sets. + + Get + OVStorageVolumeSet + + + A collection of volumes is referred to as volume set in HPE OneView. Volume sets are used to govern data-protection policies, such as snapshot and replication schedules. For HPE Nimble storage, the corresponding terminology for "volume sets" is "data protection volume collections". Volumes that hold multiple components of an application, such as databases and transaction logs, can be grouped into a volume set. + +This Cmdlet will return the available volume sets from the available storage systems. Volume sets are created on the storage system. + + + + + Get-OVStorageVolumeSet + + Name + + Filter for the resource name. + + String + + + Label + + Specify the label associated with resources. + + String + + + Scope + + Filter resources based on provided Scope membership. By default, all resources for the accounts Active Permissions will be displayed. Allowed values:nr + * AllResources + *AllResourcesInScope + * HPEOneView.Appliance.ScopeCollection + * HPEOneView.Appliance.ConnectionPermission + + Object + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Label + + Specify the label associated with resources. + + String + + String + + + + + Name + + Filter for the resource name. + + String + + String + + + + + Scope + + Filter resources based on provided Scope membership. By default, all resources for the accounts Active Permissions will be displayed. Allowed values:nr + * AllResources + *AllResourcesInScope + * HPEOneView.Appliance.ScopeCollection + * HPEOneView.Appliance.ConnectionPermission + + Object + + Object + + AllResourcesInScope + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + HPEOneView.Storage.VolumeSet + + + + The available storage system volume set. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVStorageVolumeSet + + Get all available storage sets. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Get-OVStorageVolumeSet -Name VolumeSets + + Get the specified "VolumeSets" storage sets. + + + + + + + + + + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/storage/get-ovstoragevolumeset + + + + + + + + Get-OVStorageVolumeSnapShot + + Retrieve Storage Volume Snapshot resource(s). + + Get + OVStorageVolumeSnapShot + + + This Cmdlet will display all of the avialable snapshots for a given Storage Volume or multiple Storage Volumes. + + + + + Get-OVStorageVolumeSnapShot + + InputObject + + Aliases [-Volume] + +Provide the Storage Volume resource object. + + Object + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + +Default Value: ${Global:ConnectSessions} | ? Default + + Object + + + + + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + +Default Value: ${Global:ConnectSessions} | ? Default + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + InputObject + + Aliases [-Volume] + +Provide the Storage Volume resource object. + + Object + + Object + + + + + + + + + HPEOneView.Storage.Volume [System.Management.Automation.PSCustomObject] + + + Storage Volume resource + + + + + + + + System.Collections.ArrayList <HPEOneView.Storage.VolumeSnapshot> + + + + Multiple storage volume snapshot resources + + + + + HPEOneView.Storage.VolumeSnapshot [System.Management.Automation.PSCustomObject] + + + + Formatted table view of storage volume snapshot resources + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVStorageVolume | Get-OVStorageVolumeSnapShot +Appliance Name Parent Volume State Capacity +--------- ---- ------------- ----- -------- +hpov.domain.com Vol1_20160211220746 Vol1 Configured (None) 10.00 GB +hpov.domain.com Vol1_20160224235647 Vol1 Configured (None) 10.00 GB +hpov.domain.com Vol1_20160224235716 Vol1 Configured (None) 10.00 GB +hpov.domain.com Shared 1_20160224232717 Shared 1 Configured (None) 1,000.00 GB +hpov.domain.com Shared 1_20160224235621 Shared 1 Configured (None) 1,000.00 GB +hpov.domain.com Shared 1 Snapshot Converted_20160225214317 Shared 1 Snapshot Converted Configured (None) 1,000.00 GB + + Return all storage volume snapshot resource objects from all available storage volume resources. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Get-OVStorageVolume "Volume 1" | Get-OVStorageVolumeSnapShot + + Get available storage volume snapshots from a specific Storage Volume. + + + + + + + + + + + + + New-OVStorageVolumeSnapshot + + + + Remove-OVStorageVolumeSnapshot + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/storage/get-ovstoragevolumesnapshot + + + + + + + + Get-OVStorageVolumeTemplate + + Retrieve Storage Volume Template (SVT) resource(s). + + Get + OVStorageVolumeTemplate + + + Retrieve configured Storage Volume Template(s) from the appliance. + + + + + Get-OVStorageVolumeTemplate + + Name + + The Storage Volume Template name. + + String + + + Label + + Specify the label associated with resources. + + String + + + Scope + + Filter resources based on provided Scope membership. By default, all resources for the accounts Active Permissions will be displayed. Allowed values: + + * AllResources + * AllResourcesInScope + * HPEOneView.Appliance.ScopeCollection + * HPEOneView.Appliance.ConnectionPermission + + Object + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + +Default Value: ${Global:ConnectSessions} + + Object + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + +Default Value: ${Global:ConnectSessions} + + Object + + Object + + ${Global:ConnectedSessions} + + + Label + + Specify the label associated with resources. + + String + + String + + False + + + Name + + The Storage Volume Template name. + + String + + String + + + + + Scope + + Filter resources based on provided Scope membership. By default, all resources for the accounts Active Permissions will be displayed. Allowed values: + + * AllResources + * AllResourcesInScope + * HPEOneView.Appliance.ScopeCollection + * HPEOneView.Appliance.ConnectionPermission + + Object + + Object + + AllResourcesInScope + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + HPEOneView.Storage.VolumeTemplate [System.Management.Automation.PSCustomObject] + + + + Single Storage Volume Template + + + + + System.COllections.ArrayList <HPEOneView.Storage.VolumeTemplate> + + + + Multiple Storage Volume Template + + + + + The matching Storage Volume Template resource(s). + + + + + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVStorageVolumeTemplate + + Get all available Storage Volume Templates. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Get-OVStorageVolumeTemplate -templateName R5SVT-1 + + Get the "R5SVT-1" template. + + + + + + + + + + + + + Get-OVStorageVolumeTemplatePolicy + + + + New-OVStorageVolumeTemplate + + + + Remove-OVStorageVolumeTemplate + + + + Set-OVStorageVolumeTemplate + + + + Set-OVStorageVolumeTemplatePolicy + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/storage/get-ovstoragevolumetemplate + + + + + + + + Get-OVStorageVolumeTemplatePolicy + + Retrieve Storage Volume Template Global Policy. + + Get + OVStorageVolumeTemplatePolicy + + + By default, Storage Volumes can be created without reference to a Storage Volume Template. This Cmdlet will display the global policy setting. Use Set-OVStorageVolumeTemplatePolicy to modify the global policy setting. + + + + + Get-OVStorageVolumeTemplatePolicy + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + Array + + (${Global:ConnectedSessions} | ? Default) + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + HPEOneView.Appliance.GlobalSetting + + + + Object resource with the global setting value + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVStorageVolumeTemplatePolicy +Appliance Name Value +--------- ---- ----- +MyAppliance.domain.com StorageVolumeTemplateRequired true +MyAppliance2.domain.com StorageVolumeTemplateRequired false + + Get the Storage Volume Template Global Policy setting from all connected appliances. + + + + + + + + + + + + + Set-OVStorageVolumeTemplatePolicy + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/storage/get-ovstoragevolumetemplatepolicy + + + + + + + + Get-OVSwitch + + Get a Switch resource. + + Get + OVSwitch + + + Retrieve a Switch that is managed by HPE OneView. Currently, HPE OneView can Manage or Monitor Cisco Nexus-family of switches. This Cmdlet will retrieve the specified or all Logical Switch Group resources. + + + + + Get-OVSwitch + + Name + + The Switch resource Name. Supports the * wildcard character. + + String + + + Scope + + Filter resources based on provided Scope membership. By default, all resources for the accounts Active Permissions will be displayed. Allowed values: + + * AllResources + * AllResourcesInScope + * HPEOneView.Appliance.ScopeCollection + * HPEOneView.Appliance.ConnectionPermission + + Object + + + Label + + Specify the label associated with resources. + + String + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + + + Get-OVSwitch + + Label + + Specify the label associated with resources. + + String + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Label + + Specify the label associated with resources. + + String + + String + + False + + + Name + + The Switch resource Name. Supports the * wildcard character. + + String + + String + + + + + Scope + + Filter resources based on provided Scope membership. By default, all resources for the accounts Active Permissions will be displayed. Allowed values: + + * AllResources + * AllResourcesInScope + * HPEOneView.Appliance.ScopeCollection + * HPEOneView.Appliance.ConnectionPermission + + Object + + Object + + AllResourcesInScope + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + Async task resource after a Logical Switch Group has been created. + + + + + + + + HPEOneView.Networking.LogicalSwitchGroup [System.Management.Automation.PSCustomObject] + + + + The async task resource object to monitor (if -Async was used) or results. + + + + + System.Collections.ArrayList <HPEOneView.Networking.LogicalSwitchGroup> + + + + Collection of Logical Switch Group resources. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVSwitch + + Get all logical switch group resources found on the default appliance connection. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Get-OVSwitch -Name "10.1.1.1" + + Get the "10.1.1.1" switch resource. + + + + + + + + + + + + + Get-OVSwitchType + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/networking/get-ovswitch + + + + + + + + Get-OVSwitchType + + Retrieve Switch Type resource(s). + + Get + OVSwitchType + + + Retrieves a list of all supported Switch Types or just specific ones via a query if the name or partnumber parameters are provided. + + + + + Get-OVSwitchType + + Name + + The name of the switch type model name to retrieve. Does not support wildcard search. + + String + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + Get-OVSwitchType + + PartNumber + + The Part Number of an switch type to search for. + + String + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Name + + The name of the switch type model name to retrieve. Does not support wildcard search. + + String + + String + + + + + PartNumber + + The Part Number of an switch type to search for. + + String + + String + + + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + HPEOneView.Networking.SwitchType + + + + Single Switch Type resource. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVSwitchType + + Returns all Switch Types available from all connected appliances to standard output. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Get-OVSwitchType -Name "Cisco Nexus 55xx" + + Returns just the "Cisco Nexus 55xx" Switch Type object to standard output. + + + + + + + + + + -------------------------- EXAMPLE 3 -------------------------- + + + + Get-OVSwitchType -Partnumber "DCS-7060X-SERIES" + + Returns just the partnumber "DCS-7060X-SERIES" Switch Type object to standard output. + + + + + + + + + + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/networking/get-ovswitchtype + + + + + + + + Get-OVTask + + Retrieve Task resource(s). + + Get + OVTask + + + Obtain a collection of task resources which have the specified name and/or state. The returned data will include the task name, owner, state and status. If the task resource is in either Waiting or Running state, you can pass it to Wait-OVTaskComplete to monitor the progression and eventual final state. + + + + + Get-OVTask + + Name + + The name of the task resource to be returned. All names will match if omitted. + + String + + + InputObject + + Related resource Name or Object to the task. To be used for filtering tasks specific to a resource object (i.e. Server Profile). + + Object + + + State + + The state of the task resource a to be returned. May be one of the following strings: + + * Unknown + * New + * Running + * Suspended + * Terminated + * Killed + * Completed + * Error + * Warning + +All states will match if omitted. All tasks will be returned if both names and state are omitted. + + String + + + Count + + Specify the maximum amount of task objects to return. 0 will return all found task objects. + + Int32 + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + + + Get-OVTask + + Name + + The name of the task resource to be returned. All names will match if omitted. + + String + + + ResourceCategory + + Specify the Resource Category to filter task results to. Cannot be combined with Resource parameter. + +Some examples are: + + * ethernet-networks + * fc-networks + * power-devices + * unmanaged-devices + * server-profiles + * server-hardware + * enclosures + * enclosure-groups + * interconnects + * logical-interconnects + * logical-interconnect-groups + * appliance + * firmware-drivers + + String + + + State + + The state of the task resource a to be returned. May be one of the following strings: + + * Unknown + * New + * Running + * Suspended + * Terminated + * Killed + * Completed + * Error + * Warning + +All states will match if omitted. All tasks will be returned if both names and state are omitted. + + String + + + Count + + Specify the maximum amount of task objects to return. 0 will return all found task objects. + + Int32 + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Count + + Specify the maximum amount of task objects to return. 0 will return all found task objects. + + Int32 + + Int32 + + 0 + + + InputObject + + Related resource Name or Object to the task. To be used for filtering tasks specific to a resource object (i.e. Server Profile). + + Object + + Object + + + + + Name + + The name of the task resource to be returned. All names will match if omitted. + + String + + String + + + + + ResourceCategory + + Specify the Resource Category to filter task results to. Cannot be combined with Resource parameter. + +Some examples are: + + * ethernet-networks + * fc-networks + * power-devices + * unmanaged-devices + * server-profiles + * server-hardware + * enclosures + * enclosure-groups + * interconnects + * logical-interconnects + * logical-interconnect-groups + * appliance + * firmware-drivers + + String + + String + + + + + State + + The state of the task resource a to be returned. May be one of the following strings: + + * Unknown + * New + * Running + * Suspended + * Terminated + * Killed + * Completed + * Error + * Warning + +All states will match if omitted. All tasks will be returned if both names and state are omitted. + + String + + String + + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject ] + + + Resource Object to retrieve task resources of + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + Single Task resource + + + + + System.Collections.ArrayList <HPEOneView.Appliance.TaskResource> + + + + Multiple Task resources or formatted table list of tasks + + + + + The matching task resources. + + + + + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + $tasks = Get-OVTask -state Error + + Return all the tasks with a taskState="Error" + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Get-OVServerProfile -Name "Server 1" | Get-OVTask -State Completed + + Return completed (successful) tasks associated with the "Server 1" Server Profile. + + + + + + + + + + -------------------------- EXAMPLE 3 -------------------------- + + + + Get-OVTask -count 10 + + Display the 10 most recent tasks from the specified appliance connection. + + + + + + + + + + + + + Wait-OVTaskComplete + + + + Wait-OVTaskStart + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/get-ovtask + + + + + + + + Get-OVUnmanagedDevice + + Get Unmanaged Devices. + + Get + OVUnmanagedDevice + + + HPE OneView provides administrators with the capability to define unmanaged devices to them place within Racks, in order to provide a more realistic and complete data center layout. This Cmdlet will retrieve all or a specified Unmanaged Device. A report switch is provided to display the output in an easier to read format. + + + + + Get-OVUnmanagedDevice + + Name + + The name of the Unmanaged Device. + + String + + + List + + Deprecated parameter. Cmdlet now defaults to Format-Table output. + + SwitchParameter + + + Label + + Specify the label associated with resources. + + String + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Label + + Specify the label associated with resources. + + String + + String + + False + + + List + + Deprecated parameter. Cmdlet now defaults to Format-Table output. + + SwitchParameter + + SwitchParameter + + False + + + Name + + The name of the Unmanaged Device. + + String + + String + + + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + HPEOneView.UnmanagedResource [System.Management.Automation.PSCustomObject] + + + + Single Unmanaged Device resource object + + + + + System.Collections.ArrayList + + + + Multiple Unmanaged Device resource objects + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVUnmanagedDevice + + Get all unmanaged devices. + + + + + + + + + + + + + New-OVUnmanagedDevice + + + + Remove-OVUnmanagedDevice + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/facilities/get-ovunmanageddevice + + + + + + + + Get-OVUplinkSet + + Retrieve Uplink Set resource(s). + + Get + OVUplinkSet + + + This Cmdlet will retrieve the list of all Uplink Sets or specific by the name. The Cmdlet will only display provisioned Uplink Sets that are members of a Logical Interconnect resource. To view Uplink Sets of a Logical Interconnect Group, use the Get-OVLogicalInterconnectGroup Cmdlet. + + + + + Get-OVUplinkSet + + Name + + Name of Uplink Set + + String + + + LogicalInterconnect + + Name of the Logical Interconnect to show associated Uplink Set. + + Object + + + Report + + Generate a report of the defined Uplink Sets. Includes Uplink Set type, networks, redundancy report, and assigned uplink ports. + + SwitchParameter + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + + ExportFile + + Export the found Uplink Set resource objects to JSON files in the specified directory. + + String + + + + Get-OVUplinkSet + + LogicalInterconnect + + Name of the Logical Interconnect to show associated Uplink Set. + + Object + + + Type + + Specify the Uplink Set Type to display. Will display all Uplink Sets of the type provided. Allowed values: + + * Ethernet + * FibreChannel + + String + + + Report + + Generate a report of the defined Uplink Sets. Includes Uplink Set type, networks, redundancy report, and assigned uplink ports. + + SwitchParameter + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + + ExportFile + + Export the found Uplink Set resource objects to JSON files in the specified directory. + + String + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + ExportFile + + Export the found Uplink Set resource objects to JSON files in the specified directory. + + String + + String + + + + + LogicalInterconnect + + Name of the Logical Interconnect to show associated Uplink Set. + + Object + + Object + + + + + Name + + Name of Uplink Set + + String + + String + + + + + Report + + Generate a report of the defined Uplink Sets. Includes Uplink Set type, networks, redundancy report, and assigned uplink ports. + + SwitchParameter + + SwitchParameter + + False + + + Type + + Specify the Uplink Set Type to display. Will display all Uplink Sets of the type provided. Allowed values: + + * Ethernet + * FibreChannel + + String + + String + + + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + System.Management.Automation.PSCustomObject + + + + Single Uplink Set + + + + + System.Collections.ArrayList + + + + Multiple Uplink Sets + + + + + Collection of Uplink Sets + + + + + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + $UplinkSets = Get-OVUplinkSet + + Get list of all Uplink Sets. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Get-OVUplinkSet -name "Production Networks" + + Get the "Production Networks" Uplink Set(s). + + + + + + + + + + -------------------------- EXAMPLE 3 -------------------------- + + + + Get-OVUplinkSet -name "Production Networks" -report + + Get the "Production Networks" Uplink Set(s), and generate a report. + + + + + + + + + + -------------------------- EXAMPLE 4 -------------------------- + + + + Get-OVUplinkSet -name "Production Networks" -liname "Encl1-LI" -report + + Get the "Production Networks" Uplink Set that is associated with "Encl1-LI" Logical Interconnect and generate a report. + + + + + + + + + + + + + New-OVUplinkSet + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/networking/get-ovuplinkset + + + + + + + + Get-OVUser + + Retrieve user account resource(s). + + Get + OVUser + + + Get a local user account on the management appliance, and display it"s properties. The account password will not be displayed. + + + + + Get-OVUser + + Name + + The name of the new user account to display. + + String + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Name + + The name of the new user account to display. + + String + + String + + + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + System.Management.Automation.PSCustomObject + + + + Single User resource + + + + + System.Collections.ArrayList + + + + Multiple User resourses, or formatted table displaying a report of user accounts + + + + + User Account Information + + + + + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVUser + + List all user accounts from all connected appliances. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Get-OVUser "Sally" + + List Sally"s user account from MyAppliance.domain.com. + + + + + + + + + + + + + New-OVUser + + + + Remove-OVUser + + + + Set-OVUser + + + + Set-OVUserPassword + + + + Set-OVUserRole + + + + Show-OVUserSession + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/get-ovuser + + + + + + + + Get-OVVersion + + Display library component versions. + + Get + OVVersion + + + Display either the HPE OneView PowerShell library or appliance version. Displaying the Appliance version will provide the Major, Minor, full version, and X-API Version information. + + + + + Get-OVVersion + + ApplianceVer + + Include the appliance version. + + SwitchParameter + + + CheckOnline + + Check the GitHub repository for an updated version of the library. + + SwitchParameter + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + + + Get-OVVersion + + CheckOnline + + Check the GitHub repository for an updated version of the library. + + SwitchParameter + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + Array + + ${Global:ConnectedSessions} + + + ApplianceVer + + Include the appliance version. + + SwitchParameter + + SwitchParameter + + False + + + CheckOnline + + Check the GitHub repository for an updated version of the library. + + SwitchParameter + + SwitchParameter + + False + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + System.Management.Automation.PSCustomObject + + + + The HPE OneView PowerShell Library or Appliance version information + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVVersion + + Get the HPE OneView PowerShell library version + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Get-OVVersion -ApplianceVer +PowerShell Library Version : 1.20.208.0 +Library Path : C:\Users\user\Documents\WindowsPowerShell\Modules\HPEOneView.120 +Appliance Major Version : 1 +Appliance Minor Version : 20 +Appliance Version Info : 1.20.05-0201918 +Appliance X-API Version : 120 + + Get the HPE OneView PowerShell library, Appliance and X-API version information + + + + + + + + + + -------------------------- EXAMPLE 3 -------------------------- + + + + Get-OVVersion -CheckOnline +PowerShell Library Version : 1.20.166.0 +Library Path : C:\Users\user\Documents\WindowsPowerShell\Modules\HPEOneView.120 + + +Please Confirm +You currently have v1.20.166.0 installed. The HPE OneView PowerShell Library v1.20.208.0 was found that is newer. Do +you want to download the current version of the HPE OneView POSH Library (will open your web browser for you to +download)? +[Y] Yes [N] No [?] Help (default is "Y"): + + Display the installed library version, and check for availability of an updated version online. If an updated version is found, the Cmdlet will prompt if the user would like to download it now. If so, browser window will be opened to current version to download. + + + + + + + + + + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/library/get-ovversion + + + + + + + + Get-OVXApiVersion + + Get appliance API version. + + Get + OVXApiVersion + + + Returns the API versions supported by the appliance. You do not need to authenticate, or call Connect-OVMgmt, to an appliance in order to retrieve the supported REST API Versions by the appliance. + + + + + Get-OVXApiVersion + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + System.Management.Automation.PSCustomObject + + + + The current and minimum supported API versions on the appliance + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + (Get-OVXApiVersion myAppliance.domain.com).minimumversion + + This example retrieves the minimum XApi version supported by the appliance. An existing connection is not needed since the appliance name is provided. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + (Get-OVXApiVersion).minimumversion + + This example retrieves the minimum XApi version supported by the appliance and requires that a connection has been established by using Connect-OVMgmt. + + + + + + + + + + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/library/get-ovxapiversion + + + + + + + + Import-OVSslCertificate + + Import an appliance SSL Certificate. + + Import + OVSslCertificate + + + By default, the HPE OneView appliance creates a self signed SSL Certificate for its WebUI. There might be a desire to trust the certificate, in case the SHA-1 hash becomes invalid (either due to a certificate change or man-in-the-middle attack) and the caller would like to be notified. This Cmdlet will assist in retrieving and storing the appliance self-generated SSL Certificate into the current users Trusted Root Certification Authorities store. + +Please note that the Subject Alternate Name (SAN) must match that of the Appliance hostname you use to connect to your appliance. If it does not, an SSL conenction failure will occur. When creating a CSR on the appliance, make sure to include the additional FQDN and IP address(es) in the Alternative Name field. + + + + + Import-OVSslCertificate + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + Array + + ${Global:ConnectedSessions} + + + + + + + HPEOneView.Appliance.Connection + + + HPE OneView Appliance Connection object + + + + + + + + None. + + + + + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + $Connection = Connect-OVMgmt Myappliance.domain.com Administrator MyP@ssword +Import-OVSslCertificate + + Import the SSL certificate from the specific appliance. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Connect-OVMgmt Myappliance.domain.com Administrator MyP@ssword +Connect-OVMgmt Myappliance2.domain.com Administrator MyP@ssword +$ConnectedSessions | Import-OVSslCertificate + + Import the SSL Certificate from all connected sessions. + + + + + + + + + + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/import-ovsslcertificate + + + + + + + + Install-OVApplianceCertificate + + Install signed private key. + + Install + OVApplianceCertificate + + + After using New-OVApplianceCSR to generate a Certificate Signing Request (CSR), this Cmdlet will install the CA signed and approved SSL private key to the appliance. + + + + + Install-OVApplianceCertificate + + Path + + The signed certificate for the appliance, or PKCS#12 file containing the private key and public signed certificate. + + System.IO.FileInfo + + + Passphrase + + PKCS#12 (PFX) certificate files can be encrypted using a passphrase. Supply the passphrase in SecureString format. + + SecureString + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + ApplianceConnection + + Specify the HPEOneView.Appliance.Connection object or Name property value. + + Object + + + + + + + ApplianceConnection + + Specify the HPEOneView.Appliance.Connection object or Name property value. + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + SwitchParameter + + False + + + Passphrase + + PKCS#12 (PFX) certificate files can be encrypted using a passphrase. Supply the passphrase in SecureString format. + + SecureString + + SecureString + + False + + + Path + + The signed certificate for the appliance, or PKCS#12 file containing the private key and public signed certificate. + + System.IO.FileInfo + + System.IO.FileInfo + + + + + + + + + System.IO.FileInfo + + + Certificate file path + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + Async task resource object to monitor committing certificate, and deploying HPE SSO certificate update to managed/monitored devices + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + $Task = C:\dir\hpov.cer | Install-OVApplianceCertificate + + Read the signed appliance web certificate key and install it on the appliance, and wait for the task to complete. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + $cert = Get-ChildItem C:\dir\hpov.cer +$TaskToMonitor = Install-OVApplianceCertificate -Path $Cert -Async +C:\> $TaskToMonitor | Wait-OVTaskComplete + + Read the signed appliance web certificate and install it on the appliance, and wait for the task to complete. + + + + + + + + + + -------------------------- EXAMPLE 3 -------------------------- + + + + $cert = Get-ChildItem C:\dir\hpov.pfx +Install-OVApplianceCertificate -Path $Cert -Passphrase (Read-Host -Prompt Passphrase -AsSecureString) + + Specify a PKCS#12 file with a passphrase. + + + + + + + + + + + + + Get-OVApplianceCertificateStatus + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/install-ovappliancecertificate + + + + + + + + Install-OVLogicalInterconnectFirmware + + Install Logical Interconnect Firmware. + + Install + OVLogicalInterconnectFirmware + + + Firmware activation options allow you to maintain network availability by always keeping one path up for production traffic and reduce the outages due to human errors. You also have the option of staging the firmware for later activation. You can activate the staged firmware on an individual interconnect or on all interconnects. + +You have the following options when updating firmware based on a logical interconnect: + + * Update (stage + activate) - Stages (uploads) the selected firmware to the secondary flash memory on the interconnect, and then activates the firmware as the baseline. At the end of this operation, all member interconnects are running the same firmware baseline and are compliant with one another. This option and parallel activation affects the connectivity to and from the servers until the activation is complete, but does update the firmware in the shortest time. + * Stage - Stages (uploads) the selected firmware to the secondary flash memory on the interconnect, but does not activate the firmware. You can activate the firmware at a later time. This option allows manual sequencing of the firmware activation and is the preferred approach to minimize service interruption. + * Activate - Activates the selected staged firmware by rebooting the interconnect modules. + +NOTE: When updating firmware based on the logical interconnect, if one or more interconnects are already running the targeted firmware version, HPE OneView excludes those interconnects from the firmware update. + +FORCE INSTALLATION + +By using the Force parameter, the update requires (forces) firmware update on every member interconnect regardless of its current installed version. + +This option is not available if you select Activate for the Update parameter. + +To install an older firmware version than the version contained in the SPP, you must specify the Force parameter option to downgrade the firmware. You might want to install older firmware if the newer firmware is known to cause a problem in your environment. + +There are a few different activation methods available, depending on the platform: + +INSTALLATION METHODS + +WARNING: Firmware updates using parallel activation must be performed during a maintenance window. + + * OddEven - Will perform updates to all odd module bays first, then even. An activation delay can be specified with the EthernetActivateDelay parameter. + * Serial - Will perform updates to all device bays, starting with the first bay. An activation delay can be specified with the EthernetActivateDelay parameter. + * Parallel - Will perform updates to all device bays, at the same time. Activation will happen immediately once staging and installation have completed. You cannot specify an activation delay. If one or more interconnects are already running the targeted firmware version, HPE OneView excludes the interconnects from the firmware downgrade. + + Performing a parallel downgrade without selecting the Force installation option enables HPE OneView to perform the operation only on the non-compliant interconnects. A maintenance window might not be required to downgrade only the non-compliant interconnects. + + Compliant modules are the modules that are compliant with the firmware baseline for the logical interconnect. You can make the newly inserted interconnect compliant with the baseline by performing upgrade or downgrade without selecting the Force installation. HPE OneView performs firmware upgrade or downgrade only on the non-compliant interconnects which requires upgrade or downgrade without disturbing the compliant modules. In cases where such downgrade is not possible, you are notified to select the Force installation option. In case of partial possibility, the Interconnect Link modules which can cause data disruption are ignored for downgrade. You are notified that these interconnect link modules are not updated during the task update. + + Downgrading without the Force installation can be done on the following modules: + + * HPE Virtual Connect SE 40Gb F8 Module for HPE Synergy + * HPE Virtual Connect SE 100Gb F32 Module for HPE Synergy + * HPE Synergy 50Gb Interconnect Link Module + * HPE Synergy 20Gb Interconnect Link Module + * HPE Synergy 10Gb Interconnect Link Module + + * Orchestrated - Supported with HPE Synergy Virtual Connect and SAS modules only, a nondisruptive firmware update is attempted for the logical interconnects. The following scenarios might occur: + + * Firmware update is executed automatically without any disruption to application network traffic. + * Firmware update is executed with minimal impact to application network traffic. A context-specific warning message displays along with an option to proceed or cancel the firmware update. + * For example, a warning message displays to ensure that OS level NIC teaming or bonding is enabled for Ethernet networks and MPIO is enabled when Fibre Channel connections are involved. + * Firmware update will result in a system outage. A warning message displays when network and storage connections might be disrupted. + + * Manual - You can orchestrate the update in a stepwise approach using the following operations. These operations are not possible with the Parallel and Orchestrated firmware activation options. + + * Select and update one side of the interconnect topology at a time by using the -ManualOrder parameter. You must specify the appropriate Bay side to update first. + * Once the update for the chosen side is complete, proceed to update the other side. If the firmware update on the interconnect module side that is updated first is not satisfactory, roll back to the original firmware version. + + Manual orchestration is available on the following modules: + + * HPE Virtual Connect SE 40Gb F8 Module for HPE Synergy + * HPE Virtual Connect SE 100Gb F32 Module for HPE Synergy + * HPE Synergy 10Gb/20Gb/50Gb Interconnect Link Module + + The firmware update is performed on the chosen side while the other side is available to carry production traffic. This side-by-side firmware update is allowed only at the logical interconnect level. Manual orchestration is applicable to most updates and downgrades. There are a few exceptions where you cannot use the manual orchestration option. When you try the option for any such exceptions, an error is displayed and the operation does not proceed. For example, you cannot downgrade to a firmware version that is less than the minimum version that is supported on the interconnect module. + + NOTE: To minimize potential disruption, ensure that the logical interconnect is redundantly configured. + + NOTE: After the interconnects in the first side of the logical interconnect are updated successfully, update the interconnects in the second side soon after. If the firmware versions of the interconnects in a logical interconnect are different, the interconnects remain in maintenance mode and you are not allowed to make any configuration changes until they are at the same version. + +Minimum required privileges: Network administrator, Server administrator (for the HPE Synergy 12Gb SAS Connection Module), or Infrastructure administrator. + + + + + Install-OVLogicalInterconnectFirmware + + InputObject + + The Logical Interconnect object(s) from Get-OVLogicalInterconnect or Get-OVSasLogicalInterconnect Cmdlets to be updated. + + Object + + + Method + + Upgrade method to perform. Accepted values are: + + * UPDATE (Default) + * STAGE + * ACTIVATE + + String + + + EthernetActivateOrder + + Specify the Ethernet module firmware activation order. Accepted values are: + + * OddEven (Default) + * Parallel + * Serial + * Orchetrated + * Manual + + Orchestrated and Manual are only supported with HPE Synergy logical interconnect resources. + + String + + + EthernetActivateDelay + + The amount of time in seconds to delay activating additional modules. + +Default is 5 seconds. + + Int32 + + + FCActivateOrder + + Specify the Fibre Channel module firmware activation order. Accepted values are: + + * OddEven + * Parallel + * Serial (Default) + * Orchestrated + + Orchestrated is only supported with HPE Synergy logical interconnect resources. + + String + + + FCActivateDelay + + The amount of time in seconds to delay activating additional modules. + +Default is 5 seconds. + + Int32 + + + Baseline + + Firmware Baseline Name, URI or Object. + + Object + + + NoPreview + + By default, the Cmdlet will display a report if the interconnects can be updated without an outage by identifying the configuration. This option is only supported with HPE Synergy. + + SwitchParameter + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + Force + + Force the firmware update if the update version matches what is already installed. + + SwitchParameter + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + + WhatIf + + + + SwitchParameter + + + Confirm + + + + SwitchParameter + + + + Install-OVLogicalInterconnectFirmware + + InputObject + + The Logical Interconnect object(s) from Get-OVLogicalInterconnect or Get-OVSasLogicalInterconnect Cmdlets to be updated. + + Object + + + ManualOrder + + Use this parameter when the EthActivationOrder is set to Manual. The allowed values are: + + * Bay3 + * Bay6 + * Bay1 + * Bay5 + * Bay2 + * Bay4 + + String + + + Method + + Upgrade method to perform. Accepted values are: + + * UPDATE (Default) + * STAGE + * ACTIVATE + + String + + + EthernetActivateOrder + + Specify the Ethernet module firmware activation order. Accepted values are: + + * OddEven (Default) + * Parallel + * Serial + * Orchetrated + * Manual + + Orchestrated and Manual are only supported with HPE Synergy logical interconnect resources. + + String + + + Baseline + + Firmware Baseline Name, URI or Object. + + Object + + + NoPreview + + By default, the Cmdlet will display a report if the interconnects can be updated without an outage by identifying the configuration. This option is only supported with HPE Synergy. + + SwitchParameter + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + Force + + Force the firmware update if the update version matches what is already installed. + + SwitchParameter + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + + WhatIf + + + + SwitchParameter + + + Confirm + + + + SwitchParameter + + + + Install-OVLogicalInterconnectFirmware + + InputObject + + The Logical Interconnect object(s) from Get-OVLogicalInterconnect or Get-OVSasLogicalInterconnect Cmdlets to be updated. + + Object + + + Method + + Upgrade method to perform. Accepted values are: + + * UPDATE (Default) + * STAGE + * ACTIVATE + + String + + + SasActivationMethod + + Specify the HPE Synergy SAS module firmware activation order. Accepted values are: + + * Parallel + * Orchestrated + + String + + + Baseline + + Firmware Baseline Name, URI or Object. + + Object + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + Force + + Force the firmware update if the update version matches what is already installed. + + SwitchParameter + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + + WhatIf + + + + SwitchParameter + + + Confirm + + + + SwitchParameter + + + + + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + SwitchParameter + + False + + + Baseline + + Firmware Baseline Name, URI or Object. + + Object + + Object + + + + + Confirm + + + + SwitchParameter + + SwitchParameter + + + + + EthernetActivateDelay + + The amount of time in seconds to delay activating additional modules. + +Default is 5 seconds. + + Int32 + + Int32 + + 5 + + + EthernetActivateOrder + + Specify the Ethernet module firmware activation order. Accepted values are: + + * OddEven (Default) + * Parallel + * Serial + * Orchetrated + * Manual + + Orchestrated and Manual are only supported with HPE Synergy logical interconnect resources. + + String + + String + + OddEven + + + FCActivateDelay + + The amount of time in seconds to delay activating additional modules. + +Default is 5 seconds. + + Int32 + + Int32 + + 5 + + + FCActivateOrder + + Specify the Fibre Channel module firmware activation order. Accepted values are: + + * OddEven + * Parallel + * Serial (Default) + * Orchestrated + + Orchestrated is only supported with HPE Synergy logical interconnect resources. + + String + + String + + Serial + + + Force + + Force the firmware update if the update version matches what is already installed. + + SwitchParameter + + SwitchParameter + + False + + + InputObject + + The Logical Interconnect object(s) from Get-OVLogicalInterconnect or Get-OVSasLogicalInterconnect Cmdlets to be updated. + + Object + + Object + + + + + ManualOrder + + Use this parameter when the EthActivationOrder is set to Manual. The allowed values are: + + * Bay3 + * Bay6 + * Bay1 + * Bay5 + * Bay2 + * Bay4 + + String + + String + + + + + Method + + Upgrade method to perform. Accepted values are: + + * UPDATE (Default) + * STAGE + * ACTIVATE + + String + + String + + Update + + + NoPreview + + By default, the Cmdlet will display a report if the interconnects can be updated without an outage by identifying the configuration. This option is only supported with HPE Synergy. + + SwitchParameter + + SwitchParameter + + + + + SasActivationMethod + + Specify the HPE Synergy SAS module firmware activation order. Accepted values are: + + * Parallel + * Orchestrated + + String + + String + + + + + WhatIf + + + + SwitchParameter + + SwitchParameter + + + + + + + + + HPEOneView.Networking.LogicalInterconnect [System.Management.Automation.PSCustomObject] + + + Logical Interconnect Resource Object + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + Returns an async task resource to monitor. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + $li = Get-OVLogicalInterconnect Encl1-LI +$spp = Get-OVBaseline "HPE Service Pack for ProLiant" +$task = Install-OVLogicalInterconnectFirmware -Method Stage -InputObject $li -Baseline $spp +Wait-OVTaskComplete $task +$task = Install-OVLogicalInterconnectFirmware -Method Activate -InputObject $li +Wait-OVTaskComplete $task + + Perform a firmware update of the Encl1-LI Logical Interconnect by first staging the firmware. Then Acitate the firmware using the default OddEven Interconnect Bay order. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Get-OVLogicalInterconnect -Name Encl1-LI | Install-OVLogicalInterconnectFirmware -Method Update -Baseline (Get-OVBaseline -Name "HPE Service Pack for ProLiant") -Confirm:$false | Wait-OVTaskComplete + + Perform a firmware update of the Encl1-LI Logical Interconnect, do not prompt for confirmation, then wait for the task to complete. + + + + + + + + + + -------------------------- EXAMPLE 3 -------------------------- + + + + $Alerts = Get-OVLogicalInterconnect -Name Encl1-LI | ? status -ne "OK" | Get-OVAlert -State Active +$Alerts | ForEach { + if ($_.alertTypeID -eq "firmwareupdate.status" -and ` + $_.correctiveAction -match "Update the firmware on the the logical interconnect") { + + Install-OVLogicalInterconnectFirmware -InputObject (Send-OVRequest -Uri $_.resourceUri) -Method Activate -EthernetActivateOrder Orchestrated -Confirm:$false | Wait-OVTaskComplete + + } +} + + Find active firmware update alert, and then activate the staged firmware on the logical interconnect. + + + + + + + + + + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/networking/install-ovlogicalinterconnectfirmware + + + Get-OVLogicalInterconnect + + + + Get-OVSasLogicalInterconnect + + + + + + + + + Install-OVUpdate + + Install or stage an appliance update. + + Install + OVUpdate + + + The Install-OVUpdate installs an appliance update package to upgrade the platform to the specified version. Use the -Stage switch to stage an update on the appliance. + + + + + Install-OVUpdate + + File + + Appliance Update file to install. + + String + + + Eula + + Will display EULA if no value is provided. Pass "accept" to accept and not display EULA. + + String + + + DisplayReleaseNotes + + Display Release Notes of Update + + SwitchParameter + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + WhatIf + + + + SwitchParameter + + + Confirm + + + + SwitchParameter + + + + Install-OVUpdate + + File + + Appliance Update file to install. + + String + + + Stage + + Used to upload update to appliance and not apply update. + + SwitchParameter + + + DisplayReleaseNotes + + Display Release Notes of Update + + SwitchParameter + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + WhatIf + + + + SwitchParameter + + + Confirm + + + + SwitchParameter + + + + Install-OVUpdate + + InstallNow + + Install pending update that was previously staged. + + SwitchParameter + + + Eula + + Will display EULA if no value is provided. Pass "accept" to accept and not display EULA. + + String + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + WhatIf + + + + SwitchParameter + + + Confirm + + + + SwitchParameter + + + + Install-OVUpdate + + ListPending + + List any pending updates on the appliance that might have been staged. + + SwitchParameter + + + DisplayReleaseNotes + + Display Release Notes of Update + + SwitchParameter + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + WhatIf + + + + SwitchParameter + + + Confirm + + + + SwitchParameter + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Confirm + + + + SwitchParameter + + SwitchParameter + + + + + DisplayReleaseNotes + + Display Release Notes of Update + + SwitchParameter + + SwitchParameter + + False + + + Eula + + Will display EULA if no value is provided. Pass "accept" to accept and not display EULA. + + String + + String + + + + + File + + Appliance Update file to install. + + String + + String + + + + + InstallNow + + Install pending update that was previously staged. + + SwitchParameter + + SwitchParameter + + False + + + ListPending + + List any pending updates on the appliance that might have been staged. + + SwitchParameter + + SwitchParameter + + False + + + Stage + + Used to upload update to appliance and not apply update. + + SwitchParameter + + SwitchParameter + + False + + + WhatIf + + + + SwitchParameter + + SwitchParameter + + + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + Write-Progress + + + + Will display a progress bar indicating the Appliance Update status + + + + + System.Collections.ArrayList (System.Management.Automation.PSCustomObject) + + + + When performing stage and install (no switch options provided), the return will include the uploaded patch information from the appliance, and the completed upgrade message + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Install-OVUpdate -file C:\Path\update.bin + + Install the Update.bin package to the appliance. User will be prompted to accept the upgrade EULA, and if a reboot is required also be prompted to confirm. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Install-OVUpdate -file C:\Path\update.bin -Stage -DisplayReleaseNotes + + Stage the update on the appliance, and display the Release Notes to the PowerShell console. + + + + + + + + + + -------------------------- EXAMPLE 3 -------------------------- + + + + Install-OVUpdate -file C:\Path\update.bin -Stage +Install-OVUpdate -EULA Accept -InstallNow + + Stage the Update.bin package to the appliance. After update has been staged, install the update now on specified appliance. + + + + + + + + + + -------------------------- EXAMPLE 4 -------------------------- + + + + Install-OVUpdate -ListPending -DisplayReleaseNotes + + List a pending, staged updates on the appliance, then display the Release Notes to the PowerShell console. + + + + + + + + + + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/install-ovupdate + + + + + + + + Invoke-OVMigrateServer + + Transfer the management of one or more servers and associated profiles from another OneView appliance to this appliance. + + Invoke + OVMigrateServer + + + Migration transfers the management of rackmount servers along with their associated profiles, and copies dependent resources from one HPE OneView appliance to another appliance. This migration process does not impact the applications or workloads that are running on the server. + +You can consolidate one or more rackmount servers from multiple appliances into a single appliance to increase the server scale support. + +Supported migration paths + +You can use the migration utility that is available with the HPE OneView 7.0 appliance to migrate servers from: + + * HPE OneView 6.6, which is a long-term support (LTS) version, and + * other HPE OneView 7.0 or newer appliances + +Please see the HPE OneView online help "Migrating server hardware" help topic for more information and best practices. + +This Cmdlet will initiate supported server migration. Use the Get-OVMigratableServer Cmdlet to connect to the source appliance and return the list of servers that can be migrated. + +Minimum required privileges: Infrastructure administrator and Server administrator + + + + + Invoke-OVMigrateServer + + InputObject + + Collection of migratable servers from Get-OVMigratableServer. + + HPEOneView.Servers.MigratableServer[] + + + Credential + + Parameter to provide credentials in order to authenticate to the source appliance. + + PSCredential + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + ApplianceConnection + + Specify one or more HPEOneView.Appliance.Connection object(s) or Name property value(s). + +Default Value: ${Global:ConnectedSessions} | ? Default + + Object + + + WhatIf + + + + + + + Confirm + + Use to override the confirmation prompt. + + SwitchParameter + + + + + + + ApplianceConnection + + Specify one or more HPEOneView.Appliance.Connection object(s) or Name property value(s). + +Default Value: ${Global:ConnectedSessions} | ? Default + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + SwitchParameter + + False + + + Confirm + + Use to override the confirmation prompt. + + SwitchParameter + + SwitchParameter + + + + + Credential + + Parameter to provide credentials in order to authenticate to the source appliance. + + PSCredential + + PSCredential + + + + + InputObject + + Collection of migratable servers from Get-OVMigratableServer. + + HPEOneView.Servers.MigratableServer[] + + HPEOneView.Servers.MigratableServer[] + + + + + WhatIf + + + + + + + + + + + + + + + HPEOneView.Servers.MigratableServer + + + Class object of migratable server resources from Get-OVMigratableServer. + + + + + + + + HPOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + Async task resource to monitor. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + $Credential = Get-Credential -Username myadminaccount + +# Get the list of migratable servers from the source appliance +$MigratableServers = Get-OVMigratableServer -Hostname $SourceServerMigrationHost -Credential $Credential + +# Begin server migration +$tasks = Invoke-OVMigrateServer -InputObject $MigratableServers -Credential $Credential -Async + + Connect to the specified source appliance, return the list of migratable servers, then begin migration, returning the created async tasks. + + + + + + + + + + + + + Get-OVMigratableServer + + + + Online: + https://hpe-docs.gitbook.io/posh-hpeoneview/cmdlets/v9.00/servers/invoke-ovmigrateserver + + + + + + + + Invoke-OVVcmMigration + + Migrate Virtual Connect Manager to HPE OneView. + + Invoke + OVVcmMigration + + + This function is used to migrate an existing Virtual Connect Manager configuration to HPE OneView. If an enclosure was added to an HPE OneView appliance as Monitor-Only, then you must first remove the enclosure from the appliance, and then use this Cmdlet to migrate the enclosure. + +Using the -VCEMCMS, -VCEMUser and -VCEMPassword parameters, the targeted Virtual Connect Domain can be removed from a Virual Connect Enterprise Manager Domain Group first before initiating the VC Migration tool within the HPE OneView appliance. + +The required VCEM 7.3/7.4 Patch is available here: ftp://ftp.hp.com/pub/softlib2/software1/pubsw-generic/p270829882/v106568. + +VCEM 7.4.1 or greater users do not require the patch to be installed, as the API is built into 7.4.1 or greater. + +It is important to also have a Virtual Connect Domain Backup prior to migration. You may also want to gather the output from the "show config -includepoolinfo" VCM CLI command to review or verify resources were migrated successfully. + +Please read "Chapter 9 Planning for enclosure migration from VCM into HPE OneView" in the HPE OneView 1.20 User Guide for more information about migration and other planning resources. + + + + + Invoke-OVVcmMigration + + OAIPAddress + + REQUIRED. IP address or FQDN of the Primary Onboard Administrator in the target enclosure. + + String + + + OAUserName + + Parameter is being deprecated. Please transition to using -OACredential. Administrator account of the target OA. + + String + + + OAPassword + + Parameter is being deprecated. Please transition to using -OACredential. Password for the Administrator account of the target OA. + + String + + + OACredential + + PSCredential object containing the username and password details for the c-Class Onboard Administrator. + + PSCredential + + + VCMUserName + + Parameter is being deprecated. Please transition to using -VCMCredential. +Username for the administrator account for Virtual Connect Manager. + + String + + + VCMPassword + + Parameter is being deprecated. Please transition to using -VCMCredential. Password for the Administrator account of Virtual Connect Manager. + + String + + + VCMCredential + + PSCredential object containing the username and password details for the c-Class Virtual Connect Manager. + + PSCredential + + + EnclosureGroup + + OPTIONAL. The Name, URI or Object of an existing Enclosure Group. If the Enclosure Group Name does not exist, a new resource with the String value provided will be created. If omitted, a new Enclosure Group will be created based on the Serial Number of the Enclosure (Example: "EG_USE1234567A"). + + Object + + + LogicalInterconnectGroup + + OPTIONAL. The Name, URI or Object of an existing Logical Interconnect Group. If the Logical Interconnect Group Name does not exist, a new resource with the String value provided will be created. If omitted, a new Logical Interconnect Group will be created based on the Serial Number of the Enclosure (Example: "LIG_USE1234567A"). + + Object + + + LicensingIntent + + REQUIRED. Specifies whether the intent is to apply either OneView or OneView w/o iLO licenses to the servers in the enclosure being imported. + +Accepted values are + + * OneView + * OneViewNoiLO + + String + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + + WhatIf + + + + + + + Confirm + + + + + + + + Invoke-OVVcmMigration + + OAIPAddress + + REQUIRED. IP address or FQDN of the Primary Onboard Administrator in the target enclosure. + + String + + + OAUserName + + Parameter is being deprecated. Please transition to using -OACredential. Administrator account of the target OA. + + String + + + OAPassword + + Parameter is being deprecated. Please transition to using -OACredential. Password for the Administrator account of the target OA. + + String + + + OACredential + + PSCredential object containing the username and password details for the c-Class Onboard Administrator. + + PSCredential + + + VCMUserName + + Parameter is being deprecated. Please transition to using -VCMCredential. +Username for the administrator account for Virtual Connect Manager. + + String + + + VCMPassword + + Parameter is being deprecated. Please transition to using -VCMCredential. Password for the Administrator account of Virtual Connect Manager. + + String + + + VCMCredential + + PSCredential object containing the username and password details for the c-Class Virtual Connect Manager. + + PSCredential + + + EnclosureGroup + + OPTIONAL. The Name, URI or Object of an existing Enclosure Group. If the Enclosure Group Name does not exist, a new resource with the String value provided will be created. If omitted, a new Enclosure Group will be created based on the Serial Number of the Enclosure (Example: "EG_USE1234567A"). + + Object + + + LogicalInterconnectGroup + + OPTIONAL. The Name, URI or Object of an existing Logical Interconnect Group. If the Logical Interconnect Group Name does not exist, a new resource with the String value provided will be created. If omitted, a new Logical Interconnect Group will be created based on the Serial Number of the Enclosure (Example: "LIG_USE1234567A"). + + Object + + + LicensingIntent + + REQUIRED. Specifies whether the intent is to apply either OneView or OneView w/o iLO licenses to the servers in the enclosure being imported. + +Accepted values are + + * OneView + * OneViewNoiLO + + String + + + VCEMCMS + + The IP Address or FQDN of the VCEM host. + + String + + + VCEMUser + + Parameter is being deprecated. Please transition to using -VCEMCredential + +Administrator level account name available on the VCEM host. + + String + + + VCEMPassword + + Parameter is being deprecated. Please transition to using -VCEMCredential + +Administrator level account password on the VCEM host. + + String + + + VCEMCredential + + PSCredential object containing the username and password details for the Virtual Connect Enterprise Manager associated with the Virtual Connect Manager Domain. + + PSCredential + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + + WhatIf + + + + + + + Confirm + + + + + + + + Invoke-OVVcmMigration + + OAIPAddress + + REQUIRED. IP address or FQDN of the Primary Onboard Administrator in the target enclosure. + + String + + + OAUserName + + Parameter is being deprecated. Please transition to using -OACredential. Administrator account of the target OA. + + String + + + OAPassword + + Parameter is being deprecated. Please transition to using -OACredential. Password for the Administrator account of the target OA. + + String + + + OACredential + + PSCredential object containing the username and password details for the c-Class Onboard Administrator. + + PSCredential + + + VCMUserName + + Parameter is being deprecated. Please transition to using -VCMCredential. +Username for the administrator account for Virtual Connect Manager. + + String + + + VCMPassword + + Parameter is being deprecated. Please transition to using -VCMCredential. Password for the Administrator account of Virtual Connect Manager. + + String + + + VCMCredential + + PSCredential object containing the username and password details for the c-Class Virtual Connect Manager. + + PSCredential + + + EnclosureGroup + + OPTIONAL. The Name, URI or Object of an existing Enclosure Group. If the Enclosure Group Name does not exist, a new resource with the String value provided will be created. If omitted, a new Enclosure Group will be created based on the Serial Number of the Enclosure (Example: "EG_USE1234567A"). + + Object + + + LogicalInterconnectGroup + + OPTIONAL. The Name, URI or Object of an existing Logical Interconnect Group. If the Logical Interconnect Group Name does not exist, a new resource with the String value provided will be created. If omitted, a new Logical Interconnect Group will be created based on the Serial Number of the Enclosure (Example: "LIG_USE1234567A"). + + Object + + + LicensingIntent + + REQUIRED. Specifies whether the intent is to apply either OneView or OneView w/o iLO licenses to the servers in the enclosure being imported. + +Accepted values are + + * OneView + * OneViewNoiLO + + String + + + Report + + OPTIONAL. Execute the migration report only. Do not execute the migration process. + + SwitchParameter + + + Path + + The directory path in which to save the report output to a file. + + * Filename will be created in the format: [path]\{enclsoureName}_{date}.report + + String + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + + WhatIf + + + + + + + Confirm + + + + + + + + + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + SwitchParameter + + False + + + Confirm + + + + + + + + + + + EnclosureGroup + + OPTIONAL. The Name, URI or Object of an existing Enclosure Group. If the Enclosure Group Name does not exist, a new resource with the String value provided will be created. If omitted, a new Enclosure Group will be created based on the Serial Number of the Enclosure (Example: "EG_USE1234567A"). + + Object + + Object + + + + + LicensingIntent + + REQUIRED. Specifies whether the intent is to apply either OneView or OneView w/o iLO licenses to the servers in the enclosure being imported. + +Accepted values are + + * OneView + * OneViewNoiLO + + String + + String + + + + + LogicalInterconnectGroup + + OPTIONAL. The Name, URI or Object of an existing Logical Interconnect Group. If the Logical Interconnect Group Name does not exist, a new resource with the String value provided will be created. If omitted, a new Logical Interconnect Group will be created based on the Serial Number of the Enclosure (Example: "LIG_USE1234567A"). + + Object + + Object + + + + + OACredential + + PSCredential object containing the username and password details for the c-Class Onboard Administrator. + + PSCredential + + PSCredential + + + + + OAIPAddress + + REQUIRED. IP address or FQDN of the Primary Onboard Administrator in the target enclosure. + + String + + String + + + + + OAPassword + + Parameter is being deprecated. Please transition to using -OACredential. Password for the Administrator account of the target OA. + + String + + String + + + + + OAUserName + + Parameter is being deprecated. Please transition to using -OACredential. Administrator account of the target OA. + + String + + String + + + + + Path + + The directory path in which to save the report output to a file. + + * Filename will be created in the format: [path]\{enclsoureName}_{date}.report + + String + + String + + + + + Report + + OPTIONAL. Execute the migration report only. Do not execute the migration process. + + SwitchParameter + + SwitchParameter + + False + + + VCEMCMS + + The IP Address or FQDN of the VCEM host. + + String + + String + + + + + VCEMCredential + + PSCredential object containing the username and password details for the Virtual Connect Enterprise Manager associated with the Virtual Connect Manager Domain. + + PSCredential + + PSCredential + + + + + VCEMPassword + + Parameter is being deprecated. Please transition to using -VCEMCredential + +Administrator level account password on the VCEM host. + + String + + String + + + + + VCEMUser + + Parameter is being deprecated. Please transition to using -VCEMCredential + +Administrator level account name available on the VCEM host. + + String + + String + + + + + VCMCredential + + PSCredential object containing the username and password details for the c-Class Virtual Connect Manager. + + PSCredential + + PSCredential + + + + + VCMPassword + + Parameter is being deprecated. Please transition to using -VCMCredential. Password for the Administrator account of Virtual Connect Manager. + + String + + String + + + + + VCMUserName + + Parameter is being deprecated. Please transition to using -VCMCredential. +Username for the administrator account for Virtual Connect Manager. + + String + + String + + + + + WhatIf + + + + + + + + + + + + + + + System.Management.Automation.PSCustomObject + + + Valid Enclosure Group resource the appliance will migrate the source enclosure into + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + Async task Resource object for monitoring the enclosure import process + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + $OACreds = Get-Credential -Username Administrator -Message "Password" $VCMCreds = Get-Credential -Username Administrator -Message "Password" Invoke-OVVcmMigration -OAIPAddress 192.168.19.40 -OACredential $OACreds -VCMCredential $VCMCreds -LicensingIntent OneView -Report + + Generate Virtual Connect Manager configuration migration report for the specified enclosure. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + $OACreds = Get-Credential -Username Administrator -Message "Password" $VCMCreds = Get-Credential -Username Administrator -Message "Password" Invoke-OVVcmMigration -OAIPAddress 192.168.19.40 -OACredential $OACreds -VCMCredential $VCMCreds -LicensingIntent OneView + + Migration will occur and create a new Enclosure Group and new Logical Interconnect Group based on the enclosure serial number. + + + + + + + + + + -------------------------- EXAMPLE 3 -------------------------- + + + + $OACreds = Get-Credential -Username Administrator -Message "Password" $VCMCreds = Get-Credential -Username Administrator -Message "Password" $EnclosureGroup = Get-OVEnclosureGroup -Name EnclosureGroup1 -ErrorAction Stop Invoke-OVVcmMigration -OAIPAddress 192.168.19.40 -OACredential $OACreds -VCMCredential $VCMCreds -LicensingIntent OneView -EnclosureGroup $EnclosureGroup + + Migration will occur and import the target enclosure into an existing Enclosure Group named "EnclosureGroup1". + + + + + + + + + + -------------------------- EXAMPLE 4 -------------------------- + + + + Invoke-OVVcmMigration -OAIPAddress 192.168.19.40 -OAUserName Administrator -OAPassword hpinvent -VCMUserName Administrator -VCMPassword hpinvent -licensingIntent OneView -Report -Path "c:\VCM-MigrationReports" +". + + Migration will not be attempted. The migration report will be executed and the result saved to the file "c:\VCM-MigrationReports\{enclosureName}_{date}.report". + + + + + + + + + + -------------------------- EXAMPLE 5 -------------------------- + + + + $OACreds = Get-Credential -Username Administrator -Message "Password" $VCMCreds = Get-Credential -Username Administrator -Message "Password" $VCEMCreds = Get-Credential -Username Domain\Adminisrator -Message "Password" $EnclosureGroup = Get-OVEnclosureGroup -Name EnclosureGroup1 -ErrorAction Stop Invoke-OVVcmMigration -OAIPAddress 192.168.19.40 -OACredential $OACreds -VCMCredential $VCMCreds -VCEMCMS vcemcms.domain.com -VCEMCredential $VCEMCreds -LicensingIntent OneView + + Perform a migration of a VCEM managed enclosure to HPE OneView. + + + + + + + + + + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/networking/invoke-ovvcmmigration + + + + + + + + Invoke-OVWebBrowser + + Start default web browser opened to appliance dashboard. + + Invoke + OVWebBrowser + + + This Cmdlet will open the default web browser to the specified appliance, logged in with the same credentials as the PowerShell library connection is authenticated with. To open multiple browser windows to each appliance connection, use the global $ConnectedSessions variable to override the -ApplianceConnection parameter. + + + + + Invoke-OVWebBrowser + + Resource + + Use to quickly jump to the specific UI section of the connected appliance. Allowed values: + + * Dashboard + * Enclosures + * LogicaInterconnectGroups + * LogicalEnclosures + * LogicalInterconnects + * Networks + * RackManagers + * ServerHardware + * ServerProfiles + * ServerProfileTemplates + * Settings + * StoragePools + * StorageSystems + * StorageVolumes + +By default, the Cmdlet will open your default web browser to the appliance dashboard. + + String + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Resource + + Use to quickly jump to the specific UI section of the connected appliance. Allowed values: + + * Dashboard + * Enclosures + * LogicaInterconnectGroups + * LogicalEnclosures + * LogicalInterconnects + * Networks + * RackManagers + * ServerHardware + * ServerProfiles + * ServerProfileTemplates + * Settings + * StoragePools + * StorageSystems + * StorageVolumes + +By default, the Cmdlet will open your default web browser to the appliance dashboard. + + String + + String + + + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + None. + + + + + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Connect-OVMgmt -Hostname MyAppliance.domain.com -Username MyAccount -Password $MySecurePassword +Invoke-OVWebBrowser + + Connect to the appliance, then launch default web browser to the appliance dashboard. + + + + + + + + + + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/library/invoke-ovwebbrowser + + + + + + + + Join-OVServerProfileToTemplate + + Attach an existing server profile to a server profile template + + Join + OVServerProfileToTemplate + + + Binds a server profile resource to the provided server profile template + + + + + Join-OVServerProfileToTemplate + + Template + + A server profile template name, URI, or resource object + + Object + + + ServerProfile + + A server profile name, URI, or resource object + + Object + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + + + + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + Object + + $Global:ConnectedSessions + + + ServerProfile + + A server profile name, URI, or resource object + + Object + + Object + + + + + Template + + A server profile template name, URI, or resource object + + Object + + Object + + + + + + + + + HPEOneView.ServerProfile [System.Management.Automation.PSCustomObject] + + + A PSCustom object representing a server profile template resource retrieved from the HPE OneView appliance + + + + + + + + System.Collections.ArrayList<HPEOneView.Appliance.TaskResource> + + + + Collection of task resource objects + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + An HPE OneView task resource object + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Join-OVServerProfileToTemplate -template "MyTemplate" -profile "MyProfile" -appliance HPEOneView.contoso.com + + Attaches the server profile template named MyTemplate to the server profile name MyProfile on the OneView appliance HPEOneView.contoso.com + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + $p = Get-OVServerProfile -Name "myProfile" +Get-OVServerProfileTemplate "myTemplate" | Join-OVServerProfileToTemplate -profile $p -appliance HPEOneView.contoso.com + + Attaches the server profile template named MyTemplate to the server profile name MyProfile on the OneView appliance HPEOneView.contoso.com + + + + + + + + + + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/servers/join-ovserverprofiletotemplate + + + + + + + + New-OVAddressPoolRange + + Create an Address Range. + + New + OVAddressPoolRange + + + This Cmdlet will assist with creating a new address pool range. The support address pool Types are MAC Addresses (VMAC), Fibre Channel/FCoE World Wide Name (VWWN), Server Serial Number (VSN), and IPv4 address pools (IPv4). + +When creating new address pool ranges, the Generated Range Type will allocate 1,048,576 MAC or WWN addresses, whereas it will allocate 46,656 Serial Numbers. + +If you specify a Custom Range Type, you must specify a range of addresses no smaller than 128, and no more than 1,048,576 per range. + +Custom Address Ranges must adhere to the following format rules: + + * The MAC Address must be IEEE Compliant, and the format must be XH:XX:XX:XX:XX:XX, where H must be 0, 2, 4, 6, 8, A, C or E. + + Example: 12:22:33:44:55:00 + + * The WWN Address must be IEEE compliant, and the format must be 10:00:XH:XX:XX:XX:XX:XX, where H must be 0, 2, 4, 6, 8, A, C or E. + + Example: 10:00:6C:9F:06:B0:00:00 + + * The Serial Number addresses must start with VCU, and cannot contain more than 10 characters total. + + Example: VCU1234567 + +IPv4 Address Subnets do not support Auto Generated, as the RangeType parameter is not required. When creating a new IPv4 Address Subnet, you must provide a unique Name, Subnet Mask (CIDR [e.g. 24] or IPv4 Address Value [e.g. 255.255.255.0]), Start and End IPv4 Address, Gateway and Domain Name. DNS Servers are optional. To add more Address Ranges to a Subnet after creating it, please use the New-OVAddressPoolRange Cmdlet. + + + + + New-OVAddressPoolRange + + PoolType + + Specify the Pool Type the new Range will be assinged to. Accepted values are: + + * VMAC + * VWWN + * VSN + + String + + + RangeType + + The type of Address Range to create (not applicable for IPv4 address pools/Subnets). Accepted values are: + + * Generated + * Custom + + String + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + +When attempting to create a new IPv4 address pool/Subnet, only a single HPEOneView.Appliance.Connection object or Name property value is allowed. If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + + + New-OVAddressPoolRange + + IPSubnet + + [Aliases -IPv4Subnet] + +The IPv4 Subnet that the new IPv4 Range will be assigned to. Start and End values must be within the Network ID and Subnet value of the IPv4 Address Subnet Pool. + + Object + + + Name + + Provide the IPv4address pool range Name. + + String + + + Start + + The starting address in the range. Cannot overlap with other address ranges, and should be unique within the datacenter/infrastructure. + + String + + + End + + The ending address in the range. Cannot overlap with other address ranges, and should be unique within the datacenter/infrastructure. + + String + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + +When attempting to create a new IPv4 address pool/Subnet, only a single HPEOneView.Appliance.Connection object or Name property value is allowed. If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + + + New-OVAddressPoolRange + + PoolType + + Specify the Pool Type the new Range will be assinged to. Accepted values are: + + * VMAC + * VWWN + * VSN + + String + + + RangeType + + The type of Address Range to create (not applicable for IPv4 address pools/Subnets). Accepted values are: + + * Generated + * Custom + + String + + + Start + + The starting address in the range. Cannot overlap with other address ranges, and should be unique within the datacenter/infrastructure. + + String + + + End + + The ending address in the range. Cannot overlap with other address ranges, and should be unique within the datacenter/infrastructure. + + String + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + +When attempting to create a new IPv4 address pool/Subnet, only a single HPEOneView.Appliance.Connection object or Name property value is allowed. If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + +When attempting to create a new IPv4 address pool/Subnet, only a single HPEOneView.Appliance.Connection object or Name property value is allowed. If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + End + + The ending address in the range. Cannot overlap with other address ranges, and should be unique within the datacenter/infrastructure. + + String + + String + + + + + IPSubnet + + [Aliases -IPv4Subnet] + +The IPv4 Subnet that the new IPv4 Range will be assigned to. Start and End values must be within the Network ID and Subnet value of the IPv4 Address Subnet Pool. + + Object + + Object + + + + + Name + + Provide the IPv4address pool range Name. + + String + + String + + + + + PoolType + + Specify the Pool Type the new Range will be assinged to. Accepted values are: + + * VMAC + * VWWN + * VSN + + String + + String + + + + + RangeType + + The type of Address Range to create (not applicable for IPv4 address pools/Subnets). Accepted values are: + + * Generated + * Custom + + String + + String + + Generated + + + Start + + The starting address in the range. Cannot overlap with other address ranges, and should be unique within the datacenter/infrastructure. + + String + + String + + + + + + + + + HPEOneView.Appliance.IPAddressSubnet [System.Management.Automation.PSCustomObject] + + + IPv4 Address Subnet resource object from Get-OVAddressPoolSubnet + + + + + + + + HPEOneView.Appliance.AddressPoolRange [System.Management.Automation.PSCustomObject] + + + + Newly created and assigned address pool range resource object + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + PS C:> New-OVAddressPoolRange -PoolType vmac -RangeType Generated + + Create a new Appliance generated VMAC Pool Range. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + PS C:> New-OVAddressPoolRange -PoolType vwwn -RangeType Custom -Start 10:00:6C:9F:06:B0:00:00 -End 10:00:6C:9F:06:BF:FF:FF + + Create a new VWWN address pool range with the custom addresses, for the MyAppliance1.domain.com appliance connection. + + + + + + + + + + -------------------------- EXAMPLE 3 -------------------------- + + + + PS C:> Get-OVAddressPoolSubnet -NetworkId 192.168.20.0 | New-OVAddressPoolRange -Name "VLAN20 Mgmt" -Start 192.168.20.100 -end 192.168.20.200 + + Create a new IPv4 address pool range, for the MyAppliance1.domain.com appliance connection. + + + + + + + + + + + + + Get-OVAddressPoolRange + + + + Remove-OVAddressPoolRange + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/new-ovaddresspoolrange + + + + + + + + New-OVAddressPoolSubnet + + Create an IPv4 Subnet Pool. + + New + OVAddressPoolSubnet + + + This Cmdlet will assist with creating a new IPv4 address pool. When creating a new IPv4 Address Subnet, you must provide the Network ID, Subnet Mask (CIDR [e.g. 24] or IPv4 Address Value [e.g. 255.255.255.0]), Gateway and Domain Name. DNS Servers are optional. + +To add IPv4 Address Ranges to a Subnet after creating it, please use the New-OVAddressPoolRange Cmdlet. + + + + + New-OVAddressPoolSubnet + + NetworkId + + The IPv4 Network ID value of the subnet. + + IPAddress + + + SubnetMask + + CIDR [e.g. 24] or IPv4 Address Value [e.g. 255.255.255.0] + + String + + + Gateway + + IPv4 Address of the default gateway for the subnet. + + IPAddress + + + Domain + + DNS Domain Name of the subnet. + + String + + + DNSServers + + An array of DNS Server IPv4 Addresses. + + Array + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + DNSServers + + An array of DNS Server IPv4 Addresses. + + Array + + Array + + + + + Domain + + DNS Domain Name of the subnet. + + String + + String + + + + + Gateway + + IPv4 Address of the default gateway for the subnet. + + IPAddress + + IPAddress + + + + + NetworkId + + The IPv4 Network ID value of the subnet. + + IPAddress + + IPAddress + + + + + SubnetMask + + CIDR [e.g. 24] or IPv4 Address Value [e.g. 255.255.255.0] + + String + + String + + + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + HPEOneView.Appliance.IPAddressSubnet [System.Management.Automation.PSCustomObject] + + + + Newly created IPv4 Address Subnet + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + PS C:> New-OVAddressPoolSubnet -NetworkID 192.168.10.0 -Subnetmask 24 -Gateway 192.168.10.254 -Domain vlan10.domain.com -DNSServers 10.250.33.12,10.250.34.80 + + Create a new IPv4 address pool with the specified values. + + + + + + + + + + + + + Get-OVAddressPoolSubnet + + + + Remove-OVAddressPoolSubnet + + + + Set-OVAddressPoolSubnet + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/new-ovaddresspoolsubnet + + + + + + + + New-OVApplianceCsr + + Generate appliance CSR + + New + OVApplianceCsr + + + This Cmdlet will create the CSR for an given appliance, to then be submitted to a CA. + + + + + New-OVApplianceCsr + + Country + + The country code in either Full English or ISO3166-2 two-character format, is a required entry and must contain only two letters. + + String + + + State + + The state or province is a required entry, can contain up to 128 characters. + + String + + + Organization + + The organization name is a required entry, can contain up to 64 characters. + + String + + + CommonName + + The common name is a required entry, and can be FQDN/hostname or IPv4/IPv6 address. + +Example: "hpov.example.com" + + String + + + City + + The city or locality is a required entry, can contain up to 128 characters. + + String + + + OrganizationalUnit + + The entry for the organizational unit name, may not exceed 64 characters. + + String + + + AlternativeName + + An optional entry containing additional names that apply to the owner of the certificate, possibly including additional e-mail addresses, DNS names, IP addresses and other identifiers. + +Example: "hpov.example.com,hpov,192.168.1.1" + + String + + + ContactName + + The name of the contact person, may not exceed 64 characters. + + String + + + Email + + The contact person"s email address, which may not exceed 128 characters and is of the format name@domain. + + String + + + Surname + + The contact person"s family name, which may not exceed 64 characters. + + String + + + GivenName + + The contact person"s first name, which may not exceed 64 characters. + + String + + + Initials + + The contact person"s initials, which may not exceed 20 characters. + + String + + + DNQualifier + + The distinguished name qualifier, which further identifies the certificate recipient, which may not exceed 128 characters. + + String + + + ChallengePassword + + The challenge password is a required entry and must contain a minimum of 8 characters. If you wish to be prompted to supply the password, use an asterisk (*) character. + + String + + + UnstructuredName + + Defined by the certificate authority, and may contain up to 64 characters. Consult the certificate authority"s administrator or documentation for more information. + + String + + + CnsaCompliantRequest + + Specify to create a CNSA compliant certificate request. By default the certificate request will create a 2048bit key length, while CNSA compliant will create a 3072bit key length. + + Bool + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. + + Object + + + + + + + AlternativeName + + An optional entry containing additional names that apply to the owner of the certificate, possibly including additional e-mail addresses, DNS names, IP addresses and other identifiers. + +Example: "hpov.example.com,hpov,192.168.1.1" + + String + + String + + + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + ChallengePassword + + The challenge password is a required entry and must contain a minimum of 8 characters. If you wish to be prompted to supply the password, use an asterisk (*) character. + + String + + String + + + + + City + + The city or locality is a required entry, can contain up to 128 characters. + + String + + String + + + + + CnsaCompliantRequest + + Specify to create a CNSA compliant certificate request. By default the certificate request will create a 2048bit key length, while CNSA compliant will create a 3072bit key length. + + Bool + + Bool + + + + + CommonName + + The common name is a required entry, and can be FQDN/hostname or IPv4/IPv6 address. + +Example: "hpov.example.com" + + String + + String + + + + + ContactName + + The name of the contact person, may not exceed 64 characters. + + String + + String + + + + + Country + + The country code in either Full English or ISO3166-2 two-character format, is a required entry and must contain only two letters. + + String + + String + + + + + DNQualifier + + The distinguished name qualifier, which further identifies the certificate recipient, which may not exceed 128 characters. + + String + + String + + + + + Email + + The contact person"s email address, which may not exceed 128 characters and is of the format name@domain. + + String + + String + + + + + GivenName + + The contact person"s first name, which may not exceed 64 characters. + + String + + String + + + + + Initials + + The contact person"s initials, which may not exceed 20 characters. + + String + + String + + + + + Organization + + The organization name is a required entry, can contain up to 64 characters. + + String + + String + + + + + OrganizationalUnit + + The entry for the organizational unit name, may not exceed 64 characters. + + String + + String + + + + + State + + The state or province is a required entry, can contain up to 128 characters. + + String + + String + + + + + Surname + + The contact person"s family name, which may not exceed 64 characters. + + String + + String + + + + + UnstructuredName + + Defined by the certificate authority, and may contain up to 64 characters. Consult the certificate authority"s administrator or documentation for more information. + + String + + String + + + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + System.Management.Automation.PSCustomObject + + + + Object that contains the base64data property, which can then be written to a file or submitted to CA + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + $CSR = @{ +>> Country = "US"; +>> State = "California"; +>> City = "Palo Alto"; +>> Organization = "Hewlett-Packard"; +>> CommonName = "hpov.example.com"; +>> AlternativeName = "hpov.example.com,192.168.1.1,hpov" +>> } +>> +$request = New-OVApplianceCsr @CSR -ApplianceConnection Appliance.domain.com +Set-Content -path C:\dir\hpov.csr -value $request.base64Data -Force + + Create a CSR request to submit to CA. + + + + + + + + + + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/new-ovappliancecsr + + + + + + + + New-OVApplianceDataAtRestEncryptionKey + + Generate a new HPE Synergy Composer appliance encryption key. + + New + OVApplianceDataAtRestEncryptionKey + + + HPE OneView encrypts sensitive data, such as managed device credentials, when it is stored on-disk in the appliance. The HPE OneView appliance encryption key (AEK) is used internally to encrypt the credentials for managed devices (such as, iLO, onboard administrator, frame link module). By default, the AEK is stored on the HPE Synergy Composer disk and also included in the appliance backup. This could pose a security risk in case the disk is stolen. + +The secure data-at-rest option, when enabled, stores the AEK off-disk in Composer NVRAM, and does not include the key in the appliance backup. Enabling this option requires the administrator to save a copy of the AEK (recovery AEK) for use in the following circumstances: + +* When restoring a backup taken when a different AEK was in effect. +* To successfully boot the system in the unlikely event that the system copy of the key is corrupted. +* A backup is being restored to a different new Composer or to the same Composer that has been factory reset. + +The administrator must store the recovery AEK in a secure location, where it can be only accessed by authorized personnel. In the rare circumstance where the key cannot be read from the Composer NVRAM or the key gets corrupted, the administrator must use the appliance maintenance console to upload the AEK recovery copy, based on the error resolution message displayed. In the rare circumstance where the Composer NVRAM itself becomes inaccessible, users can choose to disable secure-data-at-rest option until the hardware issue itself is resolved. + +If the downloaded recovery key and the AEK stored in the Composer NVRAM are both lost, the appliance data cannot be recovered. + +This Cmdlet will generate a new encryption key, if the existing encryption key is lost or unknown. Any existing backups that were created with the prior encryption key will become invalid. After creating a new encryption key, it is highly recommended to create a new backup using New-OVBackup and save it, along with the new encryption key file that can be generated by this Cmdlet by using the -Location parameter, to a secure and safe location. This Cmdlet can only be used when data at rest encryption has been enabled. + + + + + New-OVApplianceDataAtRestEncryptionKey + + Location + + Specify the location where to save the generated encryption key file to. + + String + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Location + + Specify the location where to save the generated encryption key file to. + + String + + String + + + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + System.IO.FileInfo + + + + The newly created file if the -Location paramter is provided. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + New-OVApplianceDataAtRestEncryptionKey + + Generate a new appliance encryption key, using the current working directory. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + New-OVApplianceDataAtRestEncryptionKey -Location \Fileserver.corp.domain\Share\ApplianceKeys + + Generate a new appliance encryption key, save the created file to a specific location. + + + + + + + + + + + + + Save-OVApplianceDataAtRestEncryptionKey + + + + Enable-OVApplianceDataAtRestEncryption + + + + Disable-OVApplianceDataAtRestEncryption + + + + Get-OVApplianceDataAtRestEncryption + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/security/new-ovappliancedataatrestencryptionkey + + + + + + + + New-OVApplianceSelfSignedCertificate + + Create a new appliance self signed Certificate. + + New + OVApplianceSelfSignedCertificate + + + Use thid Cmdlet to create or recreate a self signed Certificate for the appliance. + + + + + New-OVApplianceSelfSignedCertificate + + Country + + The country code in either Full English or ISO3166-2 two-character format, is a required entry and must contain only two letters. + + String + + + State + + The state or province is a required entry, can contain up to 128 characters. + + String + + + Organization + + The organization name is a required entry, can contain up to 64 characters. + + String + + + CommonName + + The common name is a required entry, and can be FQDN/hostname or IPv4/IPv6 address. + +Example: "hpov.example.com" + + String + + + City + + The city or locality is a required entry, can contain up to 128 characters. + + String + + + OrganizationalUnit + + The entry for the organizational unit name, may not exceed 64 characters. + + String + + + AlternativeName + + An optional entry containing additional names that apply to the owner of the certificate, possibly including additional e-mail addresses, DNS names, IP addresses and other identifiers. + +Example: "hpov.example.com,hpov,192.168.1.1" + + String + + + ContactName + + The name of the contact person, may not exceed 64 characters. + + String + + + Email + + The contact person"s email address, which may not exceed 128 characters and is of the format name@domain. + + String + + + Surname + + The contact person"s family name, which may not exceed 64 characters. + + String + + + GivenName + + The contact person"s first name, which may not exceed 64 characters. + + String + + + Initials + + The contact person"s initials, which may not exceed 20 characters. + + String + + + DNQualifier + + The distinguished name qualifier, which further identifies the certificate recipient, which may not exceed 128 characters. + + String + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. + + Object + + + WhatIf + + + + + + + Confirm + + + + + + + + + + + AlternativeName + + An optional entry containing additional names that apply to the owner of the certificate, possibly including additional e-mail addresses, DNS names, IP addresses and other identifiers. + +Example: "hpov.example.com,hpov,192.168.1.1" + + String + + String + + + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + City + + The city or locality is a required entry, can contain up to 128 characters. + + String + + String + + + + + CommonName + + The common name is a required entry, and can be FQDN/hostname or IPv4/IPv6 address. + +Example: "hpov.example.com" + + String + + String + + + + + Confirm + + + + + + + + + + + ContactName + + The name of the contact person, may not exceed 64 characters. + + String + + String + + + + + Country + + The country code in either Full English or ISO3166-2 two-character format, is a required entry and must contain only two letters. + + String + + String + + + + + DNQualifier + + The distinguished name qualifier, which further identifies the certificate recipient, which may not exceed 128 characters. + + String + + String + + + + + Email + + The contact person"s email address, which may not exceed 128 characters and is of the format name@domain. + + String + + String + + + + + GivenName + + The contact person"s first name, which may not exceed 64 characters. + + String + + String + + + + + Initials + + The contact person"s initials, which may not exceed 20 characters. + + String + + String + + + + + Organization + + The organization name is a required entry, can contain up to 64 characters. + + String + + String + + + + + OrganizationalUnit + + The entry for the organizational unit name, may not exceed 64 characters. + + String + + String + + + + + State + + The state or province is a required entry, can contain up to 128 characters. + + String + + String + + + + + Surname + + The contact person"s family name, which may not exceed 64 characters. + + String + + String + + + + + WhatIf + + + + + + + + + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + System.Management.Automation.PSCustomObject + + + + Object that contains the "base64data" property of the certificate + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + $CSR = @{ +>> Country = "US"; +>> State = "California"; +>> City = "Palo Alto"; +>> Organization = "Hewlett-Packard"; +>> CommonName = "hpov.example.com"; +>> AlternativeName = "hpov.example.com,192.168.1.1,hpov" +>> } +>> +New-OVApplianceSelfSignedCertificate @CSR -ApplianceConnection Appliance.domain.com + + Generate self signed Certificate for the appliance. + + + + + + + + + + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/new-ovapplianceselfsignedcertificate + + + + + + + + New-OVApplianceStaticRoute + + Create new configured static route on an appliance. + + New + OVApplianceStaticRoute + + + When configuring a second NIC on a virtual machine appliance, static routes can be configured as only a single appliance NIC can be configured with a default gateway. Both IPv4 and IPv6 static routes are supported. Use Get-OVApplianceIPAddress to display the configured NIC interfaces, and supply the interface name with the -Interface parameter. + +Minimum required privileges: Infrastructure administrator + + + + + New-OVApplianceStaticRoute + + Destination + + IP Address of the destination subnet. Format must follow {address}/{bits}. Can either be IPv4 or IPv6 address type. + + String + + + Gateway + + The IP address of the router. Can either be an IPv4 or IPv6 address, but must match the type provided in the -Destination parameter. + + IPAddress + + + Interface + + Interface name of the NIC the static route will be configured for. + + String + + + Metric + + Route weight value if multiple next hop routes will be configured for the same subnet. If no value provided, the route weight will be set to 100. + + int + + + ApplianceConnection + + Specify one or more HPEOneView.Appliance.Connection object(s) or Name property value(s). + +Default Value: ${Global:ConnectedSessions} | ? Default + + Object + + + + + + + ApplianceConnection + + Specify one or more HPEOneView.Appliance.Connection object(s) or Name property value(s). + +Default Value: ${Global:ConnectedSessions} | ? Default + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Destination + + IP Address of the destination subnet. Format must follow {address}/{bits}. Can either be IPv4 or IPv6 address type. + + String + + String + + + + + Gateway + + The IP address of the router. Can either be an IPv4 or IPv6 address, but must match the type provided in the -Destination parameter. + + IPAddress + + IPAddress + + + + + Interface + + Interface name of the NIC the static route will be configured for. + + String + + String + + + + + Metric + + Route weight value if multiple next hop routes will be configured for the same subnet. If no value provided, the route weight will be set to 100. + + int + + int + + + + + + + + + None. You cannot pipe objects to this cmdlet. + + + + + + + + + + + HPOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + Async task resource to monitor. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + New-OVApplianceStaticRoute -Destination 192.168.199.9/24 -Gateway 192.168.33.1 -Interface SecondNIC + + + Add the specific IPv4 static route to an appliance. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + New-OVApplianceStaticRoute -Destination 2001:db8:abcd:0012::0/64 -Gateway 2001:db8:85a3:0000:0000:8a2e:0370:7334 -Interface SecondNIC + + + Add the specific IPv6 static route to an appliance. + + + + + + + + + + + + + Get-OVApplianceStaticRoute + + + + Remove-OVApplianceStaticRoute + + + + Set-OVApplianceStaticRoute + + + + Online: + https://hpe-docs.gitbook.io/posh-hpeoneview/cmdlets/v9.00/appliance/new-ovappliancestaticroute + + + + + + + + New-OVApplianceTrapDestination + + Create a new appliance SNMP trap destiation. + + New + OVApplianceTrapDestination + + + HPE OneView can be used as a proxy to forward device traps from servers and enclosures (OA) to other SNMP-enabled applications on the network. HPE OneView can forward traps, as SNMPv3 or SNMPv1 traps, to configured destinations. + +Appliance SNMP settings allow you to add destinations to which the traps need to be forwarded. You can configure each destination as an SNMPv1 or SNMPv3 destination, depending on whether the traps are sent in SNMPv1 or SNMPv3 formats. + +Additionally, if you have Gen6 or Gen7 servers being monitored by HPE OneView in your environment, you can configure the read community string that HPE OneView uses for monitoring these servers with SNMPv1. + +Minimum required privileges: Infrastructure administrator + + + + + New-OVApplianceTrapDestination + + Destination + + IP Address or Hostname of the target SNMP trap reciever. + + String + + + CommunityString + + SNMPv1 trap community string. + + String + + + Port + + Specify the alternate SNMP destination port. + + Int + + + Type + + SNMP version type. Allowed values: + + * SNMPv1 + * SNMPv3 + + String + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + + + New-OVApplianceTrapDestination + + Destination + + IP Address or Hostname of the target SNMP trap reciever. + + String + + + SnmpV3User + + The defined SNMPv3 user created on the appliance with Get-OVSnmpV3User. + + HPEOneView.Appliance.SnmpV3User + + + Port + + Specify the alternate SNMP destination port. + + Int + + + Type + + SNMP version type. Allowed values: + + * SNMPv1 + * SNMPv3 + + String + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + Array + + (${Global:ConnectedSessions} | ? Default) + + + CommunityString + + SNMPv1 trap community string. + + String + + String + + + + + Destination + + IP Address or Hostname of the target SNMP trap reciever. + + String + + String + + + + + Port + + Specify the alternate SNMP destination port. + + Int + + Int + + 161 + + + SnmpV3User + + The defined SNMPv3 user created on the appliance with Get-OVSnmpV3User. + + HPEOneView.Appliance.SnmpV3User + + HPEOneView.Appliance.SnmpV3User + + + + + Type + + SNMP version type. Allowed values: + + * SNMPv1 + * SNMPv3 + + String + + String + + SNMPv1 + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + HPEOneView.Appliance.SnmpV1TrapDestination + + + + The configured SNMPv1 Trap Destination on the appliance. + + + + + HPEOneView.Appliance.SnmpV3TrapDestination + + + + The configured SNMPv3 Trap Destination on the appliance. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + New-OVApplianceTrapDestination -Destination $SnmpV1TrapDestinationAddress -Type SNMPv1 -Port $SnmpV1TrapDestinationPort -CommunityString $SnmpV1Community + + Create a new SNMPv1 trap destination on the appliance. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + $SnmpV3Password = ConvertTo-SecureString -String $CommonPassword -AsPlainText -Force +$Snmpv3User = New-OVSnmpV3User -ApplianceSnmpUser -Username Tr@pUser -SecurityLevel AuthAndPriv -AuthProtocol SHA512 -AuthPassword $SnmpV3Password -PrivProtocol AES192 -PrivPassword $SnmpV3Password +New-OVApplianceTrapDestination -Type SnmpV3 -SnmpV3User $CreatedSnmpSnmpv3UserV3User -Destination monitor1.contoso.com + + Define a new SNMPv3 user, and associate it with the new SNMPv3 trap destination on the appliance. + + + + + + + + + + + + + Get-OVApplianceTrapDestination + + + + Remove-OVApplianceTrapDestination + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/new-ovappliancetrapdestination + + + + + + + + New-OVBackup + + Generate and download or remote save appliance backup. + + New + OVBackup + + + HPE OneView provides the ability to save your configuration settings and management data to a backup file and enables you to use that backup to restore a corrupted appliance in the event of a catastrophic failure. + +The backup process involves creating a backup file and then downloading that file so that you can store it to a safe and secure (off-appliance) location for future use. You can schedule automatic backup operations and designate a remote location for the backup file. + +Use this Cmdlet to generate and download an appliance configuration backup file for backup purposes. The backup file does not contain user account passwords. The backup file is not meant to restore to other appliance for quick provisioning, as it is an encrypted TAR GZIP file. + +If an automatic backup policy is configured on the appliance, the Cmdlet is instruct the appliance to offload the newly created backup to the remote location. If you wish to download the backup, use the -Location and -Force parameters, which will initiate a download to the value provided. + + + + + New-OVBackup + + Passphrase + + Introduced in the HPE OneView 6.60.06 patch, a secure Passphrase is required to encrypt the appliance backup. The parameter is only required if the appliance version is 6.60.06 or 6.60.07. An exception will be generated if this parameter is used and the target appliance doesn't meet the minimum required version. + + SwitchParameter + + + Location + + The full path to where the Support Dump will be saved to. The downloaded file name will be generated by the appliance. If the directory does not exist, it will be created. By default will use current directory. + + String + + + Force + + The Cmdlet will validate if the appliance is configured to save backup files to a remote location. Use this option to force download the backup file instead of copying to the remote location. + + SwitchParameter + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + Array + + (${Global:ConnectedSessions} | ? Default) + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + SwitchParameter + + False + + + Force + + The Cmdlet will validate if the appliance is configured to save backup files to a remote location. Use this option to force download the backup file instead of copying to the remote location. + + SwitchParameter + + SwitchParameter + + False + + + Location + + The full path to where the Support Dump will be saved to. The downloaded file name will be generated by the appliance. If the directory does not exist, it will be created. By default will use current directory. + + String + + String + + (get-location).Path + + + Passphrase + + Introduced in the HPE OneView 6.60.06 patch, a secure Passphrase is required to encrypt the appliance backup. The parameter is only required if the appliance version is 6.60.06 or 6.60.07. An exception will be generated if this parameter is used and the target appliance doesn't meet the minimum required version. + + SwitchParameter + + SwitchParameter + + False + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + The generated backup File if appliance is not setup for remote storage or the Force parameter is used. + + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + Async task to create the backup file. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + New-OVBackup + + This command will generate a new backup, and if a remote location is configured, will initiate the file transfer. If not configured, then the Cmdlet will download the file to the current working directory. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + New-OVBackup -Location C:\Temp -Force + + This command will save the Appliance backup file to C:\Temp + + + + + + + + + + + + + Get-OVBackup + + + + New-OVRestore + + + + Save-OVBackup + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/new-ovbackup + + + + + + + + New-OVClusterProfile + + Create a new cluster profile resource. + + New + OVClusterProfile + + + A cluster profile enables you to deploy and manage a cluster of servers (nodes) managed by HPE OneView and orchestrates consistent configuration on cluster of server nodes to share the same workload. A cluster profile and the associated server profile template are used to define a consistent configuration from server nodes to members in the cluster. The associated server profiles define physical server configurations for server nodes in the cluster, which are derived from parent cluster profile and its associated server profile template. + +NOTE: The server profile template must have a configured connection to the hypervisor management network for the template to be valid for use by a hypervisor cluster profile. + +The cluster profile helps you manage life cycle operations, such as growing or shrinking the cluster, modifying configurations based on needs, consistency checks, and nondisruptive firmware updates on the member nodes. For example, you can grow or shrink a cluster by adding or removing members from the cluster profile. Any change in the configuration of the cluster profile will be reported as an inconsistency. When inconsistencies are remediated, the changed configurations can be applied on cluster and member nodes. + +A cluster profile can manage VMware ESXi-based hypervisor clusters by leveraging VMware vCenter server. A hypervisor cluster must be managed by one instance of HPE OneView to avoid inconsistencies. + +Use this Cmdlet to create a new cluster profile within OneView. Any new created clusters within OneView cannot be removed from OneView withour destroying the cluster within the cluster manager. + +Minimum required privileges: Infrastructure administrator, Server administrator, Server profile architect, or Server profile administrator. + + + + + New-OVClusterProfile + + Name + + Provide the cluster profile name. If -Prefix is omitted, this value will become the cluster node prefix value. + + String + + + ClusterManager + + Specify the cluster manager that will manage the cluster and associated members, from Get-OVClusterManager. + + HPEOneView.Cluster.ClusterManager + + + ClusterManagerLocation + + Specify the location where the cluster will be created within the cluster manager. + + String + + + ServerProfileTemplate + + The server profile template from Get-OVServerProfileTemplate that the cluster configuration will be derived from and follow cluster consistency with. + + Object + + + ClusterPassword + + Specify the cluster administrator/root account password. + + SecureString + + + Description + + Provide a description of the cluster. + + String + + + ClusterPrefix + + Specify the cluster member hostname prefix that will be used. A unique numerical value will be appended to the end. If omitted, the clsuter name will be used as the prefix. + + String + + + Servers + + One or more server resource objects from New-OVClusterProfileMember. Value can be empty to create an empty cluster, if the target cluster manager supports that type of configuration, like VMware vSphere. + + HPEOneView.Cluster.AddHostRequest[] + + + UseIPAddressAsHostName + + Use to indicate if the IP Address allocated or assigned should be used for the cluster manager registration instead of the hostname or FQDN. + + Bool + + + LeaveHostsInMaintenanceMode + + Specify if the host should be left in maintenance mode (if applicable) before servicing the cluster. + + Bool + + + StorageVolume + + One or more storage volumes to assign. + + Object + + + StorageVolumeFileSystem + + Specify if the storage volume(s) in the StorageVolume parameter should be formatted with a specific filesystem. Allowed values: + + * VMFS + * Unmanaged + + String + + + Scope + + Provide an HPEOneView.Appliance.ScopeCollection resource object to initially associate with. Resource can also be added to scope using the Add-OVResourceToScope Cmdlet. + + Object + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + New-OVClusterProfile + + Name + + Provide the cluster profile name. If -Prefix is omitted, this value will become the cluster node prefix value. + + String + + + ClusterManager + + Specify the cluster manager that will manage the cluster and associated members, from Get-OVClusterManager. + + HPEOneView.Cluster.ClusterManager + + + ClusterManagerLocation + + Specify the location where the cluster will be created within the cluster manager. + + String + + + ServerProfileTemplate + + The server profile template from Get-OVServerProfileTemplate that the cluster configuration will be derived from and follow cluster consistency with. + + Object + + + ClusterPassword + + Specify the cluster administrator/root account password. + + SecureString + + + UnmanageVSwitch + + Use to configure the cluster profile to not manage host networking. + + SwitchParameter + + + Description + + Provide a description of the cluster. + + String + + + ClusterPrefix + + Specify the cluster member hostname prefix that will be used. A unique numerical value will be appended to the end. If omitted, the clsuter name will be used as the prefix. + + String + + + Servers + + One or more server resource objects from New-OVClusterProfileMember. Value can be empty to create an empty cluster, if the target cluster manager supports that type of configuration, like VMware vSphere. + + HPEOneView.Cluster.AddHostRequest[] + + + HAEnabled + + Specify if VMware HA (if supported) should be enabled ($True) or disabled ($false). + + Bool + + + DRSEnabled + + Specify if DRS (if supported) should be enabled ($True) or disabled ($false). + + Bool + + + MultiNicVMotionEnabled + + Specify if multi-NIC VMotion (if supported) should be enabled ($True) or disabled ($false). + + Bool + + + Scope + + Provide an HPEOneView.Appliance.ScopeCollection resource object to initially associate with. Resource can also be added to scope using the Add-OVResourceToScope Cmdlet. + + Object + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + New-OVClusterProfile + + Name + + Provide the cluster profile name. If -Prefix is omitted, this value will become the cluster node prefix value. + + String + + + ClusterManager + + Specify the cluster manager that will manage the cluster and associated members, from Get-OVClusterManager. + + HPEOneView.Cluster.ClusterManager + + + ClusterManagerLocation + + Specify the location where the cluster will be created within the cluster manager. + + String + + + ServerProfileTemplate + + The server profile template from Get-OVServerProfileTemplate that the cluster configuration will be derived from and follow cluster consistency with. + + Object + + + ClusterPassword + + Specify the cluster administrator/root account password. + + SecureString + + + Description + + Provide a description of the cluster. + + String + + + ClusterPrefix + + Specify the cluster member hostname prefix that will be used. A unique numerical value will be appended to the end. If omitted, the clsuter name will be used as the prefix. + + String + + + Servers + + One or more server resource objects from New-OVClusterProfileMember. Value can be empty to create an empty cluster, if the target cluster manager supports that type of configuration, like VMware vSphere. + + HPEOneView.Cluster.AddHostRequest[] + + + OverrideManagementAddressAssignmet + + Use to indicate address assignment. If the server profile template boot connections are set to require static addresses, the IPAddress value must be used in the New-OVClusterProfileMember Cmdlet. + + SwitchParameter + + + SubnetMask + + When deploying a new cluster profile with HPE Synergy and Image Streamer, specify the subnet mask if the management network is not configured to use an IP address pool. + + IPAddress + + + Gateway + + When deploying a new cluster profile with HPE Synergy and Image Streamer, specify the gateway if the management network is not configured to use an IP address pool. + + IPAddress + + + PrimaryDNS + + Optional - When deploying a new cluster profile with HPE Synergy and Image Streamer, specify the primary DNS if the management network is not configured to use an IP address pool. + + IPAddress + + + SecondaryDNS + + Optional - When deploying a new cluster profile with HPE Synergy and Image Streamer, specify the secondary DNS if the management network is not configured to use an IP address pool. + + IPAddress + + + TertiaryDNS + + Optional - When deploying a new cluster profile with HPE Synergy and Image Streamer, specify the tertiary DNS if the management network is not configured to use an IP address pool. + + IPAddress + + + Domain + + Optional - When deploying a new cluster profile with HPE Synergy and Image Streamer, specify the domain name if the management network is not configured to use an IP address pool. + + String + + + UseIPAddressAsHostName + + Use to indicate if the IP Address allocated or assigned should be used for the cluster manager registration instead of the hostname or FQDN. + + Bool + + + LeaveHostsInMaintenanceMode + + Specify if the host should be left in maintenance mode (if applicable) before servicing the cluster. + + Bool + + + StorageVolume + + One or more storage volumes to assign. + + Object + + + StorageVolumeFileSystem + + Specify if the storage volume(s) in the StorageVolume parameter should be formatted with a specific filesystem. Allowed values: + + * VMFS + * Unmanaged + + String + + + OverrideNetworkingConfig + + Use to indicate if network naming will be overridden. + + SwitchParameter + + + ConfigurePortGroups + + Specify if port groups should also be configured when configuring host networking. + + Bool + + + VSwitchNameOverride + + Use to specify what the vSwitch name override should be. By default, vSwitch names will be automatically assigned based on the network name, removing unique character strings. Specify an Array of Hashtable with the following format: + + @{ "NetworkName" = "OverrideName" } + + Where "NetworkName" is the name of the Ethernet Network assigned to the connection. + + hashtable + + + PortGroupNameOverride + + Use to specify what the PortGroup name override should be. By default, PortGroup names will be automatically assigned based on the network name, removing unique character strings. Specify an Array of Hashtable with the following format: + + @{ "NetworkName" = "OverrideName" } + + Where "NetworkName" is the name of the Ethernet Network assigned to the connection. + + Hashtable + + + OverrideClusterManagerConfig + + Use to indicate the desire to override the cluster manager default settings. + + SwitchParameter + + + VirtualSwitchType + + Use to indicate which vSiwtch type to configure when overriding cluster manager networking settings. Allowed values are: + + * Standard + * Distributed + + String + + + DistributedSwitchUsage + + If overriding the distributed virtual switch configuring set by the cluster manager, specify the switch usage. Allowed values: + + * Standard + * Distributed + + String + + + DistributedSwitchVersion + + If overriding the distributed virtual switch configuring set by the cluster manager, specify the version. To identify the supported versions, look at the AvailableDvsVersions property of the returned cluster manager from Get-OVClusterManager. + + String + + + HAEnabled + + Specify if VMware HA (if supported) should be enabled ($True) or disabled ($false). + + Bool + + + DRSEnabled + + Specify if DRS (if supported) should be enabled ($True) or disabled ($false). + + Bool + + + MultiNicVMotionEnabled + + Specify if multi-NIC VMotion (if supported) should be enabled ($True) or disabled ($false). + + Bool + + + Scope + + Provide an HPEOneView.Appliance.ScopeCollection resource object to initially associate with. Resource can also be added to scope using the Add-OVResourceToScope Cmdlet. + + Object + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + SwitchParameter + + False + + + ClusterManager + + Specify the cluster manager that will manage the cluster and associated members, from Get-OVClusterManager. + + HPEOneView.Cluster.ClusterManager + + HPEOneView.Cluster.ClusterManager + + + + + ClusterManagerLocation + + Specify the location where the cluster will be created within the cluster manager. + + String + + String + + + + + ClusterPassword + + Specify the cluster administrator/root account password. + + SecureString + + SecureString + + + + + ClusterPrefix + + Specify the cluster member hostname prefix that will be used. A unique numerical value will be appended to the end. If omitted, the clsuter name will be used as the prefix. + + String + + String + + + + + ConfigurePortGroups + + Specify if port groups should also be configured when configuring host networking. + + Bool + + Bool + + + + + DRSEnabled + + Specify if DRS (if supported) should be enabled ($True) or disabled ($false). + + Bool + + Bool + + + + + Description + + Provide a description of the cluster. + + String + + String + + + + + DistributedSwitchUsage + + If overriding the distributed virtual switch configuring set by the cluster manager, specify the switch usage. Allowed values: + + * Standard + * Distributed + + String + + String + + + + + DistributedSwitchVersion + + If overriding the distributed virtual switch configuring set by the cluster manager, specify the version. To identify the supported versions, look at the AvailableDvsVersions property of the returned cluster manager from Get-OVClusterManager. + + String + + String + + + + + Domain + + Optional - When deploying a new cluster profile with HPE Synergy and Image Streamer, specify the domain name if the management network is not configured to use an IP address pool. + + String + + String + + + + + Gateway + + When deploying a new cluster profile with HPE Synergy and Image Streamer, specify the gateway if the management network is not configured to use an IP address pool. + + IPAddress + + IPAddress + + + + + HAEnabled + + Specify if VMware HA (if supported) should be enabled ($True) or disabled ($false). + + Bool + + Bool + + + + + LeaveHostsInMaintenanceMode + + Specify if the host should be left in maintenance mode (if applicable) before servicing the cluster. + + Bool + + Bool + + + + + MultiNicVMotionEnabled + + Specify if multi-NIC VMotion (if supported) should be enabled ($True) or disabled ($false). + + Bool + + Bool + + + + + Name + + Provide the cluster profile name. If -Prefix is omitted, this value will become the cluster node prefix value. + + String + + String + + + + + OverrideClusterManagerConfig + + Use to indicate the desire to override the cluster manager default settings. + + SwitchParameter + + SwitchParameter + + + + + OverrideManagementAddressAssignmet + + Use to indicate address assignment. If the server profile template boot connections are set to require static addresses, the IPAddress value must be used in the New-OVClusterProfileMember Cmdlet. + + SwitchParameter + + SwitchParameter + + + + + OverrideNetworkingConfig + + Use to indicate if network naming will be overridden. + + SwitchParameter + + SwitchParameter + + + + + PortGroupNameOverride + + Use to specify what the PortGroup name override should be. By default, PortGroup names will be automatically assigned based on the network name, removing unique character strings. Specify an Array of Hashtable with the following format: + + @{ "NetworkName" = "OverrideName" } + + Where "NetworkName" is the name of the Ethernet Network assigned to the connection. + + Hashtable + + Hashtable + + + + + PrimaryDNS + + Optional - When deploying a new cluster profile with HPE Synergy and Image Streamer, specify the primary DNS if the management network is not configured to use an IP address pool. + + IPAddress + + IPAddress + + + + + Scope + + Provide an HPEOneView.Appliance.ScopeCollection resource object to initially associate with. Resource can also be added to scope using the Add-OVResourceToScope Cmdlet. + + Object + + Object + + AllResourcesInScope + + + SecondaryDNS + + Optional - When deploying a new cluster profile with HPE Synergy and Image Streamer, specify the secondary DNS if the management network is not configured to use an IP address pool. + + IPAddress + + IPAddress + + + + + ServerProfileTemplate + + The server profile template from Get-OVServerProfileTemplate that the cluster configuration will be derived from and follow cluster consistency with. + + Object + + Object + + + + + Servers + + One or more server resource objects from New-OVClusterProfileMember. Value can be empty to create an empty cluster, if the target cluster manager supports that type of configuration, like VMware vSphere. + + HPEOneView.Cluster.AddHostRequest[] + + HPEOneView.Cluster.AddHostRequest[] + + + + + StorageVolume + + One or more storage volumes to assign. + + Object + + Object + + + + + StorageVolumeFileSystem + + Specify if the storage volume(s) in the StorageVolume parameter should be formatted with a specific filesystem. Allowed values: + + * VMFS + * Unmanaged + + String + + String + + Unmanaged + + + SubnetMask + + When deploying a new cluster profile with HPE Synergy and Image Streamer, specify the subnet mask if the management network is not configured to use an IP address pool. + + IPAddress + + IPAddress + + + + + TertiaryDNS + + Optional - When deploying a new cluster profile with HPE Synergy and Image Streamer, specify the tertiary DNS if the management network is not configured to use an IP address pool. + + IPAddress + + IPAddress + + + + + UnmanageVSwitch + + Use to configure the cluster profile to not manage host networking. + + SwitchParameter + + SwitchParameter + + + + + UseIPAddressAsHostName + + Use to indicate if the IP Address allocated or assigned should be used for the cluster manager registration instead of the hostname or FQDN. + + Bool + + Bool + + + + + VSwitchNameOverride + + Use to specify what the vSwitch name override should be. By default, vSwitch names will be automatically assigned based on the network name, removing unique character strings. Specify an Array of Hashtable with the following format: + + @{ "NetworkName" = "OverrideName" } + + Where "NetworkName" is the name of the Ethernet Network assigned to the connection. + + hashtable + + hashtable + + + + + VirtualSwitchType + + Use to indicate which vSiwtch type to configure when overriding cluster manager networking settings. Allowed values are: + + * Standard + * Distributed + + String + + String + + + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + Asynchronous task resource to monitor. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + # Get the specific Cluster Manager +$ClusterManager = Get-OVHypervisorManager -Name ClusterManager1 + +# Display the allowed locations to place the cluster +$ClusterManager.Locations + +DC1 +DC2 +DC3 +DC3\Folder1 + +$ClusterPassword = Read-Host -Prompt "Cluster password" -AsSecureString + +# Get the server profile template the cluster will be created and derived from +$ServerProfileTemplate = Get-OVServerProfileTemplate -Name "Hypervisor Cluster Prod" + +# Get a list of servers based on the SPT, that are available to deploy to +$Servers = Get-OVServer -NoProfile -InputObject $ServerProfileTemplate -Count 4 + +# Create the new cluster profile +New-OVClusterProfile -Name ProdCluster1 -ClusterPrefix ProdClusterNode- -ClusterManager $ClusterManager -ClusterManagerLocation "DC2" -ServerProfileTemplate $ServerProfileTemplate -ClusterPassword $ClusterPassword -Servers $Servers + + Create a new cluster profile. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + # Get the specific Cluster Manager +$ClusterManager = Get-OVHypervisorManager -Name ClusterManager1 + +# Display the allowed distributed switch versions supported by the cluster manager +$ClusterManager.AvailableDvsVersions + +4.0 +4.10 +5.0.0 +5.1.0 +5.5.0 +6.0 +6.7 + +$ClusterPassword = Read-Host -Prompt "Cluster password" -AsSecureString + +# Get the server profile template the cluster will be created and derived from +$ServerProfileTemplate = Get-OVServerProfileTemplate -Name "Hypervisor Cluster Prod" + +# Get a list of servers based on the SPT, that are available to deploy to +$Servers = Get-OVServer -NoProfile -InputObject $ServerProfileTemplate -Count 4 + +# Create new cluster profile overriding the cluster manager settings +New-OVClusterProfile -Name ProdCluster1 -ClusterPrefix ProdClusterNode- -ClusterManager $ClusterManager -ClusterManagerLocation "DC2" -ServerProfileTemplate $ServerProfileTemplate -ClusterPassword $ClusterPassword -Servers $Servers -OverrideClusterManagerConfig -VirtualSwitchType Distributed -DistributedSwitchUsage AllNetworks -DistributedSwitchVersion 6.0 -HAEnabled $true -DRSEnabled $false + + Create a new cluster profile, overriding clsuter manager settings. + + + + + + + + + + + + + Get-OVClusterProfile + + + + New-OVClusterProfileMember + + + + Remove-OVClusterProfile + + + + Update-OVClusterProfile + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/cluster/new-ovclusterprofile + + + + + + + + New-OVClusterProfileMember + + Helper Cmdlet to create proper add host request for New-OVClusterProfile. + + New + OVClusterProfileMember + + + This is a helper Cmdlet to create a valid resourc object New-OVClusterProfile will then use for the -Servers parameter. + +Minimum required privileges: Infrastructure administrator, Server administrator, Server profile architect, or Server profile administrator. + + + + + New-OVClusterProfileMember + + InputObject + + A server hardware resource + + Object + + + IPv4Address + + A valid IPv4 Address for the hypervisor host management interface. + + IPAaddress + + + OSDeploymentAttributes + + Configured OS Deployment Plan parameters from Get-OVOSDeploymentPlanAttribute. Only applicable for HPE Synergy Image Streamer deployment. + + OSDeploymentParameter[] + + + + + + + IPv4Address + + A valid IPv4 Address for the hypervisor host management interface. + + IPAaddress + + IPAaddress + + + + + InputObject + + A server hardware resource + + Object + + Object + + + + + OSDeploymentAttributes + + Configured OS Deployment Plan parameters from Get-OVOSDeploymentPlanAttribute. Only applicable for HPE Synergy Image Streamer deployment. + + OSDeploymentParameter[] + + OSDeploymentParameter[] + + + + + + + + + HPEOneView.ServerHardware [System.Management.Automation.PSCustomObject] + + + An available server hardware resource. + + + + + + + + HPEOneView.Cluster.AddHostRequest + + + + Properly formatted object for New-OVClusterProfile. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + $Server = Get-OVServer -Name "Encl1, Bay 1" +New-OVClusterProfileMember -InputObject $Server + + Create a basic add host object for New-OVClusterProfile. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + $Server = Get-OVServer -Name "Encl1, Bay 1" +New-OVClusterProfileMember -InputObject $Server -IPAddress 192.168.10.1 + + Create anadd host object for New-OVClusterProfile and specify its managmenet IP Address if the associated Server Profile Template management network is not associated with an IP address pool. + + + + + + + + + + -------------------------- EXAMPLE 3 -------------------------- + + + + $MyDeploymentPlan = Get-OVOSDeploymentPlan -Name "vSphere 6.5 U3 Corp Standard" -ErrorAction Stop +$OSDeploymentAttributes = Get-OVOSDeploymentPlanAttributes -InputObject $MyDeploymentPlan +($OSDeploymentAttributes | Where-Object name -eq "CustomAttribute1").value = "MySpecialValue" +$Server = Get-OVServer -Name "Encl1, Bay 1" +New-OVClusterProfileMember -InputObject $Server -IPAddress 192.168.10.1 -OSDeploymentParameter $OSDeploymentAttributes + + Create a basic add host object for New-OVClusterProfile. + + + + + + + + + + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/cluster/new-ovclusterprofilemember + + + + + + + + New-OVCustomBaseline + + Create Custom Baseline from Hotfixes and Source Baseline. + + New + OVCustomBaseline + + + HPE ProLiant Hotfixes are released out of the main SPP release cycle. Administrators can use HPSUM external to HPE OneView to create a custom baseline, but then need to upload to the appliance. Hotfixes can be directly uploaded to an HPE OneView 2.0 Appliance, with the ability to create a Custom Baseline by using a source Baseline (which must exist in the Baseline Repository) and specified Hotfix(s). + + + + + New-OVCustomBaseline + + SourceBaseline + + An existing Baseline within the HPE OneView Baseline Repository. + + Object + + + Hotfixes + + Array of Hotfix filenames, or Component name. + +Example: @(cp111111.exe,cp222222.scexe,cp333333.exe,cp444444.scexe) + + Array + + + BaselineName + + The final custom Baseline name. + +Example: custom_SPPGen9Snap3_2015_0327_82 + + String + + + Scope + + Provide an HPEOneView.Appliance.ScopeCollection resource object to initially associate with. Resource can also be added to scope using the Add-OVResourceToScope Cmdlet. + + HPEOneView.Appliance.ScopeCollection[] + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + + + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + SwitchParameter + + + + + BaselineName + + The final custom Baseline name. + +Example: custom_SPPGen9Snap3_2015_0327_82 + + String + + String + + + + + Hotfixes + + Array of Hotfix filenames, or Component name. + +Example: @(cp111111.exe,cp222222.scexe,cp333333.exe,cp444444.scexe) + + Array + + Array + + + + + Scope + + Provide an HPEOneView.Appliance.ScopeCollection resource object to initially associate with. Resource can also be added to scope using the Add-OVResourceToScope Cmdlet. + + HPEOneView.Appliance.ScopeCollection[] + + HPEOneView.Appliance.ScopeCollection[] + + False + + + SourceBaseline + + An existing Baseline within the HPE OneView Baseline Repository. + + Object + + Object + + + + + + + + + HPEOneView.Appliance.Baseline [System.Management.Automation.PSCustomObject] + + + Source HPE OneView Baseline from Get-OVBaseline + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + Asynchronous task object to monitor. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + cp111111.exe,cp222222.scexe,cp333333.exe,cp444444.scexe | % { Add-OVBaseline $_ } +Get-OVBaseline -BaselineName "MyBaseline" | New-OVCustomBaseline -Hotfixes cp111111.exe,cp222222.scexe,cp333333.exe,cp444444.scexe -BaselineName "MyNewBaseline_20160222" + + Upload hotfixes to appliance, then create a new custom baseline from the "MyBaseline" baseline. + + + + + + + + + + + + + Restore-OVCustomBaseline + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/new-ovcustombaseline + + + + + + + + New-OVDataCenter + + Get a member device from a defined Rack. + + New + OVDataCenter + + + A data center represents a physically contiguous area in which racks containing IT equipment are located. +For example, you have IT equipment in two rooms or on separate floors. You could create a data center for each of these areas. +Each server, enclosure, or power distribution device in your data center can report its power requirements, but it can be difficult to understand the power and cooling requirements for your data center as a whole. The appliance enables you to bring power and cooling management of your servers, enclosures, and power delivery devices together in a single management system. +When you initialize the appliance for the first time, it creates a data center named Datacenter 1. The appliance provides this data center as a place to visualize your racks. You can rename or edit this data center to match the values and layout of your data center, you can use it as the basis for a planned data center model, or you can delete this data center without adverse effects. + +This Cmdlet will create a new datacenter. You will need to specify the Name and dimensions. Optionally, you can override the default Electrical Derating, default voltage, local currency (which will aid in power calculation costs) and power cooling capacity. Remote Support settings can only be set when Remote Support has been enabled and configured on the appliance. If omitting Remote Support location settings, then the datacenter will default to the default location set. + + + + + New-OVDataCenter + + Name + + A name to identify the data center. Must not exceed 255 characters; no leading spaces. + + String + + + Width + + Width of the datacenter, in (US) Feet. Maximum of 50 meters (164.042 feet). Millimeters can be used, which requires the -Millimeters switch parameter. + + Float + + + Depth + + Depth of the datacenter, in (US) Feet. Maximum of 50 meters (164.042 feet). Millimeters can be used, which requires the -Millimeters switch parameter. + + Float + + + Millimeters + + If specifying millimeter value for Width and Depth, this parameter is required. + + SwitchParameter + + + ElectricalDerating + + If Custom ElectricalDetratingType is set to Custom, specify a value between 20-100%. + +Default: 20% + + Int + + + ElectricalDeratingType + + The percentage below the rated maximum power dissipation at which the devices are operated, accounting for case/body temperature, ambient temperature, and type of cooling. + +You can specify a derating percentage by choosing Custom, or you can choose not to apply derating to the rated maximum power dissipation by specifying None. + +Default: NA/Jp + + String + + + DefaultVoltage + + The default power line voltage for the data center. + +Default: 220 + + Int + + + Currency + + The currency unit for energy costs. + + String + + + PowerCosts + + The energy cost per kWh, specified by the Currency. + + Float + + + CoolingCapacity + + The maximum cooling capacity for the data center, in KW. The appliance analyzes heat generation using this value. + + Int + + + CoolingMultiplier + + The ratio of cooling cost to power cost for the data center. + +This value represents the relative cost of cooling the system compared to the cost of powering the system. The default value of 1.5 indicates that it costs 1.5 times as much to cool the system as it does to power the system. + +Default: 1.5 + + Float + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + New-OVDataCenter + + Name + + A name to identify the data center. Must not exceed 255 characters; no leading spaces. + + String + + + Width + + Width of the datacenter, in (US) Feet. Maximum of 50 meters (164.042 feet). Millimeters can be used, which requires the -Millimeters switch parameter. + + Float + + + Depth + + Depth of the datacenter, in (US) Feet. Maximum of 50 meters (164.042 feet). Millimeters can be used, which requires the -Millimeters switch parameter. + + Float + + + Millimeters + + If specifying millimeter value for Width and Depth, this parameter is required. + + SwitchParameter + + + ElectricalDerating + + If Custom ElectricalDetratingType is set to Custom, specify a value between 20-100%. + +Default: 20% + + Int + + + ElectricalDeratingType + + The percentage below the rated maximum power dissipation at which the devices are operated, accounting for case/body temperature, ambient temperature, and type of cooling. + +You can specify a derating percentage by choosing Custom, or you can choose not to apply derating to the rated maximum power dissipation by specifying None. + +Default: NA/Jp + + String + + + DefaultVoltage + + The default power line voltage for the data center. + +Default: 220 + + Int + + + Currency + + The currency unit for energy costs. + + String + + + PowerCosts + + The energy cost per kWh, specified by the Currency. + + Float + + + CoolingCapacity + + The maximum cooling capacity for the data center, in KW. The appliance analyzes heat generation using this value. + + Int + + + CoolingMultiplier + + The ratio of cooling cost to power cost for the data center. + +This value represents the relative cost of cooling the system compared to the cost of powering the system. The default value of 1.5 indicates that it costs 1.5 times as much to cool the system as it does to power the system. + +Default: 1.5 + + Float + + + PrimaryContact + + Primary Remote Support Contact object from Get-OVRemoteSupportContact defined on the appliance. + + Object + + + SecondaryContact + + Secondary Remote Support Contact object from Get-OVRemoteSupportContact defined on the appliance. Must not be the same value as the Primary Contact. + + Object + + + Address1 + + Address of datacenter. + + String + + + Address2 + + Optional address line. + + String + + + City + + City of residence for the datacenter. + + String + + + State + + State/province of residence for the datacenter. + + String + + + PostCode + + Postal code for the datacenter. + + String + + + Country + + Country of residence for the datacenter. + + String + + + TimeZone + + Time Zone of residence for the datacenter. + + String + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + + + + Address1 + + Address of datacenter. + + String + + String + + + + + Address2 + + Optional address line. + + String + + String + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + City + + City of residence for the datacenter. + + String + + String + + + + + CoolingCapacity + + The maximum cooling capacity for the data center, in KW. The appliance analyzes heat generation using this value. + + Int + + Int + + + + + CoolingMultiplier + + The ratio of cooling cost to power cost for the data center. + +This value represents the relative cost of cooling the system compared to the cost of powering the system. The default value of 1.5 indicates that it costs 1.5 times as much to cool the system as it does to power the system. + +Default: 1.5 + + Float + + Float + + 1.5 + + + Country + + Country of residence for the datacenter. + + String + + String + + + + + Currency + + The currency unit for energy costs. + + String + + String + + USD + + + DefaultVoltage + + The default power line voltage for the data center. + +Default: 220 + + Int + + Int + + 220 + + + Depth + + Depth of the datacenter, in (US) Feet. Maximum of 50 meters (164.042 feet). Millimeters can be used, which requires the -Millimeters switch parameter. + + Float + + Float + + + + + ElectricalDerating + + If Custom ElectricalDetratingType is set to Custom, specify a value between 20-100%. + +Default: 20% + + Int + + Int + + 20 + + + ElectricalDeratingType + + The percentage below the rated maximum power dissipation at which the devices are operated, accounting for case/body temperature, ambient temperature, and type of cooling. + +You can specify a derating percentage by choosing Custom, or you can choose not to apply derating to the rated maximum power dissipation by specifying None. + +Default: NA/Jp + + String + + String + + NA/Jp + + + Millimeters + + If specifying millimeter value for Width and Depth, this parameter is required. + + SwitchParameter + + SwitchParameter + + + + + Name + + A name to identify the data center. Must not exceed 255 characters; no leading spaces. + + String + + String + + + + + PostCode + + Postal code for the datacenter. + + String + + String + + + + + PowerCosts + + The energy cost per kWh, specified by the Currency. + + Float + + Float + + + + + PrimaryContact + + Primary Remote Support Contact object from Get-OVRemoteSupportContact defined on the appliance. + + Object + + Object + + + + + SecondaryContact + + Secondary Remote Support Contact object from Get-OVRemoteSupportContact defined on the appliance. Must not be the same value as the Primary Contact. + + Object + + Object + + + + + State + + State/province of residence for the datacenter. + + String + + String + + + + + TimeZone + + Time Zone of residence for the datacenter. + + String + + String + + + + + Width + + Width of the datacenter, in (US) Feet. Maximum of 50 meters (164.042 feet). Millimeters can be used, which requires the -Millimeters switch parameter. + + Float + + Float + + + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + HPEOneView.Facilities.DataCenter + + + + Newly created datacenter. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + $DataCenter1Name = "LA DC 12" + +$DataCenter1Width = 30 + +$DataCenter1Depth = 30 + +$DataCenter1Voltage = 220 + +$DataCenter1PowerCosts = 0.07 + +$DataCenter1CoolingCapacity = 250 + +New-OVDataCenter -Name $DataCenter1Name -Width $DataCenter1Width -Depth $DataCenter1Depth -DefaultVoltage $DataCenter1Voltage -PowerCosts $DataCenter1PowerCosts -CoolingCapacity $DataCenter1CoolingCapacity + + Create new "LA DC 12" datacenter. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + $NewDCParams = @{ + +Name = "Houston DC1"; + Width = 10668; + Depth = 13716; + Millimeters = $True; + DefaultVoltage = 240e; + PowerCosts = 0.10; + CoolingCapacity = 350; + Address1 = "123 Main Place"; + Address2 = "Suite 400"; + City = "Houston; + State = "TX"; + Country = "US"; + PostCode = "77002"; + TimeZone = "US/Central"; + PrimaryContact = (Get-OVRemoteSupportContact -Name "Joe Ellis" -EA Stop) + SecondaryContact = (Get-OVRemoteSupportContact -Name "Brandon Pear" -EA Stop) + +} +New-OVDataCenter @NewDC2Params + + Create a new datacenter with Remote Support settings. + + + + + + + + + + + + + Get-OVDataCenter + + + + Remove-OVDataCenter + + + + Set-OVDataCenter + + + + Set-OVDataCenterRemoteSupport + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/facilities/new-ovdatacenter + + + + + + + + New-OVEnclosureGroup + + Create an Enclosure Group. + + New + OVEnclosureGroup + + + An enclosure group is a logical resource that defines a standard configuration for member logical enclosures. The network connectivity for an enclosure group is defined by the logical interconnect groups associated with the enclosure group. When configuring an HPE Synergy enclosure group, it may contain up to five enclosures. When configuring an HPE BladeSystem C-Class enclosure group, it will only contain a single enclosure. + +Enclosure groups and logical interconnect groups + + * A logical interconnect group that is assigned to a bay within an enclosure group must have that bay populated within the logical interconnect group. + * All populated bays in a logical interconnect group must be assigned to the enclosure group. For example, a logical interconnect group that has bays 1 and 2 populated must be assigned to bays 1 and 2 of the enclosure group in order for the enclosure group to be created. + * An enclosure group can contain logical interconnect groups that are highly available, redundant, A-side only, or A-side and B-side. See About interconnect bay sets. + * Synergy multiple-enclosure logical interconnect groups must have the proper bays populated in all enclosures in the interconnect link topology. + * Synergy single-enclosure logical interconnect groups, such as a Serial Attached SCSI (SAS) logical interconnect group, can be applied to individual bays in individual enclosures in the interconnect link topology. + + + + + New-OVEnclosureGroup + + Name + + A name for the new enclosure group. + + String + + + LogicalInterconnectGroupMapping + + An Enclosure Group can reference multiple Logical Interconnect Groups, once per Interconnect Bay. If a Single Logical Interconnect Group object is provided (either via parameter variable or via Pipeline), the Logical Interconnect Group objects Logical Interconnect Bay configuration will be used. + +To specify a specific C-Class Logical Interconnect Group(s) for one or more Interconnect Bays, use a Hashtable, with the Bay ID as the Key, and Logical Interconnect Group Name, URI or Object as the Value. Example: + +$LogicalInterConnectGroupMapping = @{ 1 = "MyLIg1"; 2 = "MyLig1"; 5 = "OtherLIG"; 6 = "OtherLIG"} + +$MyLig1 = Get-OVLogicalInterconnectGroup -Name MyLig1 +$OtherLIG = Get-OVLogicalInterconnectGroup OtherLIG +$LogicalInterConnectGroupMapping = @{ 1 = $MyLig1; 2 = $MyLig1; 5 = $OtherLIG; 6 = $OtherLIG" + +When attempting to define a Syenrgy-based Enclosure Group, either an Array or Hashtable is allowed. If an Array of Logical Interconnect Groups are provided, the Cmdlet will determine the Interconnect placement automatically. Example: + +$MySynergyLig1 = Get-OVLogicalInterconnectGroup -Name MySynergyLig1 +$LogicalInterConnectGroupMapping = $MySynergyLig1 +#or +$MySynergyLig1 = Get-OVLogicalInterconnectGroup -Name MySynergyLig1 +$MySynergyLig2 = Get-OVLogicalInterconnectGroup -Name MySynergyLig2 +$LogicalInterConnectGroupMapping = $MySynergyLig1,$MySynergyLig2 + + +Do know that SAS and VC FC LIGs are bound to a single frame, and will not reference other Frames if FrameCount is greater than 1. + +Use a Hashtable to bind specific LIGs to specific Frames. The Interconnect placement will be determined automatically based on either the Hashtable Key name "Frame#" (where # is the numerical value of the Frame) or Enclosure Index value (depending if a SAS or Synergy VC FC LIG). Example: + +$3FrameVCLIG = Get-OVLogicalInterconnectGroup -Name "My MultiFrame Synergy LIG 1" +$SasLIG = Get-OVLogicalInterconnectGroup -Name "My Synergy Sas LIG 1" +$LogicalInterconnectGroupMapping = @{Frame1 = $3FrameVCLIG,$SasLIG; Frame2 = $3FrameVCLIG,$SasLIG; Frame3 = $3FrameVCLIG } + + Object + + + EnclosureCount + + Specify the number of Synergy Frames will participate within the Enclosure Group. + + Int32 + + + PowerRedundantMode + + The Power Redundancy Mode to set when an Enclosure is added to the appliance. + +Allowed Values: + + * RedundantPowerFeed - Provides N+N Power Redundancy Configuration + * RedundantPowerSupply - Provided N+1 Power Redundancy Configuration + + String + + + IPv4AddressType + + Use to specify how the IPv4 Addresses will be assigned to Synergy resources management interface(s). Allowed values: + + * External - The IPv4 address is managed externally, static assignment. + * DHCP - The IPv4 address is assigned using DHCP. + * AddressPool - The IPv4 address is assigned from a pool of IP addresses specified by the AddressPool parameter, similar to HPE BladeSystem C-Class "Enclosure Bay IP Addressing" (aka EBIPA). + +Default: DHCP + + String + + + IPv4AddressRange + + The IPv4 address pool object from Get-OVAddressPoolRange. + + Object + + + IPv6AddressType + + Use to specify how the IPv6 Addresses will be assigned to Synergy resources management interface(s). Allowed values: + + * External - The IPv4 address is managed externally, static assignment. + * DHCP - The IPv4 address is assigned using DHCP. + * AddressPool - The IPv4 address is assigned from a pool of IP addresses specified by the AddressPool parameter, similar to HPE BladeSystem C-Class "Enclosure Bay IP Addressing" (aka EBIPA). + +Default: None + + String + + + IPv6AddressRange + + The IPv6 address pool object from Get-OVAddressPoolRange. + + Object + + + DeploymentNetworkType + + Specify the Synergy Image Stream deployment network type. Allowed values: + + * Internal - Deployment network is an internal, managed by the Frame links, which Logical Intercoonect Group must have an ImageStreamer Uplink Set. + * External - Deployment network is connected to an External management switch. + * None - No deployment network will be configured. + +Default: None + + String + + + DeploymentNetwork + + The Ethernet Network with the purpose property set to Management. Must also include DeploymentNetworkType parameter, value must be "External", with the Ethernet Network associated with a non-ImageStreamer Uplink Set. + + Object + + + Scope + + Provide an HPEOneView.Appliance.ScopeCollection resource object to initially associate with. Resource can also be added to scope using the Add-OVResourceToScope Cmdlet. + + HPEOneView.Appliance.ScopeCollection[] + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + +Default Value: ${Global:ConnectSessions} | ? Default + + Object + + + + New-OVEnclosureGroup + + ImportFile + + Provide the full path and file name of the JSON file. + + String + + + Scope + + Provide an HPEOneView.Appliance.ScopeCollection resource object to initially associate with. Resource can also be added to scope using the Add-OVResourceToScope Cmdlet. + + HPEOneView.Appliance.ScopeCollection[] + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + +Default Value: ${Global:ConnectSessions} | ? Default + + Object + + + + + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + +Default Value: ${Global:ConnectSessions} | ? Default + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + DeploymentNetwork + + The Ethernet Network with the purpose property set to Management. Must also include DeploymentNetworkType parameter, value must be "External", with the Ethernet Network associated with a non-ImageStreamer Uplink Set. + + Object + + Object + + + + + DeploymentNetworkType + + Specify the Synergy Image Stream deployment network type. Allowed values: + + * Internal - Deployment network is an internal, managed by the Frame links, which Logical Intercoonect Group must have an ImageStreamer Uplink Set. + * External - Deployment network is connected to an External management switch. + * None - No deployment network will be configured. + +Default: None + + String + + String + + None + + + EnclosureCount + + Specify the number of Synergy Frames will participate within the Enclosure Group. + + Int32 + + Int32 + + 1 + + + IPv4AddressRange + + The IPv4 address pool object from Get-OVAddressPoolRange. + + Object + + Object + + + + + IPv4AddressType + + Use to specify how the IPv4 Addresses will be assigned to Synergy resources management interface(s). Allowed values: + + * External - The IPv4 address is managed externally, static assignment. + * DHCP - The IPv4 address is assigned using DHCP. + * AddressPool - The IPv4 address is assigned from a pool of IP addresses specified by the AddressPool parameter, similar to HPE BladeSystem C-Class "Enclosure Bay IP Addressing" (aka EBIPA). + +Default: DHCP + + String + + String + + DHCP + + + IPv6AddressRange + + The IPv6 address pool object from Get-OVAddressPoolRange. + + Object + + Object + + + + + IPv6AddressType + + Use to specify how the IPv6 Addresses will be assigned to Synergy resources management interface(s). Allowed values: + + * External - The IPv4 address is managed externally, static assignment. + * DHCP - The IPv4 address is assigned using DHCP. + * AddressPool - The IPv4 address is assigned from a pool of IP addresses specified by the AddressPool parameter, similar to HPE BladeSystem C-Class "Enclosure Bay IP Addressing" (aka EBIPA). + +Default: None + + String + + String + + + + + ImportFile + + Provide the full path and file name of the JSON file. + + String + + String + + + + + LogicalInterconnectGroupMapping + + An Enclosure Group can reference multiple Logical Interconnect Groups, once per Interconnect Bay. If a Single Logical Interconnect Group object is provided (either via parameter variable or via Pipeline), the Logical Interconnect Group objects Logical Interconnect Bay configuration will be used. + +To specify a specific C-Class Logical Interconnect Group(s) for one or more Interconnect Bays, use a Hashtable, with the Bay ID as the Key, and Logical Interconnect Group Name, URI or Object as the Value. Example: + +$LogicalInterConnectGroupMapping = @{ 1 = "MyLIg1"; 2 = "MyLig1"; 5 = "OtherLIG"; 6 = "OtherLIG"} + +$MyLig1 = Get-OVLogicalInterconnectGroup -Name MyLig1 +$OtherLIG = Get-OVLogicalInterconnectGroup OtherLIG +$LogicalInterConnectGroupMapping = @{ 1 = $MyLig1; 2 = $MyLig1; 5 = $OtherLIG; 6 = $OtherLIG" + +When attempting to define a Syenrgy-based Enclosure Group, either an Array or Hashtable is allowed. If an Array of Logical Interconnect Groups are provided, the Cmdlet will determine the Interconnect placement automatically. Example: + +$MySynergyLig1 = Get-OVLogicalInterconnectGroup -Name MySynergyLig1 +$LogicalInterConnectGroupMapping = $MySynergyLig1 +#or +$MySynergyLig1 = Get-OVLogicalInterconnectGroup -Name MySynergyLig1 +$MySynergyLig2 = Get-OVLogicalInterconnectGroup -Name MySynergyLig2 +$LogicalInterConnectGroupMapping = $MySynergyLig1,$MySynergyLig2 + + +Do know that SAS and VC FC LIGs are bound to a single frame, and will not reference other Frames if FrameCount is greater than 1. + +Use a Hashtable to bind specific LIGs to specific Frames. The Interconnect placement will be determined automatically based on either the Hashtable Key name "Frame#" (where # is the numerical value of the Frame) or Enclosure Index value (depending if a SAS or Synergy VC FC LIG). Example: + +$3FrameVCLIG = Get-OVLogicalInterconnectGroup -Name "My MultiFrame Synergy LIG 1" +$SasLIG = Get-OVLogicalInterconnectGroup -Name "My Synergy Sas LIG 1" +$LogicalInterconnectGroupMapping = @{Frame1 = $3FrameVCLIG,$SasLIG; Frame2 = $3FrameVCLIG,$SasLIG; Frame3 = $3FrameVCLIG } + + Object + + Object + + + + + Name + + A name for the new enclosure group. + + String + + String + + + + + PowerRedundantMode + + The Power Redundancy Mode to set when an Enclosure is added to the appliance. + +Allowed Values: + + * RedundantPowerFeed - Provides N+N Power Redundancy Configuration + * RedundantPowerSupply - Provided N+1 Power Redundancy Configuration + + String + + String + + RedundantPowerFeed + + + Scope + + Provide an HPEOneView.Appliance.ScopeCollection resource object to initially associate with. Resource can also be added to scope using the Add-OVResourceToScope Cmdlet. + + HPEOneView.Appliance.ScopeCollection[] + + HPEOneView.Appliance.ScopeCollection[] + + False + + + + + + + HPEOneView.Networking.LogicalInterconnectGroup [System.Management.Automation.PSCustomObject] + + + Single Logical Interconnect Group resource object + + + + + + + + HPEOneView.EnclosureGroup [System.Management.Automation.PSCustomObject] + + + + The newly created enclosure group resource + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + $mylig = Get-OVLogicalInterconnectGroup -name "myLogicalInterconnectGroup" +New-OVEnclosureGroup -name "MyGroup" -logicalInterConnectGroup $mylig + + Get the "myLogicalInterconnectGroup" object and pass it to create the "MyGroup" Enclosure Group. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + $Prodlig = Get-OVLogicalInterconnectGroup -name "Production LIG" +$DMZlig = Get-OVLogicalInterconnectGroup -name "DMZ LIG" +$ConfigurationScript = "#Configure Insight Remote Support CentralConnect +>> ENABLE REMOTE_SUPPORT IRS 80.80.1.14 7906" +New-OVEnclosureGroup -name "Production Enclosure Group 1" -LogicalInterconnectGroupMapping @{1 = $Prodlig; 2 = $Prodlig; 5 = $DMZlig; 6 = $DMZlig} -ConfigurationScript $ConfigurationScript + + Get two different Logical Interconnect Groups, define an OA Configuration Script, then assign the LIGs to the specific Interconnect Bays for appliance "MyAppliance1.domain.com". + + + + + + + + + + -------------------------- EXAMPLE 3 -------------------------- + + + + New-OVEnclosureGroup -name "MyGroup" -DiscoverFromEnclosure -OAAddress MyOAIP.domain.com -Username Administrator -Password MyPassword + + Connect to the provided Onboard Administrator, detect the Interconnect Bay population to then create both a Logical Interconnect Group and associate it with the Enclosure Group being requested. + + + + + + + + + + -------------------------- EXAMPLE 4 -------------------------- + + + + New-OVEnclosureGroup -name "MyGroup" -DiscoverFromEnclosure -OAAddress MyOAIP.domain.com -Username Administrator -Password MyPassword -LigPrefix "My LIG Policy" + + Connect to the provided Onboard Administrator, detect the Interconnect Bay population to then create both a Logical Interconnect Group ("My LIG Policy") and associate it with the Enclosure Group being requested. + + + + + + + + + + -------------------------- EXAMPLE 5 -------------------------- + + + + $MySynergyLig1 = Get-OVLogicalInterconnectGroup -Name MySynergyLig1 +New-OVEnclosureGroup -name "My Synergy Enclosure Group 1" -LogicalInterconnectGroupMapping $MySynergyLig1 -EnclosureCount 3 -IPv4AddressType DHCP + + Create a 3-Frame Synergy Enclosure Group using a single Logical Interconnect Group. + + + + + + + + + + -------------------------- EXAMPLE 6 -------------------------- + + + + $MySynergyLig1 = Get-OVLogicalInterconnectGroup -Name MySynergyLig1 +New-OVEnclosureGroup -name "My Synergy Enclosure Group 1" -LogicalInterconnectGroupMapping @{Frame1 = $3FrameVCLIG,$SasLIG; Frame2 = $3FrameVCLIG,$SasLIG; Frame3 = $3FrameVCLIG } -EnclosureCount 3 -IPv4AddressType DHCP + + Create a 3-Frame Synergy Enclosure Group using multiple Logical Interconnect Groups specific to each Frame. + + + + + + + + + + -------------------------- EXAMPLE 7 -------------------------- + + + + $AddressPool = Get-OVAddressPoolSubnet -NetworkId "10.140.51.0" -ErrorAction Stop | Get-OVAddressPoolRange +$MySynergyLig1 = Get-OVLogicalInterconnectGroup -Name MySynergyLig1 +New-OVEnclosureGroup -name "My Synergy Enclosure Group 1" -LogicalInterconnectGroupMapping @{Frame1 = $3FrameVCLIG,$SasLIG; Frame2 = $3FrameVCLIG,$SasLIG; Frame3 = $3FrameVCLIG } -EnclosureCount 3 -IPv4AddressType AddressPool -AddressPool $AddressPool -DeploymentNetworkType Internal + + Create a 3-Frame Synergy Enclosure Group using multiple Logical Interconnect Groups specific to each Frame, with ImageStreamer support using a LIG with an ImageStreamer Uplink Set (aka Internal). + + + + + + + + + + -------------------------- EXAMPLE 8 -------------------------- + + + + $AddressPool = Get-OVAddressPoolSubnet -NetworkId "10.140.51.0" -ErrorAction Stop | Get-OVAddressPoolRange +$DeploymentNetwork = Get-OVNetwork -Name "Deployment Network" -ErrorAction Stop +$MySynergyLig1 = Get-OVLogicalInterconnectGroup -Name MySynergyLig1 +New-OVEnclosureGroup -name "My Synergy Enclosure Group 1" -LogicalInterconnectGroupMapping @{Frame1 = $3FrameVCLIG,$SasLIG; Frame2 = $3FrameVCLIG,$SasLIG; Frame3 = $3FrameVCLIG } -EnclosureCount 3 -IPv4AddressType AddressPool -AddressPool $AddressPool -DeploymentNetworkType External -DeploymentNetwork $DeploymentNetwork + + Create a 3-Frame Synergy Enclosure Group using multiple Logical Interconnect Groups specific to each Frame, with ImageStreamer support using a LIG without an ImageStreamer Uplink Set and specifying which Ethernet Network object is the deployment network (aka External). + + + + + + + + + + + + + Get-OVEnclosureGroup + + + + Remove-OVEnclosureGroup + + + + Set-OVEnclosureGroup + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/servers/new-ovenclosuregroup + + + + + + + + New-OVExternalRepository + + Create a new external baseline repository. + + New + OVExternalRepository + + + A firmware repository enables you to store firmware bundles and deploy them across your environment. An externally managed HTTP/HTTPS web server can be added to the appliance as a repository. It is a user-maintained HTTP/HTTPS web server. You can upload firmware bundles in a specific directory and then register the HTTP/HTTPS server with HPE OneView. This functionality is supported for Linux and Windows systems. + +The recommended types of external web servers to use with the repository follow: + + * Apache + * Internet Information Services (IIS) + +NOTE: Only one external repository can be added. + + + + + New-OVExternalRepository + + Name + + Provide a name for the repository. + + String + + + Hostname + + Specify IPv4 Address or FQDN of the target web server. + + String + + + Directory + + Specify the parent virtual directory where the baseline components will be kept. Baseline components can be nested within sub directories. + + String + + + NFSPath + + Specify the NFS path for Superdome Flex RMC firmware updates. + + string + + + Username + + Provide the username to authenticate to the target web server with if required. + + String + + + Password + + Provide the password of the username using a System.Security.SecureString. + + SecureString + + + Http + + Use to override the default HTTPS protocol used to communicate with the target web server. If this parameter is not used, you must specify the Base64 Certificate of the target web server. If you use this parameter, all authentication requests will be sent as clear text. + + SwitchParameter + + + Certificate + + The Base64 Certificate of the target web server. Must be specified if the -HTTP parameter is not used. + + String + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + + + New-OVExternalRepository + + Name + + Provide a name for the repository. + + String + + + Hostname + + Specify IPv4 Address or FQDN of the target web server. + + String + + + Directory + + Specify the parent virtual directory where the baseline components will be kept. Baseline components can be nested within sub directories. + + String + + + Credential + + Provide a PSCredential object if the target web server requires authentication. By default, HTTPS will be used and basic authentication is used to communicate with the target web server. + + String + + + NFSPath + + Specify the NFS path for Superdome Flex RMC firmware updates. + + string + + + Http + + Use to override the default HTTPS protocol used to communicate with the target web server. If this parameter is not used, you must specify the Base64 Certificate of the target web server. If you use this parameter, all authentication requests will be sent as clear text. + + SwitchParameter + + + Certificate + + The Base64 Certificate of the target web server. Must be specified if the -HTTP parameter is not used. + + String + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + Array + + (${Global:ConnectedSessions} | ? Default) + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + SwitchParameter + + + + + Certificate + + The Base64 Certificate of the target web server. Must be specified if the -HTTP parameter is not used. + + String + + String + + + + + Credential + + Provide a PSCredential object if the target web server requires authentication. By default, HTTPS will be used and basic authentication is used to communicate with the target web server. + + String + + String + + + + + Directory + + Specify the parent virtual directory where the baseline components will be kept. Baseline components can be nested within sub directories. + + String + + String + + + + + Hostname + + Specify IPv4 Address or FQDN of the target web server. + + String + + String + + + + + Http + + Use to override the default HTTPS protocol used to communicate with the target web server. If this parameter is not used, you must specify the Base64 Certificate of the target web server. If you use this parameter, all authentication requests will be sent as clear text. + + SwitchParameter + + SwitchParameter + + + + + NFSPath + + Specify the NFS path for Superdome Flex RMC firmware updates. + + string + + string + + + + + Name + + Provide a name for the repository. + + String + + String + + + + + Password + + Provide the password of the username using a System.Security.SecureString. + + SecureString + + SecureString + + + + + Username + + Provide the username to authenticate to the target web server with if required. + + String + + String + + + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + The async task for the caller to monitor. + + + + + System.Collections.ArrayList <HPEOneView.Appliance.TaskResource> + + + + Multiple async task resource objects. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + $Params = @{ + + Name = "MyRepoName"; + Hostname = "webserver.domain.local"; + Directory = "OneViewRepo"; + Credential = (Get-PSCredential -Username "DomainName\MyUser"); + Certificate = (Get-Content -Path C:\Directory\Base64.cer -Raw) + +} +New-OVExternalRepository @Params + + Create an external repository using a PSCredential object. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + New-OVExternalRepository -Name MyRepoName -Hostname webserver.domain.local -Directory OneViewRepo -Http + + Configure an external repository using anonymous authentication, and HTTP protocol. + + + + + + + + + + + + + Remove-OVExternalRepository + + + + Set-OVExternalRepository + + + + Update-OVExternalRepository + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/new-ovexternalrepository + + + + + + + + New-OVIloDirectoryGroup + + Create compliant iLO directory group object for server profile type resources. + + New + OVIloDirectoryGroup + + + iLO settings enable you to configure and manage the settings in HPE OneView instead of logging into the iLO to apply the needed settings. These settings are included when you move the profile to another server hardware instance. Use a server profile template if you want to maintain consistent management for a specific iLO setting across multiple iLO. + +This Cmdlet will create and grant access to specific directory groups for the iLO on the server hardware that is associated with a server profile. When managed from HPE OneView, all the directory groups on the iLO are replaced when configuring the directory groups specified in the server profile. + + + + + New-OVIloDirectoryGroup + + GroupDN + + The Distinguished Name (DN) of the group from the directory to be authorized for iLO access. + + String + + + GroupSID + + The SID of the directory group to be authorized for iLO access. + + String + + + AdministerUserAccounts + + Group has the permission to add, edit, and delete local iLO user accounts. + + Bool + + + RemoteConsole + + Group has the permission to access the iLO remote console. + + Bool + + + VirtualMedia + + Group has the permission to use the Virtual Media features on the host system. + + Bool + + + VirtualPowerAndReset + + Group has the permission to power-cycle or reset the host system. + + Bool + + + ConfigureIloSettings + + Group has the permission to configure most iLO settings, including security settings, and to update the iLO firmware. + + Bool + + + + + + + AdministerUserAccounts + + Group has the permission to add, edit, and delete local iLO user accounts. + + Bool + + Bool + + + + + ConfigureIloSettings + + Group has the permission to configure most iLO settings, including security settings, and to update the iLO firmware. + + Bool + + Bool + + + + + GroupDN + + The Distinguished Name (DN) of the group from the directory to be authorized for iLO access. + + String + + String + + + + + GroupSID + + The SID of the directory group to be authorized for iLO access. + + String + + String + + + + + RemoteConsole + + Group has the permission to access the iLO remote console. + + Bool + + Bool + + + + + VirtualMedia + + Group has the permission to use the Virtual Media features on the host system. + + Bool + + Bool + + + + + VirtualPowerAndReset + + Group has the permission to power-cycle or reset the host system. + + Bool + + Bool + + + + + + + + + None. You cannot pipe objects to this cmdlet. + + + + + + + + + + + System.Management.Automation.PSCustomObject + + + + An iLO settings complient object for server profile resources. + + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + $Group1 = New-OVIloDirectoryGroup -GroupDN "dn=ilogroup1, ou=ou1, dc=domain, dc=com" ` + -GroupSID "sid12345" ` + -AdministerUserAccounts ` + -RemoteConsole ` + -VirtualMedia ` + -ConfigureIloSettings + + Create a directory group, with the specific privileges. + + + + + + + + + + + + + New-OVServerProfileIloPolicy + + + + New-OVIloLocalUserAccount + + + + New-OVServerProfile + + + + New-OVServerProfileTemplate + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/library/new-ovilodirectorygroup + + + + + + + + New-OVIloLocalUserAccount + + Create compliant local iLO account object for server profile type resources. + + New + OVIloLocalUserAccount + + + iLO settings enable you to configure and manage the settings in HPE OneView instead of logging into the iLO to apply the needed settings. These settings are included when you move the profile to another server hardware instance. Use a server profile template if you want to maintain consistent management for a specific iLO setting across multiple iLO. + +This Cmdlet will allow you to create a new local account that can then be passed into the LocalAccounts parameter of New-OVServerProfileIloPolicy Cmdlet. When managed from HPE OneView, all the local accounts on the iLO are replaced when configuring the accounts specified in the server profile. + + + + + New-OVIloLocalUserAccount + + Username + + The username of the account that will be created. + + String + + + Password + + The securestring object of the user account password to set. + + SecureString + + + DisplayName + + Optional display name of the user account. + + String + + + AdministerUserAccounts + + User has the permission to add, edit, and delete local iLO user accounts. + + Bool + + + RemoteConsole + + User has the permission to access the iLO remote console. + + Bool + + + VirtualMedia + + User has the permission to use the Virtual Media features on the host system. + + Bool + + + VirtualPowerAndReset + + User has the permission to power-cycle or reset the host system. + + Bool + + + ConfigureIloSettings + + User has the permission to configure most iLO settings, including security settings, and to update the iLO firmware. + + Bool + + + + New-OVIloLocalUserAccount + + Username + + The username of the account that will be created. + + String + + + Password + + The securestring object of the user account password to set. + + SecureString + + + DisplayName + + Optional display name of the user account. + + String + + + AdministerUserAccounts + + User has the permission to add, edit, and delete local iLO user accounts. + + Bool + + + RemoteConsole + + User has the permission to access the iLO remote console. + + Bool + + + VirtualMedia + + User has the permission to use the Virtual Media features on the host system. + + Bool + + + VirtualPowerAndReset + + User has the permission to power-cycle or reset the host system. + + Bool + + + ConfigureIloSettings + + User has the permission to configure most iLO settings, including security settings, and to update the iLO firmware. + + Bool + + + Login + + User has the permission to log into the iLO. This permission is specific to iLO5-based systems. + + Bool + + + HostBIOS + + User has the permission to change host system BIOS configuration. This permission is specific to iLO5-based systems. + + Bool + + + HostNIC + + User has the permission to change host system NIC configuration. This permission is specific to iLO5-based systems. + + Bool + + + HostStorage + + User has the permission to change host system storage configuration. This permission is specific to iLO5-based systems. + + Bool + + + + + + + AdministerUserAccounts + + User has the permission to add, edit, and delete local iLO user accounts. + + Bool + + Bool + + + + + ConfigureIloSettings + + User has the permission to configure most iLO settings, including security settings, and to update the iLO firmware. + + Bool + + Bool + + + + + DisplayName + + Optional display name of the user account. + + String + + String + + + + + HostBIOS + + User has the permission to change host system BIOS configuration. This permission is specific to iLO5-based systems. + + Bool + + Bool + + + + + HostNIC + + User has the permission to change host system NIC configuration. This permission is specific to iLO5-based systems. + + Bool + + Bool + + + + + HostStorage + + User has the permission to change host system storage configuration. This permission is specific to iLO5-based systems. + + Bool + + Bool + + + + + Login + + User has the permission to log into the iLO. This permission is specific to iLO5-based systems. + + Bool + + Bool + + + + + Password + + The securestring object of the user account password to set. + + SecureString + + SecureString + + + + + RemoteConsole + + User has the permission to access the iLO remote console. + + Bool + + Bool + + + + + Username + + The username of the account that will be created. + + String + + String + + + + + VirtualMedia + + User has the permission to use the Virtual Media features on the host system. + + Bool + + Bool + + + + + VirtualPowerAndReset + + User has the permission to power-cycle or reset the host system. + + Bool + + Bool + + + + + + + + + None. You cannot pipe objects to this cmdlet. + + + + + + + + + + + System.Management.Automation.PSCustomObject + + + + An iLO settings complient object for server profile resources. + + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + New-OVIloLocalUserAccount -Username "localuser1" ` + -Password (Read-Host "localuser1 password" -AsSecureString) ` + -DisplayName "localuser1" ` + -AdministerUserAccounts ` + -RemoteConsole ` + -VirtualMedia ` + -VirtualPowerAndReset ` + -ConfigureIloSettings + + Create an iLO user account specific to iLO4, or does not include the additional iLO5 permissions. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + New-OVIloLocalUserAccount -Username "localuser1" ` + -Password (Read-Host "localuser1 password" -AsSecureString) ` + -DisplayName "localuser1" ` + -AdministerUserAccounts ` + -RemoteConsole ` + -VirtualMedia ` + -VirtualPowerAndReset ` + -ConfigureIloSettings ` + -Login ` + -HostBIOS ` + -HostNIC ` + -HostStorage + + Create an iLO user account that includes iLO5 permissions. + + + + + + + + + + + + + New-OVServerProfileIloPolicy + + + + New-OVIloDirectoryGroup + + + + New-OVServerProfile + + + + New-OVServerProfileTemplate + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/servers/new-ovilolocaluseraccount + + + + + + + + New-OVLdapDirectory + + Add a new Directory for Authentication + + New + OVLdapDirectory + + + This Cmdlet will create a new Directory for appliance authentication. HPE OneView currently supports either Active Directory or LDAP (e.g. OpenLDAP) for user authentication. The New-OVLdapServer Cmdlet is used to assist defining directory servers address, public SSL certificate and LDAP over SSL TCP port. + + + + + New-OVLdapDirectory + + Name + + Directory name to add. Does not need to match LDAP/AD Directory Name, but should. + + String + + + AD + + Using Active Directory, which sets the authProtocol to AD and userNameField to CN + + SwitchParameter + + + BaseDN + + Directory Base DN (E.g. dc=domian,dc=local) + + String + + + Servers + + Array of Directory Servers and their settings. Must include the following: + + * Server Name (FQDN or IP) + * Public SSL Certificate + * SSL Port, if not default 636 + + Array + + + Username + + Directory Username to authenticate with. + + String + + + Password + + Directory Username password. + + SecureString + + + Credential + + Use this parameter if you want to provide a PSCredential object instead. + + PSCredential + + + ServiceAccount + + Use to indicate the provided credential is a Service Account. Required for when configuring an Active Directory auth directory for two-factor authentication. + + SwitchParameter + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + New-OVLdapDirectory + + Name + + Directory name to add. Does not need to match LDAP/AD Directory Name, but should. + + String + + + OpenLDAP + + Using LDAP (i.e. OpenLDAP), which sets the authProtocol to LDAP and userNameField to UID + + SwitchParameter + + + BaseDN + + Directory Base DN (E.g. dc=domian,dc=local) + + String + + + OrganizationalUnits + + OpenLDAP OU"s to begin search for Directory Group and User Account authentication. +E.g. ou=admins,ou=contoso + + Array + + + Servers + + Array of Directory Servers and their settings. Must include the following: + + * Server Name (FQDN or IP) + * Public SSL Certificate + * SSL Port, if not default 636 + + Array + + + UserNamingAttribute + + Specify the naming attribute for OpenLDAP directories. Allowed values: * CN * UID +Default Value: CN + + String + + + Username + + Directory Username to authenticate with. + + String + + + Password + + Directory Username password. + + SecureString + + + Credential + + Use this parameter if you want to provide a PSCredential object instead. + + PSCredential + + + ServiceAccount + + Use to indicate the provided credential is a Service Account. Required for when configuring an Active Directory auth directory for two-factor authentication. + + SwitchParameter + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + + + + AD + + Using Active Directory, which sets the authProtocol to AD and userNameField to CN + + SwitchParameter + + SwitchParameter + + False + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + BaseDN + + Directory Base DN (E.g. dc=domian,dc=local) + + String + + String + + + + + Credential + + Use this parameter if you want to provide a PSCredential object instead. + + PSCredential + + PSCredential + + + + + Name + + Directory name to add. Does not need to match LDAP/AD Directory Name, but should. + + String + + String + + + + + OpenLDAP + + Using LDAP (i.e. OpenLDAP), which sets the authProtocol to LDAP and userNameField to UID + + SwitchParameter + + SwitchParameter + + False + + + OrganizationalUnits + + OpenLDAP OU"s to begin search for Directory Group and User Account authentication. +E.g. ou=admins,ou=contoso + + Array + + Array + + + + + Password + + Directory Username password. + + SecureString + + SecureString + + + + + Servers + + Array of Directory Servers and their settings. Must include the following: + + * Server Name (FQDN or IP) + * Public SSL Certificate + * SSL Port, if not default 636 + + Array + + Array + + + + + ServiceAccount + + Use to indicate the provided credential is a Service Account. Required for when configuring an Active Directory auth directory for two-factor authentication. + + SwitchParameter + + SwitchParameter + + + + + UserNamingAttribute + + Specify the naming attribute for OpenLDAP directories. Allowed values: * CN * UID +Default Value: CN + + String + + String + + CN + + + Username + + Directory Username to authenticate with. + + String + + String + + + + + + + + + System.Security.SecureString + + + Account Password that will be used to validate the directory + + + + + + + + System.Management.Automation.PSCustomObject + + + + Configured Authentication Directory + + + + + System.Collections.ArrayList + + + + Multiple configured Authentication Directories + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + $ServerA,$ServerB = servera.domain.com,serverb.domain.com | New-OVLdapServer +New-OVLdapDirectory -name Domain1 -AD -basedn "dc=domain,dc=com" -servers $ServerA,$ServerB -Username MyAdminAccount@domain.com + + Add a new directory with two directory servers, and be prompted for your directory account password. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + $ServerA = New-OVLdapServer -Name contoso.com +New-OVLdapDirectory -name Domain1 -AD -basedn "dc=domain,dc=com" -servers $ServerA -Username MyAdminAccount@domain.com -ServiceAccount + + Add a new Active Directory authentication directory, using SRV domain name, and specify to use the account as a service account. + + + + + + + + + + + + + Get-OVLdapDirectory + + + + Remove-OVLdapDirectory + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/security/new-ovldapdirectory + + + + + + + + New-OVLdapGroup + + Add a new Directory Group to appliance. + + New + OVLdapGroup + + + This Cmdlet provides the ability to add a new Directory Group to the appliance. You can use the Show-OVLdapGroups to retrieve a list of avialable Directory Groups from the specified Directory. + + + + + New-OVLdapGroup + + Directory + + LDAP/Active Directory Domain object. + + Object + + + Group + + Directroy Group to add. Can either be a string value of a Cononical Name of directory group, or object from Show-OVLdapGroups. + + Object + + + Roles + + The role(s) to assign to the Directroy Group, in System.Collections.ArrayList format. Accepted values are noted within the ApplianceRoles property of the HPEOneView.Appliance.Connection object stored in the $Global:ConnectedSessions variable. + +Example: $roles = "Server administrator","Network administrator" + + Array + + + Username + + Warning: This parameter is now obsolete. Please transition to using the -Credential parameter. + +Directory Username to authenticate with + + String + + + Password + + Warning: This parameter is now obsolete. Please transition to using the -Credential parameter. + +Directory User account password. Can be System.String or System.Security.SecureString object. + + Object + + + Credential + + Use this parameter if you want to provide a PSCredential object instead. + + PSCredential + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + New-OVLdapGroup + + Directory + + LDAP/Active Directory Domain object. + + Object + + + Group + + Directroy Group to add. Can either be a string value of a Cononical Name of directory group, or object from Show-OVLdapGroups. + + Object + + + ScopePermissions + + Array collection of Hashtable<Role; Scope>. + +Example: -ScopePermissions @{Role = "Network administrator"; Scope = (Get-OVScope -Name CorpNetAdmins -ErrorAction Stop) } + + Array + + + Username + + Warning: This parameter is now obsolete. Please transition to using the -Credential parameter. + +Directory Username to authenticate with + + String + + + Password + + Warning: This parameter is now obsolete. Please transition to using the -Credential parameter. + +Directory User account password. Can be System.String or System.Security.SecureString object. + + Object + + + Credential + + Use this parameter if you want to provide a PSCredential object instead. + + PSCredential + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Credential + + Use this parameter if you want to provide a PSCredential object instead. + + PSCredential + + PSCredential + + + + + Directory + + LDAP/Active Directory Domain object. + + Object + + Object + + + + + Group + + Directroy Group to add. Can either be a string value of a Cononical Name of directory group, or object from Show-OVLdapGroups. + + Object + + Object + + + + + Password + + Warning: This parameter is now obsolete. Please transition to using the -Credential parameter. + +Directory User account password. Can be System.String or System.Security.SecureString object. + + Object + + Object + + + + + Roles + + The role(s) to assign to the Directroy Group, in System.Collections.ArrayList format. Accepted values are noted within the ApplianceRoles property of the HPEOneView.Appliance.Connection object stored in the $Global:ConnectedSessions variable. + +Example: $roles = "Server administrator","Network administrator" + + Array + + Array + + + + + ScopePermissions + + Array collection of Hashtable<Role; Scope>. + +Example: -ScopePermissions @{Role = "Network administrator"; Scope = (Get-OVScope -Name CorpNetAdmins -ErrorAction Stop) } + + Array + + Array + + + + + Username + + Warning: This parameter is now obsolete. Please transition to using the -Credential parameter. + +Directory Username to authenticate with + + String + + String + + + + + + + + + HPEOneView.Appliance.DirectoryGroup [System.Management.Automation.PSCustomObject] + + + The external authentication directory object from -Get-OVLdapDirectory. + + + + + + + + System.Management.Automation.PSCustomObject + + + + New LDAP Group object with role assignment(s) + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + New-OVLdapGroup -d Domain1 -GroupName "MY Directory Group1" -roles @("Server administrator") -u "Sarah Peterson" + + Add "MY Directory Group1" from Domain1 with Server Administrator role and prompt for password for group validation. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + # Get the defined directory group from the appliance. $Directory = Get-OVLdapDirectory -Name "Domain1" -ErrorAction Stop # Collect the users AD password. This does not require Domain Admins or an administrator level account. Only a standard user account that can query the directory. $Password = ConvertTo-SecureString -AsPlainText "password123890" -force # Get the directory group object. $Group = Show-OVLdapDirectoryGroup -Name "Domain1" -Directory $Directory -Username "Sarah.Peterson@domain1.com" -Password $Password -ErrorAction Stop # Specify the roles needed to be assigned to the directory group. $Roles = "Server administrator","Backup administrator" # Create the directory group resource on the appliance, and associate with the SBAC permissions. New-OVLdapGroup -Directory $Directory -GroupName "MY Directory Group1" -Roles $Roles -Username "Sarah.Peterson@domain1.com" -Password $Password + + Add "MY Directory Group1" from Domain1 with Server and Backup administrator roles, and specify password for group validation. + + + + + + + + + + -------------------------- EXAMPLE 3 -------------------------- + + + + # Get the defined directory group from the appliance. $Directory = Get-OVLdapDirectory -Name "Domain1" -ErrorAction Stop # Collect the scope needed to assign permissions. $VirtAdminsScope = Get-OVScope -Name CorpVirtAdmins -ErrorAction Stop # Create a hashtable of the roles to scopes (SBAC) which would then be assigned to the directory group. $ScopeRoles = @{Role = "Server administrator"; Scope = $VirtAdminsScope},@{Role = "Storage administrator"; Scope = $VirtAdminsScope} # Collect the users AD credentials. This does not require Domain Admins or an administrator level account. Only a standard user account that can query the directory. $MyAdCreds = Get-Credential # Get the directory group object. $Group = Show-OVLdapDirectoryGroup -Name "CorpVirtAdmins" -Directory $Directory -Credential $MyAdCreds -ErrorAction Stop # Create the directory group resource on the appliance, and associate with the SBAC permissions. New-OVLdapGroup -Directory Directory -GroupName CorpVirtAdmins -ScopePermissions $ScopeRoles -Credential $MyAdCreds + + Add the new directory group with specific scope permissions, and using a PSCredential object for authentication directory validation. + + + + + + + + + + + + + Get-OVLdapGroup + + + + Remove-OVLdapGroup + + + + Set-OVLdapGroupRole + + + + Show-OVLdapGroups + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/security/new-ovldapgroup + + + + + + + + New-OVLdapServer + + Define LDAP Directory Server object. + + New + OVLdapServer + + + A helper Cmdlet that will define an LDAP Directory Server object to be used with the New-OVLdapDirectory Cmdlet. + + + + + New-OVLdapServer + + Hostname + + Directory server name or IP Address to add. + + String + + + SSLPort + + Directory Server"s LDAP SSL Port. + + Int32 + + + Certificate + + Directory Server SSL Certificate, either location to Base64 Cert or multiline string value. If omitted, the Cmdlet will attempt to retrieve the Directory Servers Secure LDAP Certiciate. + + Object + + + TrustLeafCertificate + + Use to specify if the certificate should be explicitly trusted, like a self signed certificate or where the root or issuing certificate authority has not been added to the appliance trust store. + + SwitchParameter + + + + + + + Certificate + + Directory Server SSL Certificate, either location to Base64 Cert or multiline string value. If omitted, the Cmdlet will attempt to retrieve the Directory Servers Secure LDAP Certiciate. + + Object + + Object + + + + + Hostname + + Directory server name or IP Address to add. + + String + + String + + + + + SSLPort + + Directory Server"s LDAP SSL Port. + + Int32 + + Int32 + + 636 + + + TrustLeafCertificate + + Use to specify if the certificate should be explicitly trusted, like a self signed certificate or where the root or issuing certificate authority has not been added to the appliance trust store. + + SwitchParameter + + SwitchParameter + + + + + + + + + System.String + + + Directory Server Name or IP Address + + + + + System.Collections.ArrayList + + + Mutlple Directory Server Name or IP Address System.String values + + + + + + + + HPEOneView.Appliance.AuthDirectoryServer [System.Management.Automation.PSCustomObject] + + + + New LDAP Server Resource Object to be used with New-OVLdapDirectory Cmdlet + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + $ServerA = New-OVLdapServer -Name servera.domain.com -Certificate C:\dir\servera.cer + + Define a new Directory Server, ServerA, specifying the Base64 Public Certificate and using the default LDAP SSL port 636. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + $ServerA = New-OVLdapServer -Name servera.domain.com -Port 2636 -Certificate C:\dir\servera.cer + + Define a new Directory Server, ServerA, specifying the Base64 Public Certificate, using a custom LDAP SSL port. + + + + + + + + + + -------------------------- EXAMPLE 3 -------------------------- + + + + $dc1,$dc2 = "dc1.mydomain.com","dc2.mydomain.com" | New-OVLdapServer + + Create two new authentication directory servers, with the Cmdlet retrieving the certificate directly from the auth servers. + + + + + + + + + + + + + Add-OVLdapServer + + + + Remove-OVLdapServer + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/security/new-ovldapserver + + + + + + + + New-OVLicense + + Install license on the appliance + + New + OVLicense + + + The following types of licenses are available for managing or monitoring hardware in HPE OneView. + +Managed hardware licenses + +HPE OneView Advanced + +This licnese type provides both an HPE OneView Advanced license and an iLO Advanced license. This license is intended for server hardware and enclosures you want to manage with HPE OneView. + +HPE OneView Advanced w/o iLO + +This license type rovides an HPE OneView Advanced license only. It is intended for server hardware you want to manage with HPE OneView. This license is for servers with iLOs that are already licensed, or server hardware for which you do not require an iLO license. An HPE OneView Advanced w/o iLO license provides support for all server hardware features on the appliance, with the following exceptions: + +* Server hardware without an iLO Advanced license does not display utilization data. +* Rack mount servers without an iLO Advanced license cannot access the remote console. + +Monitored hardware license + +HPE OneView Standard + +Provides an HPE OneView Standard license for all monitored server hardware. + +This license is automatically selected: + +* for the enclosure when adding a monitored enclosure +* for the server when adding a monitored server +* for all ProLiant G6 server blades or G7 BL680c server blades when adding a managed enclosure + +HPE OneView does not manage the hardware running with an HPE OneView Standard license. + +When you add an enclosure or rack mount server to the appliance, you must specify one of these licenses. + +When you add a rack manager, either the HPE OneView Standard license or the HPE OneView Advanced license is automatically applied based on the firmware version installed on the rack manager. + +This Cmdlet will assist with the installation of a new HPE OneView Advanced or HPE OneView Advanced without iLO Advanced license key. The type is automatically detected based on the validity of the license key. + +Minimum required privileges: Infrastructure administrator + + + + + New-OVLicense + + LicenseKey + + Used for adding license keys one at a time, or if only a single license key needs to be added. + + String + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. + + Object + + + + New-OVLicense + + File + + A text file with each license key on a new line that will be installed on the appliance. + + String + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. + + Object + + + + + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + File + + A text file with each license key on a new line that will be installed on the appliance. + + String + + String + + + + + LicenseKey + + Used for adding license keys one at a time, or if only a single license key needs to be added. + + String + + String + + + + + + + + + System.String + + + License key in String Format, from Get-Content or an Array of String + + + + + + + + HPEOneView.Appliance.License + + + + The License resource just added to the apliance + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + $license = "FC9E D9MA H9PA GTVZ C7B5 HWWB Y9JL KHPL B89H MZVU DXAU 9CSM GHTG L762 2F25 HJF9 KJVT D5TM EFVW TZNJ FGTM NQ6G 2P2J 9G82 ZJKZ EWLR VW8A Y5A4 N2SK H1MQ XJJL LUQH ZUWD 9ATC NJ79 CEJC 5S86 FC4X EKSZ X4CP XZLU FSXS FKS6 KKCE 4NMU FPN5 N82E Z2RX 3QTM EFQC 29JK 29MC "ORDER_101613 E1Y94A HP_OV_3yr_24x7_Supp_Phys_1_Svr_Lic EONEJTCDT4FJ"_35HZP-CYMTH-W414S-2DGKZ-S6MPH" +New-OVlicense -LicenseKey $license + + Install license on the appliance connection. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + New-OVlicense -File c:\licenses.txt + + Install licenses read from a file by Get-Content. + + + + + + + + + + + + + Get-OVLicense + + + + Remove-OVLicense + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/new-ovlicense + + + + + + + + New-OVLogicalEnclosure + + Create a Logical Enclosure. + + New + OVLogicalEnclosure + + + A logical enclosure represents a logical view of a single enclosure with an enclosure group serving as a template. If the intended configuration in the logical enclosure does not match the actual configuration on the enclosures, the logical enclosure becomes inconsistent. Use the Logical Enclosures screen to manage firmware, configuration scripts, create a support dump, and to apply updates made from the Enclosure Groups screen to the enclosures in the logical enclosure. + +A logical enclosure is automatically created when a c7000 enclosure is added. + +Use this Cmdlet to define a new Logical Enclosure that will include multiple Synergy Frames that share the same Virtual Connect Fabric Domain. + + + + + New-OVLogicalEnclosure + + Name + + A name for the new Logical Enclosure. + + String + + + Enclosure + + One of the connected Frames. The Interlink Topology will be discovered to include the other Frame members. + + Object + + + EnclosureGroup + + The Enclosure Group resource to deploy the policy from. + + Object + + + FirmwareBaseline + + Provide the Firmware Baseline object to use with the Logical Enclosure is being created. + + String + + + ForceFirmwareBaseline + + Specify to force the installation of firmware if the same version is found or if you wish to downgrade from a newer installed version. + + Boolean + + + Ebipa + + Use to specify a custom IPAddress assignment where the auto fill parameters are not sufficient. This parameter cannot be combined with the auto fill parameters. + +Example Hasthtable format: + +@{ + Frame# = @{ + Device1 = @{ + IPv4Address = "IPv4Address"; + IPv6Address = "IPv6Address" + }; + Interconnect1 = @{ + IPv4Address = "IPv4Address"; + IPv6Address = "IPv6Address" + } + } +} + +Where "Frame#" is the frame ID of the Synergy Enclosure. Can also be named "Enclosure" instead of "Frame". + + Object + + + Scope + + Provide an HPEOneView.Appliance.ScopeCollection resource object to initially associate with. Resource can also be added to scope using the Add-OVResourceToScope Cmdlet. + + HPEOneView.Appliance.ScopeCollection[] + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + Passthru + + Return the object created by the Cmdlet, and not to the API. This is useful when you want to modify additional properties the Cmdlet does not yet support. + + SwitchParameter + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + + + New-OVLogicalEnclosure + + Name + + A name for the new Logical Enclosure. + + String + + + Enclosure + + One of the connected Frames. The Interlink Topology will be discovered to include the other Frame members. + + Object + + + EnclosureGroup + + The Enclosure Group resource to deploy the policy from. + + Object + + + FirmwareBaseline + + Provide the Firmware Baseline object to use with the Logical Enclosure is being created. + + String + + + ForceFirmwareBaseline + + Specify to force the installation of firmware if the same version is found or if you wish to downgrade from a newer installed version. + + Boolean + + + AutoFillIPv4DeviceAddress + + Use to autofill IPv4 addresses for device bays. Must supply the StartingIPv4DeviceAddress parameter. + + SwitchParameter + + + StartingIPv4DeviceAddress + + Use to autofill IPv4 addresses for device bays. Must supply the AutoFillIPv4DeviceAddress parameter. Concurrent IP addresses will be calculated and automatically assigned. This does not take into account a subnet mask. + + IPAddress + + + AutoFillIPv4InterconnectAddress + + Use to autofill IPv4 addresses for interconnect bays. Must supply the StartingIPv4InterconnectAddress parameter. + + SwitchParameter + + + StartingIPv4InterconnectAddress + + Use to autofill IPv4 addresses for device bays. Must supply the AutoFillIPv4InterconnectAddress parameter. Concurrent IP addresses will be calculated and automatically assigned. This does not take into account a subnet mask. + + IPAddress + + + AutoFillIPv6DeviceAddress + + Use to autofill IPv6 addresses for device bays. Must supply the StartingIPv6DeviceAddress parameter. + + SwitchParameter + + + StartingIPv6DeviceAddress + + Use to autofill IPv6 addresses for device bays. Must supply the AutoFillIPv6DeviceAddress parameter. Concurrent IP addresses will be calculated and automatically assigned. This does not take into account a subnet mask. + + IPAddress + + + AutoFillIPv6InterconnectAddress + + Use to autofill IPv6 addresses for interconnect bays. Must supply the StartingIPv6InterconnectAddress parameter. + + SwitchParameter + + + StartingIPv6InterconnectAddress + + Use to autofill IPv6 addresses for device bays. Must supply the AutoFillIPv6InterconnectAddress parameter. Concurrent IP addresses will be calculated and automatically assigned. This does not take into account a subnet mask. + + IPAddress + + + Scope + + Provide an HPEOneView.Appliance.ScopeCollection resource object to initially associate with. Resource can also be added to scope using the Add-OVResourceToScope Cmdlet. + + HPEOneView.Appliance.ScopeCollection[] + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + Passthru + + Return the object created by the Cmdlet, and not to the API. This is useful when you want to modify additional properties the Cmdlet does not yet support. + + SwitchParameter + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + + + + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + SwitchParameter + + False + + + AutoFillIPv4DeviceAddress + + Use to autofill IPv4 addresses for device bays. Must supply the StartingIPv4DeviceAddress parameter. + + SwitchParameter + + SwitchParameter + + + + + AutoFillIPv4InterconnectAddress + + Use to autofill IPv4 addresses for interconnect bays. Must supply the StartingIPv4InterconnectAddress parameter. + + SwitchParameter + + SwitchParameter + + + + + AutoFillIPv6DeviceAddress + + Use to autofill IPv6 addresses for device bays. Must supply the StartingIPv6DeviceAddress parameter. + + SwitchParameter + + SwitchParameter + + + + + AutoFillIPv6InterconnectAddress + + Use to autofill IPv6 addresses for interconnect bays. Must supply the StartingIPv6InterconnectAddress parameter. + + SwitchParameter + + SwitchParameter + + + + + Ebipa + + Use to specify a custom IPAddress assignment where the auto fill parameters are not sufficient. This parameter cannot be combined with the auto fill parameters. + +Example Hasthtable format: + +@{ + Frame# = @{ + Device1 = @{ + IPv4Address = "IPv4Address"; + IPv6Address = "IPv6Address" + }; + Interconnect1 = @{ + IPv4Address = "IPv4Address"; + IPv6Address = "IPv6Address" + } + } +} + +Where "Frame#" is the frame ID of the Synergy Enclosure. Can also be named "Enclosure" instead of "Frame". + + Object + + Object + + + + + Enclosure + + One of the connected Frames. The Interlink Topology will be discovered to include the other Frame members. + + Object + + Object + + + + + EnclosureGroup + + The Enclosure Group resource to deploy the policy from. + + Object + + Object + + + + + FirmwareBaseline + + Provide the Firmware Baseline object to use with the Logical Enclosure is being created. + + String + + String + + + + + ForceFirmwareBaseline + + Specify to force the installation of firmware if the same version is found or if you wish to downgrade from a newer installed version. + + Boolean + + Boolean + + False + + + Name + + A name for the new Logical Enclosure. + + String + + String + + + + + Passthru + + Return the object created by the Cmdlet, and not to the API. This is useful when you want to modify additional properties the Cmdlet does not yet support. + + SwitchParameter + + SwitchParameter + + + + + Scope + + Provide an HPEOneView.Appliance.ScopeCollection resource object to initially associate with. Resource can also be added to scope using the Add-OVResourceToScope Cmdlet. + + HPEOneView.Appliance.ScopeCollection[] + + HPEOneView.Appliance.ScopeCollection[] + + False + + + StartingIPv4DeviceAddress + + Use to autofill IPv4 addresses for device bays. Must supply the AutoFillIPv4DeviceAddress parameter. Concurrent IP addresses will be calculated and automatically assigned. This does not take into account a subnet mask. + + IPAddress + + IPAddress + + + + + StartingIPv4InterconnectAddress + + Use to autofill IPv4 addresses for device bays. Must supply the AutoFillIPv4InterconnectAddress parameter. Concurrent IP addresses will be calculated and automatically assigned. This does not take into account a subnet mask. + + IPAddress + + IPAddress + + + + + StartingIPv6DeviceAddress + + Use to autofill IPv6 addresses for device bays. Must supply the AutoFillIPv6DeviceAddress parameter. Concurrent IP addresses will be calculated and automatically assigned. This does not take into account a subnet mask. + + IPAddress + + IPAddress + + + + + StartingIPv6InterconnectAddress + + Use to autofill IPv6 addresses for device bays. Must supply the AutoFillIPv6InterconnectAddress parameter. Concurrent IP addresses will be calculated and automatically assigned. This does not take into account a subnet mask. + + IPAddress + + IPAddress + + + + + + + + + HPEOneView.Enclosure [System.Management.Automation.PSCustomObject] + + + Single Enclosure (Synergy Frame) resource object + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + The async task resource + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + $EG = Get-OVEnclosureGroup -Name "Prod Synergy EG 1" +Get-OVEnclosure -Name 0000A66101 | New-OVLogicalEnclosure "My Synergy LE 1" -EnclosureGroup $EG + + Create a new Logical Enclosure, "My Synergy LE 1", using the specified Enclosure Group and a specific Synergy Frame. + + + + + + + + + + + + + Get-OVLogicalEnclosure + + + + Remove-OVLogicalEnclosure + + + + Set-OVLogicalEnclosure + + + + Update-OVLogicalEnclosure + + + + Update-OVLogicalEnclosureFirmware + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/servers/new-ovlogicalenclosure + + + + + + + + New-OVLogicalInterconnectGroup + + Create new Logical Interconnect Group. + + New + OVLogicalInterconnectGroup + + + This Cmdlet provides the ability to create a Logical Interconnect Group. Bays 1 and 2 are required, and need to be identical. + + + + + New-OVLogicalInterconnectGroup + + Name + + The Logical Interconnect Group Name + + String + + + Bays + + HPE BladeSystem C7000 Support - A [System.Collections.Hashtable] object of each Interconnect Bay. Accepted values are: + + * FlexFabric - HP VC FlexFabric 10Gb/24-Port Module + * Flex10 - HP VC Flex-10 Enet Module + * Flex1010D - HP VC Flex-10/10D Module + * Flex2040f8 - HP VC FlexFabric-20/40 F8 Module + * VCFC20 - HP VC 8Gb 20-Port FC Module + * VCFC24 - HP VC 8Gb 24-Port FC Module + * FEX - Cisco Fabric Extender for HP BladeSystem + +E.g. @{1 = "Flex10";2 = "Flex10";3 = "FlexFabric";4 = "Flexfabric";5 = "";6 = "";7 = "";8 = "";} + +HPE Synergy Support - A [System.Collection.Hashtable] object, with Frame and Fabric Bay definitions. Accepted values are: + + * SEVC100F32 - Virtual Connect SE 40Gb F8 Module for Synergy + + * SEVC40f8 - Virtual Connect SE 40Gb F8 Module for Synergy + * SEVCFC or SEVC16GbFC - Virtual Connect SE 16Gb FC Module for Synergy + * SE20ILM - Synergy 20Gb Interconnect Link Module + * SE10ILM - Synergy 10Gb Interconnect Link Module + * SE12SAS - Synergy 12Gb SAS Connection Module + +$Bays = @{ Frame1 = @{Bay3 = "SEVC40f8"; Bay6 = "SE20ILM"}; Frame2 = @{Bay3 = "SE20ILM"; Bay6 = "SEVC40f8"} } + +Note: When configuring Synergy SAS Connection Module, no other device bays can be specified, and only a Single Frame can be configured. + + Hashtable + + + InterconnectConsistencyChecking + + Use to indicate if the group policy will be tracked to with the deployed and configured resource. Allowed values: + + * None + * Exact + +Default: Exact + + String + + + EnableIgmpSnooping + + The IGMP snooping feature allows interconnects to monitor the IGMP IP multicast membership activities and configure hardware Layer 2 switching behavior of multicast traffic to optimize network resource usage. Currently, only IGMP v1 and v2 (RFC 2236) are supported. + +Default value: Disabled + + Boolean + + + IgmpIdleTimeoutInterval + + The Group Membership Interval value, as specified by the IGMP v2 specification (RFC 2236). +For optimum network resource usage, set the timeout interval to match your network"s multicast router settings. + +Data type: Numeric; unit of measure is seconds +Default value: 260 +Required: Yes, if IGMP snooping is enabled + + Int32 + + + IgmpSnoopingConsistencyChecking + + Use to override the consistency checking for the policy. Allowed values: + + * Exact + * None + + String + + + EnableFastMacCacheFailover + + When an uplink that was in standby mode becomes active, it can take several minutes for external Ethernet interconnects to recognize that the server blades can now be reached on this newly active connection. Enabling Fast MAC Cache Failover causes Ethernet packets to be transmitted on the newly active connection, which enables the external Ethernet interconnects to identify the new connection (and update their MAC caches). The transmission sequence is repeated a few times at the MAC refresh interval and completes in about 1 minute. + +Default value: Enabled + + Boolean + + + MacRefreshInterval + + The time interval at which MAC caches are refreshed + +Data type: Numeric; unit of measure is seconds +Default value: 5 + + Int32 + + + EnableNetworkLoopProtection + + Enables or disables network loop protection. + +Network loop protection: + +The loop protection feature enables detection of loops on downlink ports, which can be Flex-10 logical ports or physical ports. The feature applies when Device Control Channel (DCC) protocol is running on the Flex-10 port. If DCC is not available, the feature applies to the physical downlink port. + +Network loop protection uses two methods to detect loops: + +1. It periodically injects a special probe frame into the VC domain and monitors downlink ports for the looped back probe frame. If this special probe frame is detected on downlink ports, the port is considered to cause the loop condition. + +2. It monitors and intercepts common loop detection frames used in other switches. In network environments where the upstream switches send loop detection frames, the VC interconnects must ensure that any downlink loops do not cause these frames to be sent back to the uplink ports. Even though the probe frames ensure loops are detected, there is a small time window depending on the probe frame transmission interval in which the loop detection frames from the external switch might loop through down link ports and reach uplink ports. By intercepting the external loop detection frames on downlinks, the possibility of triggering loop protection on the upstream switch is eliminated. When network loop protection is enabled, VC interconnects intercept loop detection frames from various switch vendors, such as Cisco and HP Networking. + +When the network loop protection feature is enabled, any probe frame or other supported loop detection frame received on a downlink port is considered to be causing the network loop, and the port is disabled immediately until an administrative action is taken. The administrative action involves resolving the loop condition and clearing the loop protection error condition. The loop detected status on a port can be cleared by un-assigning all networks from the profile connect corresponding to the port in the loop detected state. + +The SNMP agent supports trap generation when a loop condition is detected or cleared. + +Default value: Enabled + + Boolean + + + EnablePauseFloodProtection + + Enables or disables pause flood protection. + +Pause flood protection: + +Ethernet switch interfaces use pause frame based flow control mechanisms to control data flow. When a pause frame is received on a flow control enabled interface, the transmit operation is stopped for the pause duration specified in the pause frame. All other frames destined for this interface are queued up. If another pause frame is received before the previous pause timer expires, the pause timer is refreshed to the new pause duration value. If a steady stream of pause frames is received for extended periods of time, the transmit queue for that interface continues to grow until all queuing resources are exhausted. This condition severely impacts the switch operation on other interfaces. In addition, all protocol operations on the switch are impacted because of the inability to transmit protocol frames. Both port pause and priority-based pause frames can cause the same resource exhaustion condition. + +VC interconnects provide the ability to monitor server downlink ports for pause flood conditions and take protective action by disabling the port. The default polling interval is 10 seconds and is not customer configurable. The SNMP agent supports trap generation when a pause flood condition is detected or cleared. + +This feature operates at the physical port level. When a pause flood condition is detected on a Flex-10 physical port, all Flex-10 logical ports associated with physical ports are disabled. When the pause flood protection feature is enabled, this feature detects pause flood conditions on server downlink ports and disables the port. The port remains disabled until an administrative action is taken. The administrative action involves the following steps: + +1. Resolve the issue with the NIC on the server causing the continuous pause generation. This might include updating the NIC firmware and device drivers. + +Rebooting the server might not clear the pause flood condition if the cause of the pause flood condition is in the NIC firmware. In this case, the server must be completely disconnected from the power source to reset the NIC firmware. + +2. Re-enable the disabled ports on the VC interconnect modules. + +Default value: Enabled + + Boolean + + + EnableLLDPTagging + + When enabled, tagged LLDP frames are transmitted over downlink ports to server hardware. The management IP address of the interconnect in the lowest numbered bay location in the logical interconnect will be advertised as the LLDP management address TLV. + +This parameter is only available for 2.00.07 or newer appliances. + + Boolean + + + EnableEnhancedLLDPTLV + + When enabled, the enclosure name and serial number are encapsulated in the Chassis ID TLV LLDPDU transmitted by interconnect uplink ports. + +This parameter is only available for 2.00.07 or newer appliances. + + Boolean + + + LldpAddressingMode + + Specify the IP address format type to support. Allowed values: + + * IPv4 + * IPv6 + * IPv4AndIPv6 + + Boolean + + + SNMP + + SNMP Settings to define SNMP configruation. Use New-OVSnmpConfiguration and New-OVSnmpTrapDestination Cmdlets to create the necessary SNMP Configuration object. + + Object + + + SNMPConsistencyChecking + + Use to indicate if the group policy will be tracked to with the deployed and configured resource. Allowed values: + + * None + * Exact + +Default: Exact + + String + + + SnmpV1 + + Specify the SNMP version type is SNMPv1. + + SwitchParameter + + + SnmpV3 + + Specify the SNMP version type is SNMPv3. + + SwitchParameter + + + SnmpV3User + + Provide the SNMPv3 user object from New-OVSnmpV3User. + + HPEOneView.Appliance.SnmpV3User + + + InternalNetworks + + An Array collection of Networks that will be marked as Internal only. + + Array + + + InternalNetworkConsistencyChecking + + Use to indicate if the group policy will be tracked to with the deployed and configured resource. Allowed values: + + * None + * Exact + +Default: Exact + + String + + + QosConfiguration + + A collection of QOS configurations that are created using the New-OVQosConfig helper Cmdlet. + + Object + + + QoSConsistencyChecking + + Use to indicate if the group policy will be tracked to with the deployed and configured resource. Allowed values: + + * None + * Exact + +Default: Exact + + String + + + UplinkSet + + A collection of uplink sets from New-OVUplinkSet using the -Passthru parameter. + + Hashtable[] + + + Scope + + Provide an HPEOneView.Appliance.ScopeCollection resource object to initially associate with. Resource can also be added to scope using the Add-OVResourceToScope Cmdlet. + + HPEOneView.Appliance.ScopeCollection[] + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + + New-OVLogicalInterconnectGroup + + Name + + The Logical Interconnect Group Name + + String + + + FrameCount + + The number of Synergy Frames to participate in the Logical Stack. + + Int32 + + + InterconnectBaySet + + Which Synergy Interconnect Bay Set ID will the interconnects be populated in. Allowed value: + + * 1 - Interconnect Bay set 1 & 4 + * 2 - Interconnect Bay set 2 & 5 + * 3 - Interconnect Bay set 3 & 6 + + Int32 + + + FabricModuleType + + Specify the Synergy Fabric Module type the Logical Interconnect Group will be modeled for. Allowed value: + + * SEVC100F32 - Virtual Connect SE 100Gb F32 Module for Synergy + * SEVC40F8 - Virtual Connect SE 40Gb F8 Module for Synergy + * SEVCFC or SEVC16GbFC - Virtual Connect SE 16Gb FC Module for Synergy + * SEVC32FC - Virtual Connect SE 32Gb FC Module for Synergy + * SAS - Synergy 12Gb SAS Connection Module + + String + + + Bays + + HPE BladeSystem C7000 Support - A [System.Collections.Hashtable] object of each Interconnect Bay. Accepted values are: + + * FlexFabric - HP VC FlexFabric 10Gb/24-Port Module + * Flex10 - HP VC Flex-10 Enet Module + * Flex1010D - HP VC Flex-10/10D Module + * Flex2040f8 - HP VC FlexFabric-20/40 F8 Module + * VCFC20 - HP VC 8Gb 20-Port FC Module + * VCFC24 - HP VC 8Gb 24-Port FC Module + * FEX - Cisco Fabric Extender for HP BladeSystem + +E.g. @{1 = "Flex10";2 = "Flex10";3 = "FlexFabric";4 = "Flexfabric";5 = "";6 = "";7 = "";8 = "";} + +HPE Synergy Support - A [System.Collection.Hashtable] object, with Frame and Fabric Bay definitions. Accepted values are: + + * SEVC100F32 - Virtual Connect SE 40Gb F8 Module for Synergy + + * SEVC40f8 - Virtual Connect SE 40Gb F8 Module for Synergy + * SEVCFC or SEVC16GbFC - Virtual Connect SE 16Gb FC Module for Synergy + * SE20ILM - Synergy 20Gb Interconnect Link Module + * SE10ILM - Synergy 10Gb Interconnect Link Module + * SE12SAS - Synergy 12Gb SAS Connection Module + +$Bays = @{ Frame1 = @{Bay3 = "SEVC40f8"; Bay6 = "SE20ILM"}; Frame2 = @{Bay3 = "SE20ILM"; Bay6 = "SEVC40f8"} } + +Note: When configuring Synergy SAS Connection Module, no other device bays can be specified, and only a Single Frame can be configured. + + Hashtable + + + InterconnectConsistencyChecking + + Use to indicate if the group policy will be tracked to with the deployed and configured resource. Allowed values: + + * None + * Exact + +Default: Exact + + String + + + FabricRedundancy + + Define the expected Synergy Fabric Interconnect Redundancy type. Allowed value: + + * HighlyAvailable + * Redundant + * ASide + * BSide + + String + + + DownlinkSpeedMode + + Specify the port downlink speed to be configured for HPE Virtual Connect SE 100Gb F32 module for Synergy. + +Allowed values: + + * 25 + * 50 + +Default: 25 + + String + + + EnableCutThroughSwitching + + Enables or disables the Cut-Through switching mode. When enabled, the switch starts forwarding the frame as soon as the switch has read the destination details in the packet header. When enabled, Pause flood protection is disabled. + +NOTE: This option is available for HPE Virtual Connect SE 100Gb F32 Module for HPE Synergy. + + Default value: Disabled + + Bool + + + EnableStormControl + + Enables or disables the suppression of excessive inbound broadcast, multicast, or DLF (Destination Lookup Failure) packets when a threshold is reached. + +Default value: Disabled + + Bool + + + StormControlPacketsPerSecondThreshold + + The Storm Control packet threshold at which traffic is suppressed. + +Valid range: 1-262143 packets per second + + Int + + + StormControlPollingInterval + + When enabling Storm Control, Specify a value between 5 and 30 seconds. + + Int + + + EnableDdns + + When enabled, Domain Name System (DNS) server will be updated automatically when either the IP address or hostname change for the interconnect module. Must provide -DdnsDomainNameSuffix parameter. + + Bool + + + DdnsDomainNameSuffix + + When enabled, Domain Name System (DNS) server will be updated automatically when either the IP address or hostname change for the interconnect module. + + String + + + EnableIgmpSnooping + + The IGMP snooping feature allows interconnects to monitor the IGMP IP multicast membership activities and configure hardware Layer 2 switching behavior of multicast traffic to optimize network resource usage. Currently, only IGMP v1 and v2 (RFC 2236) are supported. + +Default value: Disabled + + Boolean + + + IgmpVLANs + + Specify values or range of VLAN IDs, from 1-4094, associated with networks defined in the logical interconnect. Use comma or hyphens as separator, for example: 10-15, 52, 100-200. + + String + + + IgmpIdleTimeoutInterval + + The Group Membership Interval value, as specified by the IGMP v2 specification (RFC 2236). +For optimum network resource usage, set the timeout interval to match your network"s multicast router settings. + +Data type: Numeric; unit of measure is seconds +Default value: 260 +Required: Yes, if IGMP snooping is enabled + + Int32 + + + IgmpMulticastFloodPrevention + + By default, unregistered IGMP multicast traffic traversing VC Ethernet modules are flooded on the configured Ethernet network. The IGMP multicast flood prevention option prevents the flooding of unregistered multicast. The IGMP multicast flood prevention setting is effective only when IGMP snooping is enabled for all or a subset of VLANs. When enabled, unregistered multicast traffic from uplinks is dropped and traffic from the server ports is redirected to the active uplink port. IGMP multicast flood prevention is disabled by default. + +The IGMP multicast flood prevention option is supported only on the following interconnects: + * HPE Virtual Connect SE 100Gb F32 Module for HPE Synergy + * HPE Virtual Connect SE 40Gb F8 Module for HPE Synergy + + Bool + + + IgmpProxyReporting + + IGMP snooping with proxy reporting or report suppression actively filters the IGMP packets reducing the load on the multicast router. The IGMP proxy reporting is effective only when IGMP snooping is enabled for all or a subset of VLANs. The IGMP proxy reporting is enabled by default. + +The IGMP proxy reporting option is supported only on the following interconnects: + * HPE Virtual Connect SE 100Gb F32 Module for HPE Synergy + * HPE Virtual Connect SE 40Gb F8 Module for HPE Synergy + +You can enable or disable the IGMP proxy reporting configuration on the Logical Interconnect or Logical Interconnect Groups screen. + * Enabled ($True) - The host reports are filtered to minimize traffic to the upstream multicast router. + * Disabled ($False) - The host reports are not filtered. All the host reports are forwarded to the upstream multicast router. + + Bool + + + IgmpSnoopingConsistencyChecking + + Use to override the consistency checking for the policy. Allowed values: + + * Exact + * None + + String + + + EnableNetworkLoopProtection + + Enables or disables network loop protection. + +Network loop protection: + +The loop protection feature enables detection of loops on downlink ports, which can be Flex-10 logical ports or physical ports. The feature applies when Device Control Channel (DCC) protocol is running on the Flex-10 port. If DCC is not available, the feature applies to the physical downlink port. + +Network loop protection uses two methods to detect loops: + +1. It periodically injects a special probe frame into the VC domain and monitors downlink ports for the looped back probe frame. If this special probe frame is detected on downlink ports, the port is considered to cause the loop condition. + +2. It monitors and intercepts common loop detection frames used in other switches. In network environments where the upstream switches send loop detection frames, the VC interconnects must ensure that any downlink loops do not cause these frames to be sent back to the uplink ports. Even though the probe frames ensure loops are detected, there is a small time window depending on the probe frame transmission interval in which the loop detection frames from the external switch might loop through down link ports and reach uplink ports. By intercepting the external loop detection frames on downlinks, the possibility of triggering loop protection on the upstream switch is eliminated. When network loop protection is enabled, VC interconnects intercept loop detection frames from various switch vendors, such as Cisco and HP Networking. + +When the network loop protection feature is enabled, any probe frame or other supported loop detection frame received on a downlink port is considered to be causing the network loop, and the port is disabled immediately until an administrative action is taken. The administrative action involves resolving the loop condition and clearing the loop protection error condition. The loop detected status on a port can be cleared by un-assigning all networks from the profile connect corresponding to the port in the loop detected state. + +The SNMP agent supports trap generation when a loop condition is detected or cleared. + +Default value: Enabled + + Boolean + + + EnablePauseFloodProtection + + Enables or disables pause flood protection. + +Pause flood protection: + +Ethernet switch interfaces use pause frame based flow control mechanisms to control data flow. When a pause frame is received on a flow control enabled interface, the transmit operation is stopped for the pause duration specified in the pause frame. All other frames destined for this interface are queued up. If another pause frame is received before the previous pause timer expires, the pause timer is refreshed to the new pause duration value. If a steady stream of pause frames is received for extended periods of time, the transmit queue for that interface continues to grow until all queuing resources are exhausted. This condition severely impacts the switch operation on other interfaces. In addition, all protocol operations on the switch are impacted because of the inability to transmit protocol frames. Both port pause and priority-based pause frames can cause the same resource exhaustion condition. + +VC interconnects provide the ability to monitor server downlink ports for pause flood conditions and take protective action by disabling the port. The default polling interval is 10 seconds and is not customer configurable. The SNMP agent supports trap generation when a pause flood condition is detected or cleared. + +This feature operates at the physical port level. When a pause flood condition is detected on a Flex-10 physical port, all Flex-10 logical ports associated with physical ports are disabled. When the pause flood protection feature is enabled, this feature detects pause flood conditions on server downlink ports and disables the port. The port remains disabled until an administrative action is taken. The administrative action involves the following steps: + +1. Resolve the issue with the NIC on the server causing the continuous pause generation. This might include updating the NIC firmware and device drivers. + +Rebooting the server might not clear the pause flood condition if the cause of the pause flood condition is in the NIC firmware. In this case, the server must be completely disconnected from the power source to reset the NIC firmware. + +2. Re-enable the disabled ports on the VC interconnect modules. + +Default value: Enabled + + Boolean + + + EnableLLDPTagging + + When enabled, tagged LLDP frames are transmitted over downlink ports to server hardware. The management IP address of the interconnect in the lowest numbered bay location in the logical interconnect will be advertised as the LLDP management address TLV. + +This parameter is only available for 2.00.07 or newer appliances. + + Boolean + + + EnableEnhancedLLDPTLV + + When enabled, the enclosure name and serial number are encapsulated in the Chassis ID TLV LLDPDU transmitted by interconnect uplink ports. + +This parameter is only available for 2.00.07 or newer appliances. + + Boolean + + + LldpAddressingMode + + Specify the IP address format type to support. Allowed values: + + * IPv4 + * IPv6 + * IPv4AndIPv6 + + Boolean + + + SNMP + + SNMP Settings to define SNMP configruation. Use New-OVSnmpConfiguration and New-OVSnmpTrapDestination Cmdlets to create the necessary SNMP Configuration object. + + Object + + + SNMPConsistencyChecking + + Use to indicate if the group policy will be tracked to with the deployed and configured resource. Allowed values: + + * None + * Exact + +Default: Exact + + String + + + SnmpV1 + + Specify the SNMP version type is SNMPv1. + + SwitchParameter + + + SnmpV3 + + Specify the SNMP version type is SNMPv3. + + SwitchParameter + + + SnmpV3User + + Provide the SNMPv3 user object from New-OVSnmpV3User. + + HPEOneView.Appliance.SnmpV3User + + + InternalNetworks + + An Array collection of Networks that will be marked as Internal only. + + Array + + + InternalNetworkConsistencyChecking + + Use to indicate if the group policy will be tracked to with the deployed and configured resource. Allowed values: + + * None + * Exact + +Default: Exact + + String + + + QosConfiguration + + A collection of QOS configurations that are created using the New-OVQosConfig helper Cmdlet. + + Object + + + QoSConsistencyChecking + + Use to indicate if the group policy will be tracked to with the deployed and configured resource. Allowed values: + + * None + * Exact + +Default: Exact + + String + + + UplinkSet + + A collection of uplink sets from New-OVUplinkSet using the -Passthru parameter. + + Hashtable[] + + + Scope + + Provide an HPEOneView.Appliance.ScopeCollection resource object to initially associate with. Resource can also be added to scope using the Add-OVResourceToScope Cmdlet. + + HPEOneView.Appliance.ScopeCollection[] + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + + New-OVLogicalInterconnectGroup + + Import + + Specify JSON source file to create Logical Interconnect Group. + + Object + + + Scope + + Provide an HPEOneView.Appliance.ScopeCollection resource object to initially associate with. Resource can also be added to scope using the Add-OVResourceToScope Cmdlet. + + HPEOneView.Appliance.ScopeCollection[] + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + SwitchParameter + + False + + + Bays + + HPE BladeSystem C7000 Support - A [System.Collections.Hashtable] object of each Interconnect Bay. Accepted values are: + + * FlexFabric - HP VC FlexFabric 10Gb/24-Port Module + * Flex10 - HP VC Flex-10 Enet Module + * Flex1010D - HP VC Flex-10/10D Module + * Flex2040f8 - HP VC FlexFabric-20/40 F8 Module + * VCFC20 - HP VC 8Gb 20-Port FC Module + * VCFC24 - HP VC 8Gb 24-Port FC Module + * FEX - Cisco Fabric Extender for HP BladeSystem + +E.g. @{1 = "Flex10";2 = "Flex10";3 = "FlexFabric";4 = "Flexfabric";5 = "";6 = "";7 = "";8 = "";} + +HPE Synergy Support - A [System.Collection.Hashtable] object, with Frame and Fabric Bay definitions. Accepted values are: + + * SEVC100F32 - Virtual Connect SE 40Gb F8 Module for Synergy + + * SEVC40f8 - Virtual Connect SE 40Gb F8 Module for Synergy + * SEVCFC or SEVC16GbFC - Virtual Connect SE 16Gb FC Module for Synergy + * SE20ILM - Synergy 20Gb Interconnect Link Module + * SE10ILM - Synergy 10Gb Interconnect Link Module + * SE12SAS - Synergy 12Gb SAS Connection Module + +$Bays = @{ Frame1 = @{Bay3 = "SEVC40f8"; Bay6 = "SE20ILM"}; Frame2 = @{Bay3 = "SE20ILM"; Bay6 = "SEVC40f8"} } + +Note: When configuring Synergy SAS Connection Module, no other device bays can be specified, and only a Single Frame can be configured. + + Hashtable + + Hashtable + + + + + DdnsDomainNameSuffix + + When enabled, Domain Name System (DNS) server will be updated automatically when either the IP address or hostname change for the interconnect module. + + String + + String + + + + + DownlinkSpeedMode + + Specify the port downlink speed to be configured for HPE Virtual Connect SE 100Gb F32 module for Synergy. + +Allowed values: + + * 25 + * 50 + +Default: 25 + + String + + String + + + + + EnableCutThroughSwitching + + Enables or disables the Cut-Through switching mode. When enabled, the switch starts forwarding the frame as soon as the switch has read the destination details in the packet header. When enabled, Pause flood protection is disabled. + +NOTE: This option is available for HPE Virtual Connect SE 100Gb F32 Module for HPE Synergy. + + Default value: Disabled + + Bool + + Bool + + False + + + EnableDdns + + When enabled, Domain Name System (DNS) server will be updated automatically when either the IP address or hostname change for the interconnect module. Must provide -DdnsDomainNameSuffix parameter. + + Bool + + Bool + + False + + + EnableEnhancedLLDPTLV + + When enabled, the enclosure name and serial number are encapsulated in the Chassis ID TLV LLDPDU transmitted by interconnect uplink ports. + +This parameter is only available for 2.00.07 or newer appliances. + + Boolean + + Boolean + + False + + + EnableFastMacCacheFailover + + When an uplink that was in standby mode becomes active, it can take several minutes for external Ethernet interconnects to recognize that the server blades can now be reached on this newly active connection. Enabling Fast MAC Cache Failover causes Ethernet packets to be transmitted on the newly active connection, which enables the external Ethernet interconnects to identify the new connection (and update their MAC caches). The transmission sequence is repeated a few times at the MAC refresh interval and completes in about 1 minute. + +Default value: Enabled + + Boolean + + Boolean + + True + + + EnableIgmpSnooping + + The IGMP snooping feature allows interconnects to monitor the IGMP IP multicast membership activities and configure hardware Layer 2 switching behavior of multicast traffic to optimize network resource usage. Currently, only IGMP v1 and v2 (RFC 2236) are supported. + +Default value: Disabled + + Boolean + + Boolean + + False + + + EnableLLDPTagging + + When enabled, tagged LLDP frames are transmitted over downlink ports to server hardware. The management IP address of the interconnect in the lowest numbered bay location in the logical interconnect will be advertised as the LLDP management address TLV. + +This parameter is only available for 2.00.07 or newer appliances. + + Boolean + + Boolean + + False + + + EnableNetworkLoopProtection + + Enables or disables network loop protection. + +Network loop protection: + +The loop protection feature enables detection of loops on downlink ports, which can be Flex-10 logical ports or physical ports. The feature applies when Device Control Channel (DCC) protocol is running on the Flex-10 port. If DCC is not available, the feature applies to the physical downlink port. + +Network loop protection uses two methods to detect loops: + +1. It periodically injects a special probe frame into the VC domain and monitors downlink ports for the looped back probe frame. If this special probe frame is detected on downlink ports, the port is considered to cause the loop condition. + +2. It monitors and intercepts common loop detection frames used in other switches. In network environments where the upstream switches send loop detection frames, the VC interconnects must ensure that any downlink loops do not cause these frames to be sent back to the uplink ports. Even though the probe frames ensure loops are detected, there is a small time window depending on the probe frame transmission interval in which the loop detection frames from the external switch might loop through down link ports and reach uplink ports. By intercepting the external loop detection frames on downlinks, the possibility of triggering loop protection on the upstream switch is eliminated. When network loop protection is enabled, VC interconnects intercept loop detection frames from various switch vendors, such as Cisco and HP Networking. + +When the network loop protection feature is enabled, any probe frame or other supported loop detection frame received on a downlink port is considered to be causing the network loop, and the port is disabled immediately until an administrative action is taken. The administrative action involves resolving the loop condition and clearing the loop protection error condition. The loop detected status on a port can be cleared by un-assigning all networks from the profile connect corresponding to the port in the loop detected state. + +The SNMP agent supports trap generation when a loop condition is detected or cleared. + +Default value: Enabled + + Boolean + + Boolean + + True + + + EnablePauseFloodProtection + + Enables or disables pause flood protection. + +Pause flood protection: + +Ethernet switch interfaces use pause frame based flow control mechanisms to control data flow. When a pause frame is received on a flow control enabled interface, the transmit operation is stopped for the pause duration specified in the pause frame. All other frames destined for this interface are queued up. If another pause frame is received before the previous pause timer expires, the pause timer is refreshed to the new pause duration value. If a steady stream of pause frames is received for extended periods of time, the transmit queue for that interface continues to grow until all queuing resources are exhausted. This condition severely impacts the switch operation on other interfaces. In addition, all protocol operations on the switch are impacted because of the inability to transmit protocol frames. Both port pause and priority-based pause frames can cause the same resource exhaustion condition. + +VC interconnects provide the ability to monitor server downlink ports for pause flood conditions and take protective action by disabling the port. The default polling interval is 10 seconds and is not customer configurable. The SNMP agent supports trap generation when a pause flood condition is detected or cleared. + +This feature operates at the physical port level. When a pause flood condition is detected on a Flex-10 physical port, all Flex-10 logical ports associated with physical ports are disabled. When the pause flood protection feature is enabled, this feature detects pause flood conditions on server downlink ports and disables the port. The port remains disabled until an administrative action is taken. The administrative action involves the following steps: + +1. Resolve the issue with the NIC on the server causing the continuous pause generation. This might include updating the NIC firmware and device drivers. + +Rebooting the server might not clear the pause flood condition if the cause of the pause flood condition is in the NIC firmware. In this case, the server must be completely disconnected from the power source to reset the NIC firmware. + +2. Re-enable the disabled ports on the VC interconnect modules. + +Default value: Enabled + + Boolean + + Boolean + + True + + + EnableStormControl + + Enables or disables the suppression of excessive inbound broadcast, multicast, or DLF (Destination Lookup Failure) packets when a threshold is reached. + +Default value: Disabled + + Bool + + Bool + + + + + FabricModuleType + + Specify the Synergy Fabric Module type the Logical Interconnect Group will be modeled for. Allowed value: + + * SEVC100F32 - Virtual Connect SE 100Gb F32 Module for Synergy + * SEVC40F8 - Virtual Connect SE 40Gb F8 Module for Synergy + * SEVCFC or SEVC16GbFC - Virtual Connect SE 16Gb FC Module for Synergy + * SEVC32FC - Virtual Connect SE 32Gb FC Module for Synergy + * SAS - Synergy 12Gb SAS Connection Module + + String + + String + + + + + FabricRedundancy + + Define the expected Synergy Fabric Interconnect Redundancy type. Allowed value: + + * HighlyAvailable + * Redundant + * ASide + * BSide + + String + + String + + Redundant + + + FrameCount + + The number of Synergy Frames to participate in the Logical Stack. + + Int32 + + Int32 + + 0 + + + IgmpIdleTimeoutInterval + + The Group Membership Interval value, as specified by the IGMP v2 specification (RFC 2236). +For optimum network resource usage, set the timeout interval to match your network"s multicast router settings. + +Data type: Numeric; unit of measure is seconds +Default value: 260 +Required: Yes, if IGMP snooping is enabled + + Int32 + + Int32 + + 260 + + + IgmpMulticastFloodPrevention + + By default, unregistered IGMP multicast traffic traversing VC Ethernet modules are flooded on the configured Ethernet network. The IGMP multicast flood prevention option prevents the flooding of unregistered multicast. The IGMP multicast flood prevention setting is effective only when IGMP snooping is enabled for all or a subset of VLANs. When enabled, unregistered multicast traffic from uplinks is dropped and traffic from the server ports is redirected to the active uplink port. IGMP multicast flood prevention is disabled by default. + +The IGMP multicast flood prevention option is supported only on the following interconnects: + * HPE Virtual Connect SE 100Gb F32 Module for HPE Synergy + * HPE Virtual Connect SE 40Gb F8 Module for HPE Synergy + + Bool + + Bool + + + + + IgmpProxyReporting + + IGMP snooping with proxy reporting or report suppression actively filters the IGMP packets reducing the load on the multicast router. The IGMP proxy reporting is effective only when IGMP snooping is enabled for all or a subset of VLANs. The IGMP proxy reporting is enabled by default. + +The IGMP proxy reporting option is supported only on the following interconnects: + * HPE Virtual Connect SE 100Gb F32 Module for HPE Synergy + * HPE Virtual Connect SE 40Gb F8 Module for HPE Synergy + +You can enable or disable the IGMP proxy reporting configuration on the Logical Interconnect or Logical Interconnect Groups screen. + * Enabled ($True) - The host reports are filtered to minimize traffic to the upstream multicast router. + * Disabled ($False) - The host reports are not filtered. All the host reports are forwarded to the upstream multicast router. + + Bool + + Bool + + + + + IgmpSnoopingConsistencyChecking + + Use to override the consistency checking for the policy. Allowed values: + + * Exact + * None + + String + + String + + + + + IgmpVLANs + + Specify values or range of VLAN IDs, from 1-4094, associated with networks defined in the logical interconnect. Use comma or hyphens as separator, for example: 10-15, 52, 100-200. + + String + + String + + + + + Import + + Specify JSON source file to create Logical Interconnect Group. + + Object + + Object + + + + + InterconnectBaySet + + Which Synergy Interconnect Bay Set ID will the interconnects be populated in. Allowed value: + + * 1 - Interconnect Bay set 1 & 4 + * 2 - Interconnect Bay set 2 & 5 + * 3 - Interconnect Bay set 3 & 6 + + Int32 + + Int32 + + 0 + + + InterconnectConsistencyChecking + + Use to indicate if the group policy will be tracked to with the deployed and configured resource. Allowed values: + + * None + * Exact + +Default: Exact + + String + + String + + + + + InternalNetworkConsistencyChecking + + Use to indicate if the group policy will be tracked to with the deployed and configured resource. Allowed values: + + * None + * Exact + +Default: Exact + + String + + String + + + + + InternalNetworks + + An Array collection of Networks that will be marked as Internal only. + + Array + + Array + + + + + LldpAddressingMode + + Specify the IP address format type to support. Allowed values: + + * IPv4 + * IPv6 + * IPv4AndIPv6 + + Boolean + + Boolean + + False + + + MacRefreshInterval + + The time interval at which MAC caches are refreshed + +Data type: Numeric; unit of measure is seconds +Default value: 5 + + Int32 + + Int32 + + 5 + + + Name + + The Logical Interconnect Group Name + + String + + String + + + + + QoSConsistencyChecking + + Use to indicate if the group policy will be tracked to with the deployed and configured resource. Allowed values: + + * None + * Exact + +Default: Exact + + String + + String + + + + + QosConfiguration + + A collection of QOS configurations that are created using the New-OVQosConfig helper Cmdlet. + + Object + + Object + + + + + SNMP + + SNMP Settings to define SNMP configruation. Use New-OVSnmpConfiguration and New-OVSnmpTrapDestination Cmdlets to create the necessary SNMP Configuration object. + + Object + + Object + + + + + SNMPConsistencyChecking + + Use to indicate if the group policy will be tracked to with the deployed and configured resource. Allowed values: + + * None + * Exact + +Default: Exact + + String + + String + + + + + Scope + + Provide an HPEOneView.Appliance.ScopeCollection resource object to initially associate with. Resource can also be added to scope using the Add-OVResourceToScope Cmdlet. + + HPEOneView.Appliance.ScopeCollection[] + + HPEOneView.Appliance.ScopeCollection[] + + False + + + SnmpV1 + + Specify the SNMP version type is SNMPv1. + + SwitchParameter + + SwitchParameter + + + + + SnmpV3 + + Specify the SNMP version type is SNMPv3. + + SwitchParameter + + SwitchParameter + + + + + SnmpV3User + + Provide the SNMPv3 user object from New-OVSnmpV3User. + + HPEOneView.Appliance.SnmpV3User + + HPEOneView.Appliance.SnmpV3User + + + + + StormControlPacketsPerSecondThreshold + + The Storm Control packet threshold at which traffic is suppressed. + +Valid range: 1-262143 packets per second + + Int + + Int + + + + + StormControlPollingInterval + + When enabling Storm Control, Specify a value between 5 and 30 seconds. + + Int + + Int + + + + + UplinkSet + + A collection of uplink sets from New-OVUplinkSet using the -Passthru parameter. + + Hashtable[] + + Hashtable[] + + + + + + + + + System.Collections.Hashtable + + + Hashtable containing Interconnect Bay layout and associated interconnect module + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + Logical Interconnect Group creation async task + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + $Dest1 = New-OVSnmpTrapDestination -Destination mysnmpserver.domain.local -Community MyR3adcommun1ty -SnmpFormat SNMPv1 -TrapSeverities critical,warning +$Dest2 = New-OVSnmpTrapDestination 10.44.120.9 MyR3adcommun1ty SNMPv1 critical,warning legacy "Other","PortStatus","PortThresholds" "Other","PortStatus" +$SnmpConfig = New-OVSnmpConfiguration -ReadCommunity MyR3adC0mmun1ty -AccessList "10.44.120.9/32","172.20.148.0/22" -TrapDestinations $Dest1,$Dest2 +$Bays = @{1 = "FlexFabric";2 = "FlexFabric"} +New-OVLogicalInterconnectGroup "FlexFabric Production 1" -bays $Bays -snmp $SnmpConfig + + Create a Logical Interconnect Group with VC FlexFabric modules in Bays 1 and 2, and SNMP Settings + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + $InternalNetworks = Get-OVNetwork -Name "My Internal VLANs*" +New-OVLogicalInterconnectGroup -Name "Synergy VC Prod" -FrameCount 3 -InterconnectBaySet 3 -FabricModuleType "SEVC40F8" -Bays @{Frame1 = @{Bay3 = "SEVC40f8" ; Bay6 = "SE20ILM"};Frame2 = @{Bay3 = "SE20ILM"; Bay6 = "SEVC40f8" };Frame3 = @{Bay3 = "SE20ILM"; Bay6 = "SE20ILM"}} -FabricRedundancy "HighlyAvailable" -InternalNetworks $InternalNetworks + + Create a Synergy Virtual Connect multi-Frame Logical Interconnect Group resource, using Bay Set 3 and Synergy 20Gb Satellite modules. + + + + + + + + + + -------------------------- EXAMPLE 3 -------------------------- + + + + New-OVLogicalInterconnectGroup -LIGName "Flex10/10D and FlexFabric Production 1" -bays @{1 = "Flex1010D";2 = "Flex1010D";3 = "FlexFabric";4 = "FlexFabric"} -enableIgmpSnooping $True -igmpIdleTimeoutInterval 300 -LoopProtect $True + + Create a Logical Interconnect Group with VC Flex10/10D in Bays 1 and 2, FlexFabric modules in Bays 3 and 4, Enable IGMP Snooping, IGMP Idle timeout and LoopProtect + + + + + + + + + + -------------------------- EXAMPLE 4 -------------------------- + + + + New-OVLogicalInterconnectGroup -Name "Synergy SAS Prod" -FrameCount 1 -InterconnectBaySet 1 -FabricModuleType "SAS" -Bays @{Frame1 = @{Bay1 = "SE12SAS" ; Bay4 = "SE12SAS"}} + + Create a Synergy SAS Logical Interconnect Group resource. + + + + + + + + + + -------------------------- EXAMPLE 5 -------------------------- + + + + New-OVLogicalInterconnectGroup -Name "Synergy VC FC Prod" -FrameCount 1 -InterconnectBaySet 2 -FabricModuleType "SEVCFC" -Bays @{Frame1 = @{Bay2 = "SEVC16GbFC" ; Bay5 = "SEVC16GbFC"}} + + Create a Synergy Virtual Connect Fibre Channel Logical Interconnect Group resource. + + + + + + + + + + -------------------------- EXAMPLE 6 -------------------------- + + + + New-OVLogicalInterconnectGroup -import c:\dir\mylig.json + + Create a Logical Interconnect Group by using a JSON formatted input file. + + + + + + + + + + + + + Get-OVLogicalInterconnectGroup + + + + Remove-OVLogicalInterconnectGroup + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/networking/new-ovlogicalinterconnectgroup + + + + + + + + New-OVLogicalJBOD + + Create a new HPE Synergy Logical JBOD resource. + + New + OVLogicalJBOD + + + A logical JBOD is a group of physical drives that are dynamically defined as virtual drives. Logical JBOD uses the drives from the drive enclosures that are installed in the device bays of the enclosure and are associated with a SAS logical interconnect. You can assign or unassign a logical JBOD to a server hardware through the server profile. + +If the logical drive settings in the server profile indicate that the data in the logical JBOD is to be retained when you delete the server profile, then the data is retained and you can assign this logical JBOD to a different server profile. + +Using this Cmdlet will create a new logical JBOD on the connected appliance. + +Considerations when configuring logical JBODs: + +* You can configure the available scopes to allow or restrict access to the drive enclosures. +* You can assign a logical JBOD to only one server profile. +* You can choose the drive enclosures that belong to the same SAS logical interconnect to create the logical JBOD. +* You can create a logical JBOD using homogenous drives like SAS SSD, SAS HDD, SATA SSD, or SATA HDD. You cannot mix different types of drives in a logical JBOD. +* You cannot add or remove drives to a logical JBOD after it is created. +* You can choose to either erase or retain the drive data when you delete the logical JBOD by setting using the -EraseDataOnDelete parameter during the creation of a logical JBOD. You can change the Erase on delete settings later, using the Set-OVLogicalJBOD Cmdlet, only if you set -EraseDataOnDelete to True during creation. + +Minimum required privileges: Infrastructure administrator, server administrator, server profile architect, server profile administrator + +* A logical interconnect group is created with the interconnect type Synergy 12 GB SAS Connection Module. +* An enclosure group is created with the above created logical interconnect group set as the Logical interconnect group. +* A logical enclosure is created. A SAS logical interconnect is created as part of creating the logical enclosure. +* If scopes have been defined, make sure that sufficient number of drive enclosures are mapped to the user scopes. + + + + + New-OVLogicalJBOD + + Name + + Provide a globally unique name for the logical JBOD resource. + + String + + + InputObject + + When attempting to create a logical JBOD, and not specifying the exact drives, you must provide either a SAS Logical Interconnect or HPE Synergy Frame resource. + + Object + + + DriveType + + When attempting to create a logical JBOD, specify the interface type for drives that will be used to build the logical drive. Supported values depend on the local storage capabilities of the selected server hardware type. Allowed value: + + * SAS + * SATA + * SASSSD + * SATASSD + * Auto + +NOTE: Auto is not supported when attempting to create an HPE Synergy D3940 Logical or JBOD disk. You must specify a disk technology type with -DriveType or -AvailableDriveType is used. + + String + + + Description + + Provide a description for the resource. + + String + + + NumberofDrives + + When attempting to create a logical JBOD, you can specify the min and max drive size for the system to locate drive availability. Specify the number of drives the system should allocate. + + Int + + + MinDriveSize + + When attempting to create a logical JBOD, you can specify the min and max drive size for the system to locate drive availability. Specify the minimum disk size in GB. + + Int + + + MaxDriveSize + + When attempting to create a logical JBOD, you can specify the min and max drive size for the system to locate drive availability. Specify the maximum disk size in GB. + + Int + + + EraseDataOnDelete + + If set to True, and drives support erase on delete option, the drive enclosure will erase the data on the drives. This operation will take time, as the drive will not be added back into the available pool until the erase operation finishes. + + Bool + + + Scope + + Provide an HPEOneView.Appliance.ScopeCollection resource object to initially associate with. Resource can also be added to scope using the Add-OVResourceToScope Cmdlet. + + Object + + + + New-OVLogicalJBOD + + Name + + Provide a globally unique name for the logical JBOD resource. + + String + + + Description + + Provide a description for the resource. + + String + + + Drives + + Provide the specific drives to assign to the logical JBOD. Use the Get-OVDriveEnclosureInventory Cmdlet to identify the drives you wish to allocate to the new logical JBOD resource. Drives can be allocated from different HPE Synergy drive enclosures, but must reside within the same SAS Logical Interconnect. + + HPEOneView.Storage.Drive[] + + + EraseDataOnDelete + + If set to True, and drives support erase on delete option, the drive enclosure will erase the data on the drives. This operation will take time, as the drive will not be added back into the available pool until the erase operation finishes. + + Bool + + + Scope + + Provide an HPEOneView.Appliance.ScopeCollection resource object to initially associate with. Resource can also be added to scope using the Add-OVResourceToScope Cmdlet. + + Object + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + New-OVLogicalJBOD + + Name + + Provide a globally unique name for the logical JBOD resource. + + String + + + InputObject + + When attempting to create a logical JBOD, and not specifying the exact drives, you must provide either a SAS Logical Interconnect or HPE Synergy Frame resource. + + Object + + + AvailableDriveType + + When attempting to create a logical JBOD, specify the availabe drive type from Get-OVAvailableDriveType. + + HPEOneView.Storage.AvailableDriveType + + + Description + + Provide a description for the resource. + + String + + + NumberofDrives + + When attempting to create a logical JBOD, you can specify the min and max drive size for the system to locate drive availability. Specify the number of drives the system should allocate. + + Int + + + EraseDataOnDelete + + If set to True, and drives support erase on delete option, the drive enclosure will erase the data on the drives. This operation will take time, as the drive will not be added back into the available pool until the erase operation finishes. + + Bool + + + Scope + + Provide an HPEOneView.Appliance.ScopeCollection resource object to initially associate with. Resource can also be added to scope using the Add-OVResourceToScope Cmdlet. + + Object + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + New-OVLogicalJBOD + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + AvailableDriveType + + When attempting to create a logical JBOD, specify the availabe drive type from Get-OVAvailableDriveType. + + HPEOneView.Storage.AvailableDriveType + + HPEOneView.Storage.AvailableDriveType + + + + + Description + + Provide a description for the resource. + + String + + String + + + + + DriveType + + When attempting to create a logical JBOD, specify the interface type for drives that will be used to build the logical drive. Supported values depend on the local storage capabilities of the selected server hardware type. Allowed value: + + * SAS + * SATA + * SASSSD + * SATASSD + * Auto + +NOTE: Auto is not supported when attempting to create an HPE Synergy D3940 Logical or JBOD disk. You must specify a disk technology type with -DriveType or -AvailableDriveType is used. + + String + + String + + + + + Drives + + Provide the specific drives to assign to the logical JBOD. Use the Get-OVDriveEnclosureInventory Cmdlet to identify the drives you wish to allocate to the new logical JBOD resource. Drives can be allocated from different HPE Synergy drive enclosures, but must reside within the same SAS Logical Interconnect. + + HPEOneView.Storage.Drive[] + + HPEOneView.Storage.Drive[] + + + + + EraseDataOnDelete + + If set to True, and drives support erase on delete option, the drive enclosure will erase the data on the drives. This operation will take time, as the drive will not be added back into the available pool until the erase operation finishes. + + Bool + + Bool + + + + + InputObject + + When attempting to create a logical JBOD, and not specifying the exact drives, you must provide either a SAS Logical Interconnect or HPE Synergy Frame resource. + + Object + + Object + + + + + MaxDriveSize + + When attempting to create a logical JBOD, you can specify the min and max drive size for the system to locate drive availability. Specify the maximum disk size in GB. + + Int + + Int + + + + + MinDriveSize + + When attempting to create a logical JBOD, you can specify the min and max drive size for the system to locate drive availability. Specify the minimum disk size in GB. + + Int + + Int + + + + + Name + + Provide a globally unique name for the logical JBOD resource. + + String + + String + + + + + NumberofDrives + + When attempting to create a logical JBOD, you can specify the min and max drive size for the system to locate drive availability. Specify the number of drives the system should allocate. + + Int + + Int + + + + + Scope + + Provide an HPEOneView.Appliance.ScopeCollection resource object to initially associate with. Resource can also be added to scope using the Add-OVResourceToScope Cmdlet. + + Object + + Object + + AllResourcesInScope + + + + + + + HPEOneView.Storage.AvailableDriveType + + + The available drive type from Get-OVAvailableDriveType + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + Asynchronous task resource to monitor. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + $CreatedLogicalJbod = New-OVLogicalJbod -Name "MyLogicalJBOD1" ` + -InputObject (Get-OVSasLogicalInterconnect -Name "LE1-SAS Synergy LIG-1" -ErrorAction Stop) ` + -DriveType "SAS" ` + -MinDriveSize 600 ` + -NumberOfDrives 5 ` + -EraseDataOnDelete $True | Wait-OVTaskComplete + + Create a new logical JBOD specifying a SAS logical interconnect, requesting a specific drive media type, minimum size and number of drives. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + $CreatedLogicalJbod = New-OVLogicalJbod -Name "MyLogicalJBOD1" ` + -InputObject (Get-OVDriveEnclosure -Name "Frame1, bay 1" -ErrorAction Stop) ` + -DriveType "SAS" ` + -MinDriveSize 600 ` + -NumberOfDrives 5 ` + -EraseDataOnDelete $True | Wait-OVTaskComplete + + Create a new logical JBOD specifying a SAS drive enclosure, requesting a specific drive media type, minimum size and number of drives. + + + + + + + + + + -------------------------- EXAMPLE 3 -------------------------- + + + + $Drives = Get-OVDriveEnclosureInventory -Available ` + -SasLogicalInterconnect (Get-OVSasLogicalInterconnect -Name "LE1-SAS Synergy LIG-1" -ErrorAction Stop) | ? Capacity -eq 1200 +$CreatedLogicalJbod = New-OVLogicalJbod -Name "MyLogicalJBOD2" ` + -Drives $Drives ` + -EraseDataOnDelete $True | Wait-OVTaskComplete + + Create a new logical JBOD with specific drive bays from a SAS logical interconnect. + + + + + + + + + + -------------------------- EXAMPLE 4 -------------------------- + + + + $Drives = Get-OVDriveEnclosureInventory -Available ` + -DriveEnclosure (Get-OVDriveEnclosure -Name "Frame1, bay 1" -ErrorAction Stop) | ? Capacity -eq 1200 +$CreatedLogicalJbod = New-OVLogicalJbod -Name "MyLogicalJBOD2" ` + -Drives $Drives ` + -EraseDataOnDelete $True | Wait-OVTaskComplete + + Create a new logical JBOD with specific drive bays from a specific drive enclosure. + + + + + + + + + + + + + Get-OVDriveEnclosure + + + + Get-OVDriveEnclosureInventory + + + + Get-OVLogicalJBOD + + + + Remove-OVLogicalJBOD + + + + Set-OVLogicalJBOD + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/storage/new-ovlogicaljbod + + + + + + + + New-OVLogicalSwitch + + Create a new Logical Switch resource. + + New + OVLogicalSwitch + + + A logical switch is added into HPE OneView as a managed or monitored logical switch. The logical switch can consist of a maximum of two physical top-of-rack switches (external to the c7000 enclosure) configured in a single stacking domain. It is based on a logical switch group configuration. If the logical switch transitions to an Inconsistent with group state (because of changes in either the logical switch or the logical switch group), update the logical switch configuration based on the logical switch group to return to a consistent state. + +You can create a logical switch with a maximum of two Cisco Nexus switches. When there are two Cisco Nexus switches in a logical switch, they are expected to be in a virtual port channel (vPC) environment. vPC must be configured on both switches, and they should belong to the same vPC domain. For information about supported switches, see the Hewlett Packard Enterprise Information Library for supportability information. + +Before you add a logical switch as managed, consider the following for Fabric Extender and Virtual Connect interconnects physically connected to the logical switch: + + * When only IPv4 Ethernet networks are assigned to an uplink set at creation time, the uplink set can be physically connected to any upstream switch in the logical switch. + * When an FCoE network is assigned to an uplink set at creation time, the uplink set is limited to single-homed physical connectivity and all uplink ports must connect to the same upstream switch in the logical switch. If a port is subsequently added to the uplink set with an FCoE network or an existing port in the uplink set is connected to a second upstream switch, that port is not available for configuration and an alert is generated. If a new port added to the uplink set is connected to the same switch as the other ports, that port is available to carry traffic and an alert is not generated. To change an uplink set from single-homed connectivity to multi-homed connectivity or vice-versa, the uplink set configuration must be deleted and re-created with the appropriate network assignments and physical configuration. + * Make sure that LLDP is enabled on the top-of-rack switch internal (downlink) ports where Virtual Connect interconnects under HPE OneView management are connected. + +Adding a logical switch as monitored enables HPE OneView to monitor the logical switch for operation status, collect statistics, and alert users to specific conditions and incompatibilities between the switch and Fabric Extender or Virtual Connect interconnect. In the monitored mode, deployment of the server profile connections is supported for HPE Virtual Connect interconnects but not for Fabric Extender (FEX) interconnects. + +Logical switch configuration guidelines + + * When Virtual Connect interconnects are connected to a logical switch, an uplink set cannot span multiple interconnects. This limitation is similar to FEX interconnects. However, multiple uplink sets are supported on a single Virtual Connect interconnect. + * When you enable or disable a top-of-rack switch internal port, the associated port on a FEX interconnect also displays the updated port status. + * When retrieving MAC addresses for FEX interconnects, only the entries that are associated with the managed FEX interconnects are displayed. + * If an FCoE network is assigned to an uplink set that is configured as dual-homed, (an invalid configuration), that FCoE network is not provisioned on the switch. Deployment of any server profile connection with this FCoE network will fail. + * When a logical switch is defined and configured with only a single physical switch, the uplink set associated with any FEX module connected to this logical switch is considered single-homed. Therefore, you can add an FCoE network to the uplink set even if the uplink set was initially created only with Ethernet networks. Deployment of any server profile connection with this FCoE network will succeed. + * For server profiles created for server ports connected to FEX interconnects, Ethernet networks are only supported on physical function a, and FCoE networks are only supported on physical function b at the server port. When both physical functions have connections defined, traffic is split evenly across both ports. + * If HPE OneView cannot log in to the switch, a critical alert is generated. Prevent any event on the switch that might trigger switch configuration; otherwise, the switch transitions to ConfigError state and you must reapply the configuration on the associated logical interconnects to recover. + * If HPE OneView is unable to claim a member switch of the logical switch when the operational mode of the logical switch is Managed, the operating state of the switch will transition to Added with Error. In this case, the Message of the Day (MOTD) banner on the switch will indicate that the switch is currently claimed by another HPE OneView appliance and the message "This switch is being controlled by OneView Domain, Appliance ID: {}" displays. You should remove the logical switch from that HPE OneView appliance, and then perform a refresh on the logical switch from the current HPE OneView appliance to re-initiate the claim operation. + * HPE OneView does not fully automate configuration of FCoE connectivity on the switch specified in the logical switch. For each FCoE network specified in the uplink set, HPE OneView only provisions the VLAN for that network on the switch. Network administrators must provision additional configuration for FCoE connectivity manually on the switch in addition to what HPE OneView provisions. + * To deploy server profile connections to a FEX interconnect, HPE OneView provisions the virtual Fibre Channel interface (VFC), VFC binding to FEX downlink port, and VSAN interface assignment on the switch. + * For the deployment of server profile connections for a Virtual Connect interconnect, the Network administrator must configure the virtual Fibre Channel interface (vFC), VFC binding to server port, and VSAN interface assignment binding manually. + * When a Nexus switch expansion module is removed, a warning alert is generated unless the module is powered off. + * HPE OneView can detect configuration changes that occur on the switches specified in the logical switch when it no longer matches the configuration that HPE OneView provisions. Warning alerts are generated. Administrators can correct the configuration manually or reapply the configuration on the associated logical interconnects to recover. + +Minimum required privileges: Infrastructure administrator or Network administrator + + + + + New-OVLogicalSwitch + + Name + + Name of the Logical Switch resource. Supports wildcard * character. + + String + + + LogicalSwitchGroup + + Provide the Logical Switch Group policy object. + + Object + + + Managed + + Specify if the Logical Switch will be a Managed resource. + + SwitchParameter + + + Switch1Address + + IP Address or FQDN of first Switch resource. + + String + + + SshUserName + + The SSH account name. + + String + + + SshPassword + + Password of the SSH User. Either [System.String] or [System.Security.SecureString] values are supported. + + Object + + + SnmpCommunity + + Specify the SNMPv1 Community name. This parameter is not used if needing to configure SNMPv3. + + String + + + Switch2Address + + IP Address or FQDN of first Switch resource. + + String + + + SnmpPort + + The UDP port SNMP is configured to listen on the target Switch resource. + + Int + + + SnmpV1 + + Specify if SNMPv1 is available. Otherwise, use the -SNMPv3 switch parameter. + + SwitchParameter + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + + + New-OVLogicalSwitch + + Name + + Name of the Logical Switch resource. Supports wildcard * character. + + String + + + LogicalSwitchGroup + + Provide the Logical Switch Group policy object. + + Object + + + Monitored + + Specify if the Logical Switch will be a Monintored resource. + + SwitchParameter + + + Switch1Address + + IP Address or FQDN of first Switch resource. + + String + + + SshUserName + + The SSH account name. + + String + + + SshPassword + + Password of the SSH User. Either [System.String] or [System.Security.SecureString] values are supported. + + Object + + + Switch2Address + + IP Address or FQDN of first Switch resource. + + String + + + SnmpPort + + The UDP port SNMP is configured to listen on the target Switch resource. + + Int + + + SnmpV3 + + Specify if SNMPv3 is available. Otherwise, use the -SNMPv1 switch parameter. + + SwitchParameter + + + SnmpUserName + + Specify the SNMPv3 Username. + + String + + + SnmpAuthLevel + + Defines the security levels supported by SNMPv3: * Auth - Communication with authorization and without privacy. Messages are authenticated but not encrypted. * AuthAndPrive - Communication with authorization as well as privacy. Messages are authenticated as well as encrypted. + + String + + + SnmpAuthProtocol + + The protocol used for Authentication are either MD5 (Message Digest 5) or SHA (Secure Hash Algorithm). + + String + + + SnmpAuthPassword + + SNMPv3 Authorization Password. Either [System.String] or [System.Security.SecureString] values are supported. + + Object + + + SnmpPrivProtocol + + The protocols used to encrypt the messages are Data Encryption Standard (DES56) or Advanced Encryption Standard (AES128). + + String + + + SnmpPrivPassword + + SNMPv3 Privacy Password. Either [System.String] or [System.Security.SecureString] values are supported. + + Object + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + + + New-OVLogicalSwitch + + Name + + Name of the Logical Switch resource. Supports wildcard * character. + + String + + + LogicalSwitchGroup + + Provide the Logical Switch Group policy object. + + Object + + + Managed + + Specify if the Logical Switch will be a Managed resource. + + SwitchParameter + + + Switch1Address + + IP Address or FQDN of first Switch resource. + + String + + + SshUserName + + The SSH account name. + + String + + + SshPassword + + Password of the SSH User. Either [System.String] or [System.Security.SecureString] values are supported. + + Object + + + Switch2Address + + IP Address or FQDN of first Switch resource. + + String + + + SnmpPort + + The UDP port SNMP is configured to listen on the target Switch resource. + + Int + + + SnmpV3 + + Specify if SNMPv3 is available. Otherwise, use the -SNMPv1 switch parameter. + + SwitchParameter + + + SnmpUserName + + Specify the SNMPv3 Username. + + String + + + SnmpAuthLevel + + Defines the security levels supported by SNMPv3: * Auth - Communication with authorization and without privacy. Messages are authenticated but not encrypted. * AuthAndPrive - Communication with authorization as well as privacy. Messages are authenticated as well as encrypted. + + String + + + SnmpAuthProtocol + + The protocol used for Authentication are either MD5 (Message Digest 5) or SHA (Secure Hash Algorithm). + + String + + + SnmpAuthPassword + + SNMPv3 Authorization Password. Either [System.String] or [System.Security.SecureString] values are supported. + + Object + + + SnmpPrivProtocol + + The protocols used to encrypt the messages are Data Encryption Standard (DES56) or Advanced Encryption Standard (AES128). + + String + + + SnmpPrivPassword + + SNMPv3 Privacy Password. Either [System.String] or [System.Security.SecureString] values are supported. + + Object + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + + + New-OVLogicalSwitch + + Name + + Name of the Logical Switch resource. Supports wildcard * character. + + String + + + LogicalSwitchGroup + + Provide the Logical Switch Group policy object. + + Object + + + Monitored + + Specify if the Logical Switch will be a Monintored resource. + + SwitchParameter + + + Switch1Address + + IP Address or FQDN of first Switch resource. + + String + + + SshUserName + + The SSH account name. + + String + + + SshPassword + + Password of the SSH User. Either [System.String] or [System.Security.SecureString] values are supported. + + Object + + + SnmpCommunity + + Specify the SNMPv1 Community name. This parameter is not used if needing to configure SNMPv3. + + String + + + Switch2Address + + IP Address or FQDN of first Switch resource. + + String + + + SnmpPort + + The UDP port SNMP is configured to listen on the target Switch resource. + + Int + + + SnmpV1 + + Specify if SNMPv1 is available. Otherwise, use the -SNMPv3 switch parameter. + + SwitchParameter + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + SwitchParameter + + + + + LogicalSwitchGroup + + Provide the Logical Switch Group policy object. + + Object + + Object + + + + + Managed + + Specify if the Logical Switch will be a Managed resource. + + SwitchParameter + + SwitchParameter + + + + + Monitored + + Specify if the Logical Switch will be a Monintored resource. + + SwitchParameter + + SwitchParameter + + + + + Name + + Name of the Logical Switch resource. Supports wildcard * character. + + String + + String + + + + + SnmpAuthLevel + + Defines the security levels supported by SNMPv3: * Auth - Communication with authorization and without privacy. Messages are authenticated but not encrypted. * AuthAndPrive - Communication with authorization as well as privacy. Messages are authenticated as well as encrypted. + + String + + String + + + + + SnmpAuthPassword + + SNMPv3 Authorization Password. Either [System.String] or [System.Security.SecureString] values are supported. + + Object + + Object + + + + + SnmpAuthProtocol + + The protocol used for Authentication are either MD5 (Message Digest 5) or SHA (Secure Hash Algorithm). + + String + + String + + + + + SnmpCommunity + + Specify the SNMPv1 Community name. This parameter is not used if needing to configure SNMPv3. + + String + + String + + + + + SnmpPort + + The UDP port SNMP is configured to listen on the target Switch resource. + + Int + + Int + + 161 + + + SnmpPrivPassword + + SNMPv3 Privacy Password. Either [System.String] or [System.Security.SecureString] values are supported. + + Object + + Object + + + + + SnmpPrivProtocol + + The protocols used to encrypt the messages are Data Encryption Standard (DES56) or Advanced Encryption Standard (AES128). + + String + + String + + + + + SnmpUserName + + Specify the SNMPv3 Username. + + String + + String + + + + + SnmpV1 + + Specify if SNMPv1 is available. Otherwise, use the -SNMPv3 switch parameter. + + SwitchParameter + + SwitchParameter + + + + + SnmpV3 + + Specify if SNMPv3 is available. Otherwise, use the -SNMPv1 switch parameter. + + SwitchParameter + + SwitchParameter + + + + + SshPassword + + Password of the SSH User. Either [System.String] or [System.Security.SecureString] values are supported. + + Object + + Object + + + + + SshUserName + + The SSH account name. + + String + + String + + + + + Switch1Address + + IP Address or FQDN of first Switch resource. + + String + + String + + + + + Switch2Address + + IP Address or FQDN of first Switch resource. + + String + + String + + + + + + + + + HPEOneView.Networking.LogicalSwitchGroup [System.Management.Automation.PSCustomObject] + + + Logical Switch Group resource. + + + + + + + + HPEOneView.Networking.LogicalSwitch [System.Management.Automation.PSCustomObject] + + + + Single Logical Switch resource. + + + + + System.Collections.ArrayList <HPEOneView.Networking.LogicalSwitch> + + + + Collection of Logical Switch resources. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + $LogicalSwitchGroup = Get-OVLogicalSwitchGroup -Name "My Nexus 5500 Switch Group Policy" +$SshPassword = ConvertTo-SecureString -String "MyPassword" -AsPlainText -Force +New-OVLogicalSwitch -Name "My Logical Switch 1" -LogicalSwitchGroup $LogicalSwitchGroup -Monitored -Switch1Address 10.1.1.1 -Switch2Address 10.1.1.2 -SshUserName admin -SshPassword $SshPassword -Snmpv1 -SnmpCommunity MyCommunity + + Create the "My Logical Switch 1" as a Monitored Logical Switch resource. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + $LogicalSwitchGroup = Get-OVLogicalSwitchGroup -Name "My Nexus 6001 Switch Group Policy" +$Password = ConvertTo-SecureString -String "MyPassword" -AsPlainText -Force +$Results = New-OVLogicalSwitch -Name "My Logical Switch 2" -LogicalSwitchGroup $LogicalSwitchGroup -Managed -Switch1Address 10.1.2.1 -Switch2Address 10.1.2.2 -SshUserName admin-SshPassword $Password -Snmpv3 -SnmpUserName SnmpV3User -SnmpAuthLevel AuthAndPriv -SnmpAuthProtocol SHA -SnmpAuthPassword $Password -SnmpPrivProtocol aes128 -SnmpPrivPassword $Password -Async + + Create the "My Logical Switch 2" as a Managed Logical Switch resource. + + + + + + + + + + + + + Get-OVLogicalSwitch + + + + Get-OVLogicalSwitchGroup + + + + New-OVLogicalSwitchGroup + + + + Remove-OVLogicalSwitch + + + + Remove-OVLogicalSwitchGroup + + + + Update-OVLogicalSwitch + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/networking/new-ovlogicalswitch + + + + + + + + New-OVLogicalSwitchGroup + + Create a new Logical Switch Group resource. + + New + OVLogicalSwitchGroup + + + The logical switch group is a template for creating logical switches. Logical switches are an aggregation of up to two physical top-of-rack switches. Once constructed from a logical switch group, a logical switch continues to be associated with its logical switch group. Any change in consistency between the logical switch group and its associated logical switches is monitored and made visible on the associated logical switch screen in HPE OneView. This Cmdlet will help create a Logical Switch Group resources. Use Get-OVSwitchType to identify which switch family and models are supported. Please refer to either Get-OVSwitchType values, or the HPE OneView Support Matrix for which specific models are supported. Minimum required privileges: Infrastructure administrator or Network administrator + + + + + New-OVLogicalSwitchGroup + + Name + + The Logical Switch Group resource Name. + + String + + + SwitchType + + The Switch Type resource from Get-OVSwitchType. + + HPEOneView.Networking.SwitchType + + + NumberOfSwitches + + The maximum number of switches supported in the Logical Switch Group. Only 1 or 2 are allowed. + + Int + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + SwitchParameter + + + + + Name + + The Logical Switch Group resource Name. + + String + + String + + + + + NumberOfSwitches + + The maximum number of switches supported in the Logical Switch Group. Only 1 or 2 are allowed. + + Int + + Int + + 1 + + + SwitchType + + The Switch Type resource from Get-OVSwitchType. + + HPEOneView.Networking.SwitchType + + HPEOneView.Networking.SwitchType + + + + + + + + + HPEOneView.Networking.SwitchType + + + Switch Type resource from Get-OVSwitchType. + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + The async task resource object to monitor (if -Async was used) or results. + + + + + System.Collections.ArrayList <HPEOneView.Appliance.TaskResource> + + + + Collection of remove Logical Switch async task resources. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVSwitchType -Name "Cisco Nexus 56xx" | New-OVLogicalSwitchGroup -Name "My Logical Switch Group Policy 1" -NumberOfSwitches 2 + + Create a Logical Switch Group fro the "Cisco Nexus 5600" series, specifying 2 expected switches. + + + + + + + + + + + + + Get-OVLogicalSwitchGroup + + + + Remove-OVLogicalSwitchGroup + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/networking/new-ovlogicalswitchgroup + + + + + + + + New-OVNetwork + + Creates one or more new Ethernet or Fibre-Channel networks on the appliance. + + New + OVNetwork + + + Create a new network resource, including its default connection type. Network definitions can be supplied as direct Cmdlet parameters or as input from a file containing the network definition in JSON format. + +To create an Ethernet Network for Image Streamer, use the following paramters: + + * Name + * VlanType = Untagged + * IPv4Subnet Object + * Purpose = Management + + + + + New-OVNetwork + + Name + + Required object to provide a display name for the network being created. +If specifying the -VlanRange parameter, this will become the Nework Name Prefix (i.e. "VLAN" will become "VLAN-[vlanid]".) + + String + + + Type + + Required value that specifies the type of Network Resource to create. Allowed values are: + + * Ethernet + * FC + * FibreChannel + * FCoE + + String + + + VlanId + + The Virtual LAN (VLAN) identification number assigned to the network. The VLAN ID must be unique. The VLAN ID cannot be changed once the network has been created. + +When creating an Ethernet Network on an HPE Synergy Composer, Vlan ID 1 is not a valid ID. The allowed range is 2-4095. + + Int32 + + + NetworkSet + + Specify one or more network set objects the network should be added to during creation from Get-OVNetworkSet. + + Object[] + + + Subnet + + An IPv4 Subnet Object that will be associated with a specific Ethernet Network and VLAN. + + Object + + + VLANType + + The type of VLAN configuration for the Ethernet Network. This setting is only applicable for the Uplink Set configuration, and not the Network Set it could be assigned to. Accepted values are + + * Tagged + * Tunnel + * Access + +Default value is Tagged. + + String + + + Purpose + + A description of the network"s role within the logical interconnect. Accepted values in string format are: + + * General + * Management + * VMMigration + * FaultTolerance + * iSCSI + + String + + + SmartLink + + Default value is TRUE. + + Boolean + + + PrivateNetwork + + Default value is FALSE. + + Boolean + + + TypicalBandwidth + + Preferred amount of bandwidth to assign, specified in Mbps. Default value is 2500. + + Int32 + + + MaximumBandwidth + + Maximum amount of bandwidth to assign, specified in Mbps. Default value is 10000. + + Int32 + + + Scope + + Provide an HPEOneView.Appliance.ScopeCollection resource object to initially associate with. Resource can also be added to scope using the Add-OVResourceToScope Cmdlet. + + HPEOneView.Appliance.ScopeCollection[] + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + + + New-OVNetwork + + Name + + Required object to provide a display name for the network being created. +If specifying the -VlanRange parameter, this will become the Nework Name Prefix (i.e. "VLAN" will become "VLAN-[vlanid]".) + + String + + + VlanRange + + VLAN Range of networks to create. Can be consecutive, non-consecutive or a combination of both. + +e.g. -VLANRange "10-90,94,96,200-210" + + String + + + Type + + Required value that specifies the type of Network Resource to create. Allowed values are: + + * Ethernet + * FC + * FibreChannel + * FCoE + + String + + + NetworkSet + + Specify one or more network set objects the network should be added to during creation from Get-OVNetworkSet. + + Object[] + + + VLANType + + The type of VLAN configuration for the Ethernet Network. This setting is only applicable for the Uplink Set configuration, and not the Network Set it could be assigned to. Accepted values are + + * Tagged + * Tunnel + * Access + +Default value is Tagged. + + String + + + Purpose + + A description of the network"s role within the logical interconnect. Accepted values in string format are: + + * General + * Management + * VMMigration + * FaultTolerance + * iSCSI + + String + + + SmartLink + + Default value is TRUE. + + Boolean + + + PrivateNetwork + + Default value is FALSE. + + Boolean + + + TypicalBandwidth + + Preferred amount of bandwidth to assign, specified in Mbps. Default value is 2500. + + Int32 + + + MaximumBandwidth + + Maximum amount of bandwidth to assign, specified in Mbps. Default value is 10000. + + Int32 + + + Scope + + Provide an HPEOneView.Appliance.ScopeCollection resource object to initially associate with. Resource can also be added to scope using the Add-OVResourceToScope Cmdlet. + + HPEOneView.Appliance.ScopeCollection[] + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + + + New-OVNetwork + + Name + + Required object to provide a display name for the network being created. +If specifying the -VlanRange parameter, this will become the Nework Name Prefix (i.e. "VLAN" will become "VLAN-[vlanid]".) + + String + + + Type + + Required value that specifies the type of Network Resource to create. Allowed values are: + + * Ethernet + * FC + * FibreChannel + * FCoE + + String + + + VlanId + + The Virtual LAN (VLAN) identification number assigned to the network. The VLAN ID must be unique. The VLAN ID cannot be changed once the network has been created. + +When creating an Ethernet Network on an HPE Synergy Composer, Vlan ID 1 is not a valid ID. The allowed range is 2-4095. + + Int32 + + + TypicalBandwidth + + Preferred amount of bandwidth to assign, specified in Mbps. Default value is 2500. + + Int32 + + + MaximumBandwidth + + Maximum amount of bandwidth to assign, specified in Mbps. Default value is 10000. + + Int32 + + + ManagedSan + + Managed SAN Object or Name. + + Object + + + Scope + + Provide an HPEOneView.Appliance.ScopeCollection resource object to initially associate with. Resource can also be added to scope using the Add-OVResourceToScope Cmdlet. + + HPEOneView.Appliance.ScopeCollection[] + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + + + New-OVNetwork + + Name + + Required object to provide a display name for the network being created. +If specifying the -VlanRange parameter, this will become the Nework Name Prefix (i.e. "VLAN" will become "VLAN-[vlanid]".) + + String + + + Type + + Required value that specifies the type of Network Resource to create. Allowed values are: + + * Ethernet + * FC + * FibreChannel + * FCoE + + String + + + TypicalBandwidth + + Preferred amount of bandwidth to assign, specified in Mbps. Default value is 2500. + + Int32 + + + MaximumBandwidth + + Maximum amount of bandwidth to assign, specified in Mbps. Default value is 10000. + + Int32 + + + LinkStabilityTime + + The time in seconds the appliance waits before reconnecting to a link that was previously offline (Login redistribution). This interval prevents connection loss due to reconnecting to a link that is unstable (going online and offline repeatedly). + + Int32 + + + AutoLoginRedistribution + + Used for login balancing when logins are not distributed evenly over the Fibre Channel links (for example, when an uplink that was down becomes available). + +True: Login redistribution is initiated automatically when the link stability time expires. +False: Login redistribution must be initiated manually. + +This parameter is not applicable for Direct Attach Fabric Types. + + Boolean + + + FabricType + + Valid values are DirectAttach and FabricAttach. Defaults to FabricAttach + + String + + + ManagedSan + + Managed SAN Object or Name. + + Object + + + Scope + + Provide an HPEOneView.Appliance.ScopeCollection resource object to initially associate with. Resource can also be added to scope using the Add-OVResourceToScope Cmdlet. + + HPEOneView.Appliance.ScopeCollection[] + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + + + New-OVNetwork + + ImportFile + + Full path and file name of a JSON formatted input file containing network definitions. + + String + + + Scope + + Provide an HPEOneView.Appliance.ScopeCollection resource object to initially associate with. Resource can also be added to scope using the Add-OVResourceToScope Cmdlet. + + HPEOneView.Appliance.ScopeCollection[] + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + SwitchParameter + + + + + AutoLoginRedistribution + + Used for login balancing when logins are not distributed evenly over the Fibre Channel links (for example, when an uplink that was down becomes available). + +True: Login redistribution is initiated automatically when the link stability time expires. +False: Login redistribution must be initiated manually. + +This parameter is not applicable for Direct Attach Fabric Types. + + Boolean + + Boolean + + False + + + FabricType + + Valid values are DirectAttach and FabricAttach. Defaults to FabricAttach + + String + + String + + FabricAttach + + + ImportFile + + Full path and file name of a JSON formatted input file containing network definitions. + + String + + String + + + + + LinkStabilityTime + + The time in seconds the appliance waits before reconnecting to a link that was previously offline (Login redistribution). This interval prevents connection loss due to reconnecting to a link that is unstable (going online and offline repeatedly). + + Int32 + + Int32 + + 30 + + + ManagedSan + + Managed SAN Object or Name. + + Object + + Object + + + + + MaximumBandwidth + + Maximum amount of bandwidth to assign, specified in Mbps. Default value is 10000. + + Int32 + + Int32 + + 20000 + + + Name + + Required object to provide a display name for the network being created. +If specifying the -VlanRange parameter, this will become the Nework Name Prefix (i.e. "VLAN" will become "VLAN-[vlanid]".) + + String + + String + + + + + NetworkSet + + Specify one or more network set objects the network should be added to during creation from Get-OVNetworkSet. + + Object[] + + Object[] + + + + + PrivateNetwork + + Default value is FALSE. + + Boolean + + Boolean + + False + + + Purpose + + A description of the network"s role within the logical interconnect. Accepted values in string format are: + + * General + * Management + * VMMigration + * FaultTolerance + * iSCSI + + String + + String + + General + + + Scope + + Provide an HPEOneView.Appliance.ScopeCollection resource object to initially associate with. Resource can also be added to scope using the Add-OVResourceToScope Cmdlet. + + HPEOneView.Appliance.ScopeCollection[] + + HPEOneView.Appliance.ScopeCollection[] + + False + + + SmartLink + + Default value is TRUE. + + Boolean + + Boolean + + True + + + Subnet + + An IPv4 Subnet Object that will be associated with a specific Ethernet Network and VLAN. + + Object + + Object + + + + + Type + + Required value that specifies the type of Network Resource to create. Allowed values are: + + * Ethernet + * FC + * FibreChannel + * FCoE + + String + + String + + Ethernet + + + TypicalBandwidth + + Preferred amount of bandwidth to assign, specified in Mbps. Default value is 2500. + + Int32 + + Int32 + + 2500 + + + VLANType + + The type of VLAN configuration for the Ethernet Network. This setting is only applicable for the Uplink Set configuration, and not the Network Set it could be assigned to. Accepted values are + + * Tagged + * Tunnel + * Access + +Default value is Tagged. + + String + + String + + Tagged + + + VlanId + + The Virtual LAN (VLAN) identification number assigned to the network. The VLAN ID must be unique. The VLAN ID cannot be changed once the network has been created. + +When creating an Ethernet Network on an HPE Synergy Composer, Vlan ID 1 is not a valid ID. The allowed range is 2-4095. + + Int32 + + Int32 + + 0 + + + VlanRange + + VLAN Range of networks to create. Can be consecutive, non-consecutive or a combination of both. + +e.g. -VLANRange "10-90,94,96,200-210" + + String + + String + + + + + + + + + HPEOneView.Storage.ManagedSan [System.Management.Automation.PSCustomObject] + + + ManagedSan resource object to be assigned to a FC or FCoE Network + + + + + + + + System.Collections.ArrayList + + + + A custom status object or array of objects containing the following PsCustomObject keys: * Name - name of the network object attempted to be created * Status - status of the creation attempt (Failed for http error return; Complete if a task object is returned) * Description - Task object or Error object * Exception - System.Management.Automation.ErrorRecord object of the error generated + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + New-OVNetwork -type Ethernet -name MyNetwork1 -vlanid 100 -typicalbandwidth 5000 -maximumbandwidth 7500 + + Creates new Ethernet Network type, with "MyNetwork1" name, VLAN ID 100, and specifies preferred bandwidth to 5Gb/s and max to 7.5Gb/s. Network will be created on all connected appliances. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + New-OVNetwork -type Ethernet -name MyNetwork1 -vlanid 100 -typicalbandwidth 5000 -maximumbandwidth 7500 -Appliance MyAppliance + + Creates new Ethernet Network type, with "MyNetwork1" name, VLAN ID 100, an dspecifies preferred bandwidth to 5Gb/s and max to 7.5Gb/s to be created on "MyAppliance" + + + + + + + + + + -------------------------- EXAMPLE 3 -------------------------- + + + + $Connection1 = Connect-OVMgmt MyAppliance1.domain.local Administrator MyPassword +$Connection2 = Connect-OVMgmt MyAppliance2.domain.local Administrator MyPassword +New-OVNetwork -type Ethernet -name MyNetwork1 -vlanid 100 -typicalbandwidth 5000 -maximumbandwidth 7500 -Appliance $Connection1,$Connection2 + + Creates new Ethernet Network type, with "MyNetwork1" name, VLAN ID 100, an dspecifies preferred bandwidth to 5Gb/s and max to 7.5Gb/s to be created on "MyAppliance1" and "MyAppliance2" using the connection objects. + + + + + + + + + + -------------------------- EXAMPLE 4 -------------------------- + + + + 10,20,30,40,50,60 | % { New-OVNetwork -type Ethernet -name "VLAN $_" -vlanid $_ } + + Create multiple Ethernet Networks. + + + + + + + + + + -------------------------- EXAMPLE 5 -------------------------- + + + + 10,20,30,40,50,60 | % { New-OVNetwork -type Ethernet -name "VLAN $_-A" -vlanid $_ } +10,20,30,40,50,60 | % { New-OVNetwork -type Ethernet -name "VLAN $_-B" -vlanid $_ } + + Create Ethernet Networks for an Active/Active configuration. + + + + + + + + + + -------------------------- EXAMPLE 6 -------------------------- + + + + New-OVNetwork -name "VLAN A Side" -vlanRange "10,20,30,40,50,60" +New-OVNetwork -name "VLAN B Side" -VlanRange "10,20,30,40,50,60" + + Create Ethernet Networks for an Active/Active configuration using the -VlanRange parameter. + + + + + + + + + + -------------------------- EXAMPLE 7 -------------------------- + + + + New-OVNetwork -type FC -name "Fabric A" -typicalBandwidth 2000 -maximumBandwidth 4000 + + Creates a new FC network type, called "Fabric A" and preferred bandwidth is 2Gb/s and max is 4Gb/s. + + + + + + + + + + -------------------------- EXAMPLE 8 -------------------------- + + + + New-OVNetwork -type FC -name "Fabric A" -typicalBandwidth 2000 -maximumBandwidth 4000 -fabricType FabricAttach -managedSAN Fabric_A + + Creates a new FC network type, called "Fabric A", preferred bandwidth is 2Gb/s and max is 4Gb/s, and is associated with a Managed SAN Fabric. + + + + + + + + + + -------------------------- EXAMPLE 9 -------------------------- + + + + New-OVNetwork -importFile "c:\OneViewInput\myNewNets.json" + + Creates the network(s) defined in the input file myNewNets.json + + + + + + + + + + + + + Get-OVNetwork + + + + Get-OVNetworkSet + + + + New-OVNetworkSet + + + + Remove-OVNetwork + + + + Remove-OVNetworkSet + + + + Set-OVNetwork + + + + Set-OVNetworkSet + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/networking/new-ovnetwork + + + + + + + + New-OVNetworkSet + + Create a new Network Set. + + New + OVNetworkSet + + + A network set is a group of Ethernet L2/L3 networks assigned to one or more connections, giving each single connection access to multiple networks. A network set is a shared resource available to all logical interconnects. It is directly associated with a connection template governing the bandwidth permitted to connections that use the network set. + +Within a network set, all network frames are exchanged over the connection with their 802.1Q VLAN ID in place (in other words, network traffic is tagged with its VLAN ID). However, there is one exception to this rule: one network within the network set can be designated as the 'nativeNetwork'. The 802.1Q VLAN ID is removed from 'nativeNetwork' traffic egressing the interconnect downlink (in other words, 'nativeNetwork' traffic is untagged). This allows a single connection to support multiple tagged networks plus a single untagged network over the same downlink. + +All Ethernet networks in a network set must have unique VLAN IDs. + +This Cmdlet will create a new Network Set resource. + +Minimum required permissions: Infrastructure administrator, Network administrator + + + + + New-OVNetworkSet + + Name + + The name of the new Network Set resource to be created. + + String + + + Networks + + Ethernet Network Name(s), URI(")s or Resource Object(s). + + Object + + + UntaggedNetwork + + Network (from the above list) to be considered the "native" network in this set. Traffic on this network will leave the Virtual Connect downlink port untagged. When untagged traffic is received on this port, it will be mapped to this network. + + Object + + + TypicalBandwidth + + Optional preferred amount of bandwidth to assign, specified in Mbps. Default value is 2500. + + Int32 + + + MaximumBandwidth + + Optional maximum amount of bandwidth to assign, specified in Mbps. Default value is 10000. + + Int32 + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. + + Object + + + Large + + A "Regular" network set may contain up to 162 networks. "Large" network sets can contain up to 4000 networks and can only be used by server profile template connections or server profile connections assigned to rackmount or HPE Synergy server hardware. + +By default, "Regular" Network Sets are created. + + SwitchParameter + + + + + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Large + + A "Regular" network set may contain up to 162 networks. "Large" network sets can contain up to 4000 networks and can only be used by server profile template connections or server profile connections assigned to rackmount or HPE Synergy server hardware. + +By default, "Regular" Network Sets are created. + + SwitchParameter + + SwitchParameter + + + + + MaximumBandwidth + + Optional maximum amount of bandwidth to assign, specified in Mbps. Default value is 10000. + + Int32 + + Int32 + + 10000 + + + Name + + The name of the new Network Set resource to be created. + + String + + String + + + + + Networks + + Ethernet Network Name(s), URI(")s or Resource Object(s). + + Object + + Object + + + + + TypicalBandwidth + + Optional preferred amount of bandwidth to assign, specified in Mbps. Default value is 2500. + + Int32 + + Int32 + + 2500 + + + UntaggedNetwork + + Network (from the above list) to be considered the "native" network in this set. Traffic on this network will leave the Virtual Connect downlink port untagged. When untagged traffic is received on this port, it will be mapped to this network. + + Object + + Object + + + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + System.Collections.ArrayList + + + + If bandwidth settings are specified, the newly created Network Set resource is returned + + + + + System.Management.Automation.PSCustomObject + + + + If no bandwidth settings specified, an async task object is returned + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + New-OVNetworkSet -Name "Production Networks" -untaggedNetwork yellow -networks blue, green, yellow + + Create a new Network Set called "Production Networks", adding Ethernet Networks "blue", "green", and "yellow", on all connected appliances. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + $networks = "blue","green","yellow" | % { Get-OVNetwork $_ -type Ethernet } +New-OVNetworkSet -name "Production Networks" -Networks $networks -UntaggedNetwork $networks[1] + + Get Ethernet Networks "blue", "green", and "yellow", then create a new Network Set, with "Green" as the UntaggedNetowrk for the specified appliance connection. + + + + + + + + + + -------------------------- EXAMPLE 3 -------------------------- + + + + New-OVNetworkSet -Name "Production Networks" -untaggedNetwork yellow -networks blue, green, yellow -TypicalBandwidth 1000 -MaximumBandwidth 5000 + + Create a new Network Set called "Production Networks", adding Ethernet Networks "blue", "green", and "yellow", setting the Typical and Maximum Bandwidth. + + + + + + + + + + + + + Get-OVNetworkSet + + + + Remove-OVNetworkSet + + + + Set-OVNetworkSet + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/networking/new-ovnetworkset + + + + + + + + New-OVOSDeploymentServer + + Create a new HPE Synergy OS Deployment Server. + + New + OVOSDeploymentServer + + + An OS deployment server is a resource that enables you to deploy (install and configure) operating systems for use by servers. HPE OneView connects to an OS deployment server and configures it for deploying operating systems. +HPE OneView manages the OS deployment server after it is configured and displays the list of attributes, management settings, the OS deployment plans, and the server profiles that reference the available OS deployment plans. + +To create an OS Deployment Server, HPE Synergy Image Streamer appliances must be installed into managed or monitored Synergy Frames, a Management Network created with an association to an IPv4 address pool Subnet, and available IP Addresses within the pool. + + + + + New-OVOSDeploymentServer + + Name + + OS Deployment resource name. + + String + + + InputObject + + HPE Synergy Image Streamer appliance. Can be any Image Streamer resource object from Get-OVImageStreamerAppliance. + + Object + + + ManagementNetwork + + Either a Tagged or Untagged Ethernet Network associated with an IPv4 address pool Subnet. Subnet must be in the same IPv4 Address Network ID as the HPE Synergy Composer IPv4 Address(es). + + Object + + + Description + + Description of the OS Deployment Server resource. + + String + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + SwitchParameter + + False + + + Description + + Description of the OS Deployment Server resource. + + String + + String + + + + + InputObject + + HPE Synergy Image Streamer appliance. Can be any Image Streamer resource object from Get-OVImageStreamerAppliance. + + Object + + Object + + + + + ManagementNetwork + + Either a Tagged or Untagged Ethernet Network associated with an IPv4 address pool Subnet. Subnet must be in the same IPv4 Address Network ID as the HPE Synergy Composer IPv4 Address(es). + + Object + + Object + + + + + Name + + OS Deployment resource name. + + String + + String + + + + + + + + + System.Management.Automation.PSCustomObject [HPEOneView.Appliance.ImageStreamerAppliance] + + + HPE Synergy Image Streamer Appliance object from Get-OVImageStreamerAppliance. + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + Async task Resource object for modifying the Remote Support Collection schedules. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + $ManagementNetwork = Get-OVNetwork -Type Ethernet -Name "Deployment Network" +Get-OVImageStreamerAppliance | Select -First 1 | New-OVOSDeploymentServer -Name "MY OS Deployment Server" -ManagementNetwork $ManagementNetwork + + Get the Ethernet network resource object, then pass via the pipeline the first HPE Synergy Image Streamer object, and create a new OS Deployment Server. + + + + + + + + + + + + + Get-OVOSDeploymentServer + + + + Remove-OVOSDeploymentServer + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/servers/new-ovosdeploymentserver + + + + + + + + New-OVQosConfig + + Create QoS Configuration Object + + New + OVQosConfig + + + This helper Cmdlet provides the capability to create a new Logical Interconnect Group or Logical Interconnect QoS Configuration object. TrafficClassifiers are created using the New-OVQosTrafficClass helper Cmdlet. + + + + + New-OVQosConfig + + ConfigType + + The QOS Configuration Type. Allowed values are: + + * Passthrough (Default) - All ingress packets are not classified at egress. FCoE packets having a separate PG (Priority Group) are processed at ingress. There are no traffic classes, maps, or rules applied. Passthrough mode is equivalent to no QoS (QoS disabled). + * CustomNoFCoE - Enables QoS and allows a customized configuration without FCoE. The configuration defines one system class (Best Effort). You can configure up to seven additional classes for non-FCoE Ethernet traffic. + * CustomWithFCoE - Enables QoS and allows a customized configuration that includes FCoE class. The configuration defines two default system classes, Best Effort and FCoE Lossless. FCoE Lossless class cannot be edited by the user and is pre-configured for 50% bandwidth of the port. You can also configure up to six additional classes for non-FCoE Ethernet traffic. + + String + + + + New-OVQosConfig + + ConfigType + + The QOS Configuration Type. Allowed values are: + + * Passthrough (Default) - All ingress packets are not classified at egress. FCoE packets having a separate PG (Priority Group) are processed at ingress. There are no traffic classes, maps, or rules applied. Passthrough mode is equivalent to no QoS (QoS disabled). + * CustomNoFCoE - Enables QoS and allows a customized configuration without FCoE. The configuration defines one system class (Best Effort). You can configure up to seven additional classes for non-FCoE Ethernet traffic. + * CustomWithFCoE - Enables QoS and allows a customized configuration that includes FCoE class. The configuration defines two default system classes, Best Effort and FCoE Lossless. FCoE Lossless class cannot be edited by the user and is pre-configured for 50% bandwidth of the port. You can also configure up to six additional classes for non-FCoE Ethernet traffic. + + String + + + UplinkClassificationType + + Configure the Uplink QOS Marking classification type. + + * DOT1P (Default) + * DSCP + * DOT1P_AND_DSCP + + String + + + DownlinkClassificationType + + Configure the Downlink QOS Marking classification type. + + * DOT1P + * DSCP + * DOT1P_AND_DSCP (Default) + + String + + + TrafficClassifiers + + A collection of traffic classes created using the New-OVQosTrafficClass. + + ArrayList + + + + + + + ConfigType + + The QOS Configuration Type. Allowed values are: + + * Passthrough (Default) - All ingress packets are not classified at egress. FCoE packets having a separate PG (Priority Group) are processed at ingress. There are no traffic classes, maps, or rules applied. Passthrough mode is equivalent to no QoS (QoS disabled). + * CustomNoFCoE - Enables QoS and allows a customized configuration without FCoE. The configuration defines one system class (Best Effort). You can configure up to seven additional classes for non-FCoE Ethernet traffic. + * CustomWithFCoE - Enables QoS and allows a customized configuration that includes FCoE class. The configuration defines two default system classes, Best Effort and FCoE Lossless. FCoE Lossless class cannot be edited by the user and is pre-configured for 50% bandwidth of the port. You can also configure up to six additional classes for non-FCoE Ethernet traffic. + + String + + String + + Passthrough + + + DownlinkClassificationType + + Configure the Downlink QOS Marking classification type. + + * DOT1P + * DSCP + * DOT1P_AND_DSCP (Default) + + String + + String + + DOT1P_AND_DSCP + + + TrafficClassifiers + + A collection of traffic classes created using the New-OVQosTrafficClass. + + ArrayList + + ArrayList + + @() + + + UplinkClassificationType + + Configure the Uplink QOS Marking classification type. + + * DOT1P (Default) + * DSCP + * DOT1P_AND_DSCP + + String + + String + + DOT1P + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + HPEOneView.Networking.QosConfiguration [System.Management.Automation.PSCustomObject] + + + + QoS Configuration object + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + $QosConfig = New-OVQosConfig CustomWithFCoE DSCP DOT1P_AND_DSCP $TrafficClassifiers +New-OVLogicalInterconnectGroup -LIGName "Flex10/10D and FlexFabric Production 1" -bays @{1 = "Flex1010D";2 = "Flex1010D";3 = "FlexFabric";4 = "FlexFabric"} -enableIgmpSnooping $True -igmpIdleTimeoutInterval 300 -LoopProtect $True -QosConfig $QosConfig + + Create a new QOS Configuration object,and use the created object to add to a new Logical Interconnect Group. + + + + + + + + + + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/networking/new-ovqosconfig + + + + + + + + New-OVQosTrafficClass + + Create QoS Traffic Classifier Object + + New + OVQosTrafficClass + + + This helper Cmdlet provides the capability to create a new QoS Traffic Classifier Object, which can then be added to either a Logical Interconnect Group, or Logica Interconnect resource. + +Only non-FCoE Traffic Classifiers are allowed to be created. When creating the "Best effort" Traffic Classifier, only the MaxBandwidth parameter is allowed to be modified. + + + + + New-OVQosTrafficClass + + Name + + Name of the QoS Classifier. Value cannot be "FCoE lossless". If value is "Best effort", only the MaxBandwidth Parameter is allowed to be modified. + + String + + + MaxBandwidth + + Maximum share the traffic class can use when other traffic classes are not using their guaranteed share. The max share and the % share for a real time class must be equal and not exceed 50%. For other classes, the max share is greater than or equal to the % share. + +Value between 1 and 100 + + Int32 + + + BandwidthShare + + Minimum guaranteed bandwidth for the traffic class. The % share and the max share for a real time class must be equal and not exceed 50%. + +Value between 1 and 100 + + String + + + EgressDot1pValue + + Specifies the dot1p priority value to remark for the egressing packets. This provides flexibility to control priority treatment for packets at the next hops based on the remarked dot1p value. + + Int32 + + + IngressDot1pClassMapping + + Specify an array of ingress Dot1p values, and to which traffic class it is currently mapped. Allowed values: + + * 0 + * 1 + * 2 + * 3 + * 4 + * 5 + * 5 + * 6 + * 7 + + Array + + + IngressDscpClassMapping + + Specify an array of DSCP class mappings, per RFC 2475. Allowed values: + + * DSCP 0, CS0 + * DSCP 10, AF11 + * DSCP 12, AF12 + * DSCP 14, AF13 + * DSCP 8, CS1 + * DSCP 18, AF21 + * DSCP 20, AF22 + * DSCP 22, AF23 + * DSCP 26, AF31 + * DSCP 28, AF32 + * DSCP 30, AF33 + * DSCP 34, AF41 + * DSCP 36, AF42 + * DSCP 38, AF43 + * DSCP 16, CS2 + * DSCP 24, CS3 + * DSCP 32, CS4 + * DSCP 46, EF + * DSCP 40, CS5 + * DSCP 48, CS6 + * DSCP 56, CS7 + + Array + + + RealTime + + Specifies whether the traffic class is real time. Only 1 traffic class can be real time. Enabling real time for this class removes the real time flag for other classes. + + SwitchParameter + + + Enabled + + Specify to Enable the traffic class. By default, the class is disabled, even though it is defined. + + SwitchParameter + + + + + + + BandwidthShare + + Minimum guaranteed bandwidth for the traffic class. The % share and the max share for a real time class must be equal and not exceed 50%. + +Value between 1 and 100 + + String + + String + + + + + EgressDot1pValue + + Specifies the dot1p priority value to remark for the egressing packets. This provides flexibility to control priority treatment for packets at the next hops based on the remarked dot1p value. + + Int32 + + Int32 + + 0 + + + Enabled + + Specify to Enable the traffic class. By default, the class is disabled, even though it is defined. + + SwitchParameter + + SwitchParameter + + False + + + IngressDot1pClassMapping + + Specify an array of ingress Dot1p values, and to which traffic class it is currently mapped. Allowed values: + + * 0 + * 1 + * 2 + * 3 + * 4 + * 5 + * 5 + * 6 + * 7 + + Array + + Array + + + + + IngressDscpClassMapping + + Specify an array of DSCP class mappings, per RFC 2475. Allowed values: + + * DSCP 0, CS0 + * DSCP 10, AF11 + * DSCP 12, AF12 + * DSCP 14, AF13 + * DSCP 8, CS1 + * DSCP 18, AF21 + * DSCP 20, AF22 + * DSCP 22, AF23 + * DSCP 26, AF31 + * DSCP 28, AF32 + * DSCP 30, AF33 + * DSCP 34, AF41 + * DSCP 36, AF42 + * DSCP 38, AF43 + * DSCP 16, CS2 + * DSCP 24, CS3 + * DSCP 32, CS4 + * DSCP 46, EF + * DSCP 40, CS5 + * DSCP 48, CS6 + * DSCP 56, CS7 + + Array + + Array + + + + + MaxBandwidth + + Maximum share the traffic class can use when other traffic classes are not using their guaranteed share. The max share and the % share for a real time class must be equal and not exceed 50%. For other classes, the max share is greater than or equal to the % share. + +Value between 1 and 100 + + Int32 + + Int32 + + + + + Name + + Name of the QoS Classifier. Value cannot be "FCoE lossless". If value is "Best effort", only the MaxBandwidth Parameter is allowed to be modified. + + String + + String + + + + + RealTime + + Specifies whether the traffic class is real time. Only 1 traffic class can be real time. Enabling real time for this class removes the real time flag for other classes. + + SwitchParameter + + SwitchParameter + + False + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + HPEOneView.Networking.QosTrafficClassifier [System.Management.Automation.PSCustomObject] + + + + QoS Traffic Classifier Object @{ qosTrafficClass = [PSCustomObject]@{ maxBandwidth = 100; bandwidthShare = "0"; egressDot1pValue = 0; realTime = $false; className = "Class"; enabled = $false; }; qosClassificationMapping = [PSCustomObject]@{ dot1pClassMapping = @(); dscpClassMapping = @() } } + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + $Class1 = New-OVQosTrafficClass -Name Class1 -MaxBandwidth 50 -BandwidthShare 20 -ExgressDot1pValue 2 -IngressDot1pClassMapping 5,6 -EgressDscpClassMapping "DSCP 0, CS0","DSCP 10, AF11","DSCP 12, AF12","DSCP 14, AF13" -Enabled +$Class2 = New-OVQosTrafficClass -Name Class2 -MaxBandwidth 10 -BandwidthShare 10 -ExgressDot1pValue 3 -IngressDot1pClassMapping 1 -EgressDscpClassMapping "DSCP 30, AF33","SCP 32, CS4" -Enabled +$TrafficClasses = $Class1,$Class2 + + Create new traffic class objects "Class1" and "Class2", creating a new collection $TrafficClasses. + + + + + + + + + + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/networking/new-ovqostrafficclass + + + + + + + + New-OVRack + + Create a new facilities Rack. + + New + OVRack + + + A rack is a physical structure that contains IT equipment such as enclosures, servers, power delivery devices, and unmanaged devices (an unmanaged device uses slots in the rack and consumes power or exhausts heat, but it is not managed by the appliance). You can manage your racks and the equipment in them by adding them to the appliance. Having your racks managed by the appliance enables you to use the appliance for space and power planning. The appliance also gathers statistical data and monitors the power and temperature of the racks it manages. + +When you add an enclosure to the appliance, it automatically creates a rack and places the enclosure in it. The appliance places into the rack all enclosures connected by management link cables. When enclosures are added, the appliance places them in the rack from top to bottom. When an enclosure is placed in an Intelligent Series Rack, the enclosure slots are automatically detected. For other racks, to accurately depict the layout of your enclosures within the rack you must edit the rack to place the enclosure in the proper slots. + +You can use the appliance to view and manage your rack configuration and power delivery topology. You can specify the physical dimensions of the rack (width, height, and depth), the number of U slots, and the location of each piece of equipment in the rack. You can specify the rack PDUs that provide power to the rack, and their physical position in the rack or on either side. You can also describe how the devices in the rack are connected to those PDUs. + +The appliance automatically discovers the rack height and rack model for a ProLiant server with Location Discovery Services and updates the physical locations of devices when they are relocated within and between racks for c7000 enclosures. + +This Cmdlet will create a new rack resource, which brings it under the management of the appliance, and creates a diagram that depicts the rack and its slots. After you add the rack, you can configure the layout of the devices in it by adding, removing, and repositioning the devices. + +Minimum required privileges: Infrastructure administrator or Server administrator + + + + + New-OVRack + + Name + + Name of resource. + + String + + + ThermalLimit + + Thermal limit supported by the rack, in BTU"s. + + Int + + + SerialNumber + + Serial number of the rack resource. + + String + + + PartNumber + + Part number of the rack resource. + + String + + + Model + + Provide the model of the rack to add. + + + + + Depth + + Rack depth, in millimeters. + +Default: 1000 + + Int + + + Height + + Height of rack, in millimeters. + +Default: 2004 + + Int + + + UHeight + + The rack unit height of the rack. + +Default: 40 + + Int + + + Width + + Width of rack, in millimeters. + +Default: 600 + + Int + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Depth + + Rack depth, in millimeters. + +Default: 1000 + + Int + + Int + + 1000 + + + Height + + Height of rack, in millimeters. + +Default: 2004 + + Int + + Int + + 2004 + + + Model + + Provide the model of the rack to add. + + + + + + + + + Name + + Name of resource. + + String + + String + + + + + PartNumber + + Part number of the rack resource. + + String + + String + + + + + SerialNumber + + Serial number of the rack resource. + + String + + String + + + + + ThermalLimit + + Thermal limit supported by the rack, in BTU"s. + + Int + + Int + + + + + UHeight + + The rack unit height of the rack. + +Default: 40 + + Int + + Int + + 220 + + + Width + + Width of rack, in millimeters. + +Default: 600 + + Int + + Int + + 600 + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + HPEOneView.Facilities.Rack + + + + Newly created rack. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + $Params = @{ + + Name = "Rack-230"; + ThermalLimit = 10000; + SerialNumber = "AABB1122CCDD"; + PartNumber = "AF046A"; + Depth = 1075; + Height = 2032; + UHeight = 42; + Width = 600 + +} +New-OVRack @Params + + Create new "Rack-230" rack resource. + + + + + + + + + + + + + Add-OVRackManager + + + + Add-OVRackToDataCenter + + + + Get-OVRack + + + + Get-OVRackManager + + + + Get-OVRackMember + + + + Remove-OVRack + + + + Remove-OVRackManager + + + + Remove-OVRackMember + + + + Set-OVRackMemberLocation + + + + Update-OVRackManager + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/facilities/new-ovrack + + + + + + + + New-OVRemoteSupportContact + + Configure new Remote Support contact. + + New + OVRemoteSupportContact + + + Use this Cmdlet to create a new Remote Support Contact. The Remote Support Contact is used to identify authorized users HPE Support can contact for service events. Only a single contact can be defined as the Default. The Default contact cannot be removed, and at least 1 contact must be configured before attempting to register the appliance with HPE support using the Set-OVRemoteSupport Cmdlet. + + + + + New-OVRemoteSupportContact + + Firstname + + The contacts first or given name. + + String + + + Lastname + + The contacts last or sur name. + + String + + + Email + + The contacts email address. + + String + + + PrimaryPhone + + The contacts primary phone number. + + String + + + AlternatePhone + + The contacts alternate phone number. + + String + + + Language + + The contacts primary spoken language. + + String + + + SpecialInstructions + + The contacts special instructions. + + String + + + Default + + Use to specify if this contact is the Default. + + SwitchParameter + + + DefaultSecondary + + Use to indicate if the specified contact should be the appliance default secondary contact. + + SwitchParameter + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + + + + AlternatePhone + + The contacts alternate phone number. + + String + + String + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Default + + Use to specify if this contact is the Default. + + SwitchParameter + + SwitchParameter + + + + + DefaultSecondary + + Use to indicate if the specified contact should be the appliance default secondary contact. + + SwitchParameter + + SwitchParameter + + + + + Email + + The contacts email address. + + String + + String + + + + + Firstname + + The contacts first or given name. + + String + + String + + + + + Language + + The contacts primary spoken language. + + String + + String + + en + + + Lastname + + The contacts last or sur name. + + String + + String + + + + + PrimaryPhone + + The contacts primary phone number. + + String + + String + + + + + SpecialInstructions + + The contacts special instructions. + + String + + String + + + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + HPEOneView.Appliance.RemoteSupport.Contact [System.Management.Automation.PSCustomObject] + + + + The created Remote Support Contact. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + New-OVRemoteSupportContact -Firstname Rebert -Lastname Jones -Email robert.jones@domain.local -PrimaryPhone 123-111-2222 -AlternatePhone 111-333-4444 -Language en -Default + + Configure a new user who is the default contact. + + + + + + + + + + + + + Get-OVRemoteSupportContact + + + + Remove-OVRemoteSupportContact + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/new-ovremotesupportcontact + + + + + + + + New-OVRemoteSupportPartner + + Retrieve Remote Support Default Site. + + New + OVRemoteSupportPartner + + + Use this Cmdlet to retrieve the configured default site. + + + + + New-OVRemoteSupportPartner + + Name + + Supply the Partner Name. + + String + + + Type + + Specify if the authorized partner is a Reseller or Support. If requiring a partner that is both Support and a Reseller, create it twice. + + String + + + PartnerId + + The HPE Authorized Support and/or Reseller Partner ID. + + Int + + + Default + + Use to specify if the partner should be the default Support or Reseller partner. All supproted monitored resources by default will inherit from the appliance. + + SwitchParameter + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Default + + Use to specify if the partner should be the default Support or Reseller partner. All supproted monitored resources by default will inherit from the appliance. + + SwitchParameter + + SwitchParameter + + + + + Name + + Supply the Partner Name. + + String + + String + + + + + PartnerId + + The HPE Authorized Support and/or Reseller Partner ID. + + Int + + Int + + + + + Type + + Specify if the authorized partner is a Reseller or Support. If requiring a partner that is both Support and a Reseller, create it twice. + + String + + String + + + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + HPEOneView.Appliance.RemoteSupport.Partner [System.Management.Automation.PSCustomObject] + + + + Newly created Remote Support Partner. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + New-OVRemoteSupportPartner -Name "My Authorized Partner" -Type Reseller -PartnerId 123456 + + Define a new authorized HPE Reseller partner. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + New-OVRemoteSupportPartner -Name "My Authorized Partner" -Type Support -PartnerId 123456 -Default + + Define a new authorized HPE Support partner, and make it the default appliance Support partner. + + + + + + + + + + + + + Get-OVRemoteSupportPartner + + + + Remove-OVRemoteSupportPartner + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/new-ovremotesupportpartner + + + + + + + + New-OVResource + + Create a new resource. + + New + OVResource + + + Create a new resource by passing the URI and the resource details in the form of a PowerShell hashtable. + + + + + New-OVResource + + Uri + + The location where the new object is to be created, using the HTTP POST method. + + String + + + InputObject + + The new resource that is to be created + + Object + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + + + + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + InputObject + + The new resource that is to be created + + Object + + Object + + + + + Uri + + The location where the new object is to be created, using the HTTP POST method. + + String + + String + + + + + + + + + System.Management.Automation.PSCustomObject + + + Resource object to create + + + + + + + + System.Management.Automation.PSCustomObject + + + + The newly created resource, or async task + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + New-OVResource /rest/ethernet-networks @{vlanId=2000; purpose="General"; name="VLAN 2000"; smartLink=$true; privateNetwork=$false; type="ethernet-networkV2"} + + Create a new Ethernet Network, "VLAN 2000". + + + + + + + + + + + + + Add-OVResourceToLabel + + + + Add-OVResourceToRack + + + + Add-OVResourceToScope + + + + Remove-OVResource + + + + Remove-OVResourceFromLabel + + + + Remove-OVResourceFromScope + + + + Set-OVResource + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/library/new-ovresource + + + + + + + + New-OVRestore + + Upload appliance backup file to restore its configuration. + + New + OVRestore + + + Using this Cmdlet will initiate a restore of the appliance to the backup file specified. Starts a restore operation from the backup file already uploaded to the appliance. Only one restore operation can run at a time. There is no way to cancel a restore once it has been started. The restore operation is destructive. Any configuration changes not included in the backup file will be lost. The appliance will raise alerts for any inconsistencies detected after the restore. If an unrecoverable error is detected during the restore, then the appliance will be set to the factory reset mode. + +Restoring from a backup is a disruptive action: + + * The appliance restarts and users cannot log in to the appliance during the restore process. All users are + logged out and their work is lost. + * To prevent duplicate identifiers on the network, server hardware configurations are cleared if an associated + server profile is not in the backup. + * Server profiles that have been modified since the backup was taken are flagged with this message: "Server + profile settings conflict with the server hardware configuration". To reapply the server profile + configuration and restore network connectivity, you must unassign all flagged server profiles and then + individually reassign the server profiles to the server hardware. + * To prevent unintentional assignment of duplicate addresses or identifiers, all address and identifier ranges + are disabled after the post-restore process completes. The appliance automatically re-creates replacement + address and identifier ranges. + +Minimum required privileges: Infrastructure administrator, Software administrator + + + + + New-OVRestore + + FileName + + The full path and file name of the appliance configuration backup file. + + System.IO.FileInfo + + + Passphrase + + A secure Passphrase is required to encrypt the appliance backup. An exception will be generated if this parameter is used and the target appliance doesn't meet the minimum required version. + + SecureString + + + EncryptionKey + + Provide the encryption key file path or file object. When restoring an appliance backup, and after the appliance has been factory reset, the prior encryption key is needed to decrypt the backup file. This is only supported with HPE Synergy Composer 2 appliances. + + Object + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + + WhatIf + + + + SwitchParameter + + + Confirm + + + + SwitchParameter + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + Array + + (${Global:ConnectedSessions} | ? Default) + + + Confirm + + + + SwitchParameter + + SwitchParameter + + + + + EncryptionKey + + Provide the encryption key file path or file object. When restoring an appliance backup, and after the appliance has been factory reset, the prior encryption key is needed to decrypt the backup file. This is only supported with HPE Synergy Composer 2 appliances. + + Object + + Object + + + + + FileName + + The full path and file name of the appliance configuration backup file. + + System.IO.FileInfo + + System.IO.FileInfo + + + + + Passphrase + + A secure Passphrase is required to encrypt the appliance backup. An exception will be generated if this parameter is used and the target appliance doesn't meet the minimum required version. + + SecureString + + SecureString + + False + + + WhatIf + + + + SwitchParameter + + SwitchParameter + + + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + System.Management.Automation.PSCustomObject + + + + The restore process object. This is not an Async Task + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + New-OVRestore -FileName "C:\Users\me\Documents\appliance_backup_2013-11-01_110203.bkp" + + Upload a backup file to restore in the appliance. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + New-OVRestore -FileName "C:\Users\me\Documents\appliance_backup_2013-11-01_110203.bkp -EncryptionKey "C:\Path\To\encryptionkey.aek"" + + Upload a backup file to restore in the appliance, supplying the path to the encryption key file. + + + + + + + + + + + + + New-OVBackup + + + + Save-OVApplianceDataAtRestEncryptionKey + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/new-ovrestore + + + + + + + + New-OVScope + + Create new Scope. + + New + OVScope + + + A scope is a grouping of resources that can be used to restrict the range of an operation or action. For example, you can create scopes based on: + + * Organizations (Marketing, Research and Development, Finance) + * Usage (Production, Development, Testing) + * Skills (Linux, Windows) + +The resources are arranged by categories. All the resources in these categories can be added to or removed from a scope: + + * Enclosures + * Server Hardware + * Networks (Ethernet, FC, and FCoE) + * Network Sets + * Interconnects, excluding SAS resources + * Logical Interconnects, excluding SAS resources + * Logical Interconnect Groups, excluding SAS resources + * Switches + * Logical Switches + * Logical Switch Groups + +NOTE: Resources in other categories are considered to be included in all scopes, and they cannot be removed. + +When scopes are defined and resources assigned to them, you can: + + * Restrict your view of the user interface (UI) to the resources in the scope. + * Filter email notifications for alerts based on the scope of the associated resources. + +Minimum required privileges: Infrastructure administrator + + + + + New-OVScope + + Name + + Name of the scope to create. + + String + + + Description + + Administrator account of the target iLO. + + String + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Description + + Administrator account of the target iLO. + + String + + String + + + + + Name + + Name of the scope to create. + + String + + String + + + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + HPEOneView.Appliance.Scope [System.Management.Automation.PSCustomObject] + + + + Appliance Scope resource object. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + New-OVScope -Name MyFinanceScope + + Create a "MyFinanceScope" for the default appliance connection. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + New-OVScope -Name MyFinanceScope -Descrition "Finance Scope of resources" + + Create a "MyFinanceScope" with a descrition for the default appliance connection. + + + + + + + + + + -------------------------- EXAMPLE 3 -------------------------- + + + + New-OVScope -Name MyFinanceScope -Descrition "Finance Scope of resources" -ApplianceConnection $ConnectedSessions + + Create a "MyFinanceScope" with a descrition for all appliance connections. + + + + + + + + + + + + + Get-OVScope + + + + Remove-OVScope + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/new-ovscope + + + + + + + + New-OVServerProfile + + Create or Import a Server Profile + + New + OVServerProfile + + + This Cmdlet is used to create or import an HPE OneView Server Profile. + +A server profile is the configuration for a server instance. Server profiles capture the entire server configuration in one place, enabling you to consistently replicate new server profiles and to rapidly modify them to reflect changes in your data center. + +A server profile includes: + + * Server identification information + * Connectivity settings for Ethernet networks, network sets, and Fibre Channel networks + * Firmware policy + * Local storage settings + * SAN storage settings (for environments that have Virtual Connect) + * BIOS settings + * Boot order + * Physical or virtual UUIDs, MAC addresses, and WWN addresses + +You can create an unassigned server profile that serves as a template. Typically, you capture best-practice configurations in a server profile template, and then copy and deploy instances as individual server profiles. Similar to virtual machine (VM) templates, profiles enable you to create a provisioning baseline for server hardware types in an enclosure. + +When you create a server profile, it is designated for a server hardware type and enclosure group (for server blades), whether the profile is assigned or unassigned. + +To figure out BIOS Settings to override or set within the Server Profile, you will need to get the Server Hardware Type resource that your are modeling the Server Profile for. When retrieving the resource: + +$bl460cgen9sht = Get-OVServerHardwareType "BL460c Gen9 1" + +The "biosSettings" Array property will be available (only with supported Server Hardware Types; i.e. BL460c Gen8 or newer). To locate potential BIOS Settings, you can use the following code as an example: + +$biosSettings = $bl460cgen9sht.biosSettings | ? name -match "power" + +The code example above will return all matching BIOS Settings where the name contains "power". The found BIOS settings object(s) are then saved into $biosSettings. Update the "value" property accordingly, and you can then pass $biosSettings variable to the -biosSettings parameter. + + + + + New-OVServerProfile + + Name + + The name of the server profile resource to be created. + + String + + + AssignmentType + + The instruction of how the profile will be assigned. The profile can be assigned to an empty server bay, a specific server, or unassigned. + +Valid values for this parameter are "unassigned", "server", or "bay" + + String + + + Enclosure + + The blade enclosure resource containing the bay where the server profile will be assigned. Only required if assignmentType is "bay" + + Object + + + EnclosureBay + + The empty enclosure bay to assign the server profile. + + Int32 + + + Server + + The server hardware resource where the new profile is to be applied. This is normally retrieved with a "Get-OVServer" call, and the Server state property should be "NoProfileApplied". Can also be the Server Hardware name or URI. + + Object + + + Description + + Optional description for this server profile. + + String + + + Connections + + The network connections that are to be part of this new server profile. This an array of profile connection objects which may be created with "New-OVServerProfileConnection". + +Starting with HPE OneView 5.0, unmanaged Fibre Channel connections are supported, and can be deployed to servers without HPE Virtual Connect. + +Default: No connections + + Array + + + EnclosureGroup + + The Enclosure Group resource the Server Profile will be bound to. Only required when Server value is "Unassigned". + + Object + + + ServerHardwareType + + The Server Hardware Type reource the Server Profile will be bound to. Required when Server value is "Unassigned" or assigning to an empty device bay in an enclosure which must include the -enclosure and -enclosureBay parameters. + + Object + + + Firmware + + Enable Firmware Management. Cannot be enabled with Server Hardware Type does not support Firmware Management (i.e. BL G7 servers.) + + SwitchParameter + + + Baseline + + Firmware baseline to assign. Can be either Baseline Name or URI. + + Object + + + BaselinePatchLevel + + The patch or supplement to the Update Bundle. Within the Update Bundle contains a property called Supplements ([Array] of [System.Version]). + + version + + + FirmwareInstallationPolicy + + The Installation policy option is only available for Gen10 and later servers. The option is available for Gen10 or later server hardware types only. Installation policy enables you to choose if a component needs to be updated or downgraded when its version does not match the baseline. An alert is generated when the installed version on one or more components is inconsistent with the selected installation policy. + +You can choose one of the following two policy options: + + * LowerThanBaseline (Default) - Updates only the components that have a version lower than the firmware baseline version. + * NotEqualToBaseline - Updates or downgrades components whose installed version does not match the firmware baseline version. The components with a version lower than the firmware baseline version are upgraded, and the components with a version higher than the firmware baseline version are downgraded to match the baseline. + +NOTE: For Gen9 and earlier servers, if the selected firmware baseline is older than the firmware currently installed, select the Force installation option to downgrade the firmware version. + + string + + + FirmwareInstallMode + + Specify the Firmware Baseline Policy mode. Avialable options are: + + * FirmwareOnly - Updates the system firmware without powering down the server hardware using using HP Smart Update Tools. + * FirmwareAndSoftware - Updates the firmware and OS drivers without powering down the server hardware using HP Smart Update Tools. + * FirmwareOffline - Manages the firmware through HPE OneView. Selecting this option requires the server hardware to be powered down. + + String + + + FirmwareActivationMode + + Specify the firmware activation policy. Avialable options are: + + * Immediate - Immediately activate (aka reboot the host) firmware if needed. Requires HPSUT to be installed in the Host OS or Proxy VM (for VMware only) + * Scheduled - Specify a future time to activate (aka reboot the host) firmware if needed. You will need to specify the FirmwareActivateDateTime parameter. Requires HPSUT to be installed in the Host OS or Proxy VM (for VMware only) + * NotScheduled - Scheduled firmware update is cancelled when you choose this option. + + String + + + FirmwareActivateDateTime + + Using this parameter will force the bundled firmware components to install when the Server Profile is applied to a server. This will downgrade firmware if the component firmware is newer than what the SPP Baseline contains. + + DateTime + + + ReinstallFirmware + + Replaces the Force switch parameter. Use to reinstall components that are the same version as within the specified baseline. + + SwitchParameter + + + Bios + + Enable BIOS Settings Management. Cannot be enabled with Server Hardware Type does not support BIOS Management (i.e. BL G7 servers.) + + SwitchParameter + + + BiosSettings + + BIOS Settings that are to be managed. You can get the BIOS settings available from Get-OVServerHardwareType and the returned biosSettings property. + + Array + + + BootMode + + Specify the Gen9 Boot Envrionment. + +Sets the boot mode as one of the following: + + * UEFI + * UEFIOptimized + * BIOS + * Unmanaged + +If you select UEFI or UEFI optimized for an HP ProLiant DL Gen9 rack mount server, the remaining boot setting available is the PXE boot policy. + +For the UEFI or UEFI optimized boot mode options, the boot mode choice should be based on the expected OS and required boot features for the server hardware. UEFI optimized boot mode reduces the time the system spends in POST (Video driver initialization). In order to select the appropriate boot mode, consider the following: + + * If a secure boot is required, the boot mode must be set to UEFI or UEFI optimized . + * For operating systems that do not support UEFI (such as DOS, or older versions of Windows and Linux), the boot mode must be set to BIOS. + * When booting in UEFI mode, Windows 7, Server 2008, or 2008 R2 should not be set to UEFIOptimized. + +Default: BIOS + + String + + + PxeBootPolicy + + Controls the ordering of the network modes available to the Flexible LOM (FLB); for example, IPv4 and IPv6. + +Select from the following policies: + + * Auto + * IPv4 only + * IPv6 only + * IPv4 then IPv6 + * IPv6 then IPv4 + +Setting the policy to Auto means the order of the existing network boot targets in the UEFI Boot Order list will not be modified, and any new network boot targets will be added to the end of the list using the System ROM"s default policy. + +Default: Auto + + String + + + ManageBoot + + Enable Boot Order Management. Also required for Connection boot enablement. If this is disabled ($False), then PXE or FC BfS settings are disabled within the entire Server Profile. + +Default: $True + + SwitchParameter + + + BootOrder + + Boot Order settings to be managed. + +Defines the order in which boot will be attempted on the available devices. For Gen7 and Gen8 server hardware the possible values are "CD", "Floppy", "USB", "HardDisk", and "PXE". For Gen9 BL server hardware in Legacy BIOS boot mode, the possible values are "CD", "USB", "HardDisk", and "PXE". For Gen9 BL server hardware in UEFI or UEFI Optimized boot mode, only one value is allowed and must be either "HardDisk" or "PXE". For Gen9 DL server hardware in Legacy BIOS boot mode, the possible values are "CD", "USB", "HardDisk", and "PXE". For Gen9 DL server hardware in UEFI or UEFI Optimized boot mode, boot order configuration is not supported. + +Gen7/8 BIOS Default Boot Order: "CD","Floppy","USB","HardDisk","PXE" +Gen9 Legacy BIOS Boot Order: "CD","USB","HardDisk","PXE" +Gen9 UEFI Default Boot Order: "HardDisk" + + Array + + + SecureBoot + + Specify if secure boot should be Unmanaged, Enabled or Disabled for Gen10 and newer servers. Boot Mode must be set to 'UEFI Optimized'. + + String + + + LocalStorage + + Enable local storage settings to be managed on the server. Will only enable embedded Smart Array controller management. + + SwitchParameter + + + StorageController + + A collection (System.Collections.ArrayList or System.Collections.ArrayList) of LogicalDisk Controller configuration objects from New-OVServerProfileLogicalDisk and New-OVServerProfileLogicalDiskController. + + Object + + + ManageIloSettings + + Use to indicate iLO settings will be managed from the server profile. + + Bool + + + IloSettings + + Provide an iLO settings object from New-OVServerProfileIloPolicy Cmdlet. + + PSObject + + + Affinity + + In a server profile, the Affinity control sets the remove-and-replace behavior for blade servers. If you apply a server profile to a blade server and the server is subsequently removed from the device bay, the Affinity setting controls whether the server profile is reapplied when you insert a server blade into the empty bay. Server profiles for rack servers do not have affinity. + +Accepted values are either "Bay" or "BayAndServer". Default is "Bay". + + String + + + MacAssignment + + Optional setting for MAC address assignment. May be Virtual or Physical. Use Virtual if you need to specify a UserDefined value when using the New-OVServerProfileConnection helper Cmdlet. + + String + + + WwnAssignment + + Optional setting for WWN assignment. May be Virtual or Physical. Use Virtual if you need to specify a UserDefined value when using the New-OVServerProfileConnection helper Cmdlet. + + String + + + SnAssignment + + Optional setting for serial number and UUID assignment. May be Virtual, Physical or UserDefined. + +Default: Virtual serial number and UUID assignment + + String + + + SerialNumber + + When specifying snAssignment parameter to UserDefined, you can provide a user defined Serial Number value. You must also specify the UUID by using the uuid parameter. + + String + + + Uuid + + When specifying snAssignment parameter to UserDefined, you can provide a user defined UUID value. You must also specify the Serial Number by using the serialnumber parameter. + + String + + + HideUnusedFlexNics + + This setting provides the ability to hide unused FlexNICs from the operating system. + +If Hide Unused FlexNICs is set to $True (default/enabled), FlexNICs that do not map to any server profile connections are not presented to the operating system. For example, if you have a full complement of eight FlexNICs defined in your server profile but map only four, your operating system will see only the four mapped FlexNICs instead of eight. + +If Hide Unused FlexNICs is set to $False (disabled), eight FlexNICs are enumerated in the operating system as network interfaces for each Flex-10 or FlexFabric adapter. + +Configuring Fibre Channel connections on a FlexFabric adapter can enumerate two storage interfaces, reducing the number of network interfaces to six. + +FlexNICs are hidden in pairs, starting with the fourth pair. For example, if the fourth FlexNIC on either physical port corresponds to a profile connection, all eight physical functions are enumerated. If a profile connection corresponds to the second FlexNIC on either physical port, but no connection corresponds to the third or fourth FlexNIC on either physical port, only the first and second physical functions are enumerated in the operating system. + +By default, Hide Unused FlexNICs is enabled. This setting can be changed only when the server is powered off. + + Boolean + + + OSDeploymentPlan + + The HPE Synergy Image Streamer OS deployment plan from Get-OVOSDeploymentPlan. + + Object + + + OSDeploymentAttributes + + Configured OS Deployment Plan parameters from Get-OVOSDeploymentPlanAttribute. + + Array + + + Scope + + Provide an HPEOneView.Appliance.ScopeCollection resource object to initially associate with. Resource can also be added to scope using the Add-OVResourceToScope Cmdlet. + + HPEOneView.Appliance.ScopeCollection[] + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + + Passthru + + Use this parameter to return the modified Server Profile object. In order to save the changes, please use the Save-OVServerProfile Cmdlet. + + SwitchParameter + + + WhatIf + + + + + + + Confirm + + + + + + + + New-OVServerProfile + + Name + + The name of the server profile resource to be created. + + String + + + ServerProfileTemplate + + Provide a Server Profile Template Object or Resource Name. + + Object + + + AssignmentType + + The instruction of how the profile will be assigned. The profile can be assigned to an empty server bay, a specific server, or unassigned. + +Valid values for this parameter are "unassigned", "server", or "bay" + + String + + + Enclosure + + The blade enclosure resource containing the bay where the server profile will be assigned. Only required if assignmentType is "bay" + + Object + + + EnclosureBay + + The empty enclosure bay to assign the server profile. + + Int32 + + + Server + + The server hardware resource where the new profile is to be applied. This is normally retrieved with a "Get-OVServer" call, and the Server state property should be "NoProfileApplied". Can also be the Server Hardware name or URI. + + Object + + + Description + + Optional description for this server profile. + + String + + + Connections + + The network connections that are to be part of this new server profile. This an array of profile connection objects which may be created with "New-OVServerProfileConnection". + +Starting with HPE OneView 5.0, unmanaged Fibre Channel connections are supported, and can be deployed to servers without HPE Virtual Connect. + +Default: No connections + + Array + + + FCConnectionAddresses + + When providing a server profile template to create a server profile from and it contains unmanaged Fibre Channel connections, use this parameter to specify the connection ID and the FC WWPN value that should be associated with the connection. + +Expected format: + + @{1 = "10:00:00:60:69:00:23:90"; 2 = "10:00:00:60:69:00:23:92"} + + Hashtable + + + Firmware + + Enable Firmware Management. Cannot be enabled with Server Hardware Type does not support Firmware Management (i.e. BL G7 servers.) + + SwitchParameter + + + Baseline + + Firmware baseline to assign. Can be either Baseline Name or URI. + + Object + + + BaselinePatchLevel + + The patch or supplement to the Update Bundle. Within the Update Bundle contains a property called Supplements ([Array] of [System.Version]). + + version + + + FirmwareInstallationPolicy + + The Installation policy option is only available for Gen10 and later servers. The option is available for Gen10 or later server hardware types only. Installation policy enables you to choose if a component needs to be updated or downgraded when its version does not match the baseline. An alert is generated when the installed version on one or more components is inconsistent with the selected installation policy. + +You can choose one of the following two policy options: + + * LowerThanBaseline (Default) - Updates only the components that have a version lower than the firmware baseline version. + * NotEqualToBaseline - Updates or downgrades components whose installed version does not match the firmware baseline version. The components with a version lower than the firmware baseline version are upgraded, and the components with a version higher than the firmware baseline version are downgraded to match the baseline. + +NOTE: For Gen9 and earlier servers, if the selected firmware baseline is older than the firmware currently installed, select the Force installation option to downgrade the firmware version. + + string + + + FirmwareInstallMode + + Specify the Firmware Baseline Policy mode. Avialable options are: + + * FirmwareOnly - Updates the system firmware without powering down the server hardware using using HP Smart Update Tools. + * FirmwareAndSoftware - Updates the firmware and OS drivers without powering down the server hardware using HP Smart Update Tools. + * FirmwareOffline - Manages the firmware through HPE OneView. Selecting this option requires the server hardware to be powered down. + + String + + + FirmwareActivationMode + + Specify the firmware activation policy. Avialable options are: + + * Immediate - Immediately activate (aka reboot the host) firmware if needed. Requires HPSUT to be installed in the Host OS or Proxy VM (for VMware only) + * Scheduled - Specify a future time to activate (aka reboot the host) firmware if needed. You will need to specify the FirmwareActivateDateTime parameter. Requires HPSUT to be installed in the Host OS or Proxy VM (for VMware only) + * NotScheduled - Scheduled firmware update is cancelled when you choose this option. + + String + + + FirmwareActivateDateTime + + Using this parameter will force the bundled firmware components to install when the Server Profile is applied to a server. This will downgrade firmware if the component firmware is newer than what the SPP Baseline contains. + + DateTime + + + ReinstallFirmware + + Replaces the Force switch parameter. Use to reinstall components that are the same version as within the specified baseline. + + SwitchParameter + + + ManageBoot + + Enable Boot Order Management. Also required for Connection boot enablement. If this is disabled ($False), then PXE or FC BfS settings are disabled within the entire Server Profile. + +Default: $True + + SwitchParameter + + + LocalStorage + + Enable local storage settings to be managed on the server. Will only enable embedded Smart Array controller management. + + SwitchParameter + + + StorageController + + A collection (System.Collections.ArrayList or System.Collections.ArrayList) of LogicalDisk Controller configuration objects from New-OVServerProfileLogicalDisk and New-OVServerProfileLogicalDiskController. + + Object + + + ManageIloSettings + + Use to indicate iLO settings will be managed from the server profile. + + Bool + + + IloSettings + + Provide an iLO settings object from New-OVServerProfileIloPolicy Cmdlet. + + PSObject + + + MacAssignment + + Optional setting for MAC address assignment. May be Virtual or Physical. Use Virtual if you need to specify a UserDefined value when using the New-OVServerProfileConnection helper Cmdlet. + + String + + + WwnAssignment + + Optional setting for WWN assignment. May be Virtual or Physical. Use Virtual if you need to specify a UserDefined value when using the New-OVServerProfileConnection helper Cmdlet. + + String + + + SnAssignment + + Optional setting for serial number and UUID assignment. May be Virtual, Physical or UserDefined. + +Default: Virtual serial number and UUID assignment + + String + + + SerialNumber + + When specifying snAssignment parameter to UserDefined, you can provide a user defined Serial Number value. You must also specify the UUID by using the uuid parameter. + + String + + + Uuid + + When specifying snAssignment parameter to UserDefined, you can provide a user defined UUID value. You must also specify the Serial Number by using the serialnumber parameter. + + String + + + HideUnusedFlexNics + + This setting provides the ability to hide unused FlexNICs from the operating system. + +If Hide Unused FlexNICs is set to $True (default/enabled), FlexNICs that do not map to any server profile connections are not presented to the operating system. For example, if you have a full complement of eight FlexNICs defined in your server profile but map only four, your operating system will see only the four mapped FlexNICs instead of eight. + +If Hide Unused FlexNICs is set to $False (disabled), eight FlexNICs are enumerated in the operating system as network interfaces for each Flex-10 or FlexFabric adapter. + +Configuring Fibre Channel connections on a FlexFabric adapter can enumerate two storage interfaces, reducing the number of network interfaces to six. + +FlexNICs are hidden in pairs, starting with the fourth pair. For example, if the fourth FlexNIC on either physical port corresponds to a profile connection, all eight physical functions are enumerated. If a profile connection corresponds to the second FlexNIC on either physical port, but no connection corresponds to the third or fourth FlexNIC on either physical port, only the first and second physical functions are enumerated in the operating system. + +By default, Hide Unused FlexNICs is enabled. This setting can be changed only when the server is powered off. + + Boolean + + + IscsiIPv4Address + + Parameter is required when creating a Server Profile and specifying a ServerProfileTemplate parameter value. + +A collection of IPv4 Addresses to allocate for found iSCSI initiators that are Bootable. + + Array + + + ISCSIInitatorName + + Parameter is required when creating a Server Profile and specifying a ServerProfileTemplate parameter value which contain iSCSI Connections that are bootable. + +Value to provide for the iSCSI Initiator. All iSCSI Connections will share this value. If no value is provided, the connection will default to using the Server Profile Name. + + String + + + ChapSecret + + Parameter is required when creating a Server Profile, specifying a ServerProfileTemplate parameter value, and a Connection iSCSI Authentication Protocol is set to Chap or MutualChap. + +The CHAP challange secret. Accepts ASCII or HEX values. If providing an ASCII secret value, the length must be bewteen 12 and 16 characters. If HEX, it must start with 0x and with 24-32 characters. + + System.Security.SecureString + + + MutualChapSecret + + Parameter is required when creating a Server Profile, specifying a ServerProfileTemplate parameter value, and a Connection iSCSI Authentication Protocol is set to MutualChap. + +The Mutual CHAP challange secret. Accepts ASCII or HEX values. If providing an ASCII secret value, the length must be bewteen 12 and 16 characters. If HEX, it must start with 0x and with 24-32 characters. + + System.Security.SecureString + + + OSDeploymentPlan + + The HPE Synergy Image Streamer OS deployment plan from Get-OVOSDeploymentPlan. + + Object + + + OSDeploymentAttributes + + Configured OS Deployment Plan parameters from Get-OVOSDeploymentPlanAttribute. + + Array + + + Scope + + Provide an HPEOneView.Appliance.ScopeCollection resource object to initially associate with. Resource can also be added to scope using the Add-OVResourceToScope Cmdlet. + + HPEOneView.Appliance.ScopeCollection[] + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + + Passthru + + Use this parameter to return the modified Server Profile object. In order to save the changes, please use the Save-OVServerProfile Cmdlet. + + SwitchParameter + + + WhatIf + + + + + + + Confirm + + + + + + + + New-OVServerProfile + + Name + + The name of the server profile resource to be created. + + String + + + SANStorage + + Optional. Enable SAN Storage Management within the Server Profile. + + SwitchParameter + + + HostOStype + + Optional. Specify the Host OS type, which will set the Host OS value when HPE OneView created the Host object on the Storage System. Accepted values: + + * CitrixXen = "Citrix Xen Server 5.x/6.x" + * AIX = "AIX" + * IBMVIO = "IBM VIO Server" + * RHEL4 = "RHE Linux (Pre RHEL 5)" + * RHEL3 = "RHE Linux (Pre RHEL 5)" + * RHEL = "RHE Linux (5.x, 6.x)" + * RHEV = "RHE Virtualization (5.x, 6.x)" + * VMware = "ESX 4.x/5.x" + * Win2k3 = "Windows 2003" + * Win2k8 = "Windows 2008/2008 R2" + * Win2k12 = "Windows 2012 / WS2012 R2" + * OpenVMS = "OpenVMS" + * Egenera = "Egenera" + * Exanet = "Exanet" + * Solaris9 = "Solaris 9/10" + * Solaris10 = "Solaris 9/10" + * Solaris11 = "Solaris 11" + * ONTAP = "NetApp/ONTAP" + * OEL = "OE Linux UEK (5.x, 6.x)" + * HPUX11iv1 = "HP-UX (11i v1, 11i v2)" + * HPUX11iv2 = "HP-UX (11i v1, 11i v2)" + * HPUX11iv3 = "HP-UX (11i v3)" + * SUSE = "SuSE (10.x, 11.x)" + * SUSE9 = "SuSE Linux (Pre SLES 10)" + * Inform = "InForm" + + String + + + StorageVolume + + Optional. Array of Storage Volume resources to attach. Can be created by using the New-OVServerProfileAttachVolume Cmdlet. This parameter does not accept a Storage Volume resource from the Get-OVStorageVolume Cmdlet. + +The format of the Storage Volume resource should be a PsCustomObject PowerShell resource with the following keys and values: + +[PsCustomObject]@{ + [System.Int]id - Valid Host LUN ID 0-254 + [System.String]lunType - Auto or Manual + [System.String]volumeUri - URI to Storage Volume that has been created and not + assigned to another Server Profile if it is a Private Volume. + [System.String]volumeStoragePoolUri - URI to HPE OneView managed Storage Pool + [System.String]volumeStorageSystemUri - URI to HPE OneView managed Storage System + [System.Collections.ArrayList ]storagePaths - Array specifying the Profile FC Connection ID associated + with the path to the attached volume, and if the path is + enabled or disabled. + @( + [System.Int]connectionId - FC Connection ID. If using New-OVServerProfileAttachVolume helper + Cmdlet, New-OVServerProfile will automatically determine the FC + connection ID. + [System.Boolean]isEnabled - Enable or disable the path + ) +} + + Object + + + AssignmentType + + The instruction of how the profile will be assigned. The profile can be assigned to an empty server bay, a specific server, or unassigned. + +Valid values for this parameter are "unassigned", "server", or "bay" + + String + + + Enclosure + + The blade enclosure resource containing the bay where the server profile will be assigned. Only required if assignmentType is "bay" + + Object + + + EnclosureBay + + The empty enclosure bay to assign the server profile. + + Int32 + + + Server + + The server hardware resource where the new profile is to be applied. This is normally retrieved with a "Get-OVServer" call, and the Server state property should be "NoProfileApplied". Can also be the Server Hardware name or URI. + + Object + + + Description + + Optional description for this server profile. + + String + + + Connections + + The network connections that are to be part of this new server profile. This an array of profile connection objects which may be created with "New-OVServerProfileConnection". + +Starting with HPE OneView 5.0, unmanaged Fibre Channel connections are supported, and can be deployed to servers without HPE Virtual Connect. + +Default: No connections + + Array + + + EnclosureGroup + + The Enclosure Group resource the Server Profile will be bound to. Only required when Server value is "Unassigned". + + Object + + + ServerHardwareType + + The Server Hardware Type reource the Server Profile will be bound to. Required when Server value is "Unassigned" or assigning to an empty device bay in an enclosure which must include the -enclosure and -enclosureBay parameters. + + Object + + + Firmware + + Enable Firmware Management. Cannot be enabled with Server Hardware Type does not support Firmware Management (i.e. BL G7 servers.) + + SwitchParameter + + + Baseline + + Firmware baseline to assign. Can be either Baseline Name or URI. + + Object + + + BaselinePatchLevel + + The patch or supplement to the Update Bundle. Within the Update Bundle contains a property called Supplements ([Array] of [System.Version]). + + version + + + FirmwareInstallationPolicy + + The Installation policy option is only available for Gen10 and later servers. The option is available for Gen10 or later server hardware types only. Installation policy enables you to choose if a component needs to be updated or downgraded when its version does not match the baseline. An alert is generated when the installed version on one or more components is inconsistent with the selected installation policy. + +You can choose one of the following two policy options: + + * LowerThanBaseline (Default) - Updates only the components that have a version lower than the firmware baseline version. + * NotEqualToBaseline - Updates or downgrades components whose installed version does not match the firmware baseline version. The components with a version lower than the firmware baseline version are upgraded, and the components with a version higher than the firmware baseline version are downgraded to match the baseline. + +NOTE: For Gen9 and earlier servers, if the selected firmware baseline is older than the firmware currently installed, select the Force installation option to downgrade the firmware version. + + string + + + FirmwareInstallMode + + Specify the Firmware Baseline Policy mode. Avialable options are: + + * FirmwareOnly - Updates the system firmware without powering down the server hardware using using HP Smart Update Tools. + * FirmwareAndSoftware - Updates the firmware and OS drivers without powering down the server hardware using HP Smart Update Tools. + * FirmwareOffline - Manages the firmware through HPE OneView. Selecting this option requires the server hardware to be powered down. + + String + + + FirmwareActivationMode + + Specify the firmware activation policy. Avialable options are: + + * Immediate - Immediately activate (aka reboot the host) firmware if needed. Requires HPSUT to be installed in the Host OS or Proxy VM (for VMware only) + * Scheduled - Specify a future time to activate (aka reboot the host) firmware if needed. You will need to specify the FirmwareActivateDateTime parameter. Requires HPSUT to be installed in the Host OS or Proxy VM (for VMware only) + * NotScheduled - Scheduled firmware update is cancelled when you choose this option. + + String + + + FirmwareActivateDateTime + + Using this parameter will force the bundled firmware components to install when the Server Profile is applied to a server. This will downgrade firmware if the component firmware is newer than what the SPP Baseline contains. + + DateTime + + + ReinstallFirmware + + Replaces the Force switch parameter. Use to reinstall components that are the same version as within the specified baseline. + + SwitchParameter + + + Bios + + Enable BIOS Settings Management. Cannot be enabled with Server Hardware Type does not support BIOS Management (i.e. BL G7 servers.) + + SwitchParameter + + + BiosSettings + + BIOS Settings that are to be managed. You can get the BIOS settings available from Get-OVServerHardwareType and the returned biosSettings property. + + Array + + + BootMode + + Specify the Gen9 Boot Envrionment. + +Sets the boot mode as one of the following: + + * UEFI + * UEFIOptimized + * BIOS + * Unmanaged + +If you select UEFI or UEFI optimized for an HP ProLiant DL Gen9 rack mount server, the remaining boot setting available is the PXE boot policy. + +For the UEFI or UEFI optimized boot mode options, the boot mode choice should be based on the expected OS and required boot features for the server hardware. UEFI optimized boot mode reduces the time the system spends in POST (Video driver initialization). In order to select the appropriate boot mode, consider the following: + + * If a secure boot is required, the boot mode must be set to UEFI or UEFI optimized . + * For operating systems that do not support UEFI (such as DOS, or older versions of Windows and Linux), the boot mode must be set to BIOS. + * When booting in UEFI mode, Windows 7, Server 2008, or 2008 R2 should not be set to UEFIOptimized. + +Default: BIOS + + String + + + PxeBootPolicy + + Controls the ordering of the network modes available to the Flexible LOM (FLB); for example, IPv4 and IPv6. + +Select from the following policies: + + * Auto + * IPv4 only + * IPv6 only + * IPv4 then IPv6 + * IPv6 then IPv4 + +Setting the policy to Auto means the order of the existing network boot targets in the UEFI Boot Order list will not be modified, and any new network boot targets will be added to the end of the list using the System ROM"s default policy. + +Default: Auto + + String + + + ManageBoot + + Enable Boot Order Management. Also required for Connection boot enablement. If this is disabled ($False), then PXE or FC BfS settings are disabled within the entire Server Profile. + +Default: $True + + SwitchParameter + + + BootOrder + + Boot Order settings to be managed. + +Defines the order in which boot will be attempted on the available devices. For Gen7 and Gen8 server hardware the possible values are "CD", "Floppy", "USB", "HardDisk", and "PXE". For Gen9 BL server hardware in Legacy BIOS boot mode, the possible values are "CD", "USB", "HardDisk", and "PXE". For Gen9 BL server hardware in UEFI or UEFI Optimized boot mode, only one value is allowed and must be either "HardDisk" or "PXE". For Gen9 DL server hardware in Legacy BIOS boot mode, the possible values are "CD", "USB", "HardDisk", and "PXE". For Gen9 DL server hardware in UEFI or UEFI Optimized boot mode, boot order configuration is not supported. + +Gen7/8 BIOS Default Boot Order: "CD","Floppy","USB","HardDisk","PXE" +Gen9 Legacy BIOS Boot Order: "CD","USB","HardDisk","PXE" +Gen9 UEFI Default Boot Order: "HardDisk" + + Array + + + SecureBoot + + Specify if secure boot should be Unmanaged, Enabled or Disabled for Gen10 and newer servers. Boot Mode must be set to 'UEFI Optimized'. + + String + + + LocalStorage + + Enable local storage settings to be managed on the server. Will only enable embedded Smart Array controller management. + + SwitchParameter + + + StorageController + + A collection (System.Collections.ArrayList or System.Collections.ArrayList) of LogicalDisk Controller configuration objects from New-OVServerProfileLogicalDisk and New-OVServerProfileLogicalDiskController. + + Object + + + ManageIloSettings + + Use to indicate iLO settings will be managed from the server profile. + + Bool + + + IloSettings + + Provide an iLO settings object from New-OVServerProfileIloPolicy Cmdlet. + + PSObject + + + EvenPathDisabled + + Enable to disable even paths in the attached storage volume(s). + + SwitchParameter + + + OddPathDisabled + + Enable to disable odd paths in the attached storage volume(s). + + SwitchParameter + + + Affinity + + In a server profile, the Affinity control sets the remove-and-replace behavior for blade servers. If you apply a server profile to a blade server and the server is subsequently removed from the device bay, the Affinity setting controls whether the server profile is reapplied when you insert a server blade into the empty bay. Server profiles for rack servers do not have affinity. + +Accepted values are either "Bay" or "BayAndServer". Default is "Bay". + + String + + + MacAssignment + + Optional setting for MAC address assignment. May be Virtual or Physical. Use Virtual if you need to specify a UserDefined value when using the New-OVServerProfileConnection helper Cmdlet. + + String + + + WwnAssignment + + Optional setting for WWN assignment. May be Virtual or Physical. Use Virtual if you need to specify a UserDefined value when using the New-OVServerProfileConnection helper Cmdlet. + + String + + + SnAssignment + + Optional setting for serial number and UUID assignment. May be Virtual, Physical or UserDefined. + +Default: Virtual serial number and UUID assignment + + String + + + SerialNumber + + When specifying snAssignment parameter to UserDefined, you can provide a user defined Serial Number value. You must also specify the UUID by using the uuid parameter. + + String + + + Uuid + + When specifying snAssignment parameter to UserDefined, you can provide a user defined UUID value. You must also specify the Serial Number by using the serialnumber parameter. + + String + + + HideUnusedFlexNics + + This setting provides the ability to hide unused FlexNICs from the operating system. + +If Hide Unused FlexNICs is set to $True (default/enabled), FlexNICs that do not map to any server profile connections are not presented to the operating system. For example, if you have a full complement of eight FlexNICs defined in your server profile but map only four, your operating system will see only the four mapped FlexNICs instead of eight. + +If Hide Unused FlexNICs is set to $False (disabled), eight FlexNICs are enumerated in the operating system as network interfaces for each Flex-10 or FlexFabric adapter. + +Configuring Fibre Channel connections on a FlexFabric adapter can enumerate two storage interfaces, reducing the number of network interfaces to six. + +FlexNICs are hidden in pairs, starting with the fourth pair. For example, if the fourth FlexNIC on either physical port corresponds to a profile connection, all eight physical functions are enumerated. If a profile connection corresponds to the second FlexNIC on either physical port, but no connection corresponds to the third or fourth FlexNIC on either physical port, only the first and second physical functions are enumerated in the operating system. + +By default, Hide Unused FlexNICs is enabled. This setting can be changed only when the server is powered off. + + Boolean + + + OSDeploymentPlan + + The HPE Synergy Image Streamer OS deployment plan from Get-OVOSDeploymentPlan. + + Object + + + OSDeploymentAttributes + + Configured OS Deployment Plan parameters from Get-OVOSDeploymentPlanAttribute. + + Array + + + Scope + + Provide an HPEOneView.Appliance.ScopeCollection resource object to initially associate with. Resource can also be added to scope using the Add-OVResourceToScope Cmdlet. + + HPEOneView.Appliance.ScopeCollection[] + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + + Passthru + + Use this parameter to return the modified Server Profile object. In order to save the changes, please use the Save-OVServerProfile Cmdlet. + + SwitchParameter + + + WhatIf + + + + + + + Confirm + + + + + + + + New-OVServerProfile + + Import + + Switch to import Server Profile JSON object or file. + + SwitchParameter + + + ProfileObj + + Source Server Profile JSON object or file. + + Object + + + AssignmentType + + The instruction of how the profile will be assigned. The profile can be assigned to an empty server bay, a specific server, or unassigned. + +Valid values for this parameter are "unassigned", "server", or "bay" + + String + + + Server + + The server hardware resource where the new profile is to be applied. This is normally retrieved with a "Get-OVServer" call, and the Server state property should be "NoProfileApplied". Can also be the Server Hardware name or URI. + + Object + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + + WhatIf + + + + + + + Confirm + + + + + + + + + + + Affinity + + In a server profile, the Affinity control sets the remove-and-replace behavior for blade servers. If you apply a server profile to a blade server and the server is subsequently removed from the device bay, the Affinity setting controls whether the server profile is reapplied when you insert a server blade into the empty bay. Server profiles for rack servers do not have affinity. + +Accepted values are either "Bay" or "BayAndServer". Default is "Bay". + + String + + String + + Bay + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + AssignmentType + + The instruction of how the profile will be assigned. The profile can be assigned to an empty server bay, a specific server, or unassigned. + +Valid values for this parameter are "unassigned", "server", or "bay" + + String + + String + + + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + SwitchParameter + + false + + + Baseline + + Firmware baseline to assign. Can be either Baseline Name or URI. + + Object + + Object + + + + + BaselinePatchLevel + + The patch or supplement to the Update Bundle. Within the Update Bundle contains a property called Supplements ([Array] of [System.Version]). + + version + + version + + + + + Bios + + Enable BIOS Settings Management. Cannot be enabled with Server Hardware Type does not support BIOS Management (i.e. BL G7 servers.) + + SwitchParameter + + SwitchParameter + + False + + + BiosSettings + + BIOS Settings that are to be managed. You can get the BIOS settings available from Get-OVServerHardwareType and the returned biosSettings property. + + Array + + Array + + @() + + + BootMode + + Specify the Gen9 Boot Envrionment. + +Sets the boot mode as one of the following: + + * UEFI + * UEFIOptimized + * BIOS + * Unmanaged + +If you select UEFI or UEFI optimized for an HP ProLiant DL Gen9 rack mount server, the remaining boot setting available is the PXE boot policy. + +For the UEFI or UEFI optimized boot mode options, the boot mode choice should be based on the expected OS and required boot features for the server hardware. UEFI optimized boot mode reduces the time the system spends in POST (Video driver initialization). In order to select the appropriate boot mode, consider the following: + + * If a secure boot is required, the boot mode must be set to UEFI or UEFI optimized . + * For operating systems that do not support UEFI (such as DOS, or older versions of Windows and Linux), the boot mode must be set to BIOS. + * When booting in UEFI mode, Windows 7, Server 2008, or 2008 R2 should not be set to UEFIOptimized. + +Default: BIOS + + String + + String + + BIOS + + + BootOrder + + Boot Order settings to be managed. + +Defines the order in which boot will be attempted on the available devices. For Gen7 and Gen8 server hardware the possible values are "CD", "Floppy", "USB", "HardDisk", and "PXE". For Gen9 BL server hardware in Legacy BIOS boot mode, the possible values are "CD", "USB", "HardDisk", and "PXE". For Gen9 BL server hardware in UEFI or UEFI Optimized boot mode, only one value is allowed and must be either "HardDisk" or "PXE". For Gen9 DL server hardware in Legacy BIOS boot mode, the possible values are "CD", "USB", "HardDisk", and "PXE". For Gen9 DL server hardware in UEFI or UEFI Optimized boot mode, boot order configuration is not supported. + +Gen7/8 BIOS Default Boot Order: "CD","Floppy","USB","HardDisk","PXE" +Gen9 Legacy BIOS Boot Order: "CD","USB","HardDisk","PXE" +Gen9 UEFI Default Boot Order: "HardDisk" + + Array + + Array + + @() + + + ChapSecret + + Parameter is required when creating a Server Profile, specifying a ServerProfileTemplate parameter value, and a Connection iSCSI Authentication Protocol is set to Chap or MutualChap. + +The CHAP challange secret. Accepts ASCII or HEX values. If providing an ASCII secret value, the length must be bewteen 12 and 16 characters. If HEX, it must start with 0x and with 24-32 characters. + + System.Security.SecureString + + System.Security.SecureString + + + + + Confirm + + + + + + + + + + + Connections + + The network connections that are to be part of this new server profile. This an array of profile connection objects which may be created with "New-OVServerProfileConnection". + +Starting with HPE OneView 5.0, unmanaged Fibre Channel connections are supported, and can be deployed to servers without HPE Virtual Connect. + +Default: No connections + + Array + + Array + + + + + Description + + Optional description for this server profile. + + String + + String + + + + + Enclosure + + The blade enclosure resource containing the bay where the server profile will be assigned. Only required if assignmentType is "bay" + + Object + + Object + + + + + EnclosureBay + + The empty enclosure bay to assign the server profile. + + Int32 + + Int32 + + 0 + + + EnclosureGroup + + The Enclosure Group resource the Server Profile will be bound to. Only required when Server value is "Unassigned". + + Object + + Object + + + + + EvenPathDisabled + + Enable to disable even paths in the attached storage volume(s). + + SwitchParameter + + SwitchParameter + + False + + + FCConnectionAddresses + + When providing a server profile template to create a server profile from and it contains unmanaged Fibre Channel connections, use this parameter to specify the connection ID and the FC WWPN value that should be associated with the connection. + +Expected format: + + @{1 = "10:00:00:60:69:00:23:90"; 2 = "10:00:00:60:69:00:23:92"} + + Hashtable + + Hashtable + + + + + Firmware + + Enable Firmware Management. Cannot be enabled with Server Hardware Type does not support Firmware Management (i.e. BL G7 servers.) + + SwitchParameter + + SwitchParameter + + False + + + FirmwareActivateDateTime + + Using this parameter will force the bundled firmware components to install when the Server Profile is applied to a server. This will downgrade firmware if the component firmware is newer than what the SPP Baseline contains. + + DateTime + + DateTime + + + + + FirmwareActivationMode + + Specify the firmware activation policy. Avialable options are: + + * Immediate - Immediately activate (aka reboot the host) firmware if needed. Requires HPSUT to be installed in the Host OS or Proxy VM (for VMware only) + * Scheduled - Specify a future time to activate (aka reboot the host) firmware if needed. You will need to specify the FirmwareActivateDateTime parameter. Requires HPSUT to be installed in the Host OS or Proxy VM (for VMware only) + * NotScheduled - Scheduled firmware update is cancelled when you choose this option. + + String + + String + + Immediate + + + FirmwareInstallMode + + Specify the Firmware Baseline Policy mode. Avialable options are: + + * FirmwareOnly - Updates the system firmware without powering down the server hardware using using HP Smart Update Tools. + * FirmwareAndSoftware - Updates the firmware and OS drivers without powering down the server hardware using HP Smart Update Tools. + * FirmwareOffline - Manages the firmware through HPE OneView. Selecting this option requires the server hardware to be powered down. + + String + + String + + FirmwareAndSoftware + + + FirmwareInstallationPolicy + + The Installation policy option is only available for Gen10 and later servers. The option is available for Gen10 or later server hardware types only. Installation policy enables you to choose if a component needs to be updated or downgraded when its version does not match the baseline. An alert is generated when the installed version on one or more components is inconsistent with the selected installation policy. + +You can choose one of the following two policy options: + + * LowerThanBaseline (Default) - Updates only the components that have a version lower than the firmware baseline version. + * NotEqualToBaseline - Updates or downgrades components whose installed version does not match the firmware baseline version. The components with a version lower than the firmware baseline version are upgraded, and the components with a version higher than the firmware baseline version are downgraded to match the baseline. + +NOTE: For Gen9 and earlier servers, if the selected firmware baseline is older than the firmware currently installed, select the Force installation option to downgrade the firmware version. + + string + + string + + + + + HideUnusedFlexNics + + This setting provides the ability to hide unused FlexNICs from the operating system. + +If Hide Unused FlexNICs is set to $True (default/enabled), FlexNICs that do not map to any server profile connections are not presented to the operating system. For example, if you have a full complement of eight FlexNICs defined in your server profile but map only four, your operating system will see only the four mapped FlexNICs instead of eight. + +If Hide Unused FlexNICs is set to $False (disabled), eight FlexNICs are enumerated in the operating system as network interfaces for each Flex-10 or FlexFabric adapter. + +Configuring Fibre Channel connections on a FlexFabric adapter can enumerate two storage interfaces, reducing the number of network interfaces to six. + +FlexNICs are hidden in pairs, starting with the fourth pair. For example, if the fourth FlexNIC on either physical port corresponds to a profile connection, all eight physical functions are enumerated. If a profile connection corresponds to the second FlexNIC on either physical port, but no connection corresponds to the third or fourth FlexNIC on either physical port, only the first and second physical functions are enumerated in the operating system. + +By default, Hide Unused FlexNICs is enabled. This setting can be changed only when the server is powered off. + + Boolean + + Boolean + + True + + + HostOStype + + Optional. Specify the Host OS type, which will set the Host OS value when HPE OneView created the Host object on the Storage System. Accepted values: + + * CitrixXen = "Citrix Xen Server 5.x/6.x" + * AIX = "AIX" + * IBMVIO = "IBM VIO Server" + * RHEL4 = "RHE Linux (Pre RHEL 5)" + * RHEL3 = "RHE Linux (Pre RHEL 5)" + * RHEL = "RHE Linux (5.x, 6.x)" + * RHEV = "RHE Virtualization (5.x, 6.x)" + * VMware = "ESX 4.x/5.x" + * Win2k3 = "Windows 2003" + * Win2k8 = "Windows 2008/2008 R2" + * Win2k12 = "Windows 2012 / WS2012 R2" + * OpenVMS = "OpenVMS" + * Egenera = "Egenera" + * Exanet = "Exanet" + * Solaris9 = "Solaris 9/10" + * Solaris10 = "Solaris 9/10" + * Solaris11 = "Solaris 11" + * ONTAP = "NetApp/ONTAP" + * OEL = "OE Linux UEK (5.x, 6.x)" + * HPUX11iv1 = "HP-UX (11i v1, 11i v2)" + * HPUX11iv2 = "HP-UX (11i v1, 11i v2)" + * HPUX11iv3 = "HP-UX (11i v3)" + * SUSE = "SuSE (10.x, 11.x)" + * SUSE9 = "SuSE Linux (Pre SLES 10)" + * Inform = "InForm" + + String + + String + + + + + ISCSIInitatorName + + Parameter is required when creating a Server Profile and specifying a ServerProfileTemplate parameter value which contain iSCSI Connections that are bootable. + +Value to provide for the iSCSI Initiator. All iSCSI Connections will share this value. If no value is provided, the connection will default to using the Server Profile Name. + + String + + String + + + + + IloSettings + + Provide an iLO settings object from New-OVServerProfileIloPolicy Cmdlet. + + PSObject + + PSObject + + + + + Import + + Switch to import Server Profile JSON object or file. + + SwitchParameter + + SwitchParameter + + False + + + IscsiIPv4Address + + Parameter is required when creating a Server Profile and specifying a ServerProfileTemplate parameter value. + +A collection of IPv4 Addresses to allocate for found iSCSI initiators that are Bootable. + + Array + + Array + + + + + LocalStorage + + Enable local storage settings to be managed on the server. Will only enable embedded Smart Array controller management. + + SwitchParameter + + SwitchParameter + + False + + + MacAssignment + + Optional setting for MAC address assignment. May be Virtual or Physical. Use Virtual if you need to specify a UserDefined value when using the New-OVServerProfileConnection helper Cmdlet. + + String + + String + + Virtual + + + ManageBoot + + Enable Boot Order Management. Also required for Connection boot enablement. If this is disabled ($False), then PXE or FC BfS settings are disabled within the entire Server Profile. + +Default: $True + + SwitchParameter + + SwitchParameter + + False + + + ManageIloSettings + + Use to indicate iLO settings will be managed from the server profile. + + Bool + + Bool + + + + + MutualChapSecret + + Parameter is required when creating a Server Profile, specifying a ServerProfileTemplate parameter value, and a Connection iSCSI Authentication Protocol is set to MutualChap. + +The Mutual CHAP challange secret. Accepts ASCII or HEX values. If providing an ASCII secret value, the length must be bewteen 12 and 16 characters. If HEX, it must start with 0x and with 24-32 characters. + + System.Security.SecureString + + System.Security.SecureString + + + + + Name + + The name of the server profile resource to be created. + + String + + String + + + + + OSDeploymentAttributes + + Configured OS Deployment Plan parameters from Get-OVOSDeploymentPlanAttribute. + + Array + + Array + + + + + OSDeploymentPlan + + The HPE Synergy Image Streamer OS deployment plan from Get-OVOSDeploymentPlan. + + Object + + Object + + + + + OddPathDisabled + + Enable to disable odd paths in the attached storage volume(s). + + SwitchParameter + + SwitchParameter + + False + + + Passthru + + Use this parameter to return the modified Server Profile object. In order to save the changes, please use the Save-OVServerProfile Cmdlet. + + SwitchParameter + + SwitchParameter + + + + + ProfileObj + + Source Server Profile JSON object or file. + + Object + + Object + + + + + PxeBootPolicy + + Controls the ordering of the network modes available to the Flexible LOM (FLB); for example, IPv4 and IPv6. + +Select from the following policies: + + * Auto + * IPv4 only + * IPv6 only + * IPv4 then IPv6 + * IPv6 then IPv4 + +Setting the policy to Auto means the order of the existing network boot targets in the UEFI Boot Order list will not be modified, and any new network boot targets will be added to the end of the list using the System ROM"s default policy. + +Default: Auto + + String + + String + + Auto + + + ReinstallFirmware + + Replaces the Force switch parameter. Use to reinstall components that are the same version as within the specified baseline. + + SwitchParameter + + SwitchParameter + + + + + SANStorage + + Optional. Enable SAN Storage Management within the Server Profile. + + SwitchParameter + + SwitchParameter + + False + + + Scope + + Provide an HPEOneView.Appliance.ScopeCollection resource object to initially associate with. Resource can also be added to scope using the Add-OVResourceToScope Cmdlet. + + HPEOneView.Appliance.ScopeCollection[] + + HPEOneView.Appliance.ScopeCollection[] + + + + + SecureBoot + + Specify if secure boot should be Unmanaged, Enabled or Disabled for Gen10 and newer servers. Boot Mode must be set to 'UEFI Optimized'. + + String + + String + + + + + SerialNumber + + When specifying snAssignment parameter to UserDefined, you can provide a user defined Serial Number value. You must also specify the UUID by using the uuid parameter. + + String + + String + + + + + Server + + The server hardware resource where the new profile is to be applied. This is normally retrieved with a "Get-OVServer" call, and the Server state property should be "NoProfileApplied". Can also be the Server Hardware name or URI. + + Object + + Object + + + + + ServerHardwareType + + The Server Hardware Type reource the Server Profile will be bound to. Required when Server value is "Unassigned" or assigning to an empty device bay in an enclosure which must include the -enclosure and -enclosureBay parameters. + + Object + + Object + + + + + ServerProfileTemplate + + Provide a Server Profile Template Object or Resource Name. + + Object + + Object + + + + + SnAssignment + + Optional setting for serial number and UUID assignment. May be Virtual, Physical or UserDefined. + +Default: Virtual serial number and UUID assignment + + String + + String + + Virtual + + + StorageController + + A collection (System.Collections.ArrayList or System.Collections.ArrayList) of LogicalDisk Controller configuration objects from New-OVServerProfileLogicalDisk and New-OVServerProfileLogicalDiskController. + + Object + + Object + + + + + StorageVolume + + Optional. Array of Storage Volume resources to attach. Can be created by using the New-OVServerProfileAttachVolume Cmdlet. This parameter does not accept a Storage Volume resource from the Get-OVStorageVolume Cmdlet. + +The format of the Storage Volume resource should be a PsCustomObject PowerShell resource with the following keys and values: + +[PsCustomObject]@{ + [System.Int]id - Valid Host LUN ID 0-254 + [System.String]lunType - Auto or Manual + [System.String]volumeUri - URI to Storage Volume that has been created and not + assigned to another Server Profile if it is a Private Volume. + [System.String]volumeStoragePoolUri - URI to HPE OneView managed Storage Pool + [System.String]volumeStorageSystemUri - URI to HPE OneView managed Storage System + [System.Collections.ArrayList ]storagePaths - Array specifying the Profile FC Connection ID associated + with the path to the attached volume, and if the path is + enabled or disabled. + @( + [System.Int]connectionId - FC Connection ID. If using New-OVServerProfileAttachVolume helper + Cmdlet, New-OVServerProfile will automatically determine the FC + connection ID. + [System.Boolean]isEnabled - Enable or disable the path + ) +} + + Object + + Object + + + + + Uuid + + When specifying snAssignment parameter to UserDefined, you can provide a user defined UUID value. You must also specify the Serial Number by using the serialnumber parameter. + + String + + String + + + + + WhatIf + + + + + + + + + + + WwnAssignment + + Optional setting for WWN assignment. May be Virtual or Physical. Use Virtual if you need to specify a UserDefined value when using the New-OVServerProfileConnection helper Cmdlet. + + String + + String + + Virtual + + + + + + + System.String + + + The full path to the Server Profile JSON export file + + + + + HPEOneView.ServerHardware [System.Management.Automation.PSCustomObject] + + + Server Hardware resource object + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + If successful returns a task resource which may be polled to follow the progress of the profile creation. Otherwise, a request validation error will be returned + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + $svr = Get-OVServer -Name "Encl1, Bay 1" +New-OVServerProfile -name "My Basic Server Profile" -server $svr | Wait-OVTaskComplete + + Create a simple profile for "ServerA", and wait for it to be applied. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + $spt = Get-OVServerProfileTemplate -Name "Hypervisor Cluster Node Template v1" +Get-OVServer -Name "Encl1, Bay 1" | New-OVServerProfile -name "Hyp-Clus-01" -ServerProfileTemplate $spt | Wait-OVTaskComplete + + Create a Server Profile from the "Hypervisor Cluster Node Template v1" Server Profile Template, assigning to "Encl1, Bay 1" server device. + + + + + + + + + + -------------------------- EXAMPLE 3 -------------------------- + + + + $profileName = "Web Server 10" +$svr = Get-OVServer -Name "Encl1, Bay 1" +$con1 = Get-OVNetwork -Name "Net-41-A" | New-OVServerProfileConnection -ConnectionId 1 +$con2 = Get-OVNetwork -Name "Net-41-B" | New-OVServerProfileConnection -ConnectionId 2 +$params = @{ +>> name = $profileName; +>> assignmentType = "server"; +>> server = $svr; +>> connections = ($con1, $con2); +>> ApplianceConnection = "MyAppliance.domain.com" +>> } +>> +New-OVServerProfile @params | Wait-OVTaskComplete + + Create a BL Gen8 Server Profile template, and pipe to Wait-OVTaskComplete. + + + + + + + + + + -------------------------- EXAMPLE 4 -------------------------- + + + + $profileName = "Hypervisor Cluster Node 1" +$svr = Get-OVServer -Name "Encl1, Bay 1" +$con1 = Get-OVNetwork -Name "Net-41" | New-OVServerProfileConnection -id 1 -type Ethernet +$con2 = Get-OVNetwork -Name "Net-42" | New-OVServerProfileConnection -id 2 -type Ethernet +$con3 = Get-OVNetwork -Name "fabric a" | New-OVServerProfileConnection -id 3 -type FibreChannel -bootable -priority Primary -arrayWWPn "21:11:00:02:AC:00:72:03" -LUN 0 +$con4 = Get-OVNetwork -Name "fabric b" | New-OVServerProfileConnection -id 4 -type FibreChannel -bootable -priority Secondary -arrayWWPn "22:12:00:02:AC:00:72:03" -LUN 0 +$conList = $con1, $con2, $con3, $con4 +$task = New-OVServerProfile -name $profileName -assignmentType "unassigned" -connections $conList | Wait-OVTaskComplete + + Create an unassigned server profile which includes networks "Net-41" and "Net-42", adds FC Connections for BfS. + + + + + + + + + + -------------------------- EXAMPLE 5 -------------------------- + + + + $profileName = "Hypervisor Cluster Node 1" +$svr = Get-OVServer -Name "Encl1, Bay 1" +$con1 = Get-OVNetwork -Name "Net-41" | New-OVServerProfileConnection -id 1 -type Ethernet +$con2 = Get-OVNetwork -Name "Net-42" | New-OVServerProfileConnection -id 2 -type Ethernet +$con3 = Get-OVNetwork -Name "fabric a" | New-OVServerProfileConnection -id 3 -type FibreChannel -bootable -priority Primary -arrayWWPn "21:11:00:02:AC:00:72:03" -LUN 0 +$con4 = Get-OVNetwork -Name "fabric b" | New-OVServerProfileConnection -id 4 -type FibreChannel -bootable -priority Secondary -arrayWWPn "22:12:00:02:AC:00:72:03" -LUN 0 +$conList = $con1, $con2, $con3, $con4 +$volume1 = Get-OVStorageVolume -Name Volume1 | New-OVServerProfileAttachVolume -volumeid 1 +$volume2 = Get-OVStorageVolume SharedVolume1 | New-OVServerProfileAttachVolume -volumeid 2 +$attachVolumes = @($volume1,$volume2) +$task = New-OVServerProfile -name $profileName -assignmentType "unassigned" -connections $conList -SANStorage -ostype VMware -StorageVolume $attachVolumes | Wait-OVTaskComplete + + Create an unassigned server profile which includes networks "Net-41" and "Net-42", and attaches two storage volumes. + + + + + + + + + + -------------------------- EXAMPLE 6 -------------------------- + + + + $profileName = "Hypervisor Cluster Node 1" +$bl460SHT = Get-OVServerHardwareTypes -name "BL460c Gen8 1" +$enclosure = Get-OVEnclosure -Name "Encl1" +$bay = 12 +$con1 = Get-OVNetwork -Name "Net-41" | New-OVServerProfileConnection -id 1 -type Ethernet +$con2 = Get-OVNetwork -Name "Net-42" | New-OVServerProfileConnection -id 2 -type Ethernet +$con3 = Get-OVNetwork -Name "fabric a" | New-OVServerProfileConnection -id 3 -type FibreChannel -bootable -priority Primary -arrayWWPn "21:11:00:02:AC:00:72:03" -LUN 0 +$con4 = Get-OVNetwork -Name "fabric b" | New-OVServerProfileConnection -id 4 -type FibreChannel -bootable -priority Secondary -arrayWWPn "22:12:00:02:AC:00:72:03" -LUN 0 +$conList = $con1, $con2, $con3, $con4 +$task = New-OVServerProfile -name $profileName -assignmentType bay -connections $conList -sht $bl460SHT -enclosure $enclosure -bay $bay | Wait-OVTaskComplete + + Create a profile which includes networks "Net-41" and "Net-42", adds FC Connections for BfS, and assign to Bay 12 of "Encl1" which is currently empty. + + + + + + + + + + -------------------------- EXAMPLE 7 -------------------------- + + + + $profileName = "Hypervisor Cluster Node 1" +$server = Get-OVServer -Name "Encl1, Bay 1" +#display the BL460 Gen8 BIOS Settings +$bl460SHT.biosSettings +#Set HP Power Profile (ID 210) to Maximum Performance and HP Power Regulator (ID 140) to HP Static High Performance Mode. +$bl460bios = @(@{id=210;value=3},@{id=140;value=3}) +$con41 = Get-OVNetwork -Name "Net-41" | New-OVServerProfileConnection -ID 1 -bootable -priority Primary +$con42 = Get-OVNetwork -Name "Net-42" | New-OVServerProfileConnection -ID 2 -bootable -priority Secondary +$conList = @($con41, $con42) +$task = New-OVServerProfile -name $profileName -assignmentType "server" -server $server -connections $conList -manageboot -bootorder @("PXE","HardDisk","CD","Floppy","USB") -bios -biossettings $bl460bios | Wait-OVTaskComplete + + Create a profile which includes networks "Net-41" and "Net-42", sets the boot order, and sets the BIOS. Then pipes to Wait-OVTaskComplete. + + + + + + + + + + -------------------------- EXAMPLE 8 -------------------------- + + + + $profileName = "Hypervisor Cluster Node 1" +$server = Get-OVServer -Name "Encl1, Bay 1" #Gen9 Server +$con1 = Get-OVNetwork -Name "Net-41-A" | New-OVServerProfileConnection -connectionId 1 +$con2 = Get-OVNetwork -Name "Net-41-B" | New-OVServerProfileConnection -connectionId 2 +$LogicalDisk = New-OVServerProfileLogicalDisk -Name "My Local Disk" -RAID RAID1 -NumberofDrives 2 -DiskType SasSsd +$params = @{ +>> name = $profileName; +>> assignmentType = "server" +>> server = $server; +>> connections = $con1, $con2 +>> manageboot = $True; +>> bootMode = "UEFI"; +>> pxeBootPolicy = "IPv4ThenIPv6"; +>> bootOrder = "HardDisk"; +>> HideUnusedFlexnics = $True; +>> LocalStorage = $True; +>> Initialize = $True; +>> LogicalDisk = $LogicalDisk +>> } +>> +New-OVServerProfile @params | Wait-OVTaskComplete + + Create a BL Gen9 UEFI Server Profile, and pipe to Wait-OVTaskComplete. + + + + + + + + + + -------------------------- EXAMPLE 9 -------------------------- + + + + $profileName = "Synergy Hypervisor Cluster Node 1" +$sht = Get-OVServerHardwareType -Name "SY480 Gen9 1" +$server = Get-OVServer -NoProfile -ServerHardwareType $sht | ? { $_.cpuCount -ge 4 -and $_.memoryMb -ge 524288 } | Select -First 1 +$con1 = Get-OVNetwork -Name "Net-41-A" | New-OVServerProfileConnection -connectionId 1 +$con2 = Get-OVNetwork -Name "Net-41-B" | New-OVServerProfileConnection -connectionId 2 +$LogicalDisk = New-OVServerProfileLogicalDisk -Name "Data Drive" -RAID RAID1 -NumberofDrives 5 -DiskType SasSsd +$Controller = New-OVServerProfileLogicalDiskController -ControllerID "Mezz 1" -Initialize -LogicalDisk $LogicalDisk +$params = @{ +>> name = $profileName; +>> assignmentType = "server" +>> server = $server; +>> connections = $con1, $con2 +>> manageboot = $True; +>> bootMode = "UEFI"; +>> pxeBootPolicy = "IPv4ThenIPv6"; +>> bootOrder = "HardDisk"; +>> HideUnusedFlexnics = $True; +>> LocalStorage = $True; +>> Initialize = $True; +>> LogicalDisk = $LogicalDisk +>> } +>> +New-OVServerProfile @params | Wait-OVTaskComplete + + Create a Synergy Gen9 Server Profile by looking for the first available SY480 Gen9 with 4 CPU"s and 512GB of RAM, configuring with D3940 Disk Storage. + + + + + + + + + + -------------------------- EXAMPLE 10 -------------------------- + + + + $ServerProfileName = 'My DL with FC Server Profile 1' +$FCConnection1FibreChannelNetworkName = 'Fabric A' +$FCConnection1Wwpn = '10:00:00:60:69:00:23:90' +$FCConnection2FibreChannelNetworkName = 'Fabric B' +$FCConnection2Wwpn = '10:00:00:60:69:00:23:92' +$FCConnection1 = Get-OVNetwork -Type FibreChannel -Name $FCConnection1FibreChannelNetworkName | New-OVServerProfileConnection -type FibreChannel -ConnectionID 1 -WWPN $FCConnection1Wwpn -UserDefined +$FCConnection2 = Get-OVNetwork -Type FibreChannel -Name $FCConnection2FibreChannelNetworkName | New-OVServerProfileConnection -type FibreChannel -ConnectionID 2 -WWPN $FCConnection2Wwpn -UserDefined +$Params = @{ + + Name = $DLServerProfileWithUnManagedFCConnectionsName; + Description = 'Testing Creation'; + BootMode = 'UEFI'; + ServerHardwareType = (Get-OVServerHardwareType -Name 'DL360 Gen9 1' -ErrorAction Stop); + AssignmentType = 'Unassigned'; + Connections = $FCConnection1, $FCConnection2 +} + +New-OVServerProfile -Confirm:$False @Params | Wait-OVTaskComplete + + Create a server profile with unmanaged Fibre Channel connections. + + + + + + + + + + -------------------------- EXAMPLE 11 -------------------------- + + + + New-OVServerProfile -import -file C:\profiles\ServerProfile1.json + + Basic Server Profile import. + + + + + + + + + + -------------------------- EXAMPLE 12 -------------------------- + + + + (Get-Content C:\profiles\ServerProfile1.json) -join "`n" | New-OVServerProfile -import + + Read the contents from ServerProfile1.json, join each line into a single object, and pipe to New-OVServerProfile to import. + + + + + + + + + + -------------------------- EXAMPLE 13 -------------------------- + + + + $jsonProfiles = Get-ChildItem C:\profiles\*.json +$jsonProfiles | foreach-object { New-OVServerProfile -import -file $_.fullname } + + Retrieve list of all JSON files in C:\profiles, then pass each file and its full path to New-OVServerProfile. + + + + + + + + + + + + + Convert-OVServerProfile + + + + Convert-OVServerProfileTemplate + + + + ConvertTo-OVServerProfileTemplate + + + + Copy-OVServerProfile + + + + Get-OVServerProfile + + + + Get-OVServerProfileConnectionList + + + + Get-OVServerProfileMessage + + + + Get-OVServerProfileTemplate + + + + Join-OVServerProfileToTemplate + + + + New-OVServerProfileAssign + + + + New-OVServerProfileAttachVolume + + + + New-OVServerProfileConnection + + + + New-OVServerProfileLogicalDisk + + + + New-OVServerProfileLogicalDiskController + + + + New-OVServerProfileTemplate + + + + Remove-OVServerProfile + + + + Remove-OVServerProfileTemplate + + + + Save-OVServerProfile + + + + Save-OVServerProfileTemplate + + + + Set-OVServerProfile + + + + Set-OVServerProfileTemplate + + + + Update-OVServerProfile + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/servers/new-ovserverprofile + + + + + + + + New-OVServerProfileAssign + + Unassign or Reassign an existing Server Profile. + + New + OVServerProfileAssign + + + This Cmdlet is used to unassign or reassign an existing HPE OneView Server Profile. The destination Server and its Server Hardware Type does not need to match the original Server Hardware Type defined in the Server Profile. The Server Profile will be updated accordingly. + + + + + New-OVServerProfileAssign + + ServerProfile + + The name or object of the server profile resource to modify assignment. + + Object + + + Server + + The server hardware resource where the new profile is to be applied. This is normally retrieved with a "Get-OVServer" call, and the Server state property should be "NoProfileApplied". Can also be the Server Hardware name.s + + Object + + + Force + + Use to force add the Server Profile if there are any async task validation failures, like server hardware is in a Warning or Failed state, or SAN attach volume only have a single path configured. + + SwitchParameter + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + + WhatIf + + + + + + + Confirm + + + + + + + + New-OVServerProfileAssign + + ServerProfile + + The name or object of the server profile resource to modify assignment. + + Object + + + Unassigned + + Siwtch parameter to unassign a Server Profile. + + SwitchParameter + + + Force + + Use to force add the Server Profile if there are any async task validation failures, like server hardware is in a Warning or Failed state, or SAN attach volume only have a single path configured. + + SwitchParameter + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + + WhatIf + + + + + + + Confirm + + + + + + + + + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + SwitchParameter + + False + + + Confirm + + + + + + + + + + + Force + + Use to force add the Server Profile if there are any async task validation failures, like server hardware is in a Warning or Failed state, or SAN attach volume only have a single path configured. + + SwitchParameter + + SwitchParameter + + + + + Server + + The server hardware resource where the new profile is to be applied. This is normally retrieved with a "Get-OVServer" call, and the Server state property should be "NoProfileApplied". Can also be the Server Hardware name.s + + Object + + Object + + + + + ServerProfile + + The name or object of the server profile resource to modify assignment. + + Object + + Object + + + + + Unassigned + + Siwtch parameter to unassign a Server Profile. + + SwitchParameter + + SwitchParameter + + False + + + WhatIf + + + + + + + + + + + + + + + System.Management.Automation.PSCustomObject + + + Server Profile resource object from Get-OVServerProfile + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + If successful returns a task resource which may be polled to follow the progress of the profile creation. Otherwise, a request validation error will be returned + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVServerProfile -Name "Profile 1" | New-OVServerProfileAssign -Server "Encl1, Bay 10" | Wait-OVTaskComplete + + Get "Profile 1" Server Profile and assign it to "Encl1, Bay 10", then wait for the async task to complete. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Get-OVServerProfile -Name "Profile 1" | New-OVServerProfileAssign -unassign | Wait-OVTaskComplete + + Get "Profile 1" Server Profile and unassign it, then wait for the async task to complete. + + + + + + + + + + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/servers/new-ovserverprofileassign + + + + + + + + New-OVServerProfileAttachVolume + + Create volume attachment for a server profile. + + New + OVServerProfileAttachVolume + + + This Cmdlet will assist with creating a Storage Volume object to then attach to a new Server Profile being created (New-OVServerProfile), and attach either an existing Storage Volume (Get-OVStorageVolume) or new Ephemeral Volume to an existing Server Profile (Get-OVServerProfile). If attempting to attach to an existing Server Profile, the HostOSType parameter is required, and will enable SAN Management within the Server Profile, if the Server Hardware resource supports the feature. + + + + + New-OVServerProfileAttachVolume + + Volume + + The Volume Name, URI or Object to attach. + + Array + + + VolumeID + + The numeric identifier for this volume. Does not pertain to exported LUN ID value on array. + + Int32 + + + LunIdType + + Specify Auto or Manual for the LUN ID assignment type. If Manual, use the -LunID parameter and provide a numerical value. + + String + + + BootVolume + + Use to indicate this volume is a bootable device. When using this parameter, the Server Profile"s FC Connection(s) BootVolumeSource parameter set to "ManagedVolume". + +This parameter is only applicable with Private volumes. + + SwitchParameter + + + TargetPortAssignment + + Define whether host initiator port(s) should be mapped to target storage ports automatically or manually. + + SwitchParameter + + + TargetAddresses + + An array of target Port ID(s) or WWN(s). Example: @("1:0:1", "1:2:1", "3:1:1", "4:0:0") + + Array + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + + + New-OVServerProfileAttachVolume + + Name + + Ephemeral Storage Volume resource name. + + Object + + + ServerProfile + + An existing Server Profile resource object from Get-OVServerProfile Cmdlet. + + Object + + + PassThru + + Use this parameter to return the modified Server Profile object. In order to save the changes, please use the Save-OVServerProfile Cmdlet. + + SwitchParameter + + + VolumeID + + The numeric identifier for this volume. Does not pertain to exported LUN ID value on array. + + Int32 + + + VolumeTemplate + + For Ephemeral (private) volumes that should be provisioned from Storage Volume Templates. Provide a valid resource from Get-OVStorageVolumeTemplate. + + Object + + + StoragePool + + The Storage Resource Pool object to provision the Ephemeral Volume from. + + Object + + + SnapshotStoragePool + + The supported Snapshot storage pool for a StoreServ storage system. Snapshot storage pool must originate from the same storage system as the assigned storage pool. + + Object + + + StorageSystem + + If provided a StoragePool Resource Name, you must provide the StorageSystem name value if there are multiple Storage Pool resources with the same name. + + Object + + + Capacity + + The requested Ephemeral Volume storage capacity in GB. e.g. 20 to specify 20GB. + + Int64 + + + ProvisioningType + + Specify the volume provisioning type. Supported values: + + * Thin + * Full + * ThinDeduplication (only supported with HPE StoreServe) + + String + + + Full + + DEPRECATED. This parameter is replaced by ProvisioningType. + +Specify if the Ephemeral Volume provisioning type should be Thick. Default is Thin Volume. + + SwitchParameter + + + Permanent + + Specify if the Ephemeral Volume should be permanent. + + SwitchParameter + + + PerformancePolicy + + A Nimble Performance Policy is associated with a storage system. Using the Show-OVStorageSystemPerformancePolicy, choose an available performance policy. + +Example: + + Get-OVStorageSystem -Name MyNimbleSys | Show-OVStorageSystemPerformancePolicy + + HPEOneView.Storage.PerformancePolicy + + + EnableEncryption + + When the storage system has encryption enabled, the volume can also be encrypted. Specify if the volume should be encrypted during creation. + + Bool + + + CachePinning + + This is applicable for hybrid (a mix of flash and mechanical storage) arrays, and provides a 100 percent cache hit rate for specific volumes (for example, volumes dedicated to critical applications), and delivers the response times of an all-flash storage system. A volume is pinned when the entire active volume is placed in cache; associated snapshot (inactive) blocks are not pinned. All incoming data after that point is pinned. The number of volumes that can be pinned is limited by the size of the volumes and amount of available cache. + +When defined in the Performance Profile, select to enable Cache Pinnning for the Nimble volume to be created. + + Bool + + + VolumeSet + + Use to specify a Volume Set the volume will be associated with, from Get-OVStorageVolumeSet. + + HPEOneView.Storage.VolumeSet + + + EnableIOPSLimit + + Set to enable or disable IOPS limit. If enabled, the -IOPSLimit parameter must be set. By default, IOPS limit is not set. + + Bool + + + IOPSLimit + + When enabling IOPS limit, provide a value that is greater than or equal to 256. + + Int + + + EnableDataTransferLimit + + Enable data transfer limit. If enabled, the -DataTransferLimit parameter must be set. By default, data transfer limit is not set. + + Bool + + + DataTransferLimit + + Specify the data transfer limit in MiB/S. + + Int + + + Folder + + Specify the Nimble folder where the volume should be created. To get availabe folder objects, use the Get-OVStoragePool Cmdlet. Folders are defined as a device specific attribute. + +Example: + + (Get-OVStoragePool -name default).DeviceSpecificAttributes.Folders + +ID Name +-- ---- +2f1ca8a5d76e271722000000000000000000000001 POSH + + HPEOneView.Storage.NimbleFolder + + + LunIdType + + Specify Auto or Manual for the LUN ID assignment type. If Manual, use the -LunID parameter and provide a numerical value. + + String + + + LunID + + The Host LUN ID numerical value that will be configured in the Volume export on the Storage System. Accepted range: 0-254 + + Int32 + + + HostOStype + + Specify the Host OS type, which will set the Host OS value when HPE OneView creates the Host object on the Storage System. This parameter is only necessary if the Server Profile object does not have SAN Management enabled. + +Accepted values: + + * CitrixXen = "Citrix Xen Server 5.x/6.x" + * AIX = "AIX" + * IBMVIO = "IBM VIO Server" + * RHEL4 = "RHE Linux (Pre RHEL 5)" + * RHEL3 = "RHE Linux (Pre RHEL 5)" + * RHEL = "RHE Linux (5.x, 6.x)" + * RHEV = "RHE Virtualization (5.x, 6.x)" + * VMware = "ESX 4.x/5.x" + * Win2k3 = "Windows 2003" + * Win2k8 = "Windows 2008/2008 R2" + * Win2k12 = "Windows 2012 / WS2012 R2" + * OpenVMS = "OpenVMS" + * Egenera = "Egenera" + * Exanet = "Exanet" + * Solaris9 = "Solaris 9/10" + * Solaris10 = "Solaris 9/10" + * Solaris11 = "Solaris 11" + * ONTAP = "NetApp/ONTAP" + * OEL = "OE Linux UEK (5.x, 6.x)" + * HPUX11iv1 = "HP-UX (11i v1, 11i v2)" + * HPUX11iv2 = "HP-UX (11i v1, 11i v2)" + * HPUX11iv3 = "HP-UX (11i v3)" + * SUSE = "SuSE (10.x, 11.x)" + * SUSE9 = "SuSE Linux (Pre SLES 10)" + * Inform = "InForm" + + String + + + BootVolume + + Use to indicate this volume is a bootable device. When using this parameter, the Server Profile"s FC Connection(s) BootVolumeSource parameter set to "ManagedVolume". + +This parameter is only applicable with Private volumes. + + SwitchParameter + + + TargetPortAssignment + + Define whether host initiator port(s) should be mapped to target storage ports automatically or manually. + + SwitchParameter + + + TargetAddresses + + An array of target Port ID(s) or WWN(s). Example: @("1:0:1", "1:2:1", "3:1:1", "4:0:0") + + Array + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + + + New-OVServerProfileAttachVolume + + ServerProfile + + An existing Server Profile resource object from Get-OVServerProfile Cmdlet. + + Object + + + Volume + + The Volume Name, URI or Object to attach. + + Array + + + PassThru + + Use this parameter to return the modified Server Profile object. In order to save the changes, please use the Save-OVServerProfile Cmdlet. + + SwitchParameter + + + VolumeID + + The numeric identifier for this volume. Does not pertain to exported LUN ID value on array. + + Int32 + + + LunIdType + + Specify Auto or Manual for the LUN ID assignment type. If Manual, use the -LunID parameter and provide a numerical value. + + String + + + LunID + + The Host LUN ID numerical value that will be configured in the Volume export on the Storage System. Accepted range: 0-254 + + Int32 + + + HostOStype + + Specify the Host OS type, which will set the Host OS value when HPE OneView creates the Host object on the Storage System. This parameter is only necessary if the Server Profile object does not have SAN Management enabled. + +Accepted values: + + * CitrixXen = "Citrix Xen Server 5.x/6.x" + * AIX = "AIX" + * IBMVIO = "IBM VIO Server" + * RHEL4 = "RHE Linux (Pre RHEL 5)" + * RHEL3 = "RHE Linux (Pre RHEL 5)" + * RHEL = "RHE Linux (5.x, 6.x)" + * RHEV = "RHE Virtualization (5.x, 6.x)" + * VMware = "ESX 4.x/5.x" + * Win2k3 = "Windows 2003" + * Win2k8 = "Windows 2008/2008 R2" + * Win2k12 = "Windows 2012 / WS2012 R2" + * OpenVMS = "OpenVMS" + * Egenera = "Egenera" + * Exanet = "Exanet" + * Solaris9 = "Solaris 9/10" + * Solaris10 = "Solaris 9/10" + * Solaris11 = "Solaris 11" + * ONTAP = "NetApp/ONTAP" + * OEL = "OE Linux UEK (5.x, 6.x)" + * HPUX11iv1 = "HP-UX (11i v1, 11i v2)" + * HPUX11iv2 = "HP-UX (11i v1, 11i v2)" + * HPUX11iv3 = "HP-UX (11i v3)" + * SUSE = "SuSE (10.x, 11.x)" + * SUSE9 = "SuSE Linux (Pre SLES 10)" + * Inform = "InForm" + + String + + + BootVolume + + Use to indicate this volume is a bootable device. When using this parameter, the Server Profile"s FC Connection(s) BootVolumeSource parameter set to "ManagedVolume". + +This parameter is only applicable with Private volumes. + + SwitchParameter + + + TargetPortAssignment + + Define whether host initiator port(s) should be mapped to target storage ports automatically or manually. + + SwitchParameter + + + TargetAddresses + + An array of target Port ID(s) or WWN(s). Example: @("1:0:1", "1:2:1", "3:1:1", "4:0:0") + + Array + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + BootVolume + + Use to indicate this volume is a bootable device. When using this parameter, the Server Profile"s FC Connection(s) BootVolumeSource parameter set to "ManagedVolume". + +This parameter is only applicable with Private volumes. + + SwitchParameter + + SwitchParameter + + False + + + CachePinning + + This is applicable for hybrid (a mix of flash and mechanical storage) arrays, and provides a 100 percent cache hit rate for specific volumes (for example, volumes dedicated to critical applications), and delivers the response times of an all-flash storage system. A volume is pinned when the entire active volume is placed in cache; associated snapshot (inactive) blocks are not pinned. All incoming data after that point is pinned. The number of volumes that can be pinned is limited by the size of the volumes and amount of available cache. + +When defined in the Performance Profile, select to enable Cache Pinnning for the Nimble volume to be created. + + Bool + + Bool + + + + + Capacity + + The requested Ephemeral Volume storage capacity in GB. e.g. 20 to specify 20GB. + + Int64 + + Int64 + + 0 + + + DataTransferLimit + + Specify the data transfer limit in MiB/S. + + Int + + Int + + + + + EnableDataTransferLimit + + Enable data transfer limit. If enabled, the -DataTransferLimit parameter must be set. By default, data transfer limit is not set. + + Bool + + Bool + + + + + EnableEncryption + + When the storage system has encryption enabled, the volume can also be encrypted. Specify if the volume should be encrypted during creation. + + Bool + + Bool + + + + + EnableIOPSLimit + + Set to enable or disable IOPS limit. If enabled, the -IOPSLimit parameter must be set. By default, IOPS limit is not set. + + Bool + + Bool + + + + + Folder + + Specify the Nimble folder where the volume should be created. To get availabe folder objects, use the Get-OVStoragePool Cmdlet. Folders are defined as a device specific attribute. + +Example: + + (Get-OVStoragePool -name default).DeviceSpecificAttributes.Folders + +ID Name +-- ---- +2f1ca8a5d76e271722000000000000000000000001 POSH + + HPEOneView.Storage.NimbleFolder + + HPEOneView.Storage.NimbleFolder + + + + + Full + + DEPRECATED. This parameter is replaced by ProvisioningType. + +Specify if the Ephemeral Volume provisioning type should be Thick. Default is Thin Volume. + + SwitchParameter + + SwitchParameter + + False + + + HostOStype + + Specify the Host OS type, which will set the Host OS value when HPE OneView creates the Host object on the Storage System. This parameter is only necessary if the Server Profile object does not have SAN Management enabled. + +Accepted values: + + * CitrixXen = "Citrix Xen Server 5.x/6.x" + * AIX = "AIX" + * IBMVIO = "IBM VIO Server" + * RHEL4 = "RHE Linux (Pre RHEL 5)" + * RHEL3 = "RHE Linux (Pre RHEL 5)" + * RHEL = "RHE Linux (5.x, 6.x)" + * RHEV = "RHE Virtualization (5.x, 6.x)" + * VMware = "ESX 4.x/5.x" + * Win2k3 = "Windows 2003" + * Win2k8 = "Windows 2008/2008 R2" + * Win2k12 = "Windows 2012 / WS2012 R2" + * OpenVMS = "OpenVMS" + * Egenera = "Egenera" + * Exanet = "Exanet" + * Solaris9 = "Solaris 9/10" + * Solaris10 = "Solaris 9/10" + * Solaris11 = "Solaris 11" + * ONTAP = "NetApp/ONTAP" + * OEL = "OE Linux UEK (5.x, 6.x)" + * HPUX11iv1 = "HP-UX (11i v1, 11i v2)" + * HPUX11iv2 = "HP-UX (11i v1, 11i v2)" + * HPUX11iv3 = "HP-UX (11i v3)" + * SUSE = "SuSE (10.x, 11.x)" + * SUSE9 = "SuSE Linux (Pre SLES 10)" + * Inform = "InForm" + + String + + String + + + + + IOPSLimit + + When enabling IOPS limit, provide a value that is greater than or equal to 256. + + Int + + Int + + + + + LunID + + The Host LUN ID numerical value that will be configured in the Volume export on the Storage System. Accepted range: 0-254 + + Int32 + + Int32 + + 0 + + + LunIdType + + Specify Auto or Manual for the LUN ID assignment type. If Manual, use the -LunID parameter and provide a numerical value. + + String + + String + + Auto + + + Name + + Ephemeral Storage Volume resource name. + + Object + + Object + + + + + PassThru + + Use this parameter to return the modified Server Profile object. In order to save the changes, please use the Save-OVServerProfile Cmdlet. + + SwitchParameter + + SwitchParameter + + False + + + PerformancePolicy + + A Nimble Performance Policy is associated with a storage system. Using the Show-OVStorageSystemPerformancePolicy, choose an available performance policy. + +Example: + + Get-OVStorageSystem -Name MyNimbleSys | Show-OVStorageSystemPerformancePolicy + + HPEOneView.Storage.PerformancePolicy + + HPEOneView.Storage.PerformancePolicy + + + + + Permanent + + Specify if the Ephemeral Volume should be permanent. + + SwitchParameter + + SwitchParameter + + False + + + ProvisioningType + + Specify the volume provisioning type. Supported values: + + * Thin + * Full + * ThinDeduplication (only supported with HPE StoreServe) + + String + + String + + Thin + + + ServerProfile + + An existing Server Profile resource object from Get-OVServerProfile Cmdlet. + + Object + + Object + + + + + SnapshotStoragePool + + The supported Snapshot storage pool for a StoreServ storage system. Snapshot storage pool must originate from the same storage system as the assigned storage pool. + + Object + + Object + + + + + StoragePool + + The Storage Resource Pool object to provision the Ephemeral Volume from. + + Object + + Object + + + + + StorageSystem + + If provided a StoragePool Resource Name, you must provide the StorageSystem name value if there are multiple Storage Pool resources with the same name. + + Object + + Object + + + + + TargetAddresses + + An array of target Port ID(s) or WWN(s). Example: @("1:0:1", "1:2:1", "3:1:1", "4:0:0") + + Array + + Array + + + + + TargetPortAssignment + + Define whether host initiator port(s) should be mapped to target storage ports automatically or manually. + + SwitchParameter + + SwitchParameter + + + + + Volume + + The Volume Name, URI or Object to attach. + + Array + + Array + + + + + VolumeID + + The numeric identifier for this volume. Does not pertain to exported LUN ID value on array. + + Int32 + + Int32 + + 1 + + + VolumeSet + + Use to specify a Volume Set the volume will be associated with, from Get-OVStorageVolumeSet. + + HPEOneView.Storage.VolumeSet + + HPEOneView.Storage.VolumeSet + + + + + VolumeTemplate + + For Ephemeral (private) volumes that should be provisioned from Storage Volume Templates. Provide a valid resource from Get-OVStorageVolumeTemplate. + + Object + + Object + + + + + + + + + HPEOneView.Storage.Volume [System.Management.Automation.PSCustomObject] + + + Storage Volume Resource object + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + When attaching a one or more Storage Volumes to an existing Server Profile, an Appliance Async Task will be created + + + + + HPEOneView.Profile.SanVolume [System.Management.Automation.PSCustomObject] + + + + Returns a storage volume attachment object which may be used during profile creation. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + $attachVolume = New-OVServerProfileAttachVolume -volumeid 1 -volume Volume1 + + Create a Volume Attach object that maps to the "Volume1" storage volume with an Auto assigned Host LUN ID. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + $attachVolume = Get-OVStorageVolume -Name Volume1 | New-OVServerProfileAttachVolume -volumeid 1 + + Get the "Volume1" Storage Volume via the Get-OVStorageVolume Cmdlet, and pipe the resource object to the Get-OVServerProfileAttachVolume Cmdlet. + + + + + + + + + + -------------------------- EXAMPLE 3 -------------------------- + + + + $attachVolume = Get-OVStorageVolume -Name Volume1 | New-OVServerProfileAttachVolume -volumeid 1 -lunidtype manual -lunid 1 + + Get the "Volume1" Storage Volume via the Get-OVStorageVolume Cmdlet, and pipe the resource object to the Get-OVServerProfileAttachVolume Cmdlet, providing a manual Host LUN ID. + + + + + + + + + + -------------------------- EXAMPLE 4 -------------------------- + + + + $volume1 = Get-OVStorageVolume -Name Volume1 | New-OVServerProfileAttachVolume -volumeid 1 +$volume2 = Get-OVStorageVolume SharedVolume1 | New-OVServerProfileAttachVolume -volumeid 2 +$attachVolumes = @($volume1,$volume2) + + Get the "Volume1" and "SharedVolume1" Storage Volumes via the Get-OVStorageVolume Cmdlet, and pipe the resource objects to the Get-OVServerProfileAttachVolume Cmdlet, saving to $attachVolumes array. + + + + + + + + + + -------------------------- EXAMPLE 5 -------------------------- + + + + $storagepool = Get-OVStoragePool R1_FC +$sp = Get-OVServerProfile -Name "chef-web01" +New-OVServerProfileAttachVolume -ServerProfile $sp -Name "Chef Web01 Vol 2" -StoragePool $storagepool | Wait-OVTaskComplete + + Attach a new 10Gb Ephemeral Volume to an existing Server Profile. + + + + + + + + + + -------------------------- EXAMPLE 6 -------------------------- + + + + $sp = Get-OVServerProfile -Name "chef-web01" +Get-OVStorageVolume "My New Volume 3" | New-OVServerProfileAttachVolume -ServerProfile $sp | Wait-OVTaskComplete + + Attach an existing Storage Volume to a Server Profile. + + + + + + + + + + -------------------------- EXAMPLE 7 -------------------------- + + + + $storagepool = Get-OVStoragePool R1_FC +$sp = Get-OVServerProfile -Name "My Server Profile" +New-OVServerProfileAttachVolume -Name "My Server Profile Boot Vol" -ServerProfile $sp -StoragePool $storagepool -Bootable | Wait-OVTaskComplete + + Add a bootable volume to an existing Server Profile. + + + + + + + + + + -------------------------- EXAMPLE 8 -------------------------- + + + + $SVT = Get-OVStorageVolumeTemplate -Name StoreServe4-TPDD-SVT -ErrorAction Stop +$StorageVolumeObject = New-OVServerProfileAttachVolume -Name "Template 3 Private Vol 1" -VolumeTemplate $SVT + + Create a new ephemeral storage volume attachment, using a storage volume template. + + + + + + + + + + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/servers/new-ovserverprofileattachvolume + + + + + + + + New-OVServerProfileConnection + + Create network connection for a server profile. + + New + OVServerProfileConnection + + + A helper function to assist with connections when creating (New-OVServerProfile) or editing (Set-OVProfile) a server profile. + + + + + New-OVServerProfileConnection + + ConnectionID + + The numeric identifier for this connection. Connections are normally numbered sequentially from 1 within each profile. + + Int32 + + + Network + + The Network (Ethernet or Fibre Channel) or Network Set resource object to be used with this connection. Can either be the Name, URI, or object obtained with Get-OVNetwork or Get-OVNetworkSet. + +To create an unassigned connection, use the Unassigned keyword as the value. + + Object + + + ConnectionType + + Deprecated parameter. Connection type is now derived from the provided Network resource object. + + String + + + PortId + + Identifies the port (FlexNIC) used for this connection. The port can be automatically selected by specifying "Auto" when creating the connection. "None" is a valid portID for an unconfigured, and unmapped Connection. If you wish to specify the specific port, the portId format is "[adapter_type_prefix] [adapter_id]:[subport_id]". + +G7 only: For LOM ports, the valid portId prefix will be "Lom" +Gen8 only: For FlexLOMs, the valid portId prefix will be "Flb" +Mezzanine adapter prefix is "Mezz" + +An example of a FlexLOM 1, FlexNIC 1a interface would be "Flb 1:1a". An example Mezzanine 2, FlexNIC 2c interface would be "Mezz 2:2c" + + String + + + Name + + A string used to identify the respective connection. The connection name is case insensitive, limited to 63 characters and must be unique within the profile. + + String + + + RequestedBW + + Requested bandwidth (in Mbps) to be used for this connection. + +Default: 2500 + + Int32 + + + UserDefined + + Use to specify user defined address values + + SwitchParameter + + + MAC + + Requested MAC address of the connection. Must be specified if setting WWPN and WWNN, and the connection is mapped to a FlexHBA. + + String + + + Bootable + + Specify to configure bootable settings. If omitted, then the connection is not bootable, and -priority is set to NotBootable. + + Default: False + + SwitchParameter + + + LagName + + Specify the LAG Name for a Synergy Ethernet connection. Allowed value is "LAG1" - "LAG24". + + String + + + BootVolumeSource + + Specify how the Boot Volume Source will be set. Allowed values are: + + * AdapterBIOS - Boot from adapter BIOS volume parameters. + * ManagedVolume - Boot from a managed volume defined in SAN Storage section. + * UserDefined - Boot from user defined volume parameters. + +Default: AdapterBIOS + + String + + + Priority + + Optional boot option for this connection, but Required if -bootable is specified. Allowed values: + + * NotBootable + * UseBIOS + + * Primary + * Secondary + * IscsiPrimary + * IscsiSecondary + +When the Connection Type is Ethernet, this affects PXE boot. If the Connection Type is FibreChannel, this enables BfS settings. + + Default: NotBootable + + String + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + + + New-OVServerProfileConnection + + ConnectionID + + The numeric identifier for this connection. Connections are normally numbered sequentially from 1 within each profile. + + Int32 + + + Network + + The Network (Ethernet or Fibre Channel) or Network Set resource object to be used with this connection. Can either be the Name, URI, or object obtained with Get-OVNetwork or Get-OVNetworkSet. + +To create an unassigned connection, use the Unassigned keyword as the value. + + Object + + + ConnectionType + + Deprecated parameter. Connection type is now derived from the provided Network resource object. + + String + + + PortId + + Identifies the port (FlexNIC) used for this connection. The port can be automatically selected by specifying "Auto" when creating the connection. "None" is a valid portID for an unconfigured, and unmapped Connection. If you wish to specify the specific port, the portId format is "[adapter_type_prefix] [adapter_id]:[subport_id]". + +G7 only: For LOM ports, the valid portId prefix will be "Lom" +Gen8 only: For FlexLOMs, the valid portId prefix will be "Flb" +Mezzanine adapter prefix is "Mezz" + +An example of a FlexLOM 1, FlexNIC 1a interface would be "Flb 1:1a". An example Mezzanine 2, FlexNIC 2c interface would be "Mezz 2:2c" + + String + + + Name + + A string used to identify the respective connection. The connection name is case insensitive, limited to 63 characters and must be unique within the profile. + + String + + + RequestedBW + + Requested bandwidth (in Mbps) to be used for this connection. + +Default: 2500 + + Int32 + + + UserDefined + + Use to specify user defined address values + + SwitchParameter + + + MAC + + Requested MAC address of the connection. Must be specified if setting WWPN and WWNN, and the connection is mapped to a FlexHBA. + + String + + + Bootable + + Specify to configure bootable settings. If omitted, then the connection is not bootable, and -priority is set to NotBootable. + + Default: False + + SwitchParameter + + + LagName + + Specify the LAG Name for a Synergy Ethernet connection. Allowed value is "LAG1" - "LAG24". + + String + + + BootVolumeSource + + Specify how the Boot Volume Source will be set. Allowed values are: + + * AdapterBIOS - Boot from adapter BIOS volume parameters. + * ManagedVolume - Boot from a managed volume defined in SAN Storage section. + * UserDefined - Boot from user defined volume parameters. + +Default: AdapterBIOS + + String + + + Priority + + Optional boot option for this connection, but Required if -bootable is specified. Allowed values: + + * NotBootable + * UseBIOS + + * Primary + * Secondary + * IscsiPrimary + * IscsiSecondary + +When the Connection Type is Ethernet, this affects PXE boot. If the Connection Type is FibreChannel, this enables BfS settings. + + Default: NotBootable + + String + + + LUN + + Target LUN ID, if BootVolumeSource is set to UserDefined. + + Int32 + + + IscsiIPv4AddressSource + + Specify the IPv4 Address Source for the connection. Allowed values are: + + * DHCP + * UserDefined + * SubnetPool + + String + + + ISCSIInitatorName + + Value to provide for the iSCSI Initiator. All iSCSI Connections will share this value. If no value is provided, the connection will default to using the Server Profile Name. + +If configuring a Connection for a Server Profile Template, the value will be ignored + + String + + + IscsiIPv4Address + + The IPv4 Address to allocate for the initiator. This parameter value is ignored when assiging the Connection to a Server Profile Template. It will be enforced when creating a Server Profile from a Server Profile Template. + + IPAddress + + + IscsiIPv4SubnetMask + + The IPv4 Subnet Mask in full or CIDR bit value. + + String + + + IscsiIPv4Gateway + + The IPv4 Gateway. + + IPAddress + + + IscsiBootTargetIqn + + The IQN of the target iSCSI host. + + String + + + IscsiPrimaryBootTargetAddress + + The Primary Boot Target IPv4 Address. + + IPAddress + + + IscsiPrimaryBootTargetPort + + The Primary Boot Target TCP Port. Default is 3260 if not otherwise specified. + + Int32 + + + IscsiSecondaryBootTargetAddress + + The Secondary Boot Target IPv4 Address. + + IPAddress + + + IscsiSecondaryBootTargetPort + + The Secondary Boot Target TCP Port. Default is 3260 if not otherwise specified. + + Int32 + + + IscsiAuthenticationProtocol + + Specify the Authentication protocol to use. Allowed values are None, CHAP, MutualCHAP. When creating a Server Profile Connection for a Server Profile Template, the CHAP and Mutual CHAP credential parameters are ignored. They will be enforced when creating a Server Profile from a Server Profile Template. + + String + + + ChapName + + The CHAP challange name. + + String + + + ChapSecret + + The CHAP challange secret. Accepts ASCII or HEX values. If providing an ASCII secret value, the length must be bewteen 12 and 16 characters. If HEX, it must start with 0x and with 24-32 characters. Value is ignored when creating a Connection for a Server Profile Template. + + System.Security.SecureString + + + MutualChapName + + The Mutual CHAP challange. + + String + + + MutualChapSecret + + The Mutual CHAP challange secret. Accepts ASCII or HEX values. If providing an ASCII secret value, the length must be bewteen 12 and 16 characters. If HEX, it must start with 0x and with 24-32 characters. Value is ignored when creating a Connection for a Server Profile Template. + + System.Security.SecureString + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + + + New-OVServerProfileConnection + + ConnectionID + + The numeric identifier for this connection. Connections are normally numbered sequentially from 1 within each profile. + + Int32 + + + Network + + The Network (Ethernet or Fibre Channel) or Network Set resource object to be used with this connection. Can either be the Name, URI, or object obtained with Get-OVNetwork or Get-OVNetworkSet. + +To create an unassigned connection, use the Unassigned keyword as the value. + + Object + + + ConnectionType + + Deprecated parameter. Connection type is now derived from the provided Network resource object. + + String + + + PortId + + Identifies the port (FlexNIC) used for this connection. The port can be automatically selected by specifying "Auto" when creating the connection. "None" is a valid portID for an unconfigured, and unmapped Connection. If you wish to specify the specific port, the portId format is "[adapter_type_prefix] [adapter_id]:[subport_id]". + +G7 only: For LOM ports, the valid portId prefix will be "Lom" +Gen8 only: For FlexLOMs, the valid portId prefix will be "Flb" +Mezzanine adapter prefix is "Mezz" + +An example of a FlexLOM 1, FlexNIC 1a interface would be "Flb 1:1a". An example Mezzanine 2, FlexNIC 2c interface would be "Mezz 2:2c" + + String + + + Name + + A string used to identify the respective connection. The connection name is case insensitive, limited to 63 characters and must be unique within the profile. + + String + + + RequestedBW + + Requested bandwidth (in Mbps) to be used for this connection. + +Default: 2500 + + Int32 + + + UserDefined + + Use to specify user defined address values + + SwitchParameter + + + MAC + + Requested MAC address of the connection. Must be specified if setting WWPN and WWNN, and the connection is mapped to a FlexHBA. + + String + + + WWNN + + Requested WWNN address of the connection. + + String + + + WWPN + + Requested WWPN address of the connection. + + String + + + Bootable + + Specify to configure bootable settings. If omitted, then the connection is not bootable, and -priority is set to NotBootable. + + Default: False + + SwitchParameter + + + LagName + + Specify the LAG Name for a Synergy Ethernet connection. Allowed value is "LAG1" - "LAG24". + + String + + + BootVolumeSource + + Specify how the Boot Volume Source will be set. Allowed values are: + + * AdapterBIOS - Boot from adapter BIOS volume parameters. + * ManagedVolume - Boot from a managed volume defined in SAN Storage section. + * UserDefined - Boot from user defined volume parameters. + +Default: AdapterBIOS + + String + + + Priority + + Optional boot option for this connection, but Required if -bootable is specified. Allowed values: + + * NotBootable + * UseBIOS + + * Primary + * Secondary + * IscsiPrimary + * IscsiSecondary + +When the Connection Type is Ethernet, this affects PXE boot. If the Connection Type is FibreChannel, this enables BfS settings. + + Default: NotBootable + + String + + + TargetWwpn + + Target FC array WWPN. + + String + + + LUN + + Target LUN ID, if BootVolumeSource is set to UserDefined. + + Int32 + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + + + New-OVServerProfileConnection + + ConnectionID + + The numeric identifier for this connection. Connections are normally numbered sequentially from 1 within each profile. + + Int32 + + + Network + + The Network (Ethernet or Fibre Channel) or Network Set resource object to be used with this connection. Can either be the Name, URI, or object obtained with Get-OVNetwork or Get-OVNetworkSet. + +To create an unassigned connection, use the Unassigned keyword as the value. + + Object + + + ConnectionType + + Deprecated parameter. Connection type is now derived from the provided Network resource object. + + String + + + PortId + + Identifies the port (FlexNIC) used for this connection. The port can be automatically selected by specifying "Auto" when creating the connection. "None" is a valid portID for an unconfigured, and unmapped Connection. If you wish to specify the specific port, the portId format is "[adapter_type_prefix] [adapter_id]:[subport_id]". + +G7 only: For LOM ports, the valid portId prefix will be "Lom" +Gen8 only: For FlexLOMs, the valid portId prefix will be "Flb" +Mezzanine adapter prefix is "Mezz" + +An example of a FlexLOM 1, FlexNIC 1a interface would be "Flb 1:1a". An example Mezzanine 2, FlexNIC 2c interface would be "Mezz 2:2c" + + String + + + Name + + A string used to identify the respective connection. The connection name is case insensitive, limited to 63 characters and must be unique within the profile. + + String + + + RequestedBW + + Requested bandwidth (in Mbps) to be used for this connection. + +Default: 2500 + + Int32 + + + UserDefined + + Use to specify user defined address values + + SwitchParameter + + + MAC + + Requested MAC address of the connection. Must be specified if setting WWPN and WWNN, and the connection is mapped to a FlexHBA. + + String + + + Virtualfunctions + + Specify the number of Virtual Functions to enable on an Ethernet Connection. Must be in increments of 16. + + Int32 + + + Bootable + + Specify to configure bootable settings. If omitted, then the connection is not bootable, and -priority is set to NotBootable. + + Default: False + + SwitchParameter + + + LagName + + Specify the LAG Name for a Synergy Ethernet connection. Allowed value is "LAG1" - "LAG24". + + String + + + Priority + + Optional boot option for this connection, but Required if -bootable is specified. Allowed values: + + * NotBootable + * UseBIOS + + * Primary + * Secondary + * IscsiPrimary + * IscsiSecondary + +When the Connection Type is Ethernet, this affects PXE boot. If the Connection Type is FibreChannel, this enables BfS settings. + + Default: NotBootable + + String + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + + + + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + BootVolumeSource + + Specify how the Boot Volume Source will be set. Allowed values are: + + * AdapterBIOS - Boot from adapter BIOS volume parameters. + * ManagedVolume - Boot from a managed volume defined in SAN Storage section. + * UserDefined - Boot from user defined volume parameters. + +Default: AdapterBIOS + + String + + String + + AdapterBIOS + + + Bootable + + Specify to configure bootable settings. If omitted, then the connection is not bootable, and -priority is set to NotBootable. + + Default: False + + SwitchParameter + + SwitchParameter + + False + + + ChapName + + The CHAP challange name. + + String + + String + + + + + ChapSecret + + The CHAP challange secret. Accepts ASCII or HEX values. If providing an ASCII secret value, the length must be bewteen 12 and 16 characters. If HEX, it must start with 0x and with 24-32 characters. Value is ignored when creating a Connection for a Server Profile Template. + + System.Security.SecureString + + System.Security.SecureString + + + + + ConnectionID + + The numeric identifier for this connection. Connections are normally numbered sequentially from 1 within each profile. + + Int32 + + Int32 + + 1 + + + ConnectionType + + Deprecated parameter. Connection type is now derived from the provided Network resource object. + + String + + String + + Ethernet + + + ISCSIInitatorName + + Value to provide for the iSCSI Initiator. All iSCSI Connections will share this value. If no value is provided, the connection will default to using the Server Profile Name. + +If configuring a Connection for a Server Profile Template, the value will be ignored + + String + + String + + + + + IscsiAuthenticationProtocol + + Specify the Authentication protocol to use. Allowed values are None, CHAP, MutualCHAP. When creating a Server Profile Connection for a Server Profile Template, the CHAP and Mutual CHAP credential parameters are ignored. They will be enforced when creating a Server Profile from a Server Profile Template. + + String + + String + + + + + IscsiBootTargetIqn + + The IQN of the target iSCSI host. + + String + + String + + + + + IscsiIPv4Address + + The IPv4 Address to allocate for the initiator. This parameter value is ignored when assiging the Connection to a Server Profile Template. It will be enforced when creating a Server Profile from a Server Profile Template. + + IPAddress + + IPAddress + + + + + IscsiIPv4AddressSource + + Specify the IPv4 Address Source for the connection. Allowed values are: + + * DHCP + * UserDefined + * SubnetPool + + String + + String + + + + + IscsiIPv4Gateway + + The IPv4 Gateway. + + IPAddress + + IPAddress + + + + + IscsiIPv4SubnetMask + + The IPv4 Subnet Mask in full or CIDR bit value. + + String + + String + + + + + IscsiPrimaryBootTargetAddress + + The Primary Boot Target IPv4 Address. + + IPAddress + + IPAddress + + + + + IscsiPrimaryBootTargetPort + + The Primary Boot Target TCP Port. Default is 3260 if not otherwise specified. + + Int32 + + Int32 + + 3260 + + + IscsiSecondaryBootTargetAddress + + The Secondary Boot Target IPv4 Address. + + IPAddress + + IPAddress + + + + + IscsiSecondaryBootTargetPort + + The Secondary Boot Target TCP Port. Default is 3260 if not otherwise specified. + + Int32 + + Int32 + + 3260 + + + LUN + + Target LUN ID, if BootVolumeSource is set to UserDefined. + + Int32 + + Int32 + + 0 + + + LagName + + Specify the LAG Name for a Synergy Ethernet connection. Allowed value is "LAG1" - "LAG24". + + String + + String + + + + + MAC + + Requested MAC address of the connection. Must be specified if setting WWPN and WWNN, and the connection is mapped to a FlexHBA. + + String + + String + + + + + MutualChapName + + The Mutual CHAP challange. + + String + + String + + + + + MutualChapSecret + + The Mutual CHAP challange secret. Accepts ASCII or HEX values. If providing an ASCII secret value, the length must be bewteen 12 and 16 characters. If HEX, it must start with 0x and with 24-32 characters. Value is ignored when creating a Connection for a Server Profile Template. + + System.Security.SecureString + + System.Security.SecureString + + + + + Name + + A string used to identify the respective connection. The connection name is case insensitive, limited to 63 characters and must be unique within the profile. + + String + + String + + + + + Network + + The Network (Ethernet or Fibre Channel) or Network Set resource object to be used with this connection. Can either be the Name, URI, or object obtained with Get-OVNetwork or Get-OVNetworkSet. + +To create an unassigned connection, use the Unassigned keyword as the value. + + Object + + Object + + + + + PortId + + Identifies the port (FlexNIC) used for this connection. The port can be automatically selected by specifying "Auto" when creating the connection. "None" is a valid portID for an unconfigured, and unmapped Connection. If you wish to specify the specific port, the portId format is "[adapter_type_prefix] [adapter_id]:[subport_id]". + +G7 only: For LOM ports, the valid portId prefix will be "Lom" +Gen8 only: For FlexLOMs, the valid portId prefix will be "Flb" +Mezzanine adapter prefix is "Mezz" + +An example of a FlexLOM 1, FlexNIC 1a interface would be "Flb 1:1a". An example Mezzanine 2, FlexNIC 2c interface would be "Mezz 2:2c" + + String + + String + + Auto + + + Priority + + Optional boot option for this connection, but Required if -bootable is specified. Allowed values: + + * NotBootable + * UseBIOS + + * Primary + * Secondary + * IscsiPrimary + * IscsiSecondary + +When the Connection Type is Ethernet, this affects PXE boot. If the Connection Type is FibreChannel, this enables BfS settings. + + Default: NotBootable + + String + + String + + NotBootable + + + RequestedBW + + Requested bandwidth (in Mbps) to be used for this connection. + +Default: 2500 + + Int32 + + Int32 + + 2500 + + + TargetWwpn + + Target FC array WWPN. + + String + + String + + + + + UserDefined + + Use to specify user defined address values + + SwitchParameter + + SwitchParameter + + False + + + Virtualfunctions + + Specify the number of Virtual Functions to enable on an Ethernet Connection. Must be in increments of 16. + + Int32 + + Int32 + + 0 + + + WWNN + + Requested WWNN address of the connection. + + String + + String + + + + + WWPN + + Requested WWPN address of the connection. + + String + + String + + + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + System.Management.Automation.PSCustomObject + + + + Returns a connection object which may be used during profile creation with the New-OVServerProfile Cmdlet + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + $net41 = Get-OVNetwork -Name "Net-41" -ErrorAction Stop +$con41 = New-OVServerProfileConnection -ConnectionID 1 -ConnectionType Ethernet -Network $net41 + + Create a Network Connection ID 1, that is assigned to Net41 network, with Auto Port assignment. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + $con41 = Get-OVNetwork -Name "Net-41" -ErrorAction Stop | New-OVServerProfileConnection -ConnectionID 1 + + Create a Network Connection ID 1, that is assigned to Net41 network, with Auto Port assignment. + + + + + + + + + + -------------------------- EXAMPLE 3 -------------------------- + + + + $con41 = Get-OVNetwork -Name "FCoE Fabric A" -ErrorAction Stop | New-OVServerProfileConnection -ConnectionID 1 -ConnectionType FibreChannel + + Create a Network Connection ID 1, that is assigned to the FCoE network "FCoE Fabric A", with Auto Port assignment. + + + + + + + + + + -------------------------- EXAMPLE 4 -------------------------- + + + + $net42 = Get-OVNetwork -Name "Net-42" -ErrorAction Stop +$con42 = New-OVServerProfileConnection -ConnectionID 2 -ConnectionType Ethernet -network $net42 -bootable -priority Primary + + Create a Server Profile Connection ID 2, assigned to Net42 that is PXE Primary bootable. + + + + + + + + + + -------------------------- EXAMPLE 5 -------------------------- + + + + $conFabricA = Get-OVNetwork -Name "Fabric A" -ErrorAction Stop | New-OVServerProfileConnection -ConnectionID 3 -ConnectionType FibreChannel -bootable -priority Primary -Bootable + + Create a Server Profile Connection ID 3, assigned to Fabric A that is FC BfS Primary bootable. + + + + + + + + + + -------------------------- EXAMPLE 6 -------------------------- + + + + $con41 = Get-OVNetwork -Name "Net-41" -ErrorAction Stop | New-OVServerProfileConnection -ConnectionID 1 -ConnectionType Ethernet -userdefined -mac 11:22:33:44:55:66 -name "VLAN41 Prod Net" + + Create a Network Connection ID 1, that is assigned to Net41 network, with Auto Port assignment and custom MAC Address. + + + + + + + + + + -------------------------- EXAMPLE 7 -------------------------- + + + + $con41 = Get-OVNetwork -Name "Fabric A" | New-OVServerProfileConnection -ConnectionID 3 -ConnectionType FibreChannel -userdefined -mac 11:22:33:44:55:66 -wwpn 10:00:00:00:a1:55:1b:8f -wwnn 20:00:00:00:a1:55:1b:8f -name "VC FF Fabric A Connection" + + Create a Network Connection ID 3, that is assigned to a FibreChannel network, with Auto Port assignment and user defined hardware address values. + + + + + + + + + + -------------------------- EXAMPLE 8 -------------------------- + + + + $con41 = Get-OVNetwork -Name "Fabric A" -ErrorAction Stop | New-OVServerProfileConnection -ConnectionID 3 -ConnectionType FibreChannel -userdefined -mac 11:22:33:44:55:66 -wwpn 10:00:00:00:a1:55:1b:8f -wwnn 20:00:00:00:a1:55:1b:8f -name "VC FF Fabric A Connection" + + Create a Network Connection ID 3, that is assigned to a FibreChannel network, with Auto Port assignment and user defined hardware address values. + + + + + + + + + + -------------------------- EXAMPLE 9 -------------------------- + + + + $ISCSINetwork = Get-OVNetwork -Name "ImageStreamer Boot Network" -ErrorAction Stop +$IscsiParams = @{ + ConnectionID = 1; + Name = "ImageStreamer Connection 1"; + ConnectionType = "Ethernet"; + Network = $ISCSINetwork; + Bootable = $true; + Priority = "Primary"; + IscsiIPv4AddressSource = "SubnetPool" +} +$ImageStreamerBootConnection1 = New-OVServerProfileConnection @IscsiParams + + Create an HPE Synergy Image Streamer compliant connection. + + + + + + + + + + + + + Get-OVServerProfileConnectionList + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/servers/new-ovserverprofileconnection + + + + + + + + New-OVServerProfileIloPolicy + + Create compliant iLO settings object for server profile type resources. + + New + OVServerProfileIloPolicy + + + iLO settings enable you to configure and manage the settings in HPE OneView instead of logging into the iLO to apply the needed settings. These settings are included when you move the profile to another server hardware instance. Use a server profile template if you want to maintain consistent management for a specific iLO setting across multiple iLO. + +Using this Cmdlet will help create a compliant iLO settings object for either a server profile template or server profile resource. + +Manage administrator account +Configure the password of the predefined iLO administrator account or delete the account. + +Manage local accounts +Configure and manage the local accounts. When managed from HPE OneView, all the local accounts on the iLO are replaced when configuring the accounts specified in the server profile. Use New-OVIloLocalUserAccount helper Cmdlet to create a compliant object. + +Manage iLO Hostname +Configure the iLO subsystem name (hostname). When the iLO networking is configured to use DHCP, the iLO subsystem name will be used as the DNS name for the iLO. + +When the Manage iLO Hostname setting is enabled for a server profile, the hostname applied to the iLO is determined by replacing any serverProfileName token present with the name of server profile. The resulting hostname must match the limitations of a hostname (A-Z, a-z, 0-9, and dash). When applied to the server hardware, the iLO is reset to apply the new networking configuration. When the server profile is unassigned or the Manage iLO hostname setting is disabled, the iLO hostname is reverted to the factory default, which is, ΓÇ£iLO + Server Physical Serial NumberΓÇ¥. + +Manage directory configuration +Configure the iLO directory (Active Directory, LDAP, or Kerberos) to enable single sign-on. + +Manage directory groups +Grant access to specific directory groups for the iLO on the server hardware that is associated with the profile. When managed from HPE OneView, all the directory groups on the iLO are replaced when configuring the directory groups specified in the server profile. Use New-OVIloDirectoryGroup helper Cmdlet to create a compliant object. + +Manage key manager +Configure the iLO key manager for data at rest secure encryption. + +Planning for iLOdirectory configuration and key management + +Hewlett Packard Enterprise recommends that you plan your iLOdirectory configuration and key management in advance, and test on an iLO in the iLO interface. Confirm that the configuration is correct before configuring the iLO directory and key manager in HPE OneView using the tested settings. + +For more information, see the HPE iLO User Guide (http://www.hpe.com/support/ilo-docs). + + + + + New-OVServerProfileIloPolicy + + InputObject + + When using the -GenerateiLOSecurityDashboardSettings switch parameter, provide the server hardware type to generate the available security dashboard settings. iLO5 security dashboard settings are differnt than iLO6. + + Object + + + GenerateiLOSecurityDashboardSettings + + Generate available security dashboard settings. Must be accompanied by the -Inputobject parameter, as iLO5 security dashboard settings are different from iLO6. + + SwitchParameter + + + ManageLocalAdministratorAccount + + The iLO Administrator account will be managed via the profile. + + SwitchParameter + + + LocalAdministratorPassword + + The password to set for the local administrator account. + + SecureString + + + RemoveLocalAdministratorAccount + + Delete the account named Administrator from the iLO. WARNING: The iLO account named Administrator will be deleted when the profile is applied and cannot later be restored by OneView with the original permissions. The 'Administrative Recovery Set' privilege can only be restored via an iLO factory reset operation. + + Bool + + + ManageLocalAccounts + + Replace all local iLO accounts beyond Administrator. If you omit the LocalAccount parameter, all existing local accounts will be removed, except the build-in local Administrator and the configured _HPOneViewAdmin privileged accounts. The local Administrator account can be removed using the RemoveLocalAdministratorAccount, but you then risk locking everyone from accessing the iLO. + + SwitchParameter + + + LocalAccounts + + A collection of 1 or more local accounts created from New-OVIloLocalUserAccount helper Cmdlet. + + Object + + + ManageDirectoryConfiguration + + The iLO directory configuration (Active Directory, LDAP, or Kerberos) is managed via the profile. + + SwitchParameter + + + LdapSchema + + Enable use of a directory service for iLO user authorization. + +Allowed values: + + * Disabled + * DirectoryDefaulr + * HPEExtended + + String + + + GenericLDAP + + Use the OpenLDAP supported BIND method. Only supported when LdapSchema is DirectoryDefault. + + Bool + + + LOMObjectDistinguishedName + + Specifies the CAC LDAP service account when CAC/Smartcard authentication is configured and used with the schema-free directory option. User search contexts are not applied to the iLO object DN when iLO accesses the directory server. + + String + + + IloObjectPassword + + Specifies the password for the CAC LDAP service account when CAC/Smartcard authentication is configured and used with the schema-free directory option. User search contexts are not applied to the iLO object DN when iLO accesses the directory server. + + SecureString + + + DirectoryServerAddress + + Specifies the network DNS name or IP address of the directory server. The directory server address can be up to 127 characters. + + String + + + DirectoryServerPort + + Specifies the port number for the secure LDAP service on the server. The default value is 636. If your directory service is configured to use a different port, you can specify a different value. Make sure that you enter a secured LDAP port. iLO cannot connect to an unsecured LDAP port. + + Int + + + DirectoryServerCertificate + + Specifies a CA certificate to authenticate the directory server. The relative path and file name of the PEM Base64 string format file of the certificate to be used. Omit if the certificate has already been added to the appliance trust store. + + FileInfo + + + DirectoryServerCertificateBase64 + + Specifies a CA certificate to authenticate the directory server. The PEM Base64 string format of the certificate to be used. Omit if the certificate has already been added to the appliance trust store. + + String[] + + + DirectoryUserContext + + A common directory sub-context to be searched such that users do not need to enter their full DNs at login. + + String[] + + + EnableKerberosAuthentication + + Enables Kerberos login. When Kerberos login is enabled and configured correctly, the Zero Sign In button appears on the iLO login page. Kerberos configuration is independent of the LdapSchema chosen. + + Bool + + + KerberosRealm + + The name of the Kerberos realm in which the iLO processor operates. This value can be up to 128 characters. The realm name is usually the DNS name converted to uppercase letters. Realm names are case-sensitive. + + String + + + KerberosKDCServerAddress + + The IP address or DNS name of the KDC server. This value can be up to 128 characters. Each realm must have at least one Key Distribution Center (KDC) that contains an authentication server and a ticket grant server. These servers can be combined. + + String + + + KerberosKDCServerPort + + The TCP or UDP port number on which the KDC is listening. The default value is 88. + + Int + + + KerbersKeyTabFile + + An encoded binary file that contains pairs of service principal names and encrypted passwords. In the Windows environment, you use the ktpass utility to generate the keytab file. The components of the service principal name stored in the Kerberos keytab file are case sensitive. The primary (service type) must be in upper case (HTTP). The instance (iLO hostname) must be in lower case (e.g., iloexample.example.net). The realm name must be in upper case (e.g., EXAMPLE.NET). The REST encoding of this argument is a Base64-encoded Kerberos Keytab file as a string. + + FileInfo + + + ManageDirectoryGroups + + Replace all directory groups providing iLO management permissions. If you omit the DirectoryGroups parameter, all configured directory groups that exist on the iLO will be removed. + + SwitchParameter + + + DirectoryGroups + + A collection of 1 or more directory groups created from New-OVIloDirectoryGroup helper Cmdlet. + + Object + + + ManageIloHostname + + The iLO hostname will be managed via the profile. + + SwitchParameter + + + IloHostname + + The iLO subsystem name (hostname). This cannot include the domain name. Used as the base hostname when the iLO is configured to use DHCP. + + String + + + ManageKeyManager + + The iLO Key Manager (e.g. ESKM) configuration will be managed via the profile. + + SwitchParameter + + + PrimaryKeyServerAddress + + The primary key server hostname, IP address, or FQDN. This string can be up to 79 characters long. + + String + + + PrimaryKeyServerPort + + The primary key server port. The default is 9000. + + Int + + + SecondaryKeyServerAddress + + The secondary key server hostname, IP address, or FQDN. This string can be up to 79 characters long. + + String + + + SecondaryKeyServerPort + + The secondary key server port. The default is 9000. + + Int + + + RedundancyRequired + + If enabled, both a primary and secondary key server must be specified and will be validated by the iLO. + + Bool + + + KeymanagerGroupName + + The Local Group created on the key manager for use with iLO user accounts and the keys iLO imports into the key manager. + + String + + + KeymanagerLocalCertificateName + + The optional name of the local certificate authority certificate on the key manager. It is typically named Local CA. + + String + + + KeymanagerLoginName + + The Local User name with administrator permissions that is configured on the key manager. The deployment user account must be created before you add key manager configuration details in iLO. + + String + + + KeymanagerPassword + + The password for the Local User name with administrator permissions that is configured on the key manager. + + SecureString + + + + + + + DirectoryGroups + + A collection of 1 or more directory groups created from New-OVIloDirectoryGroup helper Cmdlet. + + Object + + Object + + + + + DirectoryServerAddress + + Specifies the network DNS name or IP address of the directory server. The directory server address can be up to 127 characters. + + String + + String + + + + + DirectoryServerCertificate + + Specifies a CA certificate to authenticate the directory server. The relative path and file name of the PEM Base64 string format file of the certificate to be used. Omit if the certificate has already been added to the appliance trust store. + + FileInfo + + FileInfo + + + + + DirectoryServerCertificateBase64 + + Specifies a CA certificate to authenticate the directory server. The PEM Base64 string format of the certificate to be used. Omit if the certificate has already been added to the appliance trust store. + + String[] + + String[] + + + + + DirectoryServerPort + + Specifies the port number for the secure LDAP service on the server. The default value is 636. If your directory service is configured to use a different port, you can specify a different value. Make sure that you enter a secured LDAP port. iLO cannot connect to an unsecured LDAP port. + + Int + + Int + + + + + DirectoryUserContext + + A common directory sub-context to be searched such that users do not need to enter their full DNs at login. + + String[] + + String[] + + + + + EnableKerberosAuthentication + + Enables Kerberos login. When Kerberos login is enabled and configured correctly, the Zero Sign In button appears on the iLO login page. Kerberos configuration is independent of the LdapSchema chosen. + + Bool + + Bool + + + + + GenerateiLOSecurityDashboardSettings + + Generate available security dashboard settings. Must be accompanied by the -Inputobject parameter, as iLO5 security dashboard settings are different from iLO6. + + SwitchParameter + + SwitchParameter + + + + + GenericLDAP + + Use the OpenLDAP supported BIND method. Only supported when LdapSchema is DirectoryDefault. + + Bool + + Bool + + + + + IloHostname + + The iLO subsystem name (hostname). This cannot include the domain name. Used as the base hostname when the iLO is configured to use DHCP. + + String + + String + + + + + IloObjectPassword + + Specifies the password for the CAC LDAP service account when CAC/Smartcard authentication is configured and used with the schema-free directory option. User search contexts are not applied to the iLO object DN when iLO accesses the directory server. + + SecureString + + SecureString + + + + + InputObject + + When using the -GenerateiLOSecurityDashboardSettings switch parameter, provide the server hardware type to generate the available security dashboard settings. iLO5 security dashboard settings are differnt than iLO6. + + Object + + Object + + + + + KerberosKDCServerAddress + + The IP address or DNS name of the KDC server. This value can be up to 128 characters. Each realm must have at least one Key Distribution Center (KDC) that contains an authentication server and a ticket grant server. These servers can be combined. + + String + + String + + + + + KerberosKDCServerPort + + The TCP or UDP port number on which the KDC is listening. The default value is 88. + + Int + + Int + + + + + KerberosRealm + + The name of the Kerberos realm in which the iLO processor operates. This value can be up to 128 characters. The realm name is usually the DNS name converted to uppercase letters. Realm names are case-sensitive. + + String + + String + + + + + KerbersKeyTabFile + + An encoded binary file that contains pairs of service principal names and encrypted passwords. In the Windows environment, you use the ktpass utility to generate the keytab file. The components of the service principal name stored in the Kerberos keytab file are case sensitive. The primary (service type) must be in upper case (HTTP). The instance (iLO hostname) must be in lower case (e.g., iloexample.example.net). The realm name must be in upper case (e.g., EXAMPLE.NET). The REST encoding of this argument is a Base64-encoded Kerberos Keytab file as a string. + + FileInfo + + FileInfo + + + + + KeymanagerGroupName + + The Local Group created on the key manager for use with iLO user accounts and the keys iLO imports into the key manager. + + String + + String + + + + + KeymanagerLocalCertificateName + + The optional name of the local certificate authority certificate on the key manager. It is typically named Local CA. + + String + + String + + + + + KeymanagerLoginName + + The Local User name with administrator permissions that is configured on the key manager. The deployment user account must be created before you add key manager configuration details in iLO. + + String + + String + + + + + KeymanagerPassword + + The password for the Local User name with administrator permissions that is configured on the key manager. + + SecureString + + SecureString + + + + + LOMObjectDistinguishedName + + Specifies the CAC LDAP service account when CAC/Smartcard authentication is configured and used with the schema-free directory option. User search contexts are not applied to the iLO object DN when iLO accesses the directory server. + + String + + String + + + + + LdapSchema + + Enable use of a directory service for iLO user authorization. + +Allowed values: + + * Disabled + * DirectoryDefaulr + * HPEExtended + + String + + String + + + + + LocalAccounts + + A collection of 1 or more local accounts created from New-OVIloLocalUserAccount helper Cmdlet. + + Object + + Object + + + + + LocalAdministratorPassword + + The password to set for the local administrator account. + + SecureString + + SecureString + + + + + ManageDirectoryConfiguration + + The iLO directory configuration (Active Directory, LDAP, or Kerberos) is managed via the profile. + + SwitchParameter + + SwitchParameter + + + + + ManageDirectoryGroups + + Replace all directory groups providing iLO management permissions. If you omit the DirectoryGroups parameter, all configured directory groups that exist on the iLO will be removed. + + SwitchParameter + + SwitchParameter + + + + + ManageIloHostname + + The iLO hostname will be managed via the profile. + + SwitchParameter + + SwitchParameter + + + + + ManageKeyManager + + The iLO Key Manager (e.g. ESKM) configuration will be managed via the profile. + + SwitchParameter + + SwitchParameter + + + + + ManageLocalAccounts + + Replace all local iLO accounts beyond Administrator. If you omit the LocalAccount parameter, all existing local accounts will be removed, except the build-in local Administrator and the configured _HPOneViewAdmin privileged accounts. The local Administrator account can be removed using the RemoveLocalAdministratorAccount, but you then risk locking everyone from accessing the iLO. + + SwitchParameter + + SwitchParameter + + + + + ManageLocalAdministratorAccount + + The iLO Administrator account will be managed via the profile. + + SwitchParameter + + SwitchParameter + + + + + PrimaryKeyServerAddress + + The primary key server hostname, IP address, or FQDN. This string can be up to 79 characters long. + + String + + String + + + + + PrimaryKeyServerPort + + The primary key server port. The default is 9000. + + Int + + Int + + + + + RedundancyRequired + + If enabled, both a primary and secondary key server must be specified and will be validated by the iLO. + + Bool + + Bool + + + + + RemoveLocalAdministratorAccount + + Delete the account named Administrator from the iLO. WARNING: The iLO account named Administrator will be deleted when the profile is applied and cannot later be restored by OneView with the original permissions. The 'Administrative Recovery Set' privilege can only be restored via an iLO factory reset operation. + + Bool + + Bool + + + + + SecondaryKeyServerAddress + + The secondary key server hostname, IP address, or FQDN. This string can be up to 79 characters long. + + String + + String + + + + + SecondaryKeyServerPort + + The secondary key server port. The default is 9000. + + Int + + Int + + + + + + + + + None. You cannot pipe objects to this cmdlet. + + + + + + + + + + + System.Management.Automation.PSCustomObject + + + + An iLO settings complient object for server profile resources. + + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + $AdministratorPasswordSecureString = Read-Host "Administrator password" -AsSecureString + +# Create iLO settings policy for server profile +New-OVServerProfileIloPolicy -ManageLocalAdministratorAccount ` + -LocalAdministratorPassword $AdministratorPasswordSecureString ` + -ManageIloHostname ` + -IloHostname "{serverProfileName}-prod-ilo" + + Create a server profile compliant iLO settings policy by setting the local administrator password to the prompted value, and set the iLO hostname. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + # Create account1 object +$Account1 = New-OVIloLocalUserAccount -Username "localuser1" ` + -Password (Read-Host "localuser1 password" -AsSecureString) ` + -DisplayName "localuser1" ` + -AdministerUserAccounts ` + -RemoteConsole ` + -VirtualMedia ` + -VirtualPowerAndReset ` + -ConfigureIloSettings ` + -Login ` + -HostBIOS ` + -HostNIC ` + -HostStorage + +# Create account2 object +$Account2 = New-OVIloLocalUserAccount -Username "localuser2" ` + -Password (Read-Host "localuser1 password" -AsSecureString) ` + -DisplayName "localuser2" ` + -RemoteConsole ` + -VirtualMedia ` + -VirtualPowerAndReset ` + -Login ` + -HostBIOS ` + -HostNIC ` + -HostStorage + +# Create group1 object +$Group1 = New-OVIloDirectoryGroup -GroupDN "dn=ilogroup1, ou=ou1, dc=domain, dc=com" ` + -GroupSID "sid12345" ` + -AdministerUserAccounts ` + -RemoteConsole ` + -VirtualMedia ` + -ConfigureIloSettings + +# Create group2 object +$Group2 = New-OVIloDirectoryGroup -GroupDN "dn=opsgroup, ou=ou1, dc=domain,d c=com" ` + -GroupSID "sid67890" ` + -RemoteConsole ` + -VirtualMedia + +# Create iLO settings policy for server profile +New-OVServerProfileIloPolicy -ManageLocalAdministratorAccount ` + -LocalAdministratorPassword $AdministratorPasswordSecureString ` + -ManageLocalAccounts ` + -LocalAccounts $Account1, $Account2 ` + -ManageDirectoryConfiguration ` + -LdapSchema DirectoryDefault ` + -LOMObjectDistinguishedName "dn=lomobject, ou=OU1, dc=domain, dc=com" ` + -DirectoryServerAddress "ldap.domain.com" ` + -DirectoryUserContext 'ou=OU1, dc=domain, dc=com', 'ou=OU2, dc=domain, dc=com', 'ou=OU3, dc=domain, dc=com' ` + -ManageDirectoryGroups ` + -DirectoryGroups $Group1, $Group2 ` + -ManageIloHostname ` + -IloHostname "{serverProfileName}-prod-ilo" + + Create a server profile compliant iLO settings policy, by managing the local administrator account, adding the specified local accounts, directory authentication and directory groups, and iLO hostname. + + + + + + + + + + + + + New-OVIloLocalUserAccount + + + + New-OVIloDirectoryGroup + + + + New-OVServerProfile + + + + New-OVServerProfileTemplate + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/servers/new-ovserverprofileilopolicy + + + + + + + + New-OVServerProfileLogicalDisk + + Create Server Profile Logical Disk object. + + New + OVServerProfileLogicalDisk + + + This helper Cmdlet will create a Logical Disk object to then be assigned to a Server Profile Template or Server Profile using the -LogicalDisk parameter. The LogicalDisk configuration is supported with the embedded (or Slot 0) HPE SmartArray controller for DL and BL class systems only. + + + + + New-OVServerProfileLogicalDisk + + Name + + Logical Disk name. Must be unique within the Server Profile. + + String + + + RAID + + The RAID level of the logical drive. Supported values depend on the local storage capabilities of the selected server hardware type. + +Only RAID0 and RAID1 are supported for embedded BL disk policies. RAID5, RAID6, RAID10 are supported with DL servers with SmartArray controller that supports the RAID type. RAID0, RAID1ADM, RAID10, RAID5, and RAID6 are supported values with HPE Synergy D3940 disk shelf. + + String + + + NumberofDrives + + The number of physical drives to be used to build the logical drive. The provided values must be consistent with the selected RAID level and cannot exceed the maximum supported number of drives for the selected server hardware type. + + Int32 + + + DriveType + + Defines the interface type for drives that will be used to build the logical drive. Supported values depend on the local storage capabilities of the selected server hardware type. Allowed value: + + * SAS + *SATA + *SASSSD + *SATASSD + *Auto +NOTE: Auto is not supported when attempting to create an HPE Synergy D3940 Logical or JBOD disk. You must specify a disk technology type unless -DriveSelectionBy is changed to DriveType and -AvailableDriveType is used. Allowed values are: + + * SAS + * SATA + * SASSSD + * SATASSD + * NVMeSas + * NVMeSata + * Auto + + String + + + StorageLocation + + Specify Internal for HPE Synergy Compute Nodes that have the Expanded Storage option connected to an available mezzanine SmartArray controller for NVMe drives. DriveType parameter then must be set to NVMeSata or NVMeSAS. Use External to specify storage will be allocated from the D3940 disk shelf. + + String + + + Accelerator + + For Gen10 Smart Array controllers only. When using Auto for drive type allocation and supplied 'Enabled', the Accelorator policy will be set to 'ControllerCache'. If drive allocation type is an 'SSD' drive, the accelorator policy will be set to 'IOBypass'. Disabled will set the accelorator policy to 'None'. Default is 'Unmanaged'. + + String + + + Bootable + + Indicates if the logical drive is bootable or not. Cannot be combined with an FC or FCoE Server Profile Connection that is also set as Bootable. Parameter is not valid with defining Synergy JBOD SAS disk policies. + + Boolean + + + + New-OVServerProfileLogicalDisk + + Name + + Logical Disk name. Must be unique within the Server Profile. + + String + + + RAID + + The RAID level of the logical drive. Supported values depend on the local storage capabilities of the selected server hardware type. + +Only RAID0 and RAID1 are supported for embedded BL disk policies. RAID5, RAID6, RAID10 are supported with DL servers with SmartArray controller that supports the RAID type. RAID0, RAID1ADM, RAID10, RAID5, and RAID6 are supported values with HPE Synergy D3940 disk shelf. + + String + + + NumberofDrives + + The number of physical drives to be used to build the logical drive. The provided values must be consistent with the selected RAID level and cannot exceed the maximum supported number of drives for the selected server hardware type. + + Int32 + + + DriveType + + Defines the interface type for drives that will be used to build the logical drive. Supported values depend on the local storage capabilities of the selected server hardware type. Allowed value: + + * SAS + *SATA + *SASSSD + *SATASSD + *Auto +NOTE: Auto is not supported when attempting to create an HPE Synergy D3940 Logical or JBOD disk. You must specify a disk technology type unless -DriveSelectionBy is changed to DriveType and -AvailableDriveType is used. Allowed values are: + + * SAS + * SATA + * SASSSD + * SATASSD + * NVMeSas + * NVMeSata + * Auto + + String + + + DriveSelectionBy + + Use to specify how the drive selection will be used. Allowed values: + + * DriveType - Use Get-OVAvailableDriveType to locate available drive types, quantity to which SAS Logical Interconnect or Drive Enclosure. + * SizeAndTechnology - Use to define the attributes of the drive based on technology and min/max drive size. The -DriveType and -MinDriveSize parameters are required. + +Default: SizeAndTechnology + + String + + + AvailableDriveType + + A specific availabe drive type from Get-OVAvailableDriveType. + + HPEOneView.Storage.AvailableDriveType + + + StorageLocation + + Specify Internal for HPE Synergy Compute Nodes that have the Expanded Storage option connected to an available mezzanine SmartArray controller for NVMe drives. DriveType parameter then must be set to NVMeSata or NVMeSAS. Use External to specify storage will be allocated from the D3940 disk shelf. + + String + + + MinDriveSize + + Only for HPE Synergy D3940. Specify the minimum size disk to request. Required when -DriveSelectionBy is set to SizeAndTechnology. + + Int32 + + + MaxDriveSize + + Only for HPE Synergy D3940. If the parameter is not specified, the MinDriveSize parameter value will be used. + + Int32 + + + EraseDataOnDelete + + Indicates if the logical drive should be erased when it is deleted from or with the Server Profile. + + SwitchParameter + + + Permanent + + When set to true, the logical JBOD will not be deleted when the associated profile is deleted. + + String + + + AddSpareDrive + + When selected, an additional drive will be reserved (beyond what was specified) for use as a replacement drive in the event of a drive failure in the logical drive. Ensure the -PredictiveSpareActivation parameter is used in New-OVServerProfileLogicalDiskController. + + SwitchParameter + + + Bootable + + Indicates if the logical drive is bootable or not. Cannot be combined with an FC or FCoE Server Profile Connection that is also set as Bootable. Parameter is not valid with defining Synergy JBOD SAS disk policies. + + Boolean + + + + New-OVServerProfileLogicalDisk + + Name + + Logical Disk name. Must be unique within the Server Profile. + + String + + + Drives + + One or more drives to allocate. Use Get-OVServerHardwareAvailableController Cmdlet and examine the Drives attribute within the [HPEOneView.Servers.PhysicalDrive] object. + +NOTE: Using this parameter will create a logical drive resource that can only be used with server profile resources. + + HPEOneView.Servers.PhysicalDrive[] + + + RAID + + The RAID level of the logical drive. Supported values depend on the local storage capabilities of the selected server hardware type. + +Only RAID0 and RAID1 are supported for embedded BL disk policies. RAID5, RAID6, RAID10 are supported with DL servers with SmartArray controller that supports the RAID type. RAID0, RAID1ADM, RAID10, RAID5, and RAID6 are supported values with HPE Synergy D3940 disk shelf. + + String + + + Accelerator + + For Gen10 Smart Array controllers only. When using Auto for drive type allocation and supplied 'Enabled', the Accelorator policy will be set to 'ControllerCache'. If drive allocation type is an 'SSD' drive, the accelorator policy will be set to 'IOBypass'. Disabled will set the accelorator policy to 'None'. Default is 'Unmanaged'. + + String + + + AddSpareDrive + + When selected, an additional drive will be reserved (beyond what was specified) for use as a replacement drive in the event of a drive failure in the logical drive. Ensure the -PredictiveSpareActivation parameter is used in New-OVServerProfileLogicalDiskController. + + SwitchParameter + + + SpareDrives + + One or more drives to allocate. Use Get-OVServerHardwareAvailableController Cmdlet and examine the Drives attribute within the [HPEOneView.Servers.PhysicalDrive] object. + + HPEOneView.Servers.PhysicalDrive[] + + + Bootable + + Indicates if the logical drive is bootable or not. Cannot be combined with an FC or FCoE Server Profile Connection that is also set as Bootable. Parameter is not valid with defining Synergy JBOD SAS disk policies. + + Boolean + + + ReadCachePolicy + + Controls the read cache policy. + + * Enabled - Configures Read ahead policy on the controller. A caching technique in which the controller pre-fetches data anticipating future read requests, based on previous cache hits. + * Disabled - Disables read caching for this logical drive. + * Unmanaged - This setting is not managed by HPE OneView, but can managed by the user outside of the server profile resource. + + string + + + WriteCachePolicy + + Controls the write cache policy. + + * Enabled - Configured Protected Write Back poicy on the controller. The completion of a write request is signaled as soon as the data is in cache, and actual writing to non-volatile media is guaranteed to occur at a later time. + * Disabled - Disables write caching for this logical drive. + * Unmanaged - This setting is not managed by HPE OneView, but can managed by the user outside of the server profile resource. + + string + + + IOPerformanceMode + + Controls the logical drive's IO performance mode setting. When enabled, IO operations will bypass the controller cache and read and write cache policy settings will be set to off. A drive technology using SSD is required to enable IO performance mode. + +Managed manually: This setting is managed by the user outside OneView. + + string + + + + + + + Accelerator + + For Gen10 Smart Array controllers only. When using Auto for drive type allocation and supplied 'Enabled', the Accelorator policy will be set to 'ControllerCache'. If drive allocation type is an 'SSD' drive, the accelorator policy will be set to 'IOBypass'. Disabled will set the accelorator policy to 'None'. Default is 'Unmanaged'. + + String + + String + + Unmanaged + + + AddSpareDrive + + When selected, an additional drive will be reserved (beyond what was specified) for use as a replacement drive in the event of a drive failure in the logical drive. Ensure the -PredictiveSpareActivation parameter is used in New-OVServerProfileLogicalDiskController. + + SwitchParameter + + SwitchParameter + + + + + AvailableDriveType + + A specific availabe drive type from Get-OVAvailableDriveType. + + HPEOneView.Storage.AvailableDriveType + + HPEOneView.Storage.AvailableDriveType + + + + + Bootable + + Indicates if the logical drive is bootable or not. Cannot be combined with an FC or FCoE Server Profile Connection that is also set as Bootable. Parameter is not valid with defining Synergy JBOD SAS disk policies. + + Boolean + + Boolean + + False + + + DriveSelectionBy + + Use to specify how the drive selection will be used. Allowed values: + + * DriveType - Use Get-OVAvailableDriveType to locate available drive types, quantity to which SAS Logical Interconnect or Drive Enclosure. + * SizeAndTechnology - Use to define the attributes of the drive based on technology and min/max drive size. The -DriveType and -MinDriveSize parameters are required. + +Default: SizeAndTechnology + + String + + String + + SizeAndTechnology + + + DriveType + + Defines the interface type for drives that will be used to build the logical drive. Supported values depend on the local storage capabilities of the selected server hardware type. Allowed value: + + * SAS + *SATA + *SASSSD + *SATASSD + *Auto +NOTE: Auto is not supported when attempting to create an HPE Synergy D3940 Logical or JBOD disk. You must specify a disk technology type unless -DriveSelectionBy is changed to DriveType and -AvailableDriveType is used. Allowed values are: + + * SAS + * SATA + * SASSSD + * SATASSD + * NVMeSas + * NVMeSata + * Auto + + String + + String + + Auto + + + Drives + + One or more drives to allocate. Use Get-OVServerHardwareAvailableController Cmdlet and examine the Drives attribute within the [HPEOneView.Servers.PhysicalDrive] object. + +NOTE: Using this parameter will create a logical drive resource that can only be used with server profile resources. + + HPEOneView.Servers.PhysicalDrive[] + + HPEOneView.Servers.PhysicalDrive[] + + + + + EraseDataOnDelete + + Indicates if the logical drive should be erased when it is deleted from or with the Server Profile. + + SwitchParameter + + SwitchParameter + + False + + + IOPerformanceMode + + Controls the logical drive's IO performance mode setting. When enabled, IO operations will bypass the controller cache and read and write cache policy settings will be set to off. A drive technology using SSD is required to enable IO performance mode. + +Managed manually: This setting is managed by the user outside OneView. + + string + + string + + + + + MaxDriveSize + + Only for HPE Synergy D3940. If the parameter is not specified, the MinDriveSize parameter value will be used. + + Int32 + + Int32 + + 0 + + + MinDriveSize + + Only for HPE Synergy D3940. Specify the minimum size disk to request. Required when -DriveSelectionBy is set to SizeAndTechnology. + + Int32 + + Int32 + + 0 + + + Name + + Logical Disk name. Must be unique within the Server Profile. + + String + + String + + + + + NumberofDrives + + The number of physical drives to be used to build the logical drive. The provided values must be consistent with the selected RAID level and cannot exceed the maximum supported number of drives for the selected server hardware type. + + Int32 + + Int32 + + 2 + + + Permanent + + When set to true, the logical JBOD will not be deleted when the associated profile is deleted. + + String + + String + + Unmanaged + + + RAID + + The RAID level of the logical drive. Supported values depend on the local storage capabilities of the selected server hardware type. + +Only RAID0 and RAID1 are supported for embedded BL disk policies. RAID5, RAID6, RAID10 are supported with DL servers with SmartArray controller that supports the RAID type. RAID0, RAID1ADM, RAID10, RAID5, and RAID6 are supported values with HPE Synergy D3940 disk shelf. + + String + + String + + RAID1 + + + ReadCachePolicy + + Controls the read cache policy. + + * Enabled - Configures Read ahead policy on the controller. A caching technique in which the controller pre-fetches data anticipating future read requests, based on previous cache hits. + * Disabled - Disables read caching for this logical drive. + * Unmanaged - This setting is not managed by HPE OneView, but can managed by the user outside of the server profile resource. + + string + + string + + + + + SpareDrives + + One or more drives to allocate. Use Get-OVServerHardwareAvailableController Cmdlet and examine the Drives attribute within the [HPEOneView.Servers.PhysicalDrive] object. + + HPEOneView.Servers.PhysicalDrive[] + + HPEOneView.Servers.PhysicalDrive[] + + + + + StorageLocation + + Specify Internal for HPE Synergy Compute Nodes that have the Expanded Storage option connected to an available mezzanine SmartArray controller for NVMe drives. DriveType parameter then must be set to NVMeSata or NVMeSAS. Use External to specify storage will be allocated from the D3940 disk shelf. + + String + + String + + External + + + WriteCachePolicy + + Controls the write cache policy. + + * Enabled - Configured Protected Write Back poicy on the controller. The completion of a write request is signaled as soon as the data is in cache, and actual writing to non-volatile media is guaranteed to occur at a later time. + * Disabled - Disables write caching for this logical drive. + * Unmanaged - This setting is not managed by HPE OneView, but can managed by the user outside of the server profile resource. + + string + + string + + + + + + + + + HPEOneView.Storage.AvailableDriveType + + + An available disk drive type from Get-OVAvailableDriveType Cmdlet. + + + + + + + + System.Management.Automation.PSCustomObject + + + + Logical Disk configuration object + + + + + System.Collections.ArrayList<System.Management.Automation.PSCustomObject> + + + + Collection of Logical Disk configuration objects + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + $LogicalDisk = New-OVServerProfileLogicalDisk -Name "MyDisk" + + Create a default Logical Disk configuration object. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + $ld1 = New-OVServerProfileLogicalDisk -Name "Boot Disk" -RAID RAID1 -NumberofDrives 2 -Bootable $True + + Create a custom Logical Disk with the provided parameter values. + + + + + + + + + + -------------------------- EXAMPLE 3 -------------------------- + + + + $ld1 = New-OVServerProfileLogicalDisk -Name "Boot Disk" -RAID RAID1 -NumberofDrives 2 -DriveType SAS -MinDriveSize 300 -Bootable $True + + Create a custom HPE Synergy D3940 bootable RAID Logical Disk with the provided parameter values. + + + + + + + + + + -------------------------- EXAMPLE 4 -------------------------- + + + + $AvailableDriveType = Get-OVSasLogicalInterconnect -Name "LE1-Default SAS Synergy LIG-3" -ErrorAction Stop | Get-OVAvailableDriveType | ? { $_.Type -eq "SASHDD" -and $_.capacity -eq 900 } +$NewLogicalDisk = New-OVServerProfileLogicalDisk -Name "LD1_RAID5_900GB_SASHDD" -DriveSelectionBy DriveType -NumberofDrives 6 -RAID RAID5 -AvailableDriveType $AvailableDriveType + + Create a RAID5 Logical Disk for a Server Profile using D3940 storage, and a specific available drive type, 900GB capacity and SASHDD type. + + + + + + + + + + -------------------------- EXAMPLE 5 -------------------------- + + + + $JBODLogicalDisk = New-OVServerProfileLogicalDisk -Name "JBOD1_900GB_SASHDD" -NumberofDrives 6 -MinDriveSize 900 -DriveType SAS + + Create logical JBOD to then be attached to either a Gen10 Mixed Mode or Gen9 or newer HBA mode controller. + + + + + + + + + + -------------------------- EXAMPLE 6 -------------------------- + + + + # Get the specific server. Server must have been powered on at least 1 time to complete POST in order for server inventory to be updated +$Server = Get-OVServer -Name MyGen11Server + +# Get the available controllers and drives from the specific server +$AvailableControllers = Get-OVServerHardwareAvailableController -InputObject $Server + +# Review installed controllers +$AvailableControllers | ? { -not [String]::IsNullOrEmpty($_.DeviceSlot) } + +DeviceSlot : Slot 1 +Family : SmartRAID +Type : Standup +Model : HPE SR308i-p Gen11 +Firmware : 5.29-256 +ControllerMode : HPEOneView.Servers.ControllerModes +RaidModes : HPEOneView.Servers.RaidModes +DriveTechnologies : HPEOneView.Servers.DriveTechnologies +ReadCachePolicy : HPEOneView.Servers.ReadCachePolicy +WriteCachePolicy : HPEOneView.Servers.WriteCachePolicy +Capabilities : {RedfishConfig, RedfishDedicatedSpare} +Drives : {1I:1:41 147 GB (NvmeSsd), 1I:1:42 147 GB (NvmeSsd), 1I:1:43 147 GB (NvmeSsd), 1I:1:44 147 GB (NvmeSsd)ΓǪ} +MaximumLogicalDrives : 256 +MaximumDrives : 256 +ApplianceConnection : MyAppliance + +# Review available drives attached to controller in "Slot 1" +($AvailableControllers | ? DeviceSlot -eq "Slot 1").Drives + +Location Model Capacity DriveTechnology IsAllocated FailurePredicted LifeRemaining +-------- ----- -------- --------------- ----------- ---------------- ------------- +1I:1:41 EH0146FCBVB 147 GB NvmeSsd True False 100% +1I:1:42 EH0146FCBVB 147 GB NvmeSsd True False 100% +1I:1:43 EH0146FCBVB 147 GB NvmeSsd True False 100% +1I:1:44 EH0146FCBVB 147 GB NvmeSsd False False 100% +1I:1:45 EH0146FCBVB 147 GB SataHdd False False 0% +1I:1:46 EH0146FCBVB 147 GB SataHdd False False 0% +1I:1:47 EH0146FCBVB 147 GB SataHdd False False 0% +1I:1:48 EH0146FCBVB 147 GB SataHdd False False 0% +1I:1:49 EH0146FCBVB 147 GB SataHdd False False 0% +1I:1:50 EH0146FCBVB 147 GB SataSsd True False 100% +1I:1:51 EH0146FCBVB 147 GB SataSsd True False 100% +1I:1:52 EH0146FCBVB 147 GB SataSsd False False 100% + +# Filter out available SataHdd for a 3+1 and spare drive configuration +$DrivesToAssign = ($AvailableControllers | ? DeviceSlot -eq "Slot 1").Drives | ? { $_.DriveTechnology -eq "SataHdd" -and -not $_.IsAllocated } | Select -First 5 + +# Create the logical drive, specifying drives and the spare drive to use (which is the last drive in the collection) +$LogicalDrive = New-OVServerProfileLogicalDisk -Name RAID5+Spare-DATA -Drives $DrivesToAssign -RAID Raid5 -AddSpareDrive -SpareDrives $DrivesToAssign[-1] + + Identify available storage controllers and drives, and create a logical disk with specific drives from inventory including spare drive. + + + + + + + + + + + + + Get-OVServerHardwareAvailableController + + + + New-OVServerProfileLogicalDiskController + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/servers/new-ovserverprofilelogicaldisk + + + + + + + + New-OVServerProfileLogicalDiskController + + Create Server Profile disk controller policy object. + + New + OVServerProfileLogicalDiskController + + + This helper Cmdlet will create a Logical Disk controller object to then be assigned to a Server Profile Template or Server Profile using the -LogicalDisk parameter. + + + + + New-OVServerProfileLogicalDiskController + + ControllerID + + Specify the Controller ID location. Supported options for this parameter are + * Embedded + * Mezz1 + * Mezz2 + * Mezz3 + * Slot1 + * Slot10 + * Slot11 + * Slot12 + * Slot13 + * Slot14 + * Slot15 + * Slot16 + * Slot2 + * Slot3 + * Slot4 + * Slot5 + * Slot6 + * Slot7 + * Slot8 + * Slot9 +Please note that Mezz1, Mezz2 and Mezz3 are only supported with HPE Synergy Compute nodes connected to the HPE Synergy D3940 disk shelf. + + Object + + + Mode + + The mode to configure the Smart Array Controller as. Accepted values are: + + * HBA + * RAID + +When specifying HBA, you cannot attach a RAID Logical Disk to this policy. + + String + + + Initialize + + Use this parameter to re-initialize the controller. This will wipe any existing logical disk configured for the controller and deploy the new policy defined. Not supported when ControllerID is "Mezz 1", "Mezz 2", or "Mezz 3". + + SwitchParameter + + + WriteCache + + For Gen10 controllers, to enable, disable or unmanage controller write cache policy. Allowed values: + + * Enabled + * Disabled + * Unmanaged + +Default value: Unmanaged + + String + + + PredictiveSpareActivation + + For Gen10 and newer HPE Synergy controllers, to enable, disable or unmanage controller spare drive policy. Allowed values: + + * Enabled + * Disabled + * Unmanaged + +Default value: Unmanaged + + String + + + LogicalDisk + + A collection of Logical Disk objects from the New-OVServerProfileLogicalDisk Cmdlet. + + Object + + + + New-OVServerProfileLogicalDiskController + + InputObject + + A storage controller object from Get-OVServerHardwareAvailableController. Use to specify the exact storage controller to configure. + + HPEOneView.Servers.StorageController + + + Mode + + The mode to configure the Smart Array Controller as. Accepted values are: + + * HBA + * RAID + +When specifying HBA, you cannot attach a RAID Logical Disk to this policy. + + String + + + Initialize + + Use this parameter to re-initialize the controller. This will wipe any existing logical disk configured for the controller and deploy the new policy defined. Not supported when ControllerID is "Mezz 1", "Mezz 2", or "Mezz 3". + + SwitchParameter + + + WriteCache + + For Gen10 controllers, to enable, disable or unmanage controller write cache policy. Allowed values: + + * Enabled + * Disabled + * Unmanaged + +Default value: Unmanaged + + String + + + PredictiveSpareActivation + + For Gen10 and newer HPE Synergy controllers, to enable, disable or unmanage controller spare drive policy. Allowed values: + + * Enabled + * Disabled + * Unmanaged + +Default value: Unmanaged + + String + + + ImportExistingConfiguration + + Specify to import any found Logical Disk configuration and add to the Server Profile as the Logical Disk policy. This option is not available for Server Profile Templates. Not supported when ControllerID is "Mezz 1", "Mezz 2", or "Mezz 3". + + SwitchParameter + + + LogicalDisk + + A collection of Logical Disk objects from the New-OVServerProfileLogicalDisk Cmdlet. + + Object + + + + New-OVServerProfileLogicalDiskController + + MegaRAIDController + + By default, SmartRAID (SR) controller objects are created. Use this parameter to set the controller family to MegaRAID (MR) controller types for when the storage controller object will be attached to a server profile template and you are not using the -InputObject parameter to provide a storage controller. + + SwitchParameter + + + ControllerID + + Specify the Controller ID location. Supported options for this parameter are + * Embedded + * Mezz1 + * Mezz2 + * Mezz3 + * Slot1 + * Slot10 + * Slot11 + * Slot12 + * Slot13 + * Slot14 + * Slot15 + * Slot16 + * Slot2 + * Slot3 + * Slot4 + * Slot5 + * Slot6 + * Slot7 + * Slot8 + * Slot9 +Please note that Mezz1, Mezz2 and Mezz3 are only supported with HPE Synergy Compute nodes connected to the HPE Synergy D3940 disk shelf. + + Object + + + Mode + + The mode to configure the Smart Array Controller as. Accepted values are: + + * HBA + * RAID + +When specifying HBA, you cannot attach a RAID Logical Disk to this policy. + + String + + + Initialize + + Use this parameter to re-initialize the controller. This will wipe any existing logical disk configured for the controller and deploy the new policy defined. Not supported when ControllerID is "Mezz 1", "Mezz 2", or "Mezz 3". + + SwitchParameter + + + WriteCache + + For Gen10 controllers, to enable, disable or unmanage controller write cache policy. Allowed values: + + * Enabled + * Disabled + * Unmanaged + +Default value: Unmanaged + + String + + + ImportExistingConfiguration + + Specify to import any found Logical Disk configuration and add to the Server Profile as the Logical Disk policy. This option is not available for Server Profile Templates. Not supported when ControllerID is "Mezz 1", "Mezz 2", or "Mezz 3". + + SwitchParameter + + + LogicalDisk + + A collection of Logical Disk objects from the New-OVServerProfileLogicalDisk Cmdlet. + + Object + + + + New-OVServerProfileLogicalDiskController + + ControllerID + + Specify the Controller ID location. Supported options for this parameter are + * Embedded + * Mezz1 + * Mezz2 + * Mezz3 + * Slot1 + * Slot10 + * Slot11 + * Slot12 + * Slot13 + * Slot14 + * Slot15 + * Slot16 + * Slot2 + * Slot3 + * Slot4 + * Slot5 + * Slot6 + * Slot7 + * Slot8 + * Slot9 +Please note that Mezz1, Mezz2 and Mezz3 are only supported with HPE Synergy Compute nodes connected to the HPE Synergy D3940 disk shelf. + + Object + + + Mode + + The mode to configure the Smart Array Controller as. Accepted values are: + + * HBA + * RAID + +When specifying HBA, you cannot attach a RAID Logical Disk to this policy. + + String + + + WriteCache + + For Gen10 controllers, to enable, disable or unmanage controller write cache policy. Allowed values: + + * Enabled + * Disabled + * Unmanaged + +Default value: Unmanaged + + String + + + PredictiveSpareActivation + + For Gen10 and newer HPE Synergy controllers, to enable, disable or unmanage controller spare drive policy. Allowed values: + + * Enabled + * Disabled + * Unmanaged + +Default value: Unmanaged + + String + + + ImportExistingConfiguration + + Specify to import any found Logical Disk configuration and add to the Server Profile as the Logical Disk policy. This option is not available for Server Profile Templates. Not supported when ControllerID is "Mezz 1", "Mezz 2", or "Mezz 3". + + SwitchParameter + + + + + + + ControllerID + + Specify the Controller ID location. Supported options for this parameter are + * Embedded + * Mezz1 + * Mezz2 + * Mezz3 + * Slot1 + * Slot10 + * Slot11 + * Slot12 + * Slot13 + * Slot14 + * Slot15 + * Slot16 + * Slot2 + * Slot3 + * Slot4 + * Slot5 + * Slot6 + * Slot7 + * Slot8 + * Slot9 +Please note that Mezz1, Mezz2 and Mezz3 are only supported with HPE Synergy Compute nodes connected to the HPE Synergy D3940 disk shelf. + + Object + + Object + + Embedded + + + ImportExistingConfiguration + + Specify to import any found Logical Disk configuration and add to the Server Profile as the Logical Disk policy. This option is not available for Server Profile Templates. Not supported when ControllerID is "Mezz 1", "Mezz 2", or "Mezz 3". + + SwitchParameter + + SwitchParameter + + False + + + Initialize + + Use this parameter to re-initialize the controller. This will wipe any existing logical disk configured for the controller and deploy the new policy defined. Not supported when ControllerID is "Mezz 1", "Mezz 2", or "Mezz 3". + + SwitchParameter + + SwitchParameter + + False + + + InputObject + + A storage controller object from Get-OVServerHardwareAvailableController. Use to specify the exact storage controller to configure. + + HPEOneView.Servers.StorageController + + HPEOneView.Servers.StorageController + + + + + LogicalDisk + + A collection of Logical Disk objects from the New-OVServerProfileLogicalDisk Cmdlet. + + Object + + Object + + + + + MegaRAIDController + + By default, SmartRAID (SR) controller objects are created. Use this parameter to set the controller family to MegaRAID (MR) controller types for when the storage controller object will be attached to a server profile template and you are not using the -InputObject parameter to provide a storage controller. + + SwitchParameter + + SwitchParameter + + + + + Mode + + The mode to configure the Smart Array Controller as. Accepted values are: + + * HBA + * RAID + +When specifying HBA, you cannot attach a RAID Logical Disk to this policy. + + String + + String + + RAID + + + PredictiveSpareActivation + + For Gen10 and newer HPE Synergy controllers, to enable, disable or unmanage controller spare drive policy. Allowed values: + + * Enabled + * Disabled + * Unmanaged + +Default value: Unmanaged + + String + + String + + Unmanaged + + + WriteCache + + For Gen10 controllers, to enable, disable or unmanage controller write cache policy. Allowed values: + + * Enabled + * Disabled + * Unmanaged + +Default value: Unmanaged + + String + + String + + Unmanaged + + + + + + + HPEOneView.ServerProfile.LogicalDisk [System.Management.Automation.PSCustomObject] + + + Logical Disk configuration policy from New-OVServerProfileLogicalDisk + + + + + System.Collections.ArrayList <HPEOneView.ServerProfile.LogicalDisk> + + + Collection of Logical Disk configuration policy from New-OVServerProfileLogicalDisk + + + + + + + + HPEOneView.ServerProfile.Controller [System.Management.Automation.PSCustomObject] + + + + Server Profile Controller configuration object + + + + + System.Collections.ArrayList <HPEOneView.ServerProfile.Controller> + + + + Collection of Server Profile Controller configuration objects + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + $LogicalDisk = New-OVServerProfileLogicalDisk -Name "MyDisk" | New-OVServerProfileLogicalDiskController -Initialize + + Create a default Logical Disk and Controller configuration object policy. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + New-OVServerProfileLogicalDiskController -Mode HBA + + Create an HBA controller policy, which will then set the controller to JBOD mode. + + + + + + + + + + -------------------------- EXAMPLE 3 -------------------------- + + + + $LogicalDisk1 = New-OVServerProfileLogicalDisk -Name "MyDisk" +$LogicalDisk2 = New-OVServerProfileLogicalDisk -Name "MyDisk2" +$Controller = New-OVServerProfileLogicalDiskController -Initialize -LogicalDisk $LogicalDisk1,$LogicalDisk2 + + Create a default Logical Disk and Controller configuration object policy. + + + + + + + + + + -------------------------- EXAMPLE 4 -------------------------- + + + + $LogicalDisk1 = New-OVServerProfileLogicalDisk -Name Boot -RAID RAID1 -MinDriveSize 300 -MaxDriveSize 300 -DriveType SAS -Bootable $True +$LogicalDisk2 = New-OVServerProfileLogicalDisk -Name Data -RAID RAID5 -NumberofDrives 5 -MinDriveSize 300 -MaxDriveSize 300 -DriveType SAS +$Controller = New-OVServerProfileLogicalDiskController -ControllerID "Mezz 1" -Mode RAID -LogicalDisk $LogicalDisk1,$LogicalDisk2 + + Create a HPE Synergy D3940 RAID disk policy, with a bootable volume. + + + + + + + + + + -------------------------- EXAMPLE 5 -------------------------- + + + + $AvailableDriveType = Get-OVSasLogicalInterconnect -Name "LE1-Default SAS Synergy LIG-3" -ErrorAction Stop | Get-OVAvailableDriveType | ? { $_.Type -eq "SASHDD" -and $_.capacity -eq 900 } +$NewLogicalDisk = New-OVServerProfileLogicalDisk -Name "LD1_RAID5_900GB_SASHDD" -DriveSelectionBy DriveType -NumberofDrives 6 -RAID RAID5 -AvailableDriveType $AvailableDriveType +C:\> $Controller = New-OVServerProfileLogicalDiskController -ControllerID "Mezz 1" -Mode RAID -LogicalDisk $NewLogicalDisk + + Create a RAID5 Logical Disk for a Server Profile using D3940 storage, and a specific available drive type, 900GB capacity and SASHDD type, and assign it to a new Controller. + + + + + + + + + + -------------------------- EXAMPLE 6 -------------------------- + + + + # Get the specific server. Server must have been powered on at least 1 time to complete POST in order for server inventory to be updated +$Server = Get-OVServer -Name MyGen11Server + +# Get the available controllers and drives from the specific server +$AvailableControllers = Get-OVServerHardwareAvailableController -InputObject $Server + +# Review installed controllers +$AvailableControllers | ? { -not [String]::IsNullOrEmpty($_.DeviceSlot) } + +DeviceSlot : Slot 1 +Family : SmartRAID +Type : Standup +Model : HPE SR308i-p Gen11 +Firmware : 5.29-256 +ControllerMode : HPEOneView.Servers.ControllerModes +RaidModes : HPEOneView.Servers.RaidModes +DriveTechnologies : HPEOneView.Servers.DriveTechnologies +ReadCachePolicy : HPEOneView.Servers.ReadCachePolicy +WriteCachePolicy : HPEOneView.Servers.WriteCachePolicy +Capabilities : {RedfishConfig, RedfishDedicatedSpare} +Drives : {1I:1:41 147 GB (NvmeSsd), 1I:1:42 147 GB (NvmeSsd), 1I:1:43 147 GB (NvmeSsd), 1I:1:44 147 GB (NvmeSsd)ΓǪ} +MaximumLogicalDrives : 256 +MaximumDrives : 256 +ApplianceConnection : MyAppliance + +# Review available drives attached to controller in "Slot 1" +($AvailableControllers | ? DeviceSlot -eq "Slot 1").Drives + +Location Model Capacity DriveTechnology IsAllocated FailurePredicted LifeRemaining +-------- ----- -------- --------------- ----------- ---------------- ------------- +1I:1:41 EH0146FCBVB 147 GB NvmeSsd True False 100% +1I:1:42 EH0146FCBVB 147 GB NvmeSsd True False 100% +1I:1:43 EH0146FCBVB 147 GB NvmeSsd True False 100% +1I:1:44 EH0146FCBVB 147 GB NvmeSsd False False 100% +1I:1:45 EH0146FCBVB 147 GB SataHdd False False 0% +1I:1:46 EH0146FCBVB 147 GB SataHdd False False 0% +1I:1:47 EH0146FCBVB 147 GB SataHdd False False 0% +1I:1:48 EH0146FCBVB 147 GB SataHdd False False 0% +1I:1:49 EH0146FCBVB 147 GB SataHdd False False 0% +1I:1:50 EH0146FCBVB 147 GB SataSsd True False 100% +1I:1:51 EH0146FCBVB 147 GB SataSsd True False 100% +1I:1:52 EH0146FCBVB 147 GB SataSsd False False 100% + +# Filter out available SataHdd for a 3+1 and spare drive configuration +$DrivesToAssign = ($AvailableControllers | ? DeviceSlot -eq "Slot 1").Drives | ? { $_.DriveTechnology -eq "SataHdd" -and -not $_.IsAllocated } | Select -First 5 + +# Create the logical drive, specifying drives and the spare drive to use (which is the last drive in the collection) +$LogicalDrive = New-OVServerProfileLogicalDisk -Name RAID5+Spare-DATA -Drives $DrivesToAssign -RAID Raid5 -AddSpareDrive -SpareDrives $DrivesToAssign[-1] + + Identify available storage controllers and drives, and create a logical disk with specific drives from inventory including spare drive. + + + + + + + + + + + + + Get-OVServerHardwareAvailableController + + + + New-OVServerProfile + + + + New-OVServerProfileLogicalDisk + + + + New-OVServerProfileTemplate + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/servers/new-ovserverprofilelogicaldiskcontroller + + + + + + + + New-OVServerProfileTemplate + + Create a Server Profile Template + + New + OVServerProfileTemplate + + + This Cmdlet is used to create or import an HPE OneView Server Profile Template. + +A Server Profile Template is the parent configuration for a Server Profile instance. Server profiles capture the entire server configuration in one place, enabling you to consistently replicate new server profiles and to rapidly modify them to reflect changes in your data center. + +A Server Profile Template includes: + + * Basic server identification information + * Connectivity settings for Ethernet networks, network sets, and Fibre Channel networks + * Firmware versions + * Local storage settings + * SAN storage settings + * BIOS settings + * Boot order + * Physical or virtual UUIDs, MAC addresses, and WWN addresses + +When you create a server profile template, it is designated for a server hardware type and enclosure group (for server blades). + +To figure out BIOS Settings to override or set within the Server Profile, you will need to get the Server Hardware Type resource that your are modeling the Server Profile for. When retrieving the resource: + +$bl460cgen9sht = Get-OVServerHardwareType "BL460c Gen9 1" + +The "biosSettings" Array property will be available (only with supported Server Hardware Types; i.e. BL460c Gen8 or newer). To locate potential BIOS Settings, you can use the following code as an example: + +$biosSettings = $bl460cgen9sht.biosSettings | ? { $_.name -match "power" } + +The code example above will return all matching BIOS Settings where the name contains "power". The found BIOS settings object(s) are then saved into $biosSettings. Update the "value" property accordingly, and you can then pass $biosSettings variable to the -biosSettings parameter. + + + + + New-OVServerProfileTemplate + + Name + + The name of the server profile resource to be created. + + String + + + ServerHardwareType + + The Server Hardware Type reource the Server Profile Template will be bound to. + + Object + + + Description + + Optional description for this server profile template. + + String + + + ServerProfileDescription + + Optional description for created server profiles from this template. + + String + + + ManageConnections + + Use this parameter to specify if Connections should be tracked from the Server Profile Template for compliance. If set to False, the -Connections parameter will be ignored, and Connections must be set and managed at the Server Profile. + + Boolean + + + Connections + + The network connections that are to be part of this new server profile. This an array of profile connection objects which may be created with "New-OVServerProfileConnection". + +Expected Connection Format: + +[System.Collections.ArrayList ] @( + [PsCustomObject]@{ + [System.Int]id - Connection ID. Valid 1-64. A 0 value is allowed, + but means Auto Connection ID assignment. + [System.String]function - Ethernet or FibreChannel. + [System.String]networkUri - URI to the Network resource. + [System.String]portId - Auto or the specific Port ID. For FlexLOMs, the valid + portId prefix will be "Flb", and Mezzanine would be "Mezz". + Ex. FlexNIC 1a interface would be "Flb 1:1a" + Ex. Mezzanine 2, FlexNIC 2c interface would be "Mezz 2:2c" + [System.Int32]requestedMpbs - Requested bandwidth in Mbps. + [System.Collections.Hashtable]boot - Nested Hashtable + @{ + [System.String]priority - Boot priority for this connection. Can be used with Ethernet + or FC connections. Allowed values: + NotBootable + Primary + Secondary + [System.Collections.ArrayList ]targets - Array of FC boot targets (only 1 entry is allowed) + @( + [System.String]arrayWwpn - Target WWPN of storage array. + [System.String]lun - Boot LUN ID + + ) + } + [System.String]macType - Allowed values: + Physical + UserDefined + Virtual + [System.String]mac - UserDefined MAC Address. Required for custom MAC and FCoE WWPN addresses. + [System.String]wwpnType - Allowed values: + Physical + UserDefined + Virtual + [System.String]wwpn - UserDefined WWPN Address + [System.String]wwnn - UserDefined WWNN Address + } +) + +Default: No connections + + Array + + + ConnectionsConsistencyChecking + + Use to override the consistency checking for the policy. Allowed values: + + * Exact + * Minimum + * None + + String + + + EnclosureGroup + + The Enclosure Group resource the Server Profile Template will be bound to. When assigning to an Enclosure Group, OneView will then determine what farbic connectivity and storage devices are available. + + Object + + + Firmware + + Enable Firmware Management. Cannot be enabled with Server Hardware Type does not support Firmware Management (i.e. BL G7 servers.) + + SwitchParameter + + + Baseline + + Firmware baseline to assign. Can be either Baseline Name or URI. + + Object + + + BaselinePatchLevel + + The patch or supplement to the Update Bundle. Within the Update Bundle contains a property called Supplements ([Array] of [System.Version]). + + version + + + FirmwareConsistencyChecking + + Use to override the consistency checking for the policy. Allowed values: + + * Exact + * None + + String + + + FirmwareInstallationPolicy + + The Installation policy option is only available for Gen10 and later servers. The option is available for Gen10 or later server hardware types only. Installation policy enables you to choose if a component needs to be updated or downgraded when its version does not match the baseline. An alert is generated when the installed version on one or more components is inconsistent with the selected installation policy. + +You can choose one of the following two policy options: + + * LowerThanBaseline (Default) - Updates only the components that have a version lower than the firmware baseline version. + * NotEqualToBaseline - Updates or downgrades components whose installed version does not match the firmware baseline version. The components with a version lower than the firmware baseline version are upgraded, and the components with a version higher than the firmware baseline version are downgraded to match the baseline. + +NOTE: For Gen9 and earlier servers, if the selected firmware baseline is older than the firmware currently installed, select the Force installation option to downgrade the firmware version. + + string + + + FirmwareInstallMode + + Specify the Firmware Baseline Policy mode. Avialable options are: + + * FirmwareOnly - Updates the system firmware without powering down the server hardware using using HP Smart Update Tools. + * FirmwareAndSoftware - Updates the firmware and OS drivers without powering down the server hardware using HP Smart Update Tools. + * FirmwareOffline - Manages the firmware through HPE OneView. Selecting this option requires the server hardware to be powered down. + + String + + + FirmwareActivationMode + + Specify the firmware activation policy. Avialable options are: + + * Immediate - Immediately activate (aka reboot the host) firmware if needed. Requires HPSUT to be installed in the Host OS or Proxy VM (for VMware only) + * Scheduled - Specify a future time to activate (aka reboot the host) firmware if needed. You will need to specify the FirmwareActivateDateTime parameter. Requires HPSUT to be installed in the Host OS or Proxy VM (for VMware only) + * NotScheduled - Scheduled firmware update is cancelled when you choose this option. + + String + + + ForceInstallFirmware + + Using this parameter will force the bundled firmware components to install when the Server Profile is applied to a server. This will downgrade firmware if the component firmware is newer than what the SPP Baseline contains. + + SwitchParameter + + + OSDeploymentPlan + + The HPE Synergy Image Streamer OS deployment plan from Get-OVOSDeploymentPlan. + + Object + + + OSDeploymentConsistencyChecking + + Use to override the consistency checking for the policy. Allowed values: + + * Exact + * None + + String + + + OSDeploymentPlanAttributes + + Configured OS Deployment Plan parameters from Get-OVOSDeploymentPlanAttribute. You will need to group required NIC parameters together based on needed values. + + Array + + + Bios + + Enable BIOS Settings Management. Cannot be enabled with Server Hardware Type does not support BIOS Management (i.e. BL G7 +servers.) + + SwitchParameter + + + BiosSettings + + BIOS Settings that are to be managed. You can get the BIOS settings available from Get-OVServerHardwareType and the returned biosSettings property. + + Array + + + BiosConsistencyChecking + + Use to override the consistency checking for the policy. Allowed values: + + * Exact + * None + + String + + + BootMode + + Specify the Gen9 Boot Envrionment. + +Sets the boot mode as one of the following: + + * UEFI + * UEFIOptimized + * BIOS + * Unmanaged + +If you select UEFI or UEFI optimized for an HP ProLiant DL Gen9 rack mount server, the remaining boot setting available is the PXE boot policy. + +For the UEFI or UEFI optimized boot mode options, the boot mode choice should be based on the expected OS and required boot features for the server hardware. UEFI optimized boot mode reduces the time the system spends in POST (Video driver initialization). In order to select the appropriate boot mode, consider the following: + + * If a secure boot is required, the boot mode must be set to UEFI or UEFI optimized . + * For operating systems that do not support UEFI (such as DOS, or older versions of Windows and Linux), the boot mode must be set to BIOS. + * When booting in UEFI mode, Windows 7, Server 2008, or 2008 R2 should not be set to UEFIOptimized. + +Default: BIOS + + String + + + BootModeConsistencyChecking + + Use to override the consistency checking for the policy. Allowed values: + + * Exact + * None + + String + + + PxeBootPolicy + + Controls the ordering of the network modes available to the Flexible LOM (FLB); for example, IPv4 and IPv6. + +Select from the following policies: + + * Auto + * IPv4 only + * IPv6 only + * IPv4 then IPv6 + * IPv6 then IPv4 + +Setting the policy to Auto means the order of the existing network boot targets in the UEFI Boot Order list will not be modified, and any new network boot targets will be added to the end of the list using the System ROM"s default policy. + +Default: Auto + + String + + + ManageBoot + + Enable Boot Order Management. Also required for Connection boot enablement. If this is disabled ($False), then PXE or FC BfS settings are disabled within the entire Server Profile. + +Default: $True + + SwitchParameter + + + BootOrder + + Boot Order settings to be managed. + +Defines the order in which boot will be attempted on the available devices. For Gen7 and Gen8 server hardware the possible values are "CD", "Floppy", "USB", "HardDisk", and "PXE". For Gen9 BL server hardware in Legacy BIOS boot mode, the possible values are "CD", "USB", "HardDisk", and "PXE". For Gen9 BL server hardware in UEFI or UEFI Optimized boot mode, only one value is allowed and must be either "HardDisk" or "PXE". For Gen9 DL server hardware in Legacy BIOS boot mode, the possible values are "CD", "USB", "HardDisk", and "PXE". For Gen9 DL server hardware in UEFI or UEFI Optimized boot mode, boot order configuration is not supported. + +Gen7/8 BIOS Default Boot Order: "CD","Floppy","USB","HardDisk","PXE" +Gen9 Legacy BIOS Boot Order: "CD","USB","HardDisk","PXE" +Gen9 UEFI Default Boot Order: "HardDisk" + + Array + + + BootOrderConsistencyChecking + + Use to override the consistency checking for the policy. Allowed values: + + * Exact + * None + + String + + + SecureBoot + + Specify if secure boot should be Unmanaged, Enabled or Disabled for Gen10 and newer servers. Boot Mode must be set to 'UEFI Optimized'. + + String + + + LocalStorage + + Enable local storage settings to be managed on the server. + + SwitchParameter + + + LocalStorageConsistencyChecking + + Use to override the consistency checking for the policy. Allowed values: + + * Exact + * None + + String + + + StorageController + + A resource object containing the StorageController, LogicalDisk or SasJbod configuration. Please refer to the New-OVServerProfileLogicalDisk and New-OVServerProfileLogicalDiskController Cmdlets. + + Object + + + ManageIloSettings + + Use to indicate iLO settings will be managed from the server profile. + + Bool + + + IloSettings + + Provide an iLO settings object from New-OVServerProfileIloPolicy Cmdlet. + + PSObject + + + IloSettingsConsistencyChecking + + Use to override the consistency checking for the policy. Allowed values: + + * Exact + * None + + String + + + Affinity + + In a server profile, the Affinity control sets the remove-and-replace behavior for blade servers. If you apply a server profile to a blade server and the server is subsequently removed from the device bay, the Affinity setting controls whether the server profile is reapplied when you insert a server blade into the empty bay. Server profiles for rack servers do not have affinity. + +Accepted values are either "Bay" or "BayAndServer". Default is "Bay". + + String + + + MacAssignment + + Optional setting for MAC address assignment. May be Virtual or Physical. Use Virtual if you need to specify a UserDefined value when using the New-OVServerProfileConnection helper Cmdlet. + + String + + + WwnAssignment + + Optional setting for WWN assignment. May be Virtual or Physical. Use Virtual if you need to specify a UserDefined value when using the New-OVServerProfileConnection helper Cmdlet. + + String + + + SnAssignment + + Optional setting for serial number and UUID assignment. May be Virtual, Physical or UserDefined. + +Default: Virtual serial number and UUID assignment + + String + + + IscsiInitiatorNameAssignmet + + Specify if the iSCSI initiator name should be automatically managed and assigned, or a custom value should be used. Allowed values: * Virtual * UserDefined +Default Value: Virtual + + String + + + HideUnusedFlexNics + + This setting provides the ability to hide unused FlexNICs from the operating system. + +If Hide Unused FlexNICs is set to $True (default/enabled), FlexNICs that do not map to any server profile connections are not presented to the operating system. For example, if you have a full complement of eight FlexNICs defined in your server profile but map only four, your operating system will see only the four mapped FlexNICs instead of eight. + +If Hide Unused FlexNICs is set to $False (disabled), eight FlexNICs are enumerated in the operating system as network interfaces for each Flex-10 or FlexFabric adapter. + +Configuring Fibre Channel connections on a FlexFabric adapter can enumerate two storage interfaces, reducing the number of network interfaces to six. + +FlexNICs are hidden in pairs, starting with the fourth pair. For example, if the fourth FlexNIC on either physical port corresponds to a profile connection, all eight physical functions are enumerated. If a profile connection corresponds to the second FlexNIC on either physical port, but no connection corresponds to the third or fourth FlexNIC on either physical port, only the first and second physical functions are enumerated in the operating system. + +By default, Hide Unused FlexNICs is enabled. This setting can be changed only when the server is powered off. + + Boolean + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + PassThru + + Use this parameter to return the modified Server Profile Template object. In order to save the changes, please use the Save-OVServerProfileTemplate Cmdlet. + + SwitchParameter + + + ApplianceConnection + + The name of the appliance or list of appliances to execute the command against. + + Object + + + + New-OVServerProfileTemplate + + Name + + The name of the server profile resource to be created. + + String + + + ServerHardwareType + + The Server Hardware Type reource the Server Profile Template will be bound to. + + Object + + + SANStorage + + Optional. Enable SAN Storage Management within the Server Profile. + + SwitchParameter + + + HostOStype + + Optional. Specify the Host OS type, which will set the Host OS value when HPE OneView created the Host object on the Storage System. Accepted values: + + * CitrixXen = "Citrix Xen Server 5.x/6.x" + * AIX = "AIX" + * IBMVIO = "IBM VIO Server" + * RHEL4 = "RHE Linux (Pre RHEL 5)" + * RHEL3 = "RHE Linux (Pre RHEL 5)" + * RHEL = "RHE Linux (5.x, 6.x)" + * RHEV = "RHE Virtualization (5.x, 6.x)" + * VMware = "ESX 4.x/5.x" + * Win2k3 = "Windows 2003" + * Win2k8 = "Windows 2008/2008 R2" + * Win2k12 = "Windows 2012 / WS2012 R2" + * OpenVMS = "OpenVMS" + * Egenera = "Egenera" + * Exanet = "Exanet" + * Solaris9 = "Solaris 9/10" + * Solaris10 = "Solaris 9/10" + * Solaris11 = "Solaris 11" + * ONTAP = "NetApp/ONTAP" + * OEL = "OE Linux UEK (5.x, 6.x)" + * HPUX11iv1 = "HP-UX (11i v1, 11i v2)" + * HPUX11iv2 = "HP-UX (11i v1, 11i v2)" + * HPUX11iv3 = "HP-UX (11i v3)" + * SUSE = "SuSE (10.x, 11.x)" + * SUSE9 = "SuSE Linux (Pre SLES 10)" + * Inform = "InForm" + + String + + + StorageVolume + + Optional. Array of Storage Volume resources to attach. Can be created by using the New-OVServerProfileAttachVolume Cmdlet. This parameter does not accept a Storage Volume resource from the Get-OVStorageVolume Cmdlet. + +The format of the Storage Volume resource should be a PsCustomObject PowerShell resource with the following keys and values: + +[PsCustomObject]@{ + [System.Int]id - Valid Host LUN ID 0-254 + [System.String]lunType - Auto or Manual + [System.String]volumeUri - URI to Storage Volume that has been created and not + assigned to another Server Profile if it is a Private Volume. + [System.String]volumeStoragePoolUri - URI to HPE OneView managed Storage Pool + [System.String]volumeStorageSystemUri - URI to HPE OneView managed Storage System + [System.Collections.ArrayList ]storagePaths - Array specifying the Profile FC Connection ID associated + with the path to the attached volume, and if the path is + enabled or disabled. + @( + [System.Int]connectionId - FC Connection ID. If using New-OVServerProfileAttachVolume helper + Cmdlet, New-OVServerProfile will automatically determine the FC + connection ID. + [System.Boolean]isEnabled - Enable or disable the path + ) +} + + Object + + + Description + + Optional description for this server profile template. + + String + + + ServerProfileDescription + + Optional description for created server profiles from this template. + + String + + + ManageConnections + + Use this parameter to specify if Connections should be tracked from the Server Profile Template for compliance. If set to False, the -Connections parameter will be ignored, and Connections must be set and managed at the Server Profile. + + Boolean + + + Connections + + The network connections that are to be part of this new server profile. This an array of profile connection objects which may be created with "New-OVServerProfileConnection". + +Expected Connection Format: + +[System.Collections.ArrayList ] @( + [PsCustomObject]@{ + [System.Int]id - Connection ID. Valid 1-64. A 0 value is allowed, + but means Auto Connection ID assignment. + [System.String]function - Ethernet or FibreChannel. + [System.String]networkUri - URI to the Network resource. + [System.String]portId - Auto or the specific Port ID. For FlexLOMs, the valid + portId prefix will be "Flb", and Mezzanine would be "Mezz". + Ex. FlexNIC 1a interface would be "Flb 1:1a" + Ex. Mezzanine 2, FlexNIC 2c interface would be "Mezz 2:2c" + [System.Int32]requestedMpbs - Requested bandwidth in Mbps. + [System.Collections.Hashtable]boot - Nested Hashtable + @{ + [System.String]priority - Boot priority for this connection. Can be used with Ethernet + or FC connections. Allowed values: + NotBootable + Primary + Secondary + [System.Collections.ArrayList ]targets - Array of FC boot targets (only 1 entry is allowed) + @( + [System.String]arrayWwpn - Target WWPN of storage array. + [System.String]lun - Boot LUN ID + + ) + } + [System.String]macType - Allowed values: + Physical + UserDefined + Virtual + [System.String]mac - UserDefined MAC Address. Required for custom MAC and FCoE WWPN addresses. + [System.String]wwpnType - Allowed values: + Physical + UserDefined + Virtual + [System.String]wwpn - UserDefined WWPN Address + [System.String]wwnn - UserDefined WWNN Address + } +) + +Default: No connections + + Array + + + ConnectionsConsistencyChecking + + Use to override the consistency checking for the policy. Allowed values: + + * Exact + * Minimum + * None + + String + + + EnclosureGroup + + The Enclosure Group resource the Server Profile Template will be bound to. When assigning to an Enclosure Group, OneView will then determine what farbic connectivity and storage devices are available. + + Object + + + Firmware + + Enable Firmware Management. Cannot be enabled with Server Hardware Type does not support Firmware Management (i.e. BL G7 servers.) + + SwitchParameter + + + Baseline + + Firmware baseline to assign. Can be either Baseline Name or URI. + + Object + + + BaselinePatchLevel + + The patch or supplement to the Update Bundle. Within the Update Bundle contains a property called Supplements ([Array] of [System.Version]). + + version + + + FirmwareConsistencyChecking + + Use to override the consistency checking for the policy. Allowed values: + + * Exact + * None + + String + + + FirmwareInstallationPolicy + + The Installation policy option is only available for Gen10 and later servers. The option is available for Gen10 or later server hardware types only. Installation policy enables you to choose if a component needs to be updated or downgraded when its version does not match the baseline. An alert is generated when the installed version on one or more components is inconsistent with the selected installation policy. + +You can choose one of the following two policy options: + + * LowerThanBaseline (Default) - Updates only the components that have a version lower than the firmware baseline version. + * NotEqualToBaseline - Updates or downgrades components whose installed version does not match the firmware baseline version. The components with a version lower than the firmware baseline version are upgraded, and the components with a version higher than the firmware baseline version are downgraded to match the baseline. + +NOTE: For Gen9 and earlier servers, if the selected firmware baseline is older than the firmware currently installed, select the Force installation option to downgrade the firmware version. + + string + + + FirmwareInstallMode + + Specify the Firmware Baseline Policy mode. Avialable options are: + + * FirmwareOnly - Updates the system firmware without powering down the server hardware using using HP Smart Update Tools. + * FirmwareAndSoftware - Updates the firmware and OS drivers without powering down the server hardware using HP Smart Update Tools. + * FirmwareOffline - Manages the firmware through HPE OneView. Selecting this option requires the server hardware to be powered down. + + String + + + FirmwareActivationMode + + Specify the firmware activation policy. Avialable options are: + + * Immediate - Immediately activate (aka reboot the host) firmware if needed. Requires HPSUT to be installed in the Host OS or Proxy VM (for VMware only) + * Scheduled - Specify a future time to activate (aka reboot the host) firmware if needed. You will need to specify the FirmwareActivateDateTime parameter. Requires HPSUT to be installed in the Host OS or Proxy VM (for VMware only) + * NotScheduled - Scheduled firmware update is cancelled when you choose this option. + + String + + + ForceInstallFirmware + + Using this parameter will force the bundled firmware components to install when the Server Profile is applied to a server. This will downgrade firmware if the component firmware is newer than what the SPP Baseline contains. + + SwitchParameter + + + OSDeploymentPlan + + The HPE Synergy Image Streamer OS deployment plan from Get-OVOSDeploymentPlan. + + Object + + + OSDeploymentConsistencyChecking + + Use to override the consistency checking for the policy. Allowed values: + + * Exact + * None + + String + + + OSDeploymentPlanAttributes + + Configured OS Deployment Plan parameters from Get-OVOSDeploymentPlanAttribute. You will need to group required NIC parameters together based on needed values. + + Array + + + Bios + + Enable BIOS Settings Management. Cannot be enabled with Server Hardware Type does not support BIOS Management (i.e. BL G7 +servers.) + + SwitchParameter + + + BiosSettings + + BIOS Settings that are to be managed. You can get the BIOS settings available from Get-OVServerHardwareType and the returned biosSettings property. + + Array + + + BiosConsistencyChecking + + Use to override the consistency checking for the policy. Allowed values: + + * Exact + * None + + String + + + BootMode + + Specify the Gen9 Boot Envrionment. + +Sets the boot mode as one of the following: + + * UEFI + * UEFIOptimized + * BIOS + * Unmanaged + +If you select UEFI or UEFI optimized for an HP ProLiant DL Gen9 rack mount server, the remaining boot setting available is the PXE boot policy. + +For the UEFI or UEFI optimized boot mode options, the boot mode choice should be based on the expected OS and required boot features for the server hardware. UEFI optimized boot mode reduces the time the system spends in POST (Video driver initialization). In order to select the appropriate boot mode, consider the following: + + * If a secure boot is required, the boot mode must be set to UEFI or UEFI optimized . + * For operating systems that do not support UEFI (such as DOS, or older versions of Windows and Linux), the boot mode must be set to BIOS. + * When booting in UEFI mode, Windows 7, Server 2008, or 2008 R2 should not be set to UEFIOptimized. + +Default: BIOS + + String + + + BootModeConsistencyChecking + + Use to override the consistency checking for the policy. Allowed values: + + * Exact + * None + + String + + + PxeBootPolicy + + Controls the ordering of the network modes available to the Flexible LOM (FLB); for example, IPv4 and IPv6. + +Select from the following policies: + + * Auto + * IPv4 only + * IPv6 only + * IPv4 then IPv6 + * IPv6 then IPv4 + +Setting the policy to Auto means the order of the existing network boot targets in the UEFI Boot Order list will not be modified, and any new network boot targets will be added to the end of the list using the System ROM"s default policy. + +Default: Auto + + String + + + ManageBoot + + Enable Boot Order Management. Also required for Connection boot enablement. If this is disabled ($False), then PXE or FC BfS settings are disabled within the entire Server Profile. + +Default: $True + + SwitchParameter + + + BootOrder + + Boot Order settings to be managed. + +Defines the order in which boot will be attempted on the available devices. For Gen7 and Gen8 server hardware the possible values are "CD", "Floppy", "USB", "HardDisk", and "PXE". For Gen9 BL server hardware in Legacy BIOS boot mode, the possible values are "CD", "USB", "HardDisk", and "PXE". For Gen9 BL server hardware in UEFI or UEFI Optimized boot mode, only one value is allowed and must be either "HardDisk" or "PXE". For Gen9 DL server hardware in Legacy BIOS boot mode, the possible values are "CD", "USB", "HardDisk", and "PXE". For Gen9 DL server hardware in UEFI or UEFI Optimized boot mode, boot order configuration is not supported. + +Gen7/8 BIOS Default Boot Order: "CD","Floppy","USB","HardDisk","PXE" +Gen9 Legacy BIOS Boot Order: "CD","USB","HardDisk","PXE" +Gen9 UEFI Default Boot Order: "HardDisk" + + Array + + + BootOrderConsistencyChecking + + Use to override the consistency checking for the policy. Allowed values: + + * Exact + * None + + String + + + SecureBoot + + Specify if secure boot should be Unmanaged, Enabled or Disabled for Gen10 and newer servers. Boot Mode must be set to 'UEFI Optimized'. + + String + + + LocalStorage + + Enable local storage settings to be managed on the server. + + SwitchParameter + + + LocalStorageConsistencyChecking + + Use to override the consistency checking for the policy. Allowed values: + + * Exact + * None + + String + + + StorageController + + A resource object containing the StorageController, LogicalDisk or SasJbod configuration. Please refer to the New-OVServerProfileLogicalDisk and New-OVServerProfileLogicalDiskController Cmdlets. + + Object + + + ManageIloSettings + + Use to indicate iLO settings will be managed from the server profile. + + Bool + + + IloSettings + + Provide an iLO settings object from New-OVServerProfileIloPolicy Cmdlet. + + PSObject + + + IloSettingsConsistencyChecking + + Use to override the consistency checking for the policy. Allowed values: + + * Exact + * None + + String + + + SANStorageConsistencyChecking + + Use to override the consistency checking for the policy. Allowed values: + + * Exact + * Minimum + * None + + String + + + EvenPathDisabled + + Enable to disable even paths in the attached storage volume(s). + + SwitchParameter + + + OddPathDisabled + + Enable to disable odd paths in the attached storage volume(s). + + SwitchParameter + + + Affinity + + In a server profile, the Affinity control sets the remove-and-replace behavior for blade servers. If you apply a server profile to a blade server and the server is subsequently removed from the device bay, the Affinity setting controls whether the server profile is reapplied when you insert a server blade into the empty bay. Server profiles for rack servers do not have affinity. + +Accepted values are either "Bay" or "BayAndServer". Default is "Bay". + + String + + + MacAssignment + + Optional setting for MAC address assignment. May be Virtual or Physical. Use Virtual if you need to specify a UserDefined value when using the New-OVServerProfileConnection helper Cmdlet. + + String + + + WwnAssignment + + Optional setting for WWN assignment. May be Virtual or Physical. Use Virtual if you need to specify a UserDefined value when using the New-OVServerProfileConnection helper Cmdlet. + + String + + + SnAssignment + + Optional setting for serial number and UUID assignment. May be Virtual, Physical or UserDefined. + +Default: Virtual serial number and UUID assignment + + String + + + IscsiInitiatorNameAssignmet + + Specify if the iSCSI initiator name should be automatically managed and assigned, or a custom value should be used. Allowed values: * Virtual * UserDefined +Default Value: Virtual + + String + + + HideUnusedFlexNics + + This setting provides the ability to hide unused FlexNICs from the operating system. + +If Hide Unused FlexNICs is set to $True (default/enabled), FlexNICs that do not map to any server profile connections are not presented to the operating system. For example, if you have a full complement of eight FlexNICs defined in your server profile but map only four, your operating system will see only the four mapped FlexNICs instead of eight. + +If Hide Unused FlexNICs is set to $False (disabled), eight FlexNICs are enumerated in the operating system as network interfaces for each Flex-10 or FlexFabric adapter. + +Configuring Fibre Channel connections on a FlexFabric adapter can enumerate two storage interfaces, reducing the number of network interfaces to six. + +FlexNICs are hidden in pairs, starting with the fourth pair. For example, if the fourth FlexNIC on either physical port corresponds to a profile connection, all eight physical functions are enumerated. If a profile connection corresponds to the second FlexNIC on either physical port, but no connection corresponds to the third or fourth FlexNIC on either physical port, only the first and second physical functions are enumerated in the operating system. + +By default, Hide Unused FlexNICs is enabled. This setting can be changed only when the server is powered off. + + Boolean + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + PassThru + + Use this parameter to return the modified Server Profile Template object. In order to save the changes, please use the Save-OVServerProfileTemplate Cmdlet. + + SwitchParameter + + + ApplianceConnection + + The name of the appliance or list of appliances to execute the command against. + + Object + + + + + + + Affinity + + In a server profile, the Affinity control sets the remove-and-replace behavior for blade servers. If you apply a server profile to a blade server and the server is subsequently removed from the device bay, the Affinity setting controls whether the server profile is reapplied when you insert a server blade into the empty bay. Server profiles for rack servers do not have affinity. + +Accepted values are either "Bay" or "BayAndServer". Default is "Bay". + + String + + String + + Bay + + + ApplianceConnection + + The name of the appliance or list of appliances to execute the command against. + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + SwitchParameter + + false + + + Baseline + + Firmware baseline to assign. Can be either Baseline Name or URI. + + Object + + Object + + + + + BaselinePatchLevel + + The patch or supplement to the Update Bundle. Within the Update Bundle contains a property called Supplements ([Array] of [System.Version]). + + version + + version + + + + + Bios + + Enable BIOS Settings Management. Cannot be enabled with Server Hardware Type does not support BIOS Management (i.e. BL G7 +servers.) + + SwitchParameter + + SwitchParameter + + False + + + BiosConsistencyChecking + + Use to override the consistency checking for the policy. Allowed values: + + * Exact + * None + + String + + String + + + + + BiosSettings + + BIOS Settings that are to be managed. You can get the BIOS settings available from Get-OVServerHardwareType and the returned biosSettings property. + + Array + + Array + + @() + + + BootMode + + Specify the Gen9 Boot Envrionment. + +Sets the boot mode as one of the following: + + * UEFI + * UEFIOptimized + * BIOS + * Unmanaged + +If you select UEFI or UEFI optimized for an HP ProLiant DL Gen9 rack mount server, the remaining boot setting available is the PXE boot policy. + +For the UEFI or UEFI optimized boot mode options, the boot mode choice should be based on the expected OS and required boot features for the server hardware. UEFI optimized boot mode reduces the time the system spends in POST (Video driver initialization). In order to select the appropriate boot mode, consider the following: + + * If a secure boot is required, the boot mode must be set to UEFI or UEFI optimized . + * For operating systems that do not support UEFI (such as DOS, or older versions of Windows and Linux), the boot mode must be set to BIOS. + * When booting in UEFI mode, Windows 7, Server 2008, or 2008 R2 should not be set to UEFIOptimized. + +Default: BIOS + + String + + String + + BIOS + + + BootModeConsistencyChecking + + Use to override the consistency checking for the policy. Allowed values: + + * Exact + * None + + String + + String + + + + + BootOrder + + Boot Order settings to be managed. + +Defines the order in which boot will be attempted on the available devices. For Gen7 and Gen8 server hardware the possible values are "CD", "Floppy", "USB", "HardDisk", and "PXE". For Gen9 BL server hardware in Legacy BIOS boot mode, the possible values are "CD", "USB", "HardDisk", and "PXE". For Gen9 BL server hardware in UEFI or UEFI Optimized boot mode, only one value is allowed and must be either "HardDisk" or "PXE". For Gen9 DL server hardware in Legacy BIOS boot mode, the possible values are "CD", "USB", "HardDisk", and "PXE". For Gen9 DL server hardware in UEFI or UEFI Optimized boot mode, boot order configuration is not supported. + +Gen7/8 BIOS Default Boot Order: "CD","Floppy","USB","HardDisk","PXE" +Gen9 Legacy BIOS Boot Order: "CD","USB","HardDisk","PXE" +Gen9 UEFI Default Boot Order: "HardDisk" + + Array + + Array + + @() + + + BootOrderConsistencyChecking + + Use to override the consistency checking for the policy. Allowed values: + + * Exact + * None + + String + + String + + + + + Connections + + The network connections that are to be part of this new server profile. This an array of profile connection objects which may be created with "New-OVServerProfileConnection". + +Expected Connection Format: + +[System.Collections.ArrayList ] @( + [PsCustomObject]@{ + [System.Int]id - Connection ID. Valid 1-64. A 0 value is allowed, + but means Auto Connection ID assignment. + [System.String]function - Ethernet or FibreChannel. + [System.String]networkUri - URI to the Network resource. + [System.String]portId - Auto or the specific Port ID. For FlexLOMs, the valid + portId prefix will be "Flb", and Mezzanine would be "Mezz". + Ex. FlexNIC 1a interface would be "Flb 1:1a" + Ex. Mezzanine 2, FlexNIC 2c interface would be "Mezz 2:2c" + [System.Int32]requestedMpbs - Requested bandwidth in Mbps. + [System.Collections.Hashtable]boot - Nested Hashtable + @{ + [System.String]priority - Boot priority for this connection. Can be used with Ethernet + or FC connections. Allowed values: + NotBootable + Primary + Secondary + [System.Collections.ArrayList ]targets - Array of FC boot targets (only 1 entry is allowed) + @( + [System.String]arrayWwpn - Target WWPN of storage array. + [System.String]lun - Boot LUN ID + + ) + } + [System.String]macType - Allowed values: + Physical + UserDefined + Virtual + [System.String]mac - UserDefined MAC Address. Required for custom MAC and FCoE WWPN addresses. + [System.String]wwpnType - Allowed values: + Physical + UserDefined + Virtual + [System.String]wwpn - UserDefined WWPN Address + [System.String]wwnn - UserDefined WWNN Address + } +) + +Default: No connections + + Array + + Array + + @() + + + ConnectionsConsistencyChecking + + Use to override the consistency checking for the policy. Allowed values: + + * Exact + * Minimum + * None + + String + + String + + + + + Description + + Optional description for this server profile template. + + String + + String + + + + + EnclosureGroup + + The Enclosure Group resource the Server Profile Template will be bound to. When assigning to an Enclosure Group, OneView will then determine what farbic connectivity and storage devices are available. + + Object + + Object + + + + + EvenPathDisabled + + Enable to disable even paths in the attached storage volume(s). + + SwitchParameter + + SwitchParameter + + False + + + Firmware + + Enable Firmware Management. Cannot be enabled with Server Hardware Type does not support Firmware Management (i.e. BL G7 servers.) + + SwitchParameter + + SwitchParameter + + False + + + FirmwareActivationMode + + Specify the firmware activation policy. Avialable options are: + + * Immediate - Immediately activate (aka reboot the host) firmware if needed. Requires HPSUT to be installed in the Host OS or Proxy VM (for VMware only) + * Scheduled - Specify a future time to activate (aka reboot the host) firmware if needed. You will need to specify the FirmwareActivateDateTime parameter. Requires HPSUT to be installed in the Host OS or Proxy VM (for VMware only) + * NotScheduled - Scheduled firmware update is cancelled when you choose this option. + + String + + String + + Immediate + + + FirmwareConsistencyChecking + + Use to override the consistency checking for the policy. Allowed values: + + * Exact + * None + + String + + String + + + + + FirmwareInstallMode + + Specify the Firmware Baseline Policy mode. Avialable options are: + + * FirmwareOnly - Updates the system firmware without powering down the server hardware using using HP Smart Update Tools. + * FirmwareAndSoftware - Updates the firmware and OS drivers without powering down the server hardware using HP Smart Update Tools. + * FirmwareOffline - Manages the firmware through HPE OneView. Selecting this option requires the server hardware to be powered down. + + String + + String + + FirmwareAndSoftware + + + FirmwareInstallationPolicy + + The Installation policy option is only available for Gen10 and later servers. The option is available for Gen10 or later server hardware types only. Installation policy enables you to choose if a component needs to be updated or downgraded when its version does not match the baseline. An alert is generated when the installed version on one or more components is inconsistent with the selected installation policy. + +You can choose one of the following two policy options: + + * LowerThanBaseline (Default) - Updates only the components that have a version lower than the firmware baseline version. + * NotEqualToBaseline - Updates or downgrades components whose installed version does not match the firmware baseline version. The components with a version lower than the firmware baseline version are upgraded, and the components with a version higher than the firmware baseline version are downgraded to match the baseline. + +NOTE: For Gen9 and earlier servers, if the selected firmware baseline is older than the firmware currently installed, select the Force installation option to downgrade the firmware version. + + string + + string + + + + + ForceInstallFirmware + + Using this parameter will force the bundled firmware components to install when the Server Profile is applied to a server. This will downgrade firmware if the component firmware is newer than what the SPP Baseline contains. + + SwitchParameter + + SwitchParameter + + False + + + HideUnusedFlexNics + + This setting provides the ability to hide unused FlexNICs from the operating system. + +If Hide Unused FlexNICs is set to $True (default/enabled), FlexNICs that do not map to any server profile connections are not presented to the operating system. For example, if you have a full complement of eight FlexNICs defined in your server profile but map only four, your operating system will see only the four mapped FlexNICs instead of eight. + +If Hide Unused FlexNICs is set to $False (disabled), eight FlexNICs are enumerated in the operating system as network interfaces for each Flex-10 or FlexFabric adapter. + +Configuring Fibre Channel connections on a FlexFabric adapter can enumerate two storage interfaces, reducing the number of network interfaces to six. + +FlexNICs are hidden in pairs, starting with the fourth pair. For example, if the fourth FlexNIC on either physical port corresponds to a profile connection, all eight physical functions are enumerated. If a profile connection corresponds to the second FlexNIC on either physical port, but no connection corresponds to the third or fourth FlexNIC on either physical port, only the first and second physical functions are enumerated in the operating system. + +By default, Hide Unused FlexNICs is enabled. This setting can be changed only when the server is powered off. + + Boolean + + Boolean + + True + + + HostOStype + + Optional. Specify the Host OS type, which will set the Host OS value when HPE OneView created the Host object on the Storage System. Accepted values: + + * CitrixXen = "Citrix Xen Server 5.x/6.x" + * AIX = "AIX" + * IBMVIO = "IBM VIO Server" + * RHEL4 = "RHE Linux (Pre RHEL 5)" + * RHEL3 = "RHE Linux (Pre RHEL 5)" + * RHEL = "RHE Linux (5.x, 6.x)" + * RHEV = "RHE Virtualization (5.x, 6.x)" + * VMware = "ESX 4.x/5.x" + * Win2k3 = "Windows 2003" + * Win2k8 = "Windows 2008/2008 R2" + * Win2k12 = "Windows 2012 / WS2012 R2" + * OpenVMS = "OpenVMS" + * Egenera = "Egenera" + * Exanet = "Exanet" + * Solaris9 = "Solaris 9/10" + * Solaris10 = "Solaris 9/10" + * Solaris11 = "Solaris 11" + * ONTAP = "NetApp/ONTAP" + * OEL = "OE Linux UEK (5.x, 6.x)" + * HPUX11iv1 = "HP-UX (11i v1, 11i v2)" + * HPUX11iv2 = "HP-UX (11i v1, 11i v2)" + * HPUX11iv3 = "HP-UX (11i v3)" + * SUSE = "SuSE (10.x, 11.x)" + * SUSE9 = "SuSE Linux (Pre SLES 10)" + * Inform = "InForm" + + String + + String + + + + + IloSettings + + Provide an iLO settings object from New-OVServerProfileIloPolicy Cmdlet. + + PSObject + + PSObject + + + + + IloSettingsConsistencyChecking + + Use to override the consistency checking for the policy. Allowed values: + + * Exact + * None + + String + + String + + + + + IscsiInitiatorNameAssignmet + + Specify if the iSCSI initiator name should be automatically managed and assigned, or a custom value should be used. Allowed values: * Virtual * UserDefined +Default Value: Virtual + + String + + String + + Virtual + + + LocalStorage + + Enable local storage settings to be managed on the server. + + SwitchParameter + + SwitchParameter + + False + + + LocalStorageConsistencyChecking + + Use to override the consistency checking for the policy. Allowed values: + + * Exact + * None + + String + + String + + + + + MacAssignment + + Optional setting for MAC address assignment. May be Virtual or Physical. Use Virtual if you need to specify a UserDefined value when using the New-OVServerProfileConnection helper Cmdlet. + + String + + String + + Virtual + + + ManageBoot + + Enable Boot Order Management. Also required for Connection boot enablement. If this is disabled ($False), then PXE or FC BfS settings are disabled within the entire Server Profile. + +Default: $True + + SwitchParameter + + SwitchParameter + + False + + + ManageConnections + + Use this parameter to specify if Connections should be tracked from the Server Profile Template for compliance. If set to False, the -Connections parameter will be ignored, and Connections must be set and managed at the Server Profile. + + Boolean + + Boolean + + True + + + ManageIloSettings + + Use to indicate iLO settings will be managed from the server profile. + + Bool + + Bool + + + + + Name + + The name of the server profile resource to be created. + + String + + String + + + + + OSDeploymentConsistencyChecking + + Use to override the consistency checking for the policy. Allowed values: + + * Exact + * None + + String + + String + + + + + OSDeploymentPlan + + The HPE Synergy Image Streamer OS deployment plan from Get-OVOSDeploymentPlan. + + Object + + Object + + + + + OSDeploymentPlanAttributes + + Configured OS Deployment Plan parameters from Get-OVOSDeploymentPlanAttribute. You will need to group required NIC parameters together based on needed values. + + Array + + Array + + + + + OddPathDisabled + + Enable to disable odd paths in the attached storage volume(s). + + SwitchParameter + + SwitchParameter + + False + + + PassThru + + Use this parameter to return the modified Server Profile Template object. In order to save the changes, please use the Save-OVServerProfileTemplate Cmdlet. + + SwitchParameter + + SwitchParameter + + + + + PxeBootPolicy + + Controls the ordering of the network modes available to the Flexible LOM (FLB); for example, IPv4 and IPv6. + +Select from the following policies: + + * Auto + * IPv4 only + * IPv6 only + * IPv4 then IPv6 + * IPv6 then IPv4 + +Setting the policy to Auto means the order of the existing network boot targets in the UEFI Boot Order list will not be modified, and any new network boot targets will be added to the end of the list using the System ROM"s default policy. + +Default: Auto + + String + + String + + Auto + + + SANStorage + + Optional. Enable SAN Storage Management within the Server Profile. + + SwitchParameter + + SwitchParameter + + False + + + SANStorageConsistencyChecking + + Use to override the consistency checking for the policy. Allowed values: + + * Exact + * Minimum + * None + + String + + String + + + + + SecureBoot + + Specify if secure boot should be Unmanaged, Enabled or Disabled for Gen10 and newer servers. Boot Mode must be set to 'UEFI Optimized'. + + String + + String + + + + + ServerHardwareType + + The Server Hardware Type reource the Server Profile Template will be bound to. + + Object + + Object + + + + + ServerProfileDescription + + Optional description for created server profiles from this template. + + String + + String + + + + + SnAssignment + + Optional setting for serial number and UUID assignment. May be Virtual, Physical or UserDefined. + +Default: Virtual serial number and UUID assignment + + String + + String + + Virtual + + + StorageController + + A resource object containing the StorageController, LogicalDisk or SasJbod configuration. Please refer to the New-OVServerProfileLogicalDisk and New-OVServerProfileLogicalDiskController Cmdlets. + + Object + + Object + + + + + StorageVolume + + Optional. Array of Storage Volume resources to attach. Can be created by using the New-OVServerProfileAttachVolume Cmdlet. This parameter does not accept a Storage Volume resource from the Get-OVStorageVolume Cmdlet. + +The format of the Storage Volume resource should be a PsCustomObject PowerShell resource with the following keys and values: + +[PsCustomObject]@{ + [System.Int]id - Valid Host LUN ID 0-254 + [System.String]lunType - Auto or Manual + [System.String]volumeUri - URI to Storage Volume that has been created and not + assigned to another Server Profile if it is a Private Volume. + [System.String]volumeStoragePoolUri - URI to HPE OneView managed Storage Pool + [System.String]volumeStorageSystemUri - URI to HPE OneView managed Storage System + [System.Collections.ArrayList ]storagePaths - Array specifying the Profile FC Connection ID associated + with the path to the attached volume, and if the path is + enabled or disabled. + @( + [System.Int]connectionId - FC Connection ID. If using New-OVServerProfileAttachVolume helper + Cmdlet, New-OVServerProfile will automatically determine the FC + connection ID. + [System.Boolean]isEnabled - Enable or disable the path + ) +} + + Object + + Object + + + + + WwnAssignment + + Optional setting for WWN assignment. May be Virtual or Physical. Use Virtual if you need to specify a UserDefined value when using the New-OVServerProfileConnection helper Cmdlet. + + String + + String + + Virtual + + + + + + + System.String + + + The full path to the Server Profile JSON export file + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + If successful returns a task resource which may be polled to follow the progress of the profile creation. Otherwise, a request validation error will be returned + + + + + HPEOneView.ServerProfileTemplate [System.Management.Automation.PSCustomObject] + + + + When using the -PassThru parameter, the created server profile template object is returned. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + $Name = "HP ProLiant BL460 Gen9 Profile Template" +$con1 = Get-OVNetwork -Name "Net 41-A" | New-OVServerProfileConnection -connectionId 1 +$con2 = Get-OVNetwork -Name "Net 41-B" | New-OVServerProfileConnection -connectionId 2 +$bl460SHT = Get-OVServerHardwareTypes -name "BL460c Gen9 1" +$eg = Get-OVEnclosureGroup "Default EG1" +$params = @{ +>> name = $Name; +>> serverHardwareType = $bl460SHT; +>> enclosureGroup = $eg; +>> connections = $con1, $con2; +>> ManageBoot = $True; +>> BootMode = "UEFI"; +>> ApplianceConnection = "MyAppliance1.domain.com" +>>} +>> +New-OVServerProfileTemplate @params | Wait-OVTaskComplete + + Create a BL Gen8 Server Profile template, and pipe to Wait-OVTaskComplete. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + $net41 = Get-OVNetwork -Name "Net-41" +$con41 = New-OVServerProfileConnection -network $net41 -connectionType Ethernet -connectionId 1 +$net42 = Get-OVNetwork -Name "Net-42" +$con42 = New-OVServerProfileConnection -network $net42 -connectionType Ethernet -connectionId 2 +$conList = @($con41, $con42) +$task = New-OVServerProfileTemplate -name $Name -serverHardwareType "bl460c Gen8 1" -enclosureGroup "Production Encl Grp1" -connections $conList | Wait-OVTaskComplete + + Create a server profile template which includes networks "Net-41" and "Net-42". + + + + + + + + + + -------------------------- EXAMPLE 3 -------------------------- + + + + $profileName = "Hypervisor Cluster Node Template v1.0" +$bl460SHT = Get-OVServerHardwareTypes -name "BL460c Gen9 1" +$enclosuregroup = Get-OVEnclosureGroup "Production EG1" +$con1 = Get-OVNetwork -Name "Net 41-a" | New-OVServerProfileConnection -id 1 +$con2 = Get-OVNetwork -Name "Net 41-b" | New-OVServerProfileConnection -id 2 +$con3 = Get-OVNetworkSet "Prod Networks A" | New-OVServerProfileConnection -id 3 +$con4 = Get-OVNetworkSet "Prod Networks A" | New-OVServerProfileConnection -id 4 +$con5 = Get-OVNetwork -Name "fabric a" | New-OVServerProfileConnection -id 5 -type FibreChannel -bootable -priority Primary -arrayWWPn "21:11:00:02:AC:00:72:03" -LUN 0 +$con6 = Get-OVNetwork -Name "fabric b" | New-OVServerProfileConnection -id 6 -type FibreChannel -bootable -priority Secondary -arrayWWPn "22:12:00:02:AC:00:72:03" -LUN 0 +$conList = $con1, $con2, $con3, $con4, $con5, $con6 +$task = New-OVServerProfileTemplate -name $profileName -connections $conList -sht $bl460SHT -eg $enclosuregroup -ManageBoot | Wait-OVTaskComplete + + Create a new Server Profile template with 6 Connections, 4 Ethernet (including Network Sets) and 2 Fibre Channel (with BfS configured). + + + + + + + + + + -------------------------- EXAMPLE 4 -------------------------- + + + + $profileName = "SQL DB Cluster Node Template v1.0" +$bl660SHT = Get-OVServerHardwareTypes -name "BL660c Gen9 1" +#display the BL660 Gen9 BIOS Settings +$bl660SHT.biosSettings +#Set HP Power Profile (ID 210) to Maximum Performance and HP Power Regulator (ID 140) to HP Static High Performance Mode. +$bl660bios = @(@{id=210;value=3},@{id=140;value=3}) +$enclosuregroup = Get-OVEnclosureGroup "Production EG1" +$con1 = Get-OVNetwork -Name "Net 41-A" | New-OVServerProfileConnection -connectionId 1 +$con2 = Get-OVNetwork -Name "Net 41-B" | New-OVServerProfileConnection -connectionId 2 +$con3 = Get-OVNetwork -Name "fabric a" | New-OVServerProfileConnection -id 3 -type FibreChannel -bootable -priority Primary -arrayWWPn "21:11:00:02:AC:00:72:03" -LUN 0 +$con4 = Get-OVNetwork -Name "fabric b" | New-OVServerProfileConnection -id 4 -type FibreChannel -bootable -priority Secondary -arrayWWPn "22:12:00:02:AC:00:72:03" -LUN 0 +$LogicalDisk = New-OVServerProfileLogicalDisk -Name "My Local Disk" -RAID RAID1 -NumberofDrives 2 -DiskType SasSsd +$volume1 = Get-OVStorageVolume SharedVolume1 | New-OVServerProfileAttachVolume +$params = @{ +>> name = $profileName; +>> connections = $con1, $con2, $con3, $con4; +>> bios = $true; +>> biossettings = $bl660bios +>> manageboot = $True; +>> bootMode = "UEFI"; +>> pxeBootPolicy = "IPv4ThenIPv6"; +>> bootOrder = "HardDisk"; +>> HideUnusedFlexnics = $True; +>> LocalStorage = $True; +>> LogicalDisk = $LogicalDisk; +>> SANStorage = $True; +>> Ostype = "Win2k12"; +>> StorageVolume = $volume1; +} +>> +New-OVServerProfileTemplate @params | Wait-OVTaskComplete + + Create a BL Gen9 UEFI Server Profile template with Ethernet and FC connections, local storage, SAN Storage and BIOS Settings, then pipe to Wait-OVTaskComplete. + + + + + + + + + + + + + Convert-OVServerProfileTemplate + + + + ConvertTo-OVServerProfileTemplate + + + + Get-OVServerProfileTemplate + + + + Remove-OVServerProfileTemplate + + + + Save-OVServerProfileTemplate + + + + Set-OVServerProfileTemplate + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/servers/new-ovserverprofiletemplate + + + + + + + + New-OVSnmpConfiguration + + Create SNMP LIG Configuration Object + + New + OVSnmpConfiguration + + + This helper Cmdlet provides the capability to create a new SNMP Configuration object for a Logical Interconnect Group or Logical Interconnect resources. + + + + + New-OVSnmpConfiguration + + ReadCommunity + + The SNMP Read Community String to set. + + String + + + SnmpV1 + + Specify if SNMPv1 should be enabled. Can be disabled when SNMPv3 is enabled. + + Bool + + + SnmpV3 + + Specify if SNMPv3 should be enabled. + + Bool + + + Contact + + SNMP Contact Name. + + String + + + AccessList + + A collection [System.Collections.ArrayList ] of IP Addresses or Subnets. You must include the Subnet Mask Bit value. E.g. 10.44.120.9/32 or 172.20.148.0/22 + + Array + + + TrapDestinations + + A collection [System.Collections.ArrayList ] of SNMMP Trap Destinations. Use New-OVTrapDestination Cmdlet to create the object. + + Array + + + + New-OVSnmpConfiguration + + ReadCommunity + + The SNMP Read Community String to set. + + String + + + SnmpV3 + + Specify if SNMPv3 should be enabled. + + Bool + + + SnmpV3Users + + Collection of SNMPv3 users to configure within the SNMP configuration object. + + SnmpV3User[] + + + SnmpV1 + + Specify if SNMPv1 should be enabled. Can be disabled when SNMPv3 is enabled. + + Bool + + + Contact + + SNMP Contact Name. + + String + + + AccessList + + A collection [System.Collections.ArrayList ] of IP Addresses or Subnets. You must include the Subnet Mask Bit value. E.g. 10.44.120.9/32 or 172.20.148.0/22 + + Array + + + TrapDestinations + + A collection [System.Collections.ArrayList ] of SNMMP Trap Destinations. Use New-OVTrapDestination Cmdlet to create the object. + + Array + + + + + + + AccessList + + A collection [System.Collections.ArrayList ] of IP Addresses or Subnets. You must include the Subnet Mask Bit value. E.g. 10.44.120.9/32 or 172.20.148.0/22 + + Array + + Array + + + + + Contact + + SNMP Contact Name. + + String + + String + + + + + ReadCommunity + + The SNMP Read Community String to set. + + String + + String + + + + + SnmpV1 + + Specify if SNMPv1 should be enabled. Can be disabled when SNMPv3 is enabled. + + Bool + + Bool + + + + + SnmpV3 + + Specify if SNMPv3 should be enabled. + + Bool + + Bool + + + + + SnmpV3Users + + Collection of SNMPv3 users to configure within the SNMP configuration object. + + SnmpV3User[] + + SnmpV3User[] + + + + + TrapDestinations + + A collection [System.Collections.ArrayList ] of SNMMP Trap Destinations. Use New-OVTrapDestination Cmdlet to create the object. + + Array + + Array + + + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + HPEOneView.Networking.SnmpConfiguration [System.Management.Automation.PSCustomObject] + + + + SNMP Configuration object for a Logical Interconnect Group or Logical Interconnect resource + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + $SnmpConfig = New-OVSnmpConfiguration -ReadCommunity MyR3adC0mmun1ty -AccessList "10.44.120.9/32","172.20.148.0/22 New-OVLogicalInterconnectGroup -LIGName "Flex10/10D and FlexFabric Production 1" -bays @{1 = "Flex1010D";2 = "Flex1010D";3 = "FlexFabric";4 = "FlexFabric"} -enableIgmpSnooping $True -igmpIdleTimeoutInterval 300 -LoopProtect $True -QosConfig $QosConfig + + Create a new QOS Configuration object,and use the created object to add to a new Logical Interconnect Group. + + + + + + + + + + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/library/new-ovsnmpconfiguration + + + + + + + + New-OVSnmpTrapDestination + + Create SNMP Trap Destination Object + + New + OVSnmpTrapDestination + + + This helper Cmdlet provides the capability to create a new SNMP Trap Destination object. The object can then be used with New-OVSnmpConfiguration to create a new SNMP Configuration for a Logical Interconnect Group or Logical Interconnect resource. + + + + + New-OVSnmpTrapDestination + + Destination + + The SNMP destination IP Address or FQDN. + + String + + + Community + + The SNMP Trap Community String to set. + + String + + + Port + + Provide the alternate SNMP trap reciever port. + + Int + + + SnmpFormat + + SNMP Format type. Allowed values: + + * SNMPv1 + * SNMPv2 + * SNMPv3 + + String + + + TrapSeverities + + A collection [System.Collections.ArrayList ] of SNMP Trap Severities to generate Traps for. Allowed values: + + * Critical + * Info + * Major + * Minor + * Normal + * Unknown + * Warning + + Array + + + VCMTrapCategories + + A collection [System.Collections.ArrayList ] of VCM Trap Categories. Allowed values: + + * Legacy + + Array + + + EnetTrapCategories + + A collection [System.Collections.ArrayList ] of SNMP Trap Severities to generate Traps for. Allowed values: + + * Other + * PortStatus + * PortThresholds + + Array + + + FCTrapCategories + + A collection [System.Collections.ArrayList ] of SNMP Trap Severities to generate Traps for. Allowed values: + + * Other + * PortStatus + + Array + + + + New-OVSnmpTrapDestination + + Destination + + The SNMP destination IP Address or FQDN. + + String + + + SnmpV3User + + A valid SNMPv3 user from New-OVSnmpV3User. + + HPEOneView.Appliance.SnmpV3User + + + Port + + Provide the alternate SNMP trap reciever port. + + Int + + + SnmpFormat + + SNMP Format type. Allowed values: + + * SNMPv1 + * SNMPv2 + * SNMPv3 + + String + + + NotificationType + + Indicates whether the trap should be inform message or not. Allowed values: + + * Inform + * Trap + + String + + + EngineID + + The EngineId of remote SNMPv3 user. Only applicable when configuring an SNMPv3 object for the appliance, not logical interconnect groups or logical interconnects. + + String + + + TrapSeverities + + A collection [System.Collections.ArrayList ] of SNMP Trap Severities to generate Traps for. Allowed values: + + * Critical + * Info + * Major + * Minor + * Normal + * Unknown + * Warning + + Array + + + VCMTrapCategories + + A collection [System.Collections.ArrayList ] of VCM Trap Categories. Allowed values: + + * Legacy + + Array + + + EnetTrapCategories + + A collection [System.Collections.ArrayList ] of SNMP Trap Severities to generate Traps for. Allowed values: + + * Other + * PortStatus + * PortThresholds + + Array + + + FCTrapCategories + + A collection [System.Collections.ArrayList ] of SNMP Trap Severities to generate Traps for. Allowed values: + + * Other + * PortStatus + + Array + + + + + + + Community + + The SNMP Trap Community String to set. + + String + + String + + public + + + Destination + + The SNMP destination IP Address or FQDN. + + String + + String + + + + + EnetTrapCategories + + A collection [System.Collections.ArrayList ] of SNMP Trap Severities to generate Traps for. Allowed values: + + * Other + * PortStatus + * PortThresholds + + Array + + Array + + + + + EngineID + + The EngineId of remote SNMPv3 user. Only applicable when configuring an SNMPv3 object for the appliance, not logical interconnect groups or logical interconnects. + + String + + String + + + + + FCTrapCategories + + A collection [System.Collections.ArrayList ] of SNMP Trap Severities to generate Traps for. Allowed values: + + * Other + * PortStatus + + Array + + Array + + + + + NotificationType + + Indicates whether the trap should be inform message or not. Allowed values: + + * Inform + * Trap + + String + + String + + Trap + + + Port + + Provide the alternate SNMP trap reciever port. + + Int + + Int + + + + + SnmpFormat + + SNMP Format type. Allowed values: + + * SNMPv1 + * SNMPv2 + * SNMPv3 + + String + + String + + SNMPv1 + + + SnmpV3User + + A valid SNMPv3 user from New-OVSnmpV3User. + + HPEOneView.Appliance.SnmpV3User + + HPEOneView.Appliance.SnmpV3User + + + + + TrapSeverities + + A collection [System.Collections.ArrayList ] of SNMP Trap Severities to generate Traps for. Allowed values: + + * Critical + * Info + * Major + * Minor + * Normal + * Unknown + * Warning + + Array + + Array + + + + + VCMTrapCategories + + A collection [System.Collections.ArrayList ] of VCM Trap Categories. Allowed values: + + * Legacy + + Array + + Array + + + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + HPEOneView.Networking.SnmpTrapDestination [System.Management.Automation.PSCustomObject] + + + + SNMP Trap desitnation object for an SNMP Configuration Object + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + $Dest1 = New-OVSnmpTrapDestination -Destination mysnmpserver.domain.local -Community MyR3adcommun1ty -SnmpFormat SNMPv1 -TrapSeverities critical,warning $Dest2 = New-OVSnmpTrapDestination 10.44.120.9 MyR3adcommun1ty SNMPv1 critical,warning legacy "Other","PortStatus","PortThresholds" "Other","PortStatus" $SnmpConfig = New-OVSnmpConfiguration -ReadCommunity MyR3adC0mmun1ty -AccessList "10.44.120.9/32","172.20.148.0/22 -TrapDestinations $Dest1,$Dest2 New-OVLogicalInterconnectGroup -LIGName "Flex10/10D and FlexFabric Production 1" -bays @{1 = "Flex1010D";2 = "Flex1010D";3 = "FlexFabric";4 = "FlexFabric"} -SNMP $SnmpConfig + + Create a new SNMP Configuration object, with the specified Trap Destinations, and use the created object to add to a new Logical Interconnect Group. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + # Create SNMPv3 user account for appliance. $SNMPv3User = New-OVSnmpv3User -Username snmpv3user -SecurityLevel None -ApplianceSnmpUser $Dest1 = New-OVSnmpTrapDestination -Destination mysnmpserver.domain.local -Community MyR3adcommun1ty -SnmpFormat SNMPv1 -TrapSeverities critical,warning $Dest2 = New-OVSnmpTrapDestination 10.44.120.9 MyR3adcommun1ty SNMPv1 critical,warning legacy "Other","PortStatus","PortThresholds" "Other","PortStatus" $SnmpConfig = New-OVSnmpConfiguration -ReadCommunity MyR3adC0mmun1ty -AccessList "10.44.120.9/32","172.20.148.0/22 -TrapDestinations $Dest1,$Dest2 New-OVLogicalInterconnectGroup -LIGName "Flex10/10D and FlexFabric Production 1" -bays @{1 = "Flex1010D";2 = "Flex1010D";3 = "FlexFabric";4 = "FlexFabric"} -SNMP $SnmpConfig + + Create a new SNMP Configuration object, with the specified Trap Destinations, and use the created object to add to a new Logical Interconnect Group. + + + + + + + + + + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/library/new-ovsnmptrapdestination + + + + + + + + New-OVSnmpV3User + + Create a new SNMPv3 user from appliance or Logical Interconnect/Switch resoure. + + New + OVSnmpV3User + + + HPE OneView can be used as a proxy to forward device traps from servers and enclosures (OA) to other SNMP-enabled applications on the network. HPE OneView can forward traps, as SNMPv3 or SNMPv1 traps, to configured destinations. + +Appliance SNMP settings allow you to add destinations to which the traps need to be forwarded. You can configure each destination as an SNMPv1 or SNMPv3 destination, depending on whether the traps are sent in SNMPv1 or SNMPv3 formats. + +Additionally, if you have Gen6 or Gen7 servers being monitored by HPE OneView in your environment, you can configure the read community string that HPE OneView uses for monitoring these servers with SNMPv1. + +NOTE: To configure SNMP trap forwarding for network devices (interconnects and switches), use the New-OVSnmpV3User and include it within the New-OVSnmpTrapDestination Cmdlet. + +Minimum required privileges: Infrastructure administrator + + + + + New-OVSnmpV3User + + Username + + SNMPv3 Username + + String + + + SecurityLevel + + Specify the type of SNMPv3 security policy. Supported values: + * None + * AuthOnly + * AuthAndPriv + + String + + + AuthProtocol + + SNMPv3 Authentication protocol. Supported values: + + * None + * MD5 + * SHA + * SHA1 + * SHA256 + * SHA384 + * SHA512 + + String + + + AuthPassword + + SNMpv3 Authentication password in System.Security.SecureString format. + + System.Security.SecureString + + + PrivProtocol + + SNMPv3 Privacy protocol. Supported values: + + * none + * des56 + * 3des + * aes128 + * aes192 + * aes256" + + String + + + PrivPassword + + SNMpv3 Privacy password in System.Security.SecureString format. + + System.Security.SecureString + + + + New-OVSnmpV3User + + Username + + SNMPv3 Username + + String + + + ApplianceSnmpUser + + Use this to create an appliance SNMPv3 User. Default is to create an HPEOneView.Networking.SnmpV3User. + + SwitchParameter + + + SecurityLevel + + Specify the type of SNMPv3 security policy. Supported values: + * None + * AuthOnly + * AuthAndPriv + + String + + + AuthProtocol + + SNMPv3 Authentication protocol. Supported values: + + * None + * MD5 + * SHA + * SHA1 + * SHA256 + * SHA384 + * SHA512 + + String + + + AuthPassword + + SNMpv3 Authentication password in System.Security.SecureString format. + + System.Security.SecureString + + + PrivProtocol + + SNMPv3 Privacy protocol. Supported values: + + * none + * des56 + * 3des + * aes128 + * aes192 + * aes256" + + String + + + PrivPassword + + SNMpv3 Privacy password in System.Security.SecureString format. + + System.Security.SecureString + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + Array + + (${Global:ConnectedSessions} | ? Default) + + + ApplianceSnmpUser + + Use this to create an appliance SNMPv3 User. Default is to create an HPEOneView.Networking.SnmpV3User. + + SwitchParameter + + SwitchParameter + + + + + AuthPassword + + SNMpv3 Authentication password in System.Security.SecureString format. + + System.Security.SecureString + + System.Security.SecureString + + + + + AuthProtocol + + SNMPv3 Authentication protocol. Supported values: + + * None + * MD5 + * SHA + * SHA1 + * SHA256 + * SHA384 + * SHA512 + + String + + String + + + + + PrivPassword + + SNMpv3 Privacy password in System.Security.SecureString format. + + System.Security.SecureString + + System.Security.SecureString + + + + + PrivProtocol + + SNMPv3 Privacy protocol. Supported values: + + * none + * des56 + * 3des + * aes128 + * aes192 + * aes256" + + String + + String + + + + + SecurityLevel + + Specify the type of SNMPv3 security policy. Supported values: + * None + * AuthOnly + * AuthAndPriv + + String + + String + + + + + Username + + SNMPv3 Username + + String + + String + + + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + HPEOneView.Appliance.SnmpV3User + + + + Appliance SNMPv3 user account created on the appliance. + + + + + HPEOneView.Networking.SnmpV3User + + + + SNMPv3 user account for a networking resource. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + $Snmpv3Password = ConvertTo-SecureString "Myp@ssword" -AsPlainText -Force +New-OVSnmpV3User -ApplianceSnmpUser -Username MySNMPv3us3r -SecurityLevel AuthAndPriv -AuthProtocol SHA512 -AuthPassword AES192 -PrivProtocol $SnmpV3UserPrivProtocol -PrivPassword $Snmpv3Password + + Create a new SNMPv3 user for the appliance. + + + + + + + + + + + + + Get-OVSnmpV3User + + + + Remove-OVSnmpV3User + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/library/new-ovsnmpv3user + + + + + + + + New-OVStorageVolume + + Create a Storage Volume resource. + + New + OVStorageVolume + + + This Cmdlet will help create a Storage Volume resource on a managed Storage System. The volume can be created by specifying the Storage Pool or an existing Storage Volume Template. When the Storage Pool name is not unique, you can either use the -StorageSystem parameter, or pass via the pipeline the Storage Pool from Get-OVStoragePool. + +If the Storage Volume Template Global Policy is enabled, a valid Storage Volume Template must be provided. + + + + + New-OVStorageVolume + + Name + + Storage Volume Name. Device Volume created on the storage system will be this name without spaces. + + String + + + StoragePool + + Storage Pool URI, name or resource object. + + Object + + + Description + + Provide a description for the volume. + + String + + + SnapshotStoragePool + + Storage Pool URI, name or resource object. + + Object + + + StorageSystem + + When the Storage Pool name is not unique, specify the Storage System name the pool is managed/associate with. + + Object + + + Capacity + + Max volume capacity in GB. e.g. 20 to specify 20GB. + + Int64 + + + ProvisioningType + + Specify the type of volume to provision. Allowed values are: + + * Thin + * Full + * TPDD (Thin Provision Dedup) - Only available for HPE StoreServ storage systems with SSD storage pools (aka CPG"s). + + String + + + EnableCompression + + Enable compression for StoreServe (3PAR) supported resources. Please verify the InformOS version installed supports Compression. + + Boolean + + + EnableDeduplication + + Enable deduplication for SSD-based Storage Pools (CPG). + + Boolean + + + Full + + NOTE: This parameter is being deprecated for the -ProvisionType parameter. Please update your scripts. + +Include this switch to enable Thick volume provisioning. Omit to specify Thin storage provisioning. +Default: Thin + + SwitchParameter + + + Shared + + Include this switch to mark the Storage Volume as a Shareable resource for shared volume access. +Default: Private + + SwitchParameter + + + PerformancePolicy + + A Nimble Performance Policy is associated with a storage system. Using the Show-OVStorageSystemPerformancePolicy, choose an available performance policy. + +Example: + + Get-OVStorageSystem -Name MyNimbleSys | Show-OVStorageSystemPerformancePolicy + + HPEOneView.Storage.PerformancePolicy + + + EnableEncryption + + When the storage system has encryption enabled, the volume can also be encrypted. Specify if the volume should be encrypted during creation. + + Bool + + + CachePinning + + This is applicable for hybrid (a mix of flash and mechanical storage) arrays, and provides a 100 percent cache hit rate for specific volumes (for example, volumes dedicated to critical applications), and delivers the response times of an all-flash storage system. A volume is pinned when the entire active volume is placed in cache; associated snapshot (inactive) blocks are not pinned. All incoming data after that point is pinned. The number of volumes that can be pinned is limited by the size of the volumes and amount of available cache. + +When defined in the Performance Profile, select to enable Cache Pinnning for the Nimble volume to be created. + + Bool + + + VolumeSet + + Use to specify a Volume Set the volume will be associated with, from Get-OVStorageVolumeSet. + + HPEOneView.Storage.VolumeSet + + + EnableIOPSLimit + + Set to enable or disable IOPS limit. If enabled, the -IOPSLimit parameter must be set. By default, IOPS limit is not set. + + Bool + + + IOPSLimit + + When enabling IOPS limit, provide a value that is greater than or equal to 256. + + Int + + + EnableDataTransferLimit + + Enable data transfer limit. If enabled, the -DataTransferLimit parameter must be set. By default, data transfer limit is not set. + + Bool + + + DataTransferLimit + + Specify the data transfer limit in MiB/S. + + Int + + + Folder + + Specify the Nimble folder where the volume should be created. To get availabe folder objects, use the Get-OVStoragePool Cmdlet. Folders are defined as a device specific attribute. + +Example: + + (Get-OVStoragePool -name default).DeviceSpecificAttributes.Folders + +ID Name +-- ---- +2f1ca8a5d76e271722000000000000000000000001 POSH + + HPEOneView.Storage.NimbleFolder + + + Scope + + Provide an HPEOneView.Appliance.ScopeCollection resource object to initially associate with. Resource can also be added to scope using the Add-OVResourceToScope Cmdlet. + + HPEOneView.Appliance.ScopeCollection[] + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + + + New-OVStorageVolume + + Name + + Storage Volume Name. Device Volume created on the storage system will be this name without spaces. + + String + + + VolumeTemplate + + Specify the Storage Volume Template Name, URI or Resource. + + Object + + + Description + + Provide a description for the volume. + + String + + + SnapshotStoragePool + + Storage Pool URI, name or resource object. + + Object + + + Capacity + + Max volume capacity in GB. e.g. 20 to specify 20GB. + + Int64 + + + ProvisioningType + + Specify the type of volume to provision. Allowed values are: + + * Thin + * Full + * TPDD (Thin Provision Dedup) - Only available for HPE StoreServ storage systems with SSD storage pools (aka CPG"s). + + String + + + EnableCompression + + Enable compression for StoreServe (3PAR) supported resources. Please verify the InformOS version installed supports Compression. + + Boolean + + + EnableDeduplication + + Enable deduplication for SSD-based Storage Pools (CPG). + + Boolean + + + Full + + NOTE: This parameter is being deprecated for the -ProvisionType parameter. Please update your scripts. + +Include this switch to enable Thick volume provisioning. Omit to specify Thin storage provisioning. +Default: Thin + + SwitchParameter + + + Shared + + Include this switch to mark the Storage Volume as a Shareable resource for shared volume access. +Default: Private + + SwitchParameter + + + PerformancePolicy + + A Nimble Performance Policy is associated with a storage system. Using the Show-OVStorageSystemPerformancePolicy, choose an available performance policy. + +Example: + + Get-OVStorageSystem -Name MyNimbleSys | Show-OVStorageSystemPerformancePolicy + + HPEOneView.Storage.PerformancePolicy + + + EnableEncryption + + When the storage system has encryption enabled, the volume can also be encrypted. Specify if the volume should be encrypted during creation. + + Bool + + + CachePinning + + This is applicable for hybrid (a mix of flash and mechanical storage) arrays, and provides a 100 percent cache hit rate for specific volumes (for example, volumes dedicated to critical applications), and delivers the response times of an all-flash storage system. A volume is pinned when the entire active volume is placed in cache; associated snapshot (inactive) blocks are not pinned. All incoming data after that point is pinned. The number of volumes that can be pinned is limited by the size of the volumes and amount of available cache. + +When defined in the Performance Profile, select to enable Cache Pinnning for the Nimble volume to be created. + + Bool + + + VolumeSet + + Use to specify a Volume Set the volume will be associated with, from Get-OVStorageVolumeSet. + + HPEOneView.Storage.VolumeSet + + + EnableIOPSLimit + + Set to enable or disable IOPS limit. If enabled, the -IOPSLimit parameter must be set. By default, IOPS limit is not set. + + Bool + + + IOPSLimit + + When enabling IOPS limit, provide a value that is greater than or equal to 256. + + Int + + + EnableDataTransferLimit + + Enable data transfer limit. If enabled, the -DataTransferLimit parameter must be set. By default, data transfer limit is not set. + + Bool + + + DataTransferLimit + + Specify the data transfer limit in MiB/S. + + Int + + + Folder + + Specify the Nimble folder where the volume should be created. To get availabe folder objects, use the Get-OVStoragePool Cmdlet. Folders are defined as a device specific attribute. + +Example: + + (Get-OVStoragePool -name default).DeviceSpecificAttributes.Folders + +ID Name +-- ---- +2f1ca8a5d76e271722000000000000000000000001 POSH + + HPEOneView.Storage.NimbleFolder + + + Scope + + Provide an HPEOneView.Appliance.ScopeCollection resource object to initially associate with. Resource can also be added to scope using the Add-OVResourceToScope Cmdlet. + + HPEOneView.Appliance.ScopeCollection[] + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + + + + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + SwitchParameter + + false + + + CachePinning + + This is applicable for hybrid (a mix of flash and mechanical storage) arrays, and provides a 100 percent cache hit rate for specific volumes (for example, volumes dedicated to critical applications), and delivers the response times of an all-flash storage system. A volume is pinned when the entire active volume is placed in cache; associated snapshot (inactive) blocks are not pinned. All incoming data after that point is pinned. The number of volumes that can be pinned is limited by the size of the volumes and amount of available cache. + +When defined in the Performance Profile, select to enable Cache Pinnning for the Nimble volume to be created. + + Bool + + Bool + + + + + Capacity + + Max volume capacity in GB. e.g. 20 to specify 20GB. + + Int64 + + Int64 + + 0 + + + DataTransferLimit + + Specify the data transfer limit in MiB/S. + + Int + + Int + + + + + Description + + Provide a description for the volume. + + String + + String + + + + + EnableCompression + + Enable compression for StoreServe (3PAR) supported resources. Please verify the InformOS version installed supports Compression. + + Boolean + + Boolean + + False + + + EnableDataTransferLimit + + Enable data transfer limit. If enabled, the -DataTransferLimit parameter must be set. By default, data transfer limit is not set. + + Bool + + Bool + + + + + EnableDeduplication + + Enable deduplication for SSD-based Storage Pools (CPG). + + Boolean + + Boolean + + False + + + EnableEncryption + + When the storage system has encryption enabled, the volume can also be encrypted. Specify if the volume should be encrypted during creation. + + Bool + + Bool + + + + + EnableIOPSLimit + + Set to enable or disable IOPS limit. If enabled, the -IOPSLimit parameter must be set. By default, IOPS limit is not set. + + Bool + + Bool + + + + + Folder + + Specify the Nimble folder where the volume should be created. To get availabe folder objects, use the Get-OVStoragePool Cmdlet. Folders are defined as a device specific attribute. + +Example: + + (Get-OVStoragePool -name default).DeviceSpecificAttributes.Folders + +ID Name +-- ---- +2f1ca8a5d76e271722000000000000000000000001 POSH + + HPEOneView.Storage.NimbleFolder + + HPEOneView.Storage.NimbleFolder + + + + + Full + + NOTE: This parameter is being deprecated for the -ProvisionType parameter. Please update your scripts. + +Include this switch to enable Thick volume provisioning. Omit to specify Thin storage provisioning. +Default: Thin + + SwitchParameter + + SwitchParameter + + False + + + IOPSLimit + + When enabling IOPS limit, provide a value that is greater than or equal to 256. + + Int + + Int + + + + + Name + + Storage Volume Name. Device Volume created on the storage system will be this name without spaces. + + String + + String + + + + + PerformancePolicy + + A Nimble Performance Policy is associated with a storage system. Using the Show-OVStorageSystemPerformancePolicy, choose an available performance policy. + +Example: + + Get-OVStorageSystem -Name MyNimbleSys | Show-OVStorageSystemPerformancePolicy + + HPEOneView.Storage.PerformancePolicy + + HPEOneView.Storage.PerformancePolicy + + + + + ProvisioningType + + Specify the type of volume to provision. Allowed values are: + + * Thin + * Full + * TPDD (Thin Provision Dedup) - Only available for HPE StoreServ storage systems with SSD storage pools (aka CPG"s). + + String + + String + + + + + Scope + + Provide an HPEOneView.Appliance.ScopeCollection resource object to initially associate with. Resource can also be added to scope using the Add-OVResourceToScope Cmdlet. + + HPEOneView.Appliance.ScopeCollection[] + + HPEOneView.Appliance.ScopeCollection[] + + False + + + Shared + + Include this switch to mark the Storage Volume as a Shareable resource for shared volume access. +Default: Private + + SwitchParameter + + SwitchParameter + + False + + + SnapshotStoragePool + + Storage Pool URI, name or resource object. + + Object + + Object + + + + + StoragePool + + Storage Pool URI, name or resource object. + + Object + + Object + + + + + StorageSystem + + When the Storage Pool name is not unique, specify the Storage System name the pool is managed/associate with. + + Object + + Object + + + + + VolumeSet + + Use to specify a Volume Set the volume will be associated with, from Get-OVStorageVolumeSet. + + HPEOneView.Storage.VolumeSet + + HPEOneView.Storage.VolumeSet + + + + + VolumeTemplate + + Specify the Storage Volume Template Name, URI or Resource. + + Object + + Object + + + + + + + + + HPEOneView.Storage.Pool [System.Management.Automation.PSCustomObject] + + + Storage Pool resource object + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + Async create task + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + New-OVStorageVolume -name TestVol1 -PoolName PoolR1 -Size 60 + + Create a 60GB private, thin provisioned volume named "TestVol1" from the "PoolR1" Storage Pool. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Get-OVStoragePool PoolR1 | New-OVStorageVolume -name TestVol1 PoolR1 -Size 60 + + Get the "PoolR1" Storage Pool resource and pipe it to create a 60GB private, thin provisioned volume named "TestVol1". + + + + + + + + + + -------------------------- EXAMPLE 3 -------------------------- + + + + Get-OVStoragePool PoolR1 -StorageSystem 3ParSys1 | New-OVStorageVolume -name TestVol1 -Size 60 + + Get the "PoolR1" Storage Pool resource and pipe it to create a 60GB private, thin provisioned volume named "TestVol1". + + + + + + + + + + -------------------------- EXAMPLE 4 -------------------------- + + + + New-OVStorageVolume -name TestVol1 -StoragePool PoolR1 -StorageSystem 3ParSys1 -Size 60 + + Create a 60GB private, thin provisioned volume named "TestVol1" from the "PoolR1" Storage Pool resource that is managed by "3ParSys1". + + + + + + + + + + -------------------------- EXAMPLE 5 -------------------------- + + + + $svt = Get-OVStorageVolumeTemplate SVT_120GB_R5 +$New-OVStorageVolume testvol3 -volumetemplate $svt -capacity 90 | Wait-OVTaskComplete + + Create a 90GB volume named "TestVol1", using the "SVT_120GB_R5" Storage Volume Template, then wait for volume to be provisioned. + + + + + + + + + + + + + Add-OVStorageVolume + + + + ConvertTo-OVStorageVolume + + + + Get-OVStorageVolume + + + + Get-OVStorageVolumeSet + + + + Get-OVStorageVolumeSnapShot + + + + Get-OVStorageVolumeTemplate + + + + Get-OVStorageVolumeTemplatePolicy + + + + New-OVStorageVolumeSnapshot + + + + New-OVStorageVolumeTemplate + + + + Remove-OVStorageVolume + + + + Remove-OVStorageVolumeSnapshot + + + + Remove-OVStorageVolumeTemplate + + + + Set-OVStorageVolume + + + + Set-OVStorageVolumeTemplate + + + + Set-OVStorageVolumeTemplatePolicy + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/storage/new-ovstoragevolume + + + + + + + + New-OVStorageVolumeSnapshot + + Create new Storage Volume Snapshot resource. + + New + OVStorageVolumeSnapshot + + + This Cmdlet will help create a Storage Volume Snapshot from an existing Storage Volume resource. If a Snapshot Storage Pool has not been configured for the Storage Volume, the Snapshot cannot be created. + + + + + New-OVStorageVolumeSnapshot + + InputObject + + Specify the Storage Volume object to create a snapshot for. + + Object + + + Name + + Name of Snapshot. The parameter defaults to "{volumeName}_{timestamp}" variables provided by the appliance. + + String + + + Description + + The description for the Storage Volume Snapshot. + + String + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + +Default Value: ${Global:ConnectSessions} | ? Default + + Object + + + + + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + +Default Value: ${Global:ConnectSessions} | ? Default + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Description + + The description for the Storage Volume Snapshot. + + String + + String + + + + + InputObject + + Specify the Storage Volume object to create a snapshot for. + + Object + + Object + + + + + Name + + Name of Snapshot. The parameter defaults to "{volumeName}_{timestamp}" variables provided by the appliance. + + String + + String + + {volumeName}_{timestamp} + + + + + + + HPEOneView.Storage.Volume [System.Management.Automation.PSCustomObject] + + + Storage volume resource object + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + Async task to create storage volume snapshot + + + + + System.Collections.ArrayList <HPEOneView.Appliance.TaskResource> + + + + Multiple async tasks + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVStorageVolume "Volume 1" -ApplianceConnection hpov.domain.com | New-OVStorageVolumeSnapshot + + Create a new storage volume snapshot using the default values. + + + + + + + + + + + + + Get-OVStorageVolumeSnapShot + + + + Remove-OVStorageVolumeSnapshot + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/storage/new-ovstoragevolumesnapshot + + + + + + + + New-OVStorageVolumeTemplate + + Create storage volume template. + + New + OVStorageVolumeTemplate + + + This Cmdlet supports creating Storage Volume Templates, which are then used to provision Storage Volumes. + + + + + New-OVStorageVolumeTemplate + + Name + + Storage Volume Template name + + String + + + StoragePool + + Specify the Storage Pool (aka CPG) the Storage Volume Template will be associated with. Storage Pool must already be managed by OneView. + + Object + + + Capacity + + Max volume capacity in GB. e.g. 20 to specify 20GB. + + Int64 + + + Description + + Provide the description for the Storage Volume Template + + String + + + LockStoragePool + + Specify to lock the StoragePool value in the template. + + SwitchParameter + + + SnapshotStoragePool + + Specify the Storage Pool (aka CPG) the Storage Volume Template will use for volume snapshot use. The provided Storage Pool must already be managed by OneView. If you omit this value, then the StoragePool parameter value will be used. Only supported with HPE StoreServe platforms. + + Object + + + LockSnapShotStoragePool + + Specify to lock the SnapshotStoragePool value in the template. + + SwitchParameter + + + StorageSystem + + If there are multiple Storage Pool resources with the same name, use this parameter to filter for the correct pool object. + + Object + + + LockCapacity + + Specify to lock the Capacity value in the template. + + SwitchParameter + + + Full + + NOTE: This parameter is being deprecated for the -ProvisionType parameter. Please update your scripts. + +Include this switch to enable Thick volume provisioning. Omit to specify Thin storage provisioning. +Default: Thin + + SwitchParameter + + + ProvisioningType + + Specify the type of volume to provision. Allowed values are: + + * Thin + * Full + * TPDD (Thin Provision Dedup) - Only available for HPE StoreServ storage systems with SSD storage pools (aka CPG"s). + + String + + + LockProvisionType + + Specify to lock the ProvisionType value in the template. + + SwitchParameter + + + EnableDeduplication + + Enable deduplication for SSD-based Storage Pools (CPG). + + Boolean + + + LockEnableDeduplication + + Lock the EnableDeduplication value. + + SwitchParameter + + + EnableCompression + + Enable compression for StoreServe (3PAR) supported resources. Please verify the InformOS version installed supports Compression. + + Boolean + + + LockEnableCompression + + Lock the EnableCompression value. + + SwitchParameter + + + Shared + + Include this switch to mark the Storage Volume Template as a Shareable resource for shared volume access. + + SwitchParameter + + + LockProvisionMode + + Specify to lock the Provision Mode (Shared or Private) value in the template. + + SwitchParameter + + + Scope + + Provide an HPEOneView.Appliance.ScopeCollection resource object to initially associate with. Resource can also be added to scope using the Add-OVResourceToScope Cmdlet. + + HPEOneView.Appliance.ScopeCollection[] + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + + + New-OVStorageVolumeTemplate + + Name + + Storage Volume Template name + + String + + + StoragePool + + Specify the Storage Pool (aka CPG) the Storage Volume Template will be associated with. Storage Pool must already be managed by OneView. + + Object + + + Capacity + + Max volume capacity in GB. e.g. 20 to specify 20GB. + + Int64 + + + PerformancePolicy + + A Nimble Performance Policy is associated with a storage system. Using the Show-OVStorageSystemPerformancePolicy, choose an available performance policy. + +Example: + + Get-OVStorageSystem -Name MyNimbleSys | Show-OVStorageSystemPerformancePolicy + + HPEOneView.Storage.PerformancePolicy + + + Description + + Provide the description for the Storage Volume Template + + String + + + LockStoragePool + + Specify to lock the StoragePool value in the template. + + SwitchParameter + + + LockCapacity + + Specify to lock the Capacity value in the template. + + SwitchParameter + + + ProvisioningType + + Specify the type of volume to provision. Allowed values are: + + * Thin + * Full + * TPDD (Thin Provision Dedup) - Only available for HPE StoreServ storage systems with SSD storage pools (aka CPG"s). + + String + + + LockProvisionType + + Specify to lock the ProvisionType value in the template. + + SwitchParameter + + + Shared + + Include this switch to mark the Storage Volume Template as a Shareable resource for shared volume access. + + SwitchParameter + + + LockProvisionMode + + Specify to lock the Provision Mode (Shared or Private) value in the template. + + SwitchParameter + + + LockPerformancePolicy + + Lock the PerformancePolicy value. + + SwitchParameter + + + EnableEncryption + + When the storage system has encryption enabled, the volume can also be encrypted. Specify if the volume should be encrypted during creation. + + Bool + + + LockEnableEncryption + + Lock the EnableEncryption value. + + SwitchParameter + + + CachePinning + + This is applicable for hybrid (a mix of flash and mechanical storage) arrays, and provides a 100 percent cache hit rate for specific volumes (for example, volumes dedicated to critical applications), and delivers the response times of an all-flash storage system. A volume is pinned when the entire active volume is placed in cache; associated snapshot (inactive) blocks are not pinned. All incoming data after that point is pinned. The number of volumes that can be pinned is limited by the size of the volumes and amount of available cache. + +When defined in the Performance Profile, select to enable Cache Pinnning for the Nimble volume to be created. + + Bool + + + LockCachePinning + + Lock the CachePinning value. + + SwitchParameter + + + VolumeSet + + Use to specify a Volume Set the volume will be associated with, from Get-OVStorageVolumeSet. + + HPEOneView.Storage.VolumeSet + + + LockVolumeSet + + Lock the VolumeSet value. + + SwitchParameter + + + EnableIOPSLimit + + Set to enable or disable IOPS limit. If enabled, the -IOPSLimit parameter must be set. By default, IOPS limit is not set. + + Bool + + + IOPSLimit + + When enabling IOPS limit, provide a value that is greater than or equal to 256. + + Int + + + LockIOPSLimit + + Lock the IOPSLimit value. + + SwitchParameter + + + EnableDataTransferLimit + + Enable data transfer limit. If enabled, the -DataTransferLimit parameter must be set. By default, data transfer limit is not set. + + Bool + + + DataTransferLimit + + Specify the data transfer limit in MiB/S. + + Int + + + LockDataTransferLimit + + Lock the DataTransferLimit value. + + SwitchParameter + + + Folder + + Specify the Nimble folder where the volume should be created. To get availabe folder objects, use the Get-OVStoragePool Cmdlet. Folders are defined as a device specific attribute. + +Example: + + (Get-OVStoragePool -name default).DeviceSpecificAttributes.Folders + +ID Name +-- ---- +2f1ca8a5d76e271722000000000000000000000001 POSH + + HPEOneView.Storage.NimbleFolder + + + LockFolder + + Lock the Folder value. + + SwitchParameter + + + Scope + + Provide an HPEOneView.Appliance.ScopeCollection resource object to initially associate with. Resource can also be added to scope using the Add-OVResourceToScope Cmdlet. + + HPEOneView.Appliance.ScopeCollection[] + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + + + + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + CachePinning + + This is applicable for hybrid (a mix of flash and mechanical storage) arrays, and provides a 100 percent cache hit rate for specific volumes (for example, volumes dedicated to critical applications), and delivers the response times of an all-flash storage system. A volume is pinned when the entire active volume is placed in cache; associated snapshot (inactive) blocks are not pinned. All incoming data after that point is pinned. The number of volumes that can be pinned is limited by the size of the volumes and amount of available cache. + +When defined in the Performance Profile, select to enable Cache Pinnning for the Nimble volume to be created. + + Bool + + Bool + + + + + Capacity + + Max volume capacity in GB. e.g. 20 to specify 20GB. + + Int64 + + Int64 + + 0 + + + DataTransferLimit + + Specify the data transfer limit in MiB/S. + + Int + + Int + + + + + Description + + Provide the description for the Storage Volume Template + + String + + String + + + + + EnableCompression + + Enable compression for StoreServe (3PAR) supported resources. Please verify the InformOS version installed supports Compression. + + Boolean + + Boolean + + False + + + EnableDataTransferLimit + + Enable data transfer limit. If enabled, the -DataTransferLimit parameter must be set. By default, data transfer limit is not set. + + Bool + + Bool + + + + + EnableDeduplication + + Enable deduplication for SSD-based Storage Pools (CPG). + + Boolean + + Boolean + + False + + + EnableEncryption + + When the storage system has encryption enabled, the volume can also be encrypted. Specify if the volume should be encrypted during creation. + + Bool + + Bool + + + + + EnableIOPSLimit + + Set to enable or disable IOPS limit. If enabled, the -IOPSLimit parameter must be set. By default, IOPS limit is not set. + + Bool + + Bool + + + + + Folder + + Specify the Nimble folder where the volume should be created. To get availabe folder objects, use the Get-OVStoragePool Cmdlet. Folders are defined as a device specific attribute. + +Example: + + (Get-OVStoragePool -name default).DeviceSpecificAttributes.Folders + +ID Name +-- ---- +2f1ca8a5d76e271722000000000000000000000001 POSH + + HPEOneView.Storage.NimbleFolder + + HPEOneView.Storage.NimbleFolder + + + + + Full + + NOTE: This parameter is being deprecated for the -ProvisionType parameter. Please update your scripts. + +Include this switch to enable Thick volume provisioning. Omit to specify Thin storage provisioning. +Default: Thin + + SwitchParameter + + SwitchParameter + + False + + + IOPSLimit + + When enabling IOPS limit, provide a value that is greater than or equal to 256. + + Int + + Int + + + + + LockCachePinning + + Lock the CachePinning value. + + SwitchParameter + + SwitchParameter + + + + + LockCapacity + + Specify to lock the Capacity value in the template. + + SwitchParameter + + SwitchParameter + + False + + + LockDataTransferLimit + + Lock the DataTransferLimit value. + + SwitchParameter + + SwitchParameter + + + + + LockEnableCompression + + Lock the EnableCompression value. + + SwitchParameter + + SwitchParameter + + False + + + LockEnableDeduplication + + Lock the EnableDeduplication value. + + SwitchParameter + + SwitchParameter + + False + + + LockEnableEncryption + + Lock the EnableEncryption value. + + SwitchParameter + + SwitchParameter + + + + + LockFolder + + Lock the Folder value. + + SwitchParameter + + SwitchParameter + + + + + LockIOPSLimit + + Lock the IOPSLimit value. + + SwitchParameter + + SwitchParameter + + + + + LockPerformancePolicy + + Lock the PerformancePolicy value. + + SwitchParameter + + SwitchParameter + + + + + LockProvisionMode + + Specify to lock the Provision Mode (Shared or Private) value in the template. + + SwitchParameter + + SwitchParameter + + False + + + LockProvisionType + + Specify to lock the ProvisionType value in the template. + + SwitchParameter + + SwitchParameter + + + + + LockSnapShotStoragePool + + Specify to lock the SnapshotStoragePool value in the template. + + SwitchParameter + + SwitchParameter + + False + + + LockStoragePool + + Specify to lock the StoragePool value in the template. + + SwitchParameter + + SwitchParameter + + False + + + LockVolumeSet + + Lock the VolumeSet value. + + SwitchParameter + + SwitchParameter + + + + + Name + + Storage Volume Template name + + String + + String + + + + + PerformancePolicy + + A Nimble Performance Policy is associated with a storage system. Using the Show-OVStorageSystemPerformancePolicy, choose an available performance policy. + +Example: + + Get-OVStorageSystem -Name MyNimbleSys | Show-OVStorageSystemPerformancePolicy + + HPEOneView.Storage.PerformancePolicy + + HPEOneView.Storage.PerformancePolicy + + + + + ProvisioningType + + Specify the type of volume to provision. Allowed values are: + + * Thin + * Full + * TPDD (Thin Provision Dedup) - Only available for HPE StoreServ storage systems with SSD storage pools (aka CPG"s). + + String + + String + + + + + Scope + + Provide an HPEOneView.Appliance.ScopeCollection resource object to initially associate with. Resource can also be added to scope using the Add-OVResourceToScope Cmdlet. + + HPEOneView.Appliance.ScopeCollection[] + + HPEOneView.Appliance.ScopeCollection[] + + False + + + Shared + + Include this switch to mark the Storage Volume Template as a Shareable resource for shared volume access. + + SwitchParameter + + SwitchParameter + + False + + + SnapshotStoragePool + + Specify the Storage Pool (aka CPG) the Storage Volume Template will use for volume snapshot use. The provided Storage Pool must already be managed by OneView. If you omit this value, then the StoragePool parameter value will be used. Only supported with HPE StoreServe platforms. + + Object + + Object + + + + + StoragePool + + Specify the Storage Pool (aka CPG) the Storage Volume Template will be associated with. Storage Pool must already be managed by OneView. + + Object + + Object + + + + + StorageSystem + + If there are multiple Storage Pool resources with the same name, use this parameter to filter for the correct pool object. + + Object + + Object + + + + + VolumeSet + + Use to specify a Volume Set the volume will be associated with, from Get-OVStorageVolumeSet. + + HPEOneView.Storage.VolumeSet + + HPEOneView.Storage.VolumeSet + + + + + + + + + HPEOneView.Storage.System.Pool [System.Management.Automation.PSCustomObject] + + + Managed Storage Pool resource + + + + + + + + System.Management.Automation.PSCustomObject + + + + Created Storage Volume Template resource + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + New-OVStorageVolumeTemplate -templateName yellow-svt -storagePool yellow -capacity 40 + + Create a new Storage Volume Template, setting the max size to 40GB, Thin Provisioning and Private. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + $storageVolTemplate = New-OVStorageVolumeTemplate -templateName vmware-shared-svt -storagePool R5-CPG12 -capacity 250 -shared + + Create a new Storage Volume Template, setting the max size to 250GB, Thin Provisioning and Shareable. + + + + + + + + + + -------------------------- EXAMPLE 3 -------------------------- + + + + $storagePool = Get-OVStoragePool R5-CPG12 +$storageVolTemplate = New-OVStorageVolumeTemplate -templateName vmware-shared-svt -storagePool $storagePool -capacity 250 -shared + + Use the Get-OVStoragePool Cmdlet to get the "R5-CPG12" pool, and create a new Storage Volume Template, setting the max size to 250GB, Thin Provisioning and Shareable. + + + + + + + + + + -------------------------- EXAMPLE 4 -------------------------- + + + + $svt = Get-OVStoragePool R5-CPG12 | New-OVStorageVolumeTemplate -templateName vmware-shared-svt -SnapshotStoragePool "MySnapShotPool" -capacity 250 -shared + + Use the Get-OVStoragePool Cmdlet to get the "R5-CPG12" pool, and create a new Storage Volume Template, setting the max size to 250GB, Thin Provisioning, Shareable, and providing the Snapshot Storage Pool. + + + + + + + + + + + + + Get-OVStorageVolumeTemplate + + + + Get-OVStorageVolumeTemplatePolicy + + + + Remove-OVStorageVolumeTemplate + + + + Set-OVStorageVolumeTemplate + + + + Set-OVStorageVolumeTemplatePolicy + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/storage/new-ovstoragevolumetemplate + + + + + + + + New-OVSupportDump + + Generate and download Support Dumps. + + New + OVSupportDump + + + The support dump contains data that might be considered customer sensitive such as hostnames, IP addresses, and the appliance audit log. Unless you specify otherwise, all data in the support dump file is encrypted so that only an authorized technical support person can access it. + +You can choose not to encrypt the support dump file if you are an Infrastructure administrator. This option can be useful if you have an onsite, authorized technical support person or if your environment prohibits outside connections. You can also validate the contents of the support dump file and verify that it does not contain data considered sensitive in your environment. + +Use the `-Advanced` parameter to customize the selection of support dump logs while creating the support dump. Customizing the selection of support dump logs reduces the size of the collection and as a result enables faster creation and download of the collection. + +NOTE: Hewlett Packard Enterprise recommends that you customize the selection of the support dump logs with the help of an authorized technical support representative. + +Some error messages recommend that you create a support dump of the HPE Synergy Composer and send it to authorized technical support for analysis. The support dump process performs the following functions: + + * Deletes any previous support dump file + * Gathers logs and other information required for debugging + * Creates a compressed file with a name in the following format: + + hostname-identifiertimestamp.sdmp + + Where, for support dump files created from the UI, identifier is either CI (indicating an appliance support dump) or LE (indicating a logical enclosure support dump). + +IMPORTANT: If the appliance is in an error state, a special Appliance error screen is displayed. Anyone can create an encrypted support dump file from that screen without the need for logging in or other authentication. + + * Creating the support dump file will remove the backup file that exists on the HPE Synergy Composer. Move the backup file to an external location before proceeding. + +The support dump file contains the following: + + * Operating system logs + * Product logs + * The results of certain operating system and product-related commands + +Items logged in the support dump file are recorded according to UTC time. + +Minimum required privileges: Network administrator, Server administrator, Infrastructure administrator, Backup administrator, Read only + +NOTE: Only the Infrastructure administrator has the option of not encrypting a support dump file. When a user with a different role creates a support dump file, it is encrypted automatically. + + + + + New-OVSupportDump + + Type + + The type of Support Dump to collect. Possible values are: + +1. Appliance +2. LogicalEnclosure + + String + + + Path + + The full path to where the Support Dump will be saved to. The downloaded file name will be generated by the appliance. If the directory does not exist, it will be created. + + String + + + Encrypted + + Use this parameter for the appliance to encrypt the Support Dump. Only HPE Support representatives can decrypt the contents. + + SwitchParameter + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Array + + + + New-OVSupportDump + + Type + + The type of Support Dump to collect. Possible values are: + +1. Appliance +2. LogicalEnclosure + + String + + + InputObject + + When the support dump type is LogicalEnclosure, the logical enclosure resource must be passed from Get-OVLogicalEnclosure as a parameter value or pipeline. + + Object + + + Path + + The full path to where the Support Dump will be saved to. The downloaded file name will be generated by the appliance. If the directory does not exist, it will be created. + + String + + + ExcludeApplianceSupportDump + + Use this parameter to exclude the appliance support dump when creating a logical enclosure support dump. This reduces the time and size of the support dump. + + SwitchParameter + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Array + + + + New-OVSupportDump + + Type + + The type of Support Dump to collect. Possible values are: + +1. Appliance +2. LogicalEnclosure + + String + + + Path + + The full path to where the Support Dump will be saved to. The downloaded file name will be generated by the appliance. If the directory does not exist, it will be created. + + String + + + AdvancedSupportDump + + [To be used by the direction of HPE Support] Use to indicate certain log files are going to be requested (others not specified are excluded), resulting in a smaller support dump. This cannot be combined with a Logical Enclosure support dump. + + SwitchParameter + + + CiDebugLogs + + [To be used by the direction of HPE Support] Use to include internal debug log files. + + SwitchParameter + + + CiRequestLogs + + [To be used by the direction of HPE Support] Use to include requests log files. + + SwitchParameter + + + JettyLogs + + [To be used by the direction of HPE Support] Use to include internal jetty servlet log files. + + SwitchParameter + + + ApacheLogs + + [To be used by the direction of HPE Support] Use to include Apache internal log files. + + SwitchParameter + + + AHSLogsForComposer + + [To be used by the direction of HPE Support] Select to include the HPE Synergy Composer AHS logs. + + SwitchParameter + + + AlertLogs + + [To be used by the direction of HPE Support] Use to include internal alert logs files. + + SwitchParameter + + + CiDbLogs + + [To be used by the direction of HPE Support] Use to include internal appliance database log files. + + SwitchParameter + + + FLMLogs + + [To be used by the direction of HPE Support] Use to include HPE Synergy Frame Link Module (FLM) log files. + + SwitchParameter + + + LicenseManagerLogs + + [To be used by the direction of HPE Support] Use to include internal license manager log files. + + SwitchParameter + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Array + + + + + + + AHSLogsForComposer + + [To be used by the direction of HPE Support] Select to include the HPE Synergy Composer AHS logs. + + SwitchParameter + + SwitchParameter + + + + + AdvancedSupportDump + + [To be used by the direction of HPE Support] Use to indicate certain log files are going to be requested (others not specified are excluded), resulting in a smaller support dump. This cannot be combined with a Logical Enclosure support dump. + + SwitchParameter + + SwitchParameter + + + + + AlertLogs + + [To be used by the direction of HPE Support] Use to include internal alert logs files. + + SwitchParameter + + SwitchParameter + + + + + ApacheLogs + + [To be used by the direction of HPE Support] Use to include Apache internal log files. + + SwitchParameter + + SwitchParameter + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Array + + Array + + (${Global:ConnectedSessions} | ? Default) + + + CiDbLogs + + [To be used by the direction of HPE Support] Use to include internal appliance database log files. + + SwitchParameter + + SwitchParameter + + + + + CiDebugLogs + + [To be used by the direction of HPE Support] Use to include internal debug log files. + + SwitchParameter + + SwitchParameter + + + + + CiRequestLogs + + [To be used by the direction of HPE Support] Use to include requests log files. + + SwitchParameter + + SwitchParameter + + + + + Encrypted + + Use this parameter for the appliance to encrypt the Support Dump. Only HPE Support representatives can decrypt the contents. + + SwitchParameter + + SwitchParameter + + False + + + ExcludeApplianceSupportDump + + Use this parameter to exclude the appliance support dump when creating a logical enclosure support dump. This reduces the time and size of the support dump. + + SwitchParameter + + SwitchParameter + + + + + FLMLogs + + [To be used by the direction of HPE Support] Use to include HPE Synergy Frame Link Module (FLM) log files. + + SwitchParameter + + SwitchParameter + + + + + InputObject + + When the support dump type is LogicalEnclosure, the logical enclosure resource must be passed from Get-OVLogicalEnclosure as a parameter value or pipeline. + + Object + + Object + + + + + JettyLogs + + [To be used by the direction of HPE Support] Use to include internal jetty servlet log files. + + SwitchParameter + + SwitchParameter + + + + + LicenseManagerLogs + + [To be used by the direction of HPE Support] Use to include internal license manager log files. + + SwitchParameter + + SwitchParameter + + + + + Path + + The full path to where the Support Dump will be saved to. The downloaded file name will be generated by the appliance. If the directory does not exist, it will be created. + + String + + String + + (get-location).Path + + + Type + + The type of Support Dump to collect. Possible values are: + +1. Appliance +2. LogicalEnclosure + + String + + String + + + + + + + + + Accepts pipeline input from Get-OVLogicalEnclosure only. + + + + + + + + + + + The generated Support Dump File + + + + + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + New-OVSupportDump -Path C:\Temp -Type Appliance + + This command will create and save the Appliance support dump to C:\Temp. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + New-OVSupportDump -Path C:\Temp -Type Appliance -Advanced -CiDebugLogs -AlertLogs + + This command will create and save the appliance support dump to C:\Temp, choosing specific log files requested by HPE Support. + + + + + + + + + + -------------------------- EXAMPLE 3 -------------------------- + + + + $MyLogicalEnclosure = Get-OVLogicalEnclosure -Name MyLogicalEnclosure1 + +New-OVSupportDump -Path C:\Temp -Type LogicalEnclosure -InputObject $MyLogicalEnclosure + + This command will create and save the logical enclosure support dump to C:\Temp. + + + + + + + + + + -------------------------- EXAMPLE 4 -------------------------- + + + + Get-OVLogicalEnclosure -Name MyLogicalEnclosure1 | New-OVSupportDump -Path C:\Temp -Type LogicalEnclosure -ExcludeApplianceSupportDump + + This command will create and save the logical enclosure support dump to C:\Temp, excluding the appliance support dump. + + + + + + + + + + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/new-ovsupportdump + + + + + + + + New-OVUnmanagedDevice + + Create an Unmanaged Device. + + New + OVUnmanagedDevice + + + HPE OneView provides administrators with the capability to define unmanaged devices to them place within Racks, in order to provide a more realistic and complete data center layout. Creating a device does not provide the ability to manage it from HPE OneView. The administrator will need to specify static characteristics of the device being added. The unmanaged device can then be assigned into the appropriate rack manually. + + + + + New-OVUnmanagedDevice + + Name + + The name of the Unmanaged Device. + + String + + + Model + + The device model. + + String + + + MaxPower + + The maximum power consumption of the Unmanaged Device. + + Int32 + + + Height + + Rack Unit height of the Unmanaged Device. + + Int32 + + + MacAddress + + Provide the management interface L2 address. + + String + + + IPv4Address + + Provide the IPv4 Address value of the management interface. This value does not provide a method for an HPE OneView appliance to communicate with the management interface. + + String + + + IPv6Address + + Provide the IPv6 Address value of the management interface. This value does not provide a method for an HPE OneView appliance to communicate with the management interface. + + String + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. + + Object + + + + + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Height + + Rack Unit height of the Unmanaged Device. + + Int32 + + Int32 + + 1 + + + IPv4Address + + Provide the IPv4 Address value of the management interface. This value does not provide a method for an HPE OneView appliance to communicate with the management interface. + + String + + String + + + + + IPv6Address + + Provide the IPv6 Address value of the management interface. This value does not provide a method for an HPE OneView appliance to communicate with the management interface. + + String + + String + + + + + MacAddress + + Provide the management interface L2 address. + + String + + String + + + + + MaxPower + + The maximum power consumption of the Unmanaged Device. + + Int32 + + Int32 + + 0 + + + Model + + The device model. + + String + + String + + + + + Name + + The name of the Unmanaged Device. + + String + + String + + + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + None. You cannot pipe objects to this Cmdlet + + + + + + + + HPEOneView.UnmanagedResource [System.Management.Automation.PSCustomObject] + + + + Newly created Unmanaged Device resource + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + New-OVUnmanagedDevice -name "Unmanaged-SRVR1" -model "ProLiant DL380 G6" -height 2 -maxpower 750 -IPv4Address 10.154.1.10 + + Create a new unmanaged server device. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + New-OVUnmanagedDevice -name "HPN5900CP1" -model "HPN 5900CP" -height 1 -maxpower 260 -IPv4Address 172.18.254.99 "MyAppliance.domain.com" + + Create a new unmanaged switch device. + + + + + + + + + + + + + Get-OVUnmanagedDevice + + + + Remove-OVUnmanagedDevice + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/facilities/new-ovunmanageddevice + + + + + + + + New-OVUplinkSet + + Create a new Uplink Set. + + New + OVUplinkSet + + + Interconnect uplinks are grouped into an uplink set and managed as a unit, with an assigned set of one or more networks. The traffic carried over the uplinks is determined by the network assignment of the uplink set. Uplink sets can support either Ethernet or Fibre Channel networks. Depending on the type of the assigned networks, uplink sets can support both an automatic and a selective failover or distribution strategy. The uplink port state is monitored, which contributes to the overall reachability status of the assigned networks. For each port belonging to the uplink set, the assigned port speed can be monitored. + +Uplink Sets can be created for Logical Interconnect Groups or Logical Interconnects. When creating a new Uplink Set, either the Logical Interconnect Group or Logical Interconnect must exist. + +Please know that the UplinkPorts parameter syntax is different between HPE BladeSystem and HPE Synergy Virtual Connect. + +Minimum required privileges: Infrastructure administrator, Network administrator + + + + + New-OVUplinkSet + + InputObject + + Either a Logical Interconnect Group (Get-OVLogicalInterconnectGroup) or Logical Interconnect (Get-OVLogicalInterconnect) resource object. + + Object + + + Name + + Logical Uplink set Name + + String + + + Type + + Uplink set Type. Accepted values are + + * Ethernet (Default) + * FibreChannel + * Tunnel + * Untagged + * ImageStreamer + +ImageStreamer is only supported with Synergy infrastructure. When assigning an Ethernet Network to an ImageStreamer Uplink Set, the network resource must be a Tagged Ethernet Network. + + String + + + Networks + + Array of Ethernet Network Names + + Array + + + NativeEthNetwork + + The valid name of the Native Ethernet Network that is a member of the usNetworks parameter. + + Object + + + NetworkSets + + Use this to specify one or more network sets to track the network configuration. + + array + + + CopyNetworksFromNetworkSet + + When specifying the -NetworkSets parameter, you can choose to copy the networks from the associated set(s) only. This will not set the Uplink Set to track the network set(s). + + SwitchParameter + + + UplinkPorts + + Array of uplink ports with "BAYID:FacePlatePortID". When configuring a Synergy infrastructure, the Uplink Port format needs to be "EnclosureID:BayID:FacePlatePortID". + +FlexFabric e.g. @("BAY1:X1","BAY1:X2") or "BAY1:X5","BAY2:X5" +VC Fibre Channel e.g. @("BAY3:1","BAY3:2") or "BAY3:1","BAY3:2" +Synergy VC Ethernet e.g. "Enclosure1:Bay3:Q1","Enclosure1:Bay3:Q2","Enclosure2:Bay6:Q1","Enclosure2:Bay6:Q2" +Synergy VC Sub-Interface e.g. "Enclosure1:Bay3:Q1.1","Enclosure1:Bay3:Q2.1","Enclosure2:Bay6:Q1.2","Enclosure2:Bay6:Q2.2" +Synergy VC FC Primary Port e.g. "Bay2:Q1","Bay2:Q2" or "Bay5:Q1","Bay5:Q2" +Synergy VC FC Sub-Interface e.g. "Bay2:Q1.1","Bay2:Q2.1" or "Bay5:Q1.2","Bay5:Q2.2" + + Array + + + EthMode + + Sets the LACP mode on the uplink ports. Valid for ETHERNET Uplinks only. Accepted Values: + + * Auto (Default) + * Failover + + String + + + LacpTimer + + Set the LACP Timer value, which sets the lacpdu frequecy to the LACP peer. Accepted values: + + * Long + * Short (Default) + + String + + + LacpLoadbalancingMode + + When configuring Synergy Virtual Connect uplink sets, the LACP load balancing algorithm can be modified. + + String + + + LacpFailoverTrigger + + LACP failover trigger is only applicable to the Ethernet uplink sets in the active-standby configuration when there is no link aggregation configured on the top-of-rack (ToR) switches or an uplink set is configured without MLAG. In this case, all traffic to the compute modules will pass through the active set of uplink ports. Link failover trigger defines failover policy for when traffic will be redirected to the standby uplink ports. In case of failover trigger based on bandwidth/uplink count, link failover can be triggered either by reduction in active uplink bandwidth or increase in standby uplink bandwidth. + +Allowed values: + + * AllActiveUplinksOffline + * FailoverActiveMemberThreshold + * FailoverBandwidthThreshold + + String + + + LacpDistributeUplinkPorts + + The distribution of LACP uplink ports is supported on HPE Virtual Connect SE 40Gb F8 Module for HPE Synergy and HPE Virtual Connect SE 100Gb F32 Module for HPE Synergy interconnects. + +When the LacpDistributeUplinkPorts parameter is used, the active and standby uplink ports are distributed across the stacked interconnects within the logical interconnect. The distribution of active ports occurs when the number of uplink ports is more than 16 in an uplink set. + +LACP distribute uplink ports is applicable for Ethernet networks. This option is enabled by default for new uplink sets. + +NOTE: The port distribution depends on the number of ports added from each interconnect module. Please see the HPE OneView Online Help for more details on uplink port distribution. + + Bool + + + LacpFailoverBandwidthThreshold + + Use to specify a value of 1 through 100 % (percent), when the -LacpFailoverTrigger parameter is set to 'FailoverBandwidthThreshold'. + +WARNING: Failover from active to standby uplinks will cause a brief interruption in the network and storage connectivity. + + Int + + + LacpFailoverActiveMemberThreshold + + Use to specify a value of 1 through 16, when the -LacpFailoverTrigger parameter is set to 'FailoverActiveMemberThreshold'. + +WARNING: Failover from active to standby uplinks will cause a brief interruption in the network and storage connectivity. + + Int + + + PrimaryPort + + Specify the Primary Uplink Port when EthMode is set to Failover. Parameter is not valid when EthMode parameter is set to Auto. + +Example: "Bay1:X1" + + String + + + DCBXOverride + + Use to override the DCBx protocol version. Use the RoCEVersion parameter to specify which RoCE version should be used. + + bool + + + RoCEVersion + + Specify which RoCE version should be used. + + String[] + + + ConsistencyChecking + + Use to indicate if the group policy will be tracked to with the deployed and configured resource. Allowed values: + + * None + * Exact + +Default: Exact + + String + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + + + New-OVUplinkSet + + Name + + Logical Uplink set Name + + String + + + Type + + Uplink set Type. Accepted values are + + * Ethernet (Default) + * FibreChannel + * Tunnel + * Untagged + * ImageStreamer + +ImageStreamer is only supported with Synergy infrastructure. When assigning an Ethernet Network to an ImageStreamer Uplink Set, the network resource must be a Tagged Ethernet Network. + + String + + + Passthru + + Use this parameter to return a helper object with the New-OVLogicalInterconnectGroup -UplinkSet parameter. + + SwitchParameter + + + InputObject + + Either a Logical Interconnect Group (Get-OVLogicalInterconnectGroup) or Logical Interconnect (Get-OVLogicalInterconnect) resource object. + + Object + + + Networks + + Array of Ethernet Network Names + + Array + + + NativeEthNetwork + + The valid name of the Native Ethernet Network that is a member of the usNetworks parameter. + + Object + + + NetworkSets + + Use this to specify one or more network sets to track the network configuration. + + array + + + CopyNetworksFromNetworkSet + + When specifying the -NetworkSets parameter, you can choose to copy the networks from the associated set(s) only. This will not set the Uplink Set to track the network set(s). + + SwitchParameter + + + UplinkPorts + + Array of uplink ports with "BAYID:FacePlatePortID". When configuring a Synergy infrastructure, the Uplink Port format needs to be "EnclosureID:BayID:FacePlatePortID". + +FlexFabric e.g. @("BAY1:X1","BAY1:X2") or "BAY1:X5","BAY2:X5" +VC Fibre Channel e.g. @("BAY3:1","BAY3:2") or "BAY3:1","BAY3:2" +Synergy VC Ethernet e.g. "Enclosure1:Bay3:Q1","Enclosure1:Bay3:Q2","Enclosure2:Bay6:Q1","Enclosure2:Bay6:Q2" +Synergy VC Sub-Interface e.g. "Enclosure1:Bay3:Q1.1","Enclosure1:Bay3:Q2.1","Enclosure2:Bay6:Q1.2","Enclosure2:Bay6:Q2.2" +Synergy VC FC Primary Port e.g. "Bay2:Q1","Bay2:Q2" or "Bay5:Q1","Bay5:Q2" +Synergy VC FC Sub-Interface e.g. "Bay2:Q1.1","Bay2:Q2.1" or "Bay5:Q1.2","Bay5:Q2.2" + + Array + + + EthMode + + Sets the LACP mode on the uplink ports. Valid for ETHERNET Uplinks only. Accepted Values: + + * Auto (Default) + * Failover + + String + + + LacpTimer + + Set the LACP Timer value, which sets the lacpdu frequecy to the LACP peer. Accepted values: + + * Long + * Short (Default) + + String + + + LacpLoadbalancingMode + + When configuring Synergy Virtual Connect uplink sets, the LACP load balancing algorithm can be modified. + + String + + + LacpFailoverTrigger + + LACP failover trigger is only applicable to the Ethernet uplink sets in the active-standby configuration when there is no link aggregation configured on the top-of-rack (ToR) switches or an uplink set is configured without MLAG. In this case, all traffic to the compute modules will pass through the active set of uplink ports. Link failover trigger defines failover policy for when traffic will be redirected to the standby uplink ports. In case of failover trigger based on bandwidth/uplink count, link failover can be triggered either by reduction in active uplink bandwidth or increase in standby uplink bandwidth. + +Allowed values: + + * AllActiveUplinksOffline + * FailoverActiveMemberThreshold + * FailoverBandwidthThreshold + + String + + + LacpDistributeUplinkPorts + + The distribution of LACP uplink ports is supported on HPE Virtual Connect SE 40Gb F8 Module for HPE Synergy and HPE Virtual Connect SE 100Gb F32 Module for HPE Synergy interconnects. + +When the LacpDistributeUplinkPorts parameter is used, the active and standby uplink ports are distributed across the stacked interconnects within the logical interconnect. The distribution of active ports occurs when the number of uplink ports is more than 16 in an uplink set. + +LACP distribute uplink ports is applicable for Ethernet networks. This option is enabled by default for new uplink sets. + +NOTE: The port distribution depends on the number of ports added from each interconnect module. Please see the HPE OneView Online Help for more details on uplink port distribution. + + Bool + + + LacpFailoverBandwidthThreshold + + Use to specify a value of 1 through 100 % (percent), when the -LacpFailoverTrigger parameter is set to 'FailoverBandwidthThreshold'. + +WARNING: Failover from active to standby uplinks will cause a brief interruption in the network and storage connectivity. + + Int + + + LacpFailoverActiveMemberThreshold + + Use to specify a value of 1 through 16, when the -LacpFailoverTrigger parameter is set to 'FailoverActiveMemberThreshold'. + +WARNING: Failover from active to standby uplinks will cause a brief interruption in the network and storage connectivity. + + Int + + + PrimaryPort + + Specify the Primary Uplink Port when EthMode is set to Failover. Parameter is not valid when EthMode parameter is set to Auto. + +Example: "Bay1:X1" + + String + + + DCBXOverride + + Use to override the DCBx protocol version. Use the RoCEVersion parameter to specify which RoCE version should be used. + + bool + + + RoCEVersion + + Specify which RoCE version should be used. + + String[] + + + PortSpeed + + The allowed uplink port speed by the fabric module and traceiver type. When specifying a port speed, this value will be set for all ports. This parameter applies to Ethernet or FCoE uplink ports only. Allowed values: + + * Auto + * 100M + * 1G + * 10G + * 40G + * 100G + + String + + + FecMode + + Specify the forward error correction mode. This paraemter is only supported with Virtual Connect SE 100Gb F32 Module for Synergy modules. When configuring, the following values are supported with parent ports: + + * Auto + * Cl74 + * Cl108 + * None + +The following values are supported with sub-ports: + + * Auto + * Cl74 + * Cl91 + * None + + String + + + FcUplinkSpeed + + Specify the Fibre Channel Uplink Port speed. Accepted values: + + * Auto (Default) + * 2 + * 4 + * 8 + + String + + + EnableTrunking + + Use this parameter to enable FC port trunking. This parameter is only supported with HPE 16Gb or newer Virtual Connect Fibre Channel fabric modules. + + Boolean + + + ConsistencyChecking + + Use to indicate if the group policy will be tracked to with the deployed and configured resource. Allowed values: + + * None + * Exact + +Default: Exact + + String + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + + + New-OVUplinkSet + + InputObject + + Either a Logical Interconnect Group (Get-OVLogicalInterconnectGroup) or Logical Interconnect (Get-OVLogicalInterconnect) resource object. + + Object + + + Name + + Logical Uplink set Name + + String + + + Type + + Uplink set Type. Accepted values are + + * Ethernet (Default) + * FibreChannel + * Tunnel + * Untagged + * ImageStreamer + +ImageStreamer is only supported with Synergy infrastructure. When assigning an Ethernet Network to an ImageStreamer Uplink Set, the network resource must be a Tagged Ethernet Network. + + String + + + Networks + + Array of Ethernet Network Names + + Array + + + UplinkPorts + + Array of uplink ports with "BAYID:FacePlatePortID". When configuring a Synergy infrastructure, the Uplink Port format needs to be "EnclosureID:BayID:FacePlatePortID". + +FlexFabric e.g. @("BAY1:X1","BAY1:X2") or "BAY1:X5","BAY2:X5" +VC Fibre Channel e.g. @("BAY3:1","BAY3:2") or "BAY3:1","BAY3:2" +Synergy VC Ethernet e.g. "Enclosure1:Bay3:Q1","Enclosure1:Bay3:Q2","Enclosure2:Bay6:Q1","Enclosure2:Bay6:Q2" +Synergy VC Sub-Interface e.g. "Enclosure1:Bay3:Q1.1","Enclosure1:Bay3:Q2.1","Enclosure2:Bay6:Q1.2","Enclosure2:Bay6:Q2.2" +Synergy VC FC Primary Port e.g. "Bay2:Q1","Bay2:Q2" or "Bay5:Q1","Bay5:Q2" +Synergy VC FC Sub-Interface e.g. "Bay2:Q1.1","Bay2:Q2.1" or "Bay5:Q1.2","Bay5:Q2.2" + + Array + + + PortSpeed + + The allowed uplink port speed by the fabric module and traceiver type. When specifying a port speed, this value will be set for all ports. This parameter applies to Ethernet or FCoE uplink ports only. Allowed values: + + * Auto + * 100M + * 1G + * 10G + * 40G + * 100G + + String + + + FecMode + + Specify the forward error correction mode. This paraemter is only supported with Virtual Connect SE 100Gb F32 Module for Synergy modules. When configuring, the following values are supported with parent ports: + + * Auto + * Cl74 + * Cl108 + * None + +The following values are supported with sub-ports: + + * Auto + * Cl74 + * Cl91 + * None + + String + + + FcUplinkSpeed + + Specify the Fibre Channel Uplink Port speed. Accepted values: + + * Auto (Default) + * 2 + * 4 + * 8 + + String + + + EnableTrunking + + Use this parameter to enable FC port trunking. This parameter is only supported with HPE 16Gb or newer Virtual Connect Fibre Channel fabric modules. + + Boolean + + + ConsistencyChecking + + Use to indicate if the group policy will be tracked to with the deployed and configured resource. Allowed values: + + * None + * Exact + +Default: Exact + + String + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + SwitchParameter + + false + + + ConsistencyChecking + + Use to indicate if the group policy will be tracked to with the deployed and configured resource. Allowed values: + + * None + * Exact + +Default: Exact + + String + + String + + + + + CopyNetworksFromNetworkSet + + When specifying the -NetworkSets parameter, you can choose to copy the networks from the associated set(s) only. This will not set the Uplink Set to track the network set(s). + + SwitchParameter + + SwitchParameter + + + + + DCBXOverride + + Use to override the DCBx protocol version. Use the RoCEVersion parameter to specify which RoCE version should be used. + + bool + + bool + + + + + EnableTrunking + + Use this parameter to enable FC port trunking. This parameter is only supported with HPE 16Gb or newer Virtual Connect Fibre Channel fabric modules. + + Boolean + + Boolean + + false + + + EthMode + + Sets the LACP mode on the uplink ports. Valid for ETHERNET Uplinks only. Accepted Values: + + * Auto (Default) + * Failover + + String + + String + + Auto + + + FcUplinkSpeed + + Specify the Fibre Channel Uplink Port speed. Accepted values: + + * Auto (Default) + * 2 + * 4 + * 8 + + String + + String + + Auto + + + FecMode + + Specify the forward error correction mode. This paraemter is only supported with Virtual Connect SE 100Gb F32 Module for Synergy modules. When configuring, the following values are supported with parent ports: + + * Auto + * Cl74 + * Cl108 + * None + +The following values are supported with sub-ports: + + * Auto + * Cl74 + * Cl91 + * None + + String + + String + + + + + InputObject + + Either a Logical Interconnect Group (Get-OVLogicalInterconnectGroup) or Logical Interconnect (Get-OVLogicalInterconnect) resource object. + + Object + + Object + + + + + LacpDistributeUplinkPorts + + The distribution of LACP uplink ports is supported on HPE Virtual Connect SE 40Gb F8 Module for HPE Synergy and HPE Virtual Connect SE 100Gb F32 Module for HPE Synergy interconnects. + +When the LacpDistributeUplinkPorts parameter is used, the active and standby uplink ports are distributed across the stacked interconnects within the logical interconnect. The distribution of active ports occurs when the number of uplink ports is more than 16 in an uplink set. + +LACP distribute uplink ports is applicable for Ethernet networks. This option is enabled by default for new uplink sets. + +NOTE: The port distribution depends on the number of ports added from each interconnect module. Please see the HPE OneView Online Help for more details on uplink port distribution. + + Bool + + Bool + + + + + LacpFailoverActiveMemberThreshold + + Use to specify a value of 1 through 16, when the -LacpFailoverTrigger parameter is set to 'FailoverActiveMemberThreshold'. + +WARNING: Failover from active to standby uplinks will cause a brief interruption in the network and storage connectivity. + + Int + + Int + + + + + LacpFailoverBandwidthThreshold + + Use to specify a value of 1 through 100 % (percent), when the -LacpFailoverTrigger parameter is set to 'FailoverBandwidthThreshold'. + +WARNING: Failover from active to standby uplinks will cause a brief interruption in the network and storage connectivity. + + Int + + Int + + + + + LacpFailoverTrigger + + LACP failover trigger is only applicable to the Ethernet uplink sets in the active-standby configuration when there is no link aggregation configured on the top-of-rack (ToR) switches or an uplink set is configured without MLAG. In this case, all traffic to the compute modules will pass through the active set of uplink ports. Link failover trigger defines failover policy for when traffic will be redirected to the standby uplink ports. In case of failover trigger based on bandwidth/uplink count, link failover can be triggered either by reduction in active uplink bandwidth or increase in standby uplink bandwidth. + +Allowed values: + + * AllActiveUplinksOffline + * FailoverActiveMemberThreshold + * FailoverBandwidthThreshold + + String + + String + + + + + LacpLoadbalancingMode + + When configuring Synergy Virtual Connect uplink sets, the LACP load balancing algorithm can be modified. + + String + + String + + + + + LacpTimer + + Set the LACP Timer value, which sets the lacpdu frequecy to the LACP peer. Accepted values: + + * Long + * Short (Default) + + String + + String + + Short + + + Name + + Logical Uplink set Name + + String + + String + + + + + NativeEthNetwork + + The valid name of the Native Ethernet Network that is a member of the usNetworks parameter. + + Object + + Object + + + + + NetworkSets + + Use this to specify one or more network sets to track the network configuration. + + array + + array + + + + + Networks + + Array of Ethernet Network Names + + Array + + Array + + @() + + + Passthru + + Use this parameter to return a helper object with the New-OVLogicalInterconnectGroup -UplinkSet parameter. + + SwitchParameter + + SwitchParameter + + + + + PortSpeed + + The allowed uplink port speed by the fabric module and traceiver type. When specifying a port speed, this value will be set for all ports. This parameter applies to Ethernet or FCoE uplink ports only. Allowed values: + + * Auto + * 100M + * 1G + * 10G + * 40G + * 100G + + String + + String + + + + + PrimaryPort + + Specify the Primary Uplink Port when EthMode is set to Failover. Parameter is not valid when EthMode parameter is set to Auto. + +Example: "Bay1:X1" + + String + + String + + + + + RoCEVersion + + Specify which RoCE version should be used. + + String[] + + String[] + + + + + Type + + Uplink set Type. Accepted values are + + * Ethernet (Default) + * FibreChannel + * Tunnel + * Untagged + * ImageStreamer + +ImageStreamer is only supported with Synergy infrastructure. When assigning an Ethernet Network to an ImageStreamer Uplink Set, the network resource must be a Tagged Ethernet Network. + + String + + String + + + + + UplinkPorts + + Array of uplink ports with "BAYID:FacePlatePortID". When configuring a Synergy infrastructure, the Uplink Port format needs to be "EnclosureID:BayID:FacePlatePortID". + +FlexFabric e.g. @("BAY1:X1","BAY1:X2") or "BAY1:X5","BAY2:X5" +VC Fibre Channel e.g. @("BAY3:1","BAY3:2") or "BAY3:1","BAY3:2" +Synergy VC Ethernet e.g. "Enclosure1:Bay3:Q1","Enclosure1:Bay3:Q2","Enclosure2:Bay6:Q1","Enclosure2:Bay6:Q2" +Synergy VC Sub-Interface e.g. "Enclosure1:Bay3:Q1.1","Enclosure1:Bay3:Q2.1","Enclosure2:Bay6:Q1.2","Enclosure2:Bay6:Q2.2" +Synergy VC FC Primary Port e.g. "Bay2:Q1","Bay2:Q2" or "Bay5:Q1","Bay5:Q2" +Synergy VC FC Sub-Interface e.g. "Bay2:Q1.1","Bay2:Q2.1" or "Bay5:Q1.2","Bay5:Q2.2" + + Array + + Array + + @() + + + + + + + HPEOneView.Networking.LogicalInterconnect [System.Management.Automation.PSCustomObject] + + + Logical Interconnect Resource from Get-OVLogicalInterconnect + + + + + HPEOneView.Networking.LogicalInterconnectGroup [System.Management.Automation.PSCustomObject] + + + Logical Interconnect Group Resource from Get-OVLogicalInterconnectGroup + + + + + + + + HPEOneView.Appliance.TaskResource {System.Management.Automation.PSCustomObject} + + + + Async Task Resource object + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVLogicalInterconnectGroup -Name "LIG Prod" | New-OVUplinkSet -Name "Uplink Set 1" -Type Ethernet -Networks "RED","BLUE","GREEN" -NativeEthNetwork "RED" -UplinkPorts "BAY1:X5","BAY1:X6","BAY2:X5","BAY2:X6" -EthMode "Auto" + + To Create an Ethernet Uplink Template + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + $ethNets = "Net1","Net2","Net3" | Get-OVNetwork -Type Ethernet +Get-OVLogicalInterconnectGroup -Name "LIG Prod" | New-OVUplinkSet -Name "Uplink Set 1" -Type Ethernet -Networks $ethNets -NativeEthNetwork $ethNets[0] -UplinkPorts "BAY1:X5","BAY1:X6","BAY2:X5","BAY2:X6" -EthMode "Auto" + + Get the network resource objects, and define a new Uplink Set template that will be assigned to the Logical Interconnect Group resource. + + + + + + + + + + -------------------------- EXAMPLE 3 -------------------------- + + + + $LIGProd = Get-OVLogicalInterconnectGroup -Name "LIG Prod" +New-OVUplinkSet -Resource $LIGProd -Name "Fabric A" -Type FibreChannel -Networks "FABRIC_A" -UplinkPorts "BAY1:X1","BAY1:X2" + + To Create a Fibre Channel Uplink Template for c-Class or HPE Synergy VC FlexFabric modules. + + + + + + + + + + -------------------------- EXAMPLE 4 -------------------------- + + + + Get-OVLogicalInterconnect -Name "Encl1 LIG Prod" | New-OVUplinkSet -Name "New Uplink Set" -Type Ethernet -Networks "RED","BLUE","GREEN" -NativeEthNetwork "RED" -UplinkPorts "BAY1:X5","BAY1:X6","BAY2:X5","BAY2:X6" -EthMode "Auto" + + Add a new Uplink Set to an existing Logical Interconnect resource. + + + + + + + + + + -------------------------- EXAMPLE 5 -------------------------- + + + + $MlagNetworks = Get-OVNetwork -Type Ethernet -Name "My MLAG Network*" +Get-OVLogicalInterconnectGroup -Name "My Synergy Prod LIG" | New-OVUplinkSet -Name "MLAG UplinkSet" -Type Ethernet -Networks $MlagNetworks -NativeEthNetwork ($MlagNetworks | ? vlanid -eq 144) -UplinkPorts "Enclosure1:BAY3:Q1","Enclosure1:BAY3:Q2","Enclosure2:BAY6:Q1","Enclosure2:BAY6:Q2" -EthMode "Auto" + + Create a Synergy MLAG Uplink Set using 40Gb capable ports. + + + + + + + + + + -------------------------- EXAMPLE 6 -------------------------- + + + + $MlagNetworks = Get-OVNetwork -Type Ethernet -Name "My MLAG Network*" +Get-OVLogicalInterconnectGroup -Name "My Synergy Prod LIG" | New-OVUplinkSet -Name "MLAG UplinkSet" -Type Ethernet -Networks $MlagNetworks -NativeEthNetwork ($MlagNetworks | ? vlanid -eq 144) -UplinkPorts "Enclosure1:BAY3:Q1.1","Enclosure1:BAY3:Q2.1","Enclosure2:BAY6:Q1.1","Enclosure2:BAY6:Q2.1" -EthMode "Auto" + + Create a Synergy MLAG Uplink Set using 10Gb subports of QSFP transceiver slots. + + + + + + + + + + -------------------------- EXAMPLE 7 -------------------------- + + + + $ImageStreamerDeploymentNetworkObject = Get-OVNetwork -Name "Deployment Network" -ErrorAction Stop +Get-OVLogicalInterconnectGroup -Name "My Synergy VC+ImageStreamer LIG" -ErrorAction Stop | New-OVUplinkSet -Name "Image Streamer Uplink Set" -Type ImageStreamer -Networks $ImageStreamerDeploymentNetworkObject -UplinkPorts "Enclosure1:Bay3:Q3.1","Enclosure1:Bay3:Q4.1","Enclosure2:Bay6:Q3.1","Enclosure2:Bay6:Q4.1" + + Create a Synergy ImageStreamer Uplink Set. + + + + + + + + + + -------------------------- EXAMPLE 8 -------------------------- + + + + $ROCENet = Get-OVNetwork -Name ROCE-Net1 +$lig = Get-OVLogicalInterconnectGroup -Name "LE1-Default Ethernet LIG" +$ROCEUplinkPorts = "Enclosure1:Bay3:Q3","Enclosure2:Bay6:Q3" +$ROCEUplinkSetName = "ROCE_US1" + +$UplinkSetParams = @{ + + InputObject = $lig; + Name = $ROCEUplinkSetName; + Type = "Ethernet"; + Networks = $ROCENet; + UplinkPorts = $ROCEUplinkPorts + DCBxOverride = $true; + ROCEVersion = "ROCEV2" + +} + +New-OVUplinkSet @UplinkSetParams + + Create a RoCEv2 uplink set for a logical interconnect group. + + + + + + + + + + + + + Get-OVUplinkSet + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/networking/new-ovuplinkset + + + + + + + + New-OVUser + + Create a new user account. + + New + OVUser + + + Create a new local user account on the management appliance + + + + + New-OVUser + + UserName + + The name of the new user account to be created. + + String + + + Password + + The initial password to be assigned to the new user. +Passwords must be at least 8 characters. + + String + + + FullName + + Full name for the user. + + String + + + Roles + + The role(s) to assign to the Directroy Group, in System.Collections.ArrayList format. Accepted values are noted within the ApplianceRoles property of the HPEOneView.Appliance.Connection object stored in the $Global:ConnectedSessions variable. + +Example: $roles = "Server administrator","Network administrator" + + Array + + + ScopePermissions + + Array collection of Hashtable<Role; Scope>. Will overwrite existing scope to role mappings. + +Example: -ScopePermissions @{Role = "Network administrator"; Scope = (Get-OVScope -Name CorpNetAdmins -ErrorAction Stop) } + + Array + + + EmailAddress + + Provide the users email address. This does not set the Email Notification value when configuring SMTP Notifications. + + String + + + OfficePhone + + Office phone number. + + String + + + MobilePhone + + Mobile phone number. + + String + + + Enabled + + Deprecated parameter. By default, all new user accounts will be enabled. In order to disable a user account, use the Set-OVUser Cmdlet. + + SwitchParameter + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + +Default Value: ${Global:ConnectSessions} + + Object + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + +Default Value: ${Global:ConnectSessions} + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + EmailAddress + + Provide the users email address. This does not set the Email Notification value when configuring SMTP Notifications. + + String + + String + + + + + Enabled + + Deprecated parameter. By default, all new user accounts will be enabled. In order to disable a user account, use the Set-OVUser Cmdlet. + + SwitchParameter + + SwitchParameter + + False + + + FullName + + Full name for the user. + + String + + String + + + + + MobilePhone + + Mobile phone number. + + String + + String + + + + + OfficePhone + + Office phone number. + + String + + String + + + + + Password + + The initial password to be assigned to the new user. +Passwords must be at least 8 characters. + + String + + String + + + + + Roles + + The role(s) to assign to the Directroy Group, in System.Collections.ArrayList format. Accepted values are noted within the ApplianceRoles property of the HPEOneView.Appliance.Connection object stored in the $Global:ConnectedSessions variable. + +Example: $roles = "Server administrator","Network administrator" + + Array + + Array + + @() + + + ScopePermissions + + Array collection of Hashtable<Role; Scope>. Will overwrite existing scope to role mappings. + +Example: -ScopePermissions @{Role = "Network administrator"; Scope = (Get-OVScope -Name CorpNetAdmins -ErrorAction Stop) } + + Array + + Array + + + + + UserName + + The name of the new user account to be created. + + String + + String + + + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + HPEOneView.Appliance.User [System.Management.Automation.PSCustomObject] + + + + If successful, returns a user resource + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + New-OVUser -username Sally -fullName "Sally Smith" -password SallysPassword -roles "server administrator","network administrator" + + Create the Sally user account, and assigning to the Server Administrator and Network Administrator roles, on all connected appliances. + + + + + + + + + + + + + Get-OVUser + + + + Remove-OVUser + + + + Set-OVUser + + + + Set-OVUserPassword + + + + Set-OVUserRole + + + + Show-OVUserSession + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/security/new-ovuser + + + + + + + + Ping-OVAddress + + Validate IP Connectivity to resources. + + Ping + OVAddress + + + This Cmdlet provides the administrator the capability to PING (ICMP "echo request") to a resource the appliance is or is not managing, to help validate L2 and/or L3 connectivity from the appliance. + + + + + Ping-OVAddress + + Address + + The IP or FQDN Address of the target device. If using FQDN, please make sure valid DNS Servers are configured on the appliance for proper DNS resolution. + + String + + + Packets + + Number of Packets to generate. + +Default: 5 + + Int32 + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + + + + + Address + + The IP or FQDN Address of the target device. If using FQDN, please make sure valid DNS Servers are configured on the appliance for proper DNS resolution. + + String + + String + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + SwitchParameter + + False + + + Packets + + Number of Packets to generate. + +Default: 5 + + Int32 + + Int32 + + 5 + + + + + + + System.Net.IPAddress + + + IP Address of target node to ping + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + Task resource of the PING request + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + $results = Ping-OVAddress host.domain.com -Appliance appliance.contoso.com +$results.progressUpdates.statusUpdate +PING host.domain.com (192.168.1.100) 56(84) bytes of data. +64 bytes from host.domain.com (192.168.1.100): icmp_seq=1 ttl=64 time=0.462 ms +64 bytes from host.domain.com (192.168.1.100): icmp_seq=2 ttl=64 time=0.629 ms +64 bytes from host.domain.com (192.168.1.100): icmp_seq=3 ttl=64 time=0.478 ms +64 bytes from host.domain.com (192.168.1.100): icmp_seq=4 ttl=64 time=0.424 ms + + 64 bytes from host.domain.com (192.168.1.100): icmp_seq=5 ttl=64 time=0.578 ms + + + + + + + + + + + + + Get-OVAddressPool + + + + Get-OVAddressPoolRange + + + + Get-OVAddressPoolSubnet + + + + New-OVAddressPoolRange + + + + New-OVAddressPoolSubnet + + + + Remove-OVAddressPoolRange + + + + Remove-OVAddressPoolSubnet + + + + Set-OVAddressPoolSubnet + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/ping-ovaddress + + + + + + + + Pop-OVAppliancePermission + + Reset appliance connection active permissions back to login default. + + Pop + OVAppliancePermission + + + Upon successful login, the caller can change their active permissions, and operate in a less priviledge mode at anytime by using the Push-OVAppliancePermission. Use this Cmdlet to reset the appliance connection active permissions. A new SessionID token will be stored within the ApplianceConnection, and the ConnectionPermissions within the ActivePermissions property that were not provided will have their State set to "true". + + + + + Pop-OVAppliancePermission + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + Array + + (${Global:ConnectedSessions} | ? Default) + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + HPEOneView.Appliance.ConnectionPermission + + + + List of appliance connection permissions and their active state. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Pop-OVAppliancePermission + + Reset appliance connection active permissions to default. + + + + + + + + + + + + + Push-OVAppliancePermission + + + + about_Appliance_Connection_Permissions + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/library/pop-ovappliancepermission + + + [${Global:ConnectedSessions}] + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/library/pop-ovappliancepermission + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/library/pop-ovappliancepermission + + + + + + + + Push-OVAppliancePermission + + Change appliance connection active permissions. + + Push + OVAppliancePermission + + + Upon successful login, the caller can change their active permissions, and operate in a less priviledge mode at anytime. The Push-OVAppliancePermission Cmdlet will accept a single or collection of [HPEOneView.Appliance.ConnectionPermission] objects. A new SessionID token will be stored within the ApplianceConnection, and the ConnectionPermissions within the ActivePermissions property that were not provided will have their State set to "false". + + + + + Push-OVAppliancePermission + + SetActivePermissions + + One or more [HPEOneView.Appliance.ConnectionPermission] objects from an [HPEOneView.Appliance.Connection] ActivePermissions property. + + Object + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + Array + + (${Global:ConnectedSessions} | ? Default) + + + SetActivePermissions + + One or more [HPEOneView.Appliance.ConnectionPermission] objects from an [HPEOneView.Appliance.Connection] ActivePermissions property. + + Object + + Object + + + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + HPEOneView.Appliance.ConnectionPermission + + + + One or more appliance connection permissions and their active state. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + $ConnectedSessions[0].ActivePermissions + +RoleName ScopeName Active +-------- --------- ------ +Network administrator Site A Admins True +Server administrator AllResources True + +$NewPermissions = $ConnectedSessions[0].ActivePermissions | ? RoleName -match "Network" +Push-OVAppliancePermission -SetActivePermissions $NewPermissions + + Change active permissions by filtering for a specific Role. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + $ConnectedSessions[0].ActivePermissions + +RoleName ScopeName Active +-------- --------- ------ +Network administrator Site A Admins True +Server administrator AllResources True +Server administrator AllResources True + +$NewPermissions = $ConnectedSessions[0].ActivePermissions | ? ScopeName -match "Site A Admins" +Push-OVAppliancePermission -SetActivePermissions $NewPermissions + + Change active permissions by filtering for a specific Scope. + + + + + + + + + + + + + Pop-OVAppliancePermission + + + + about_Appliance_Connection_Permissions + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/library/push-ovappliancepermission + + + [${Global:ConnectedSessions}] + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/library/push-ovappliancepermission + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/library/push-ovappliancepermission + + + + + + + + Register-OVRemoteSupportPortalConnection + + Register appliance with the HPE Support Center + + Register + OVRemoteSupportPortalConnection + + + The Hewlett Packard Enterprise Support Center (HPESC) integration enables you to securely register the HPE OneView Remote Support client with your HPESC group. It can be a private or shared group. Registering remote support with HPESC improves case visibility for the cases originating from the client. After registration, all the group members can view the cases originating from the client. + +This feature provides an improvement over the existing contact-based access. It does not require explicit contact matching and allows you to share case content with all the HPESC group members. + +Use this Cmdlet to register the appliance to the HPESC. By default, if a previous token has been generated by another user and registration has not been completed, the generated token will be used. To generate a new token, use the -GenerateNewCode switch parameter. By default, the Cmdlet will return the token object, with the expiration time of the token. You can either copy the token and then log into the HPESC, or use the -LaunchBrowser switch parameter, which will launch your default web browser to the HPESC and the geneated token. + +Minimum required privileges: + + * Infrastructure Administrator + * HPESC credentials with the rights to add the appliance connection to the user specified group. + + + + + Register-OVRemoteSupportPortalConnection + + LaunchBrowser + + Launch your default web browser to the HPESC including the generated token. + + SwitchParameter + + + GenerateNewCode + + Generate a new token used to authenticate the appliance connection. + + SwitchParameter + + + ApplianceConnection + + Specify one or more HPEOneView.Appliance.Connection object(s) or Name property value(s). + +Default Value: ${Global:ConnectedSessions} | ? Default + + Object + + + WhatIf + + + + SwitchParameter + + + Confirm + + + + SwitchParameter + + + + + + + ApplianceConnection + + Specify one or more HPEOneView.Appliance.Connection object(s) or Name property value(s). + +Default Value: ${Global:ConnectedSessions} | ? Default + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Confirm + + + + SwitchParameter + + SwitchParameter + + + + + GenerateNewCode + + Generate a new token used to authenticate the appliance connection. + + SwitchParameter + + SwitchParameter + + + + + LaunchBrowser + + Launch your default web browser to the HPESC including the generated token. + + SwitchParameter + + SwitchParameter + + + + + WhatIf + + + + SwitchParameter + + SwitchParameter + + + + + + + + + None. You cannot pipe objects to this cmdlet. + + + + + + + + + + + HPEOneView.Appliance.RemoteSupport.PortalConnectionToken + + + + The appliance token used to establish a secure connection with the HPESC, and launch the clients default web browser. + + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Register-OVRemoteSupportPortalConnection -LaunchBrowser + + Generate a token. Return an existing token if it was created already by another user. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Register-OVRemoteSupportPortalConnection -GenerateNewCode + + Generate a new token. + + + + + + + + + + + + + Get-OVRemoteSupportPortalConnectionStatus + + + + Unregister-OVRemoteSupportPortalConnection + + + + Online: + https://hpe-docs.gitbook.io/posh-hpeoneview/cmdlets/v9.00/appliance/register-ovremotesupportportalconnection + + + + + + + + Remove-OVAddressPoolRange + + Delete address pool range from an appliance. + + Remove + OVAddressPoolRange + + + This Cmdlet provides the ability to remove one or more IPv4 Subnet Pools and associated address pool ranges from one or more appliances. + + + + + Remove-OVAddressPoolRange + + InputObject + + The address pool range resource Object. Can be accepted via pipeline input. + + Object + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + + WhatIf + + + + SwitchParameter + + + Confirm + + + + SwitchParameter + + + + + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Confirm + + + + SwitchParameter + + SwitchParameter + + + + + InputObject + + The address pool range resource Object. Can be accepted via pipeline input. + + Object + + Object + + + + + WhatIf + + + + SwitchParameter + + SwitchParameter + + + + + + + + + HPEOneView.Appliance.AddressPoolRange [System.Management.Automation.PSCustomObject] + + + address pool range from Get-OVAddressPoolRange + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + Result of resource removal + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVAddressPoolRange | Remove-OVAddressPoolSubnet + + Remove all address pool ranges the default connected appliance. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Get-OVAddressPoolSubnet | Where startAddress -eq "11:11:11:11:11:11" | Remove-OVAddressPoolSubnet + + Remove "192.168.20.0" IPv4 Subnet address pool from MyAppliance.domain.com. + + + + + + + + + + + + + Get-OVAddressPoolRange + + + + New-OVAddressPoolRange + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/remove-ovaddresspoolrange + + + + + + + + Remove-OVAddressPoolSubnet + + Delete an IPv4 Subnet Pool from an appliance. + + Remove + OVAddressPoolSubnet + + + This Cmdlet provides the ability to remove one or more IPv4 Subnet Pools and associated address pool ranges from one or more appliances. + + + + + Remove-OVAddressPoolSubnet + + InputObject + + Aliases [-Subnet, -IPv4Subnet] +The IPv4 Subnet Pool resource Object. Can be accepted via pipeline input. + + Object + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + + WhatIf + + + + SwitchParameter + + + Confirm + + + + SwitchParameter + + + + + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Confirm + + + + SwitchParameter + + SwitchParameter + + + + + InputObject + + Aliases [-Subnet, -IPv4Subnet] +The IPv4 Subnet Pool resource Object. Can be accepted via pipeline input. + + Object + + Object + + + + + WhatIf + + + + SwitchParameter + + SwitchParameter + + + + + + + + + HPEOneView.Appliance.IPAddressSubnet [System.Management.Automation.PSCustomObject] + + + IPv4 or IPv6 Subnet Pool from Get-OVAddressPoolSubnet + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + Result of resource removal + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVAddressPoolSubnet | Remove-OVAddressPoolSubnet + + Remove all IPv4 Subnet address pools from any connected appliance. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Get-OVAddressPoolSubnet 192.168.20.0 | Remove-OVAddressPoolSubnet + + Remove "192.168.20.0" IPv4 Subnet address pool from MyAppliance.domain.com. + + + + + + + + + + + + + Get-OVAddressPoolSubnet + + + + New-OVAddressPoolSubnet + + + + Set-OVAddressPoolSubnet + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/remove-ovaddresspoolsubnet + + + + + + + + Remove-OVAlert + + Delete alerts. + + Remove + OVAlert + + + This Cmdlet allows the administrator to remove one or more alerts. Alerts can be in one of two administratively controlled states: Active or Cleared. Only alerts that are no longer active (in a Cleared state) can be removed. + +In order for an administrator to remove an Alert, the administrator must be assigned to the respective resource role (Network, Server, Storage, or Infrastructure.) + + + + + Remove-OVAlert + + InputObject + + The alert to be removed. + + Object + + + Force + + Force remove the resource. + + SwitchParameter + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + + WhatIf + + + + + + + Confirm + + + + + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Confirm + + + + + + + + + + + Force + + Force remove the resource. + + SwitchParameter + + SwitchParameter + + + + + InputObject + + The alert to be removed. + + Object + + Object + + + + + WhatIf + + + + + + + + + + + + + + + HPEOneView.Alert [System.Management.Automation.PSCustomObject] + + + Alert resource object (i.e. Get-OVAlert) + + + + + + + + System.Management.Automation.PSCustomObject + + + + Status object indicating the resource was removed. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVAlert -State Cleared | Remove-OVAlert + + Remove all cleared alerts on the appliance. + + + + + + + + + + + + + Clear-OVAlert + + + + Get-OVAlert + + + + Set-OVAlert + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/remove-ovalert + + + + + + + + Remove-OVApplianceProxy + + Remove appliance HTTP/HTTPS proxy. + + Remove + OVApplianceProxy + + + The setting an appliance proxy allows you to set the HTTP/HTTPS proxy, port number for client connections, and whether authentication requires a username and a password. + +Minimum required privileges: Infrastructure administrator + + + + + Remove-OVApplianceProxy + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + + WhatIf + + + + SwitchParameter + + + Confirm + + Override confirmation prompt. + + SwitchParameter + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + Array + + (${Global:ConnectedSessions} | ? Default) + + + Confirm + + Override confirmation prompt. + + SwitchParameter + + SwitchParameter + + + + + WhatIf + + + + SwitchParameter + + SwitchParameter + + + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + HPEOneView.Appliance.ProxyServer + + + + Appliance proxy server settings. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Remove-OVApplianceProxy + + Remove the configured HTTP/HTTP proxy settings on the appliance. + + + + + + + + + + + + + Get-OVApplianceProxy + + + + Set-OVApplianceProxy + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/remove-ovapplianceproxy + + + + + + + + Remove-OVApplianceStaticRoute + + Remove configured static route on an appliance. + + Remove + OVApplianceStaticRoute + + + When configuring a second NIC on a virtual machine appliance, static routes can be configured as only a single appliance NIC can be configured with a default gateway. Both IPv4 and IPv6 static routes are supported. Use this Cmdlet to remove a static route configured on an appliance. + +Minimum required privileges: Infrastructure administrator + + + + + Remove-OVApplianceStaticRoute + + InputObject + + Static route object from Get-OVApplianceStaticRoute. + + HPEOneView.Appliance.StaticRoute + + + ApplianceConnection + + Specify one or more HPEOneView.Appliance.Connection object(s) or Name property value(s). + +Default Value: ${Global:ConnectedSessions} | ? Default + + Object + + + WhatIf + + + + + + + Confirm + + + + + + + + + + + ApplianceConnection + + Specify one or more HPEOneView.Appliance.Connection object(s) or Name property value(s). + +Default Value: ${Global:ConnectedSessions} | ? Default + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Confirm + + + + + + + + + + + InputObject + + Static route object from Get-OVApplianceStaticRoute. + + HPEOneView.Appliance.StaticRoute + + HPEOneView.Appliance.StaticRoute + + + + + WhatIf + + + + + + + + + + + + + + + HPEOneView.Appliance.StaticRoute + + + Configured static route object from Get-OVApplianceStaticRoute. + + + + + + + + HPOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + Async task resource to monitor. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVApplianceStaticRoute -Destination 192.168.44.0/24 | Remove-OVApplianceStaticRoute + + + Remove the specific static route from an appliance. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Get-OVApplianceStaticRoute -Interface SecondNIC | Remove-OVApplianceStaticRoute + + + Remove all configured static routes configured for the the specific interface from an appliance. + + + + + + + + + + + + + Get-OVApplianceStaticRoute + + + + New-OVApplianceStaticRoute + + + + Set-OVApplianceStaticRoute + + + + Online: + https://hpe-docs.gitbook.io/posh-hpeoneview/cmdlets/v9.00/appliance/remove-ovappliancestaticroute + + + + + + + + Remove-OVApplianceTrapDestination + + Remove configured appliance SNMP trap destinations. + + Remove + OVApplianceTrapDestination + + + Use this Cmdlet to remove configured SNMPv1 and/or SNMPv3 trap destinations. + +Minimum required privileges: Infrastructure administrator + + + + + Remove-OVApplianceTrapDestination + + InputObject + + The HPEOneView.Appliance.SnmpV1TrapDestination or HPEOneView.Appliance.SnmpV3TrapDestination object from Get-OVApplianceTrapDestination to remove. + + Object + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + + WhatIf + + + + SwitchParameter + + + Confirm + + Override confirmation prompt. + + SwitchParameter + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + Array + + (${Global:ConnectedSessions} | ? Default) + + + Confirm + + Override confirmation prompt. + + SwitchParameter + + SwitchParameter + + + + + InputObject + + The HPEOneView.Appliance.SnmpV1TrapDestination or HPEOneView.Appliance.SnmpV3TrapDestination object from Get-OVApplianceTrapDestination to remove. + + Object + + Object + + + + + WhatIf + + + + SwitchParameter + + SwitchParameter + + + + + + + + + HPEOneView.Appliance.SnmpV1TrapDestination + + + Appliance SNMPv1 trap destination from Get-OVApplianceTrapDestination. + + + + + HPEOneView.Appliance.SnmpV3TrapDestination + + + Appliance SNMPv3 trap destination from Get-OVApplianceTrapDestination. + + + + + + + + System.Management.Automation.PSCustomObject + + + + Success message of deleted resource. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVApplianceTrapDestination -Destination 10.45.110.76 -ErrorAction Stop | Remove-OVApplianceTrapDestination + + Remove the specified trap destination. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Get-OVApplianceTrapDestination -Type SNMPv3 | Remove-OVApplianceTrapDestination + + Remove all of the SNMPv3 trap destinations. + + + + + + + + + + + + + Get-OVApplianceTrapDestination + + + + New-OVApplianceTrapDestination + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/remove-ovappliancetrapdestination + + + + + + + + Remove-OVApplianceTrustedCertificate + + Remove X.509 SSL certificates from the appliace trusted store. + + Remove + OVApplianceTrustedCertificate + + + This Cmdlet will allow the Infrastructure Administrator to remove X.509 compliant SSL certificates on the appliance within its trusted store. + + + + + Remove-OVApplianceTrustedCertificate + + InputObject + + Aliases [-Certificate] + +The Alias Name of the certificate. Please know that wildcard is not supported. + + String + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] objects or Name property values. + + Object + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + WhatIf + + + + + + + Confirm + + + + + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] objects or Name property values. + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + SwitchParameter + + False + + + Confirm + + + + + + + + + + + InputObject + + Aliases [-Certificate] + +The Alias Name of the certificate. Please know that wildcard is not supported. + + String + + String + + + + + WhatIf + + + + + + + + + + + + + + + HPEOneView.Appliance.TrustedCertificate + + + A trusted certificate from Get-OVApplianceTrustedCertificate. + + + + + + + + System.Management.Automation.PSCustomObject + + + + Status oject of successfull deletion of trusted certificate. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVApplianceTrustedCertificate -Name myhost1.domain.com | Remove-OVApplianceTrustedCertificate + + Remove the specific trusted certificate from the appliances trusted certificate store. + + + + + + + + + + + + + Add-OVApplianceTrustedCertificate + + + + Get-OVApplianceTrustedCertificate + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/remove-ovappliancetrustedcertificate + + + + + + + + Remove-OVBaseline + + Delete a baseline or hotfix from an appliance repository. + + Remove + OVBaseline + + + This Cmdlet provides the ability to remove one or more SPP Baselines from one or more appliances. + + + + + Remove-OVBaseline + + InputObject + + The SPP Baseline or hotfix resource object. Can be accepted via pipeline input. + + Object + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + + Force + + Force remove the resource. + + SwitchParameter + + + WhatIf + + + + SwitchParameter + + + Confirm + + + + SwitchParameter + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Confirm + + + + SwitchParameter + + SwitchParameter + + + + + Force + + Force remove the resource. + + SwitchParameter + + SwitchParameter + + + + + InputObject + + The SPP Baseline or hotfix resource object. Can be accepted via pipeline input. + + Object + + Object + + + + + WhatIf + + + + SwitchParameter + + SwitchParameter + + + + + + + + + HPEOneView.Appliance.Baseline [System.Management.Automation.PSCustomObject] + + + Source HPE OneView Baseline from Get-OVBaseline + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + The progress of uploading the file to the appliance, and in-progress or completion result + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVBaseline | Remove-OVBaseline + + Remove all baselines from any connected appliance. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Get-OVBaseline -Name "My Custom Baseline" | Remove-OVBaseline + + Remove the specified "My Custom Baseline" baseline. + + + + + + + + + + + + + Add-OVBaseline + + + + Get-OVBaseline + + + + Get-OVBaselineRepository + + + + Show-OVBaselineRepositorySize + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/remove-ovbaseline + + + + + + + + Remove-OVClusterManager + + Remove configured hypervisor managers. + + Remove + OVClusterManager + + + You can register a hypervisor manager with HPE OneView by providing hostname and credentials in the Hypervisor Managers user interface. The registered hypervisor manager contains preferences, which are used as default hypervisor or cluster settings during hypervisor cluster profile creation. You can modify the hypervisor manager preferences using the edit operation. You can override these values in a hypervisor cluster profile. + +A valid hypervisor manager certificate must be added to HPE OneView trust store to be able to successfully communicate with a hypervisor manager. + +The user must have an infrastructure administrator privilege to register or update the hypervisor manager resource in HPE OneView. + + + + + Remove-OVClusterManager + + InputObject + + The HPEOneView.ClusterProfile.HypervisorManager resource to remove from Get-OVClusterManager. + + HPEOneView.ClusterProfile.HypervisorManager + + + Force + + Force delete the resource. + + SwitchParameter + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + + WhatIf + + + + SwitchParameter + + + Confirm + + + + SwitchParameter + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + Array + + (${Global:ConnectedSessions} | ? Default) + + + Confirm + + + + SwitchParameter + + SwitchParameter + + + + + Force + + Force delete the resource. + + SwitchParameter + + SwitchParameter + + + + + InputObject + + The HPEOneView.ClusterProfile.HypervisorManager resource to remove from Get-OVClusterManager. + + HPEOneView.ClusterProfile.HypervisorManager + + HPEOneView.ClusterProfile.HypervisorManager + + + + + WhatIf + + + + SwitchParameter + + SwitchParameter + + + + + + + + + HPEOneView.ClusterProfile.HypervisorManager + + + The hypervisor manager object from Get-OVClusterManager. + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + Asynchronous task resource to monitor. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVClusterManager -Name vcenter1.domain.com -ErrorAction Stop | Remove-OVClusterManager + + Remove the specified hypervisor manager. + + + + + + + + + + + + + Add-OVClusterManager + + + + Get-OVClusterManager + + + + Set-OVClusterManager + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/cluster/remove-ovclustermanager + + + + + + + + Remove-OVClusterProfile + + Remove a cluster profile resource. + + Remove + OVClusterProfile + + + A cluster profile enables you to deploy and manage a cluster of servers (nodes) managed by HPE OneView and orchestrates consistent configuration on cluster of server nodes to share the same workload. A cluster profile and the associated server profile template are used to define a consistent configuration from server nodes to members in the cluster. The associated server profiles define physical server configurations for server nodes in the cluster, which are derived from parent cluster profile and its associated server profile template. + +NOTE: The server profile template must have a configured connection to the hypervisor management network for the template to be valid for use by a hypervisor cluster profile. + +The cluster profile helps you manage life cycle operations, such as growing or shrinking the cluster, modifying configurations based on needs, consistency checks, and nondisruptive firmware updates on the member nodes. For example, you can grow or shrink a cluster by adding or removing members from the cluster profile. Any change in the configuration of the cluster profile will be reported as an inconsistency. When inconsistencies are remediated, the changed configurations can be applied on cluster and member nodes. + +A cluster profile can manage VMware ESXi-based hypervisor clusters by leveraging VMware vCenter server. A hypervisor cluster must be managed by one instance of HPE OneView to avoid inconsistencies. + +Use this Cmdlet to remove a cluster profile within OneView. Removing a cluster within OneView will also destroy the cluster within the cluster manager. + +Minimum required privileges: Infrastructure administrator, Server administrator, Server profile architect, or Server profile administrator. + + + + + Remove-OVClusterProfile + + InputObject + + The cluster profile from Get-OVClusterProfile. + + Object + + + Force + + Force delete the resource. + + SwitchParameter + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + WhatIf + + + + SwitchParameter + + + Confirm + + Use to override the prompt. + +**** WARNING **** - Use this with caution, as removing a cluster from OneView will also destroy the cluster within the cluster manager. + + SwitchParameter + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Confirm + + Use to override the prompt. + +**** WARNING **** - Use this with caution, as removing a cluster from OneView will also destroy the cluster within the cluster manager. + + SwitchParameter + + SwitchParameter + + + + + Force + + Force delete the resource. + + SwitchParameter + + SwitchParameter + + + + + InputObject + + The cluster profile from Get-OVClusterProfile. + + Object + + Object + + + + + WhatIf + + + + SwitchParameter + + SwitchParameter + + + + + + + + + HPEOneView.Cluster.ClusterProfile [System.Management.Automation.PSCustomObject] + + + Cluster profile resource from Get-OVClusterProfile. + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + Asynchronous task resource to monitor. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVClusterProfile -Name ProdCluster1 | Remove-OVClusterProfile + + Remove the specified cluster profile. + + + + + + + + + + + + + Get-OVClusterProfile + + + + New-OVClusterProfile + + + + New-OVClusterProfileMember + + + + Update-OVClusterProfile + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/cluster/remove-ovclusterprofile + + + + + + + + Remove-OVDataCenter + + Remove a datacenter resource. + + Remove + OVDataCenter + + + A data center represents a physically contiguous area in which racks containing IT equipment are located. +For example, you have IT equipment in two rooms or on separate floors. You could create a data center for each of these areas. +Each server, enclosure, or power distribution device in your data center can report its power requirements, but it can be difficult to understand the power and cooling requirements for your data center as a whole. The appliance enables you to bring power and cooling management of your servers, enclosures, and power delivery devices together in a single management system. +When you initialize the appliance for the first time, it creates a data center named Datacenter 1. The appliance provides this data center as a place to visualize your racks. You can rename or edit this data center to match the values and layout of your data center, you can use it as the basis for a planned data center model, or you can delete this data center without adverse effects. + +This Cmdlet will remove 1 or more datacenter resources from an appliance. Removing a datacenter resource will not delete or remove associated resources, like Racks. + + + + + Remove-OVDataCenter + + InputObject + + Datacenter object, from Get-OVDataCenter. + + Object + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + WhatIf + + + + + + + Confirm + + + + + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Confirm + + + + + + + + + + + InputObject + + Datacenter object, from Get-OVDataCenter. + + Object + + Object + + + + + WhatIf + + + + + + + + + + + + + + + HPEOneView.Facilities.DataCenter + + + Datacenter resource from Get-OVDataCenter. + + + + + + + + System.Management.Automation.PSCustomObject + + + + Object with status confirmation the resource was deleted. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVDataCenter -Name DC2 | Remove-OVDataCenter + + Remove "DC2" datacenter resource from the appliance. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Get-OVDataCenter | Remove-OVDataCenter + + Remove Datacenter resources from the appliance. + + + + + + + + + + + + + Get-OVDataCenter + + + + New-OVDataCenter + + + + Set-OVDataCenter + + + + Set-OVDataCenterRemoteSupport + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/facilities/remove-ovdatacenter + + + + + + + + Remove-OVEnclosure + + Removes an enclosure and associated devices. + + Remove + OVEnclosure + + + Removes an enclosure, its servers, and interconnects from appliance management + + + + + Remove-OVEnclosure + + InputObject + + The Enclosure object(s) or name(s) to be removed from management. + + Object + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Array + + + Force + + Set to force-remove the enclosure. For example, if the enclosure is gone or is now being managed by a different appliance, force-removing will remove the enclosure from this appliance without clearing vcmode. + +When the request is accepted by the appliance, it does not return an Async Task Resource. + + SwitchParameter + + + WhatIf + + + + SwitchParameter + + + Confirm + + + + SwitchParameter + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Array + + Array + + (${Global:ConnectedSessions} | ? Default) + + + Confirm + + + + SwitchParameter + + SwitchParameter + + + + + Force + + Set to force-remove the enclosure. For example, if the enclosure is gone or is now being managed by a different appliance, force-removing will remove the enclosure from this appliance without clearing vcmode. + +When the request is accepted by the appliance, it does not return an Async Task Resource. + + SwitchParameter + + SwitchParameter + + False + + + InputObject + + The Enclosure object(s) or name(s) to be removed from management. + + Object + + Object + + + + + WhatIf + + + + SwitchParameter + + SwitchParameter + + + + + + + + + System.Collections.ArrayList + + + Collection of Enclosure Resources + + + + + HPEOneView.Enclosure [System.Management.Automation.PSCustomObject] + + + Single Enclosure resource object + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + Removal async task + + + + + System.Management.Automation.PSCustomObject + + + + When using the -Force parameter, a PSCustomObject is returned indicating successful removal of the resource + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + $enclosure = Get-OVEnclosure -name "Enclosure1" +Remove-OVEnclosure $enclosure -confirm:$false + + Remove the enclosure specifed by $enclosure. Disable confirmation prompt. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Get-OVEnclosure | Remove-OVEnclosure + + Search for all enclosures and remove them from appliance. + + + + + + + + + + + + + Add-OVEnclosure + + + + Get-OVEnclosure + + + + Get-OVEnclosureGroup + + + + New-OVEnclosureGroup + + + + Remove-OVEnclosureGroup + + + + Reset-OVEnclosureDevice + + + + Set-OVEnclosure + + + + Set-OVEnclosureActiveFLM + + + + Set-OVEnclosureGroup + + + + Update-OVEnclosure + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/servers/remove-ovenclosure + + + + + + + + Remove-OVEnclosureGroup + + Remove an enclosure group. + + Remove + OVEnclosureGroup + + + Deletes an enclosure group from the appliance. +An enclosure group cannot be deleted if any enclosures are currently part of that enclosure group. + + + + + Remove-OVEnclosureGroup + + InputObject + + The Enclosure Group object(s), name(s) or uri(s) to be removed from management. + + Object + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Array + + + Force + + Specify to forceably remove the resource from the appliance. + + SwitchParameter + + + WhatIf + + + + SwitchParameter + + + Confirm + + + + SwitchParameter + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Array + + Array + + (${Global:ConnectedSessions} | ? Default) + + + Confirm + + + + SwitchParameter + + SwitchParameter + + + + + Force + + Specify to forceably remove the resource from the appliance. + + SwitchParameter + + SwitchParameter + + False + + + InputObject + + The Enclosure Group object(s), name(s) or uri(s) to be removed from management. + + Object + + Object + + + + + WhatIf + + + + SwitchParameter + + SwitchParameter + + + + + + + + + System.Collections.ArrayList + + + Collection of Enclosure Resource Objects + + + + + HPEOneView.EnclosureGroup [System.Management.Automation.PSCustomObject] + + + Single Enclosure Grou Resource Object + + + + + + + + System.Management.Automation.PSCustomObject + + + + A PSCustomObject is returned indicating successful removal of the resource + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + $resp = Remove-OVEnclosureGroup -enclosureGroup "My-EG" -force + + Force-remove the enclosure group specifed by name. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + $eg = Get-OVEnclosureGroup -name "My-EG" +Remove-OVEnclosureGroup $enclosureGroup -confirm:$false + + Remove the enclosure group specifed by $eg. Disable confirmation prompt. + + + + + + + + + + -------------------------- EXAMPLE 3 -------------------------- + + + + Get-OVEnclosureGroup | Remove-OVEnclosureGroup + + Search for all enclosure groups and remove them from appliance. + + + + + + + + + + + + + Get-OVEnclosureGroup + + + + New-OVEnclosureGroup + + + + Set-OVEnclosureGroup + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/servers/remove-ovenclosuregroup + + + + + + + + Remove-OVExternalRepository + + Remove an existing external baseline repository. + + Remove + OVExternalRepository + + + A firmware repository enables you to store firmware bundles and deploy them across your environment. An externally managed HTTP/HTTPS web server can be added to the appliance as a repository. It is a user-maintained HTTP/HTTPS web server. You can upload firmware bundles in a specific directory and then register the HTTP/HTTPS server with HPE OneView. This functionality is supported for Linux and Windows systems. + +The recommended types of external web servers to use with the repository follow: + + * Apache + * Internet Information Services (IIS) + +NOTE: Only one external repository can be added. + +This Cmdlet supports removing an existing external repository. Removing an external baseline will cause any assigned baselines in Server Profiles or Server Profile Templates to report the baseline as "removed". Any server profile that is configured to use a firmware bundle residing in the external repository must not be in "staging" state. + + + + + Remove-OVExternalRepository + + InputObject + + Provide the external repository object to remove. + + Object + + + Force + + Force remove the resource. + + SwitchParameter + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + + WhatIf + + + + + + + Confirm + + + + + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + Array + + (${Global:ConnectedSessions} | ? Default) + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + SwitchParameter + + + + + Confirm + + + + + + + + + + + Force + + Force remove the resource. + + SwitchParameter + + SwitchParameter + + + + + InputObject + + Provide the external repository object to remove. + + Object + + Object + + + + + WhatIf + + + + + + + + + + + + + + + HPEOneView.Appliance.BaselineRepository [System.Management.Automation.PSCustomObject] + + + The external repository object from Get-OVBaselineRepository + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + The async task for the caller to monitor. + + + + + System.Collections.ArrayList <HPEOneView.Appliance.TaskResource> + + + + Multiple async task resource objects. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVBaselineRepository -Name MyRepoName -ErrorAction Stop | Remove-OVExternalRepository + + Remove the existing external repository from the appliance. + + + + + + + + + + + + + New-OVExternalRepository + + + + Set-OVExternalRepository + + + + Update-OVExternalRepository + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/remove-ovexternalrepository + + + + + + + + Remove-OVFabricManager + + Remove a configured Fabric Manager and associated tenants. + + Remove + OVFabricManager + + + Fabric Managers is a resource manager in HPE OneView that enables integration of a Cisco ACI fabric (an external entity) with HPE Synergy. A fabric manager aligns HPE OneView resources as defined by Cisco Application Policy Infrastructure Controller (APIC) policies. It represents a remote Cisco APIC or an APIC cluster that manages a Cisco ACI fabric. This Cmdlet will remove the fabric manager and will disassociate it's tenant from all logical interconnects, networks and networks sets. Inconsistencies with the APIC tenant configuration will no longer be monitored or remediated by OneView. Minimum required privileges: Infrastructure administrator or Server administrator + + + + + Remove-OVFabricManager + + InputObject + + The HPEOneView.Networking.FabricManager resource to remove. + + HPEOneView.Networking.FabricManager[] + + + Force + + Force delete the resource. + + SwitchParameter + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + + WhatIf + + + + + + + Confirm + + + + + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + Array + + (${Global:ConnectedSessions} | ? Default) + + + Confirm + + + + + + + + + + + Force + + Force delete the resource. + + SwitchParameter + + SwitchParameter + + + + + InputObject + + The HPEOneView.Networking.FabricManager resource to remove. + + HPEOneView.Networking.FabricManager[] + + HPEOneView.Networking.FabricManager[] + + + + + WhatIf + + + + + + + + + + + + + + + HPEOneView.Networking.FabricManager + + + The fabric manager resource from Get-OVFabricManager. + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + Async task Resource object for configuring port monitoring on the requested logical intercinnect. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVFabricManager -Name fabricmgr.domain.com -ErrorAction Stop | Remove-OVFabricManager + + Remove the specified fabric manager. + + + + + + + + + + + + + Add-OVFabricManager + + + + Get-OVFabricManager + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/networking/remove-ovfabricmanager + + + + + + + + Remove-OVLdapDirectory + + Remove authentication Directory. + + Remove + OVLdapDirectory + + + Remove authentication Directory from the appliance. Can provide Directory Name or Object for removal. + + + + + Remove-OVLdapDirectory + + InputObject + + Configured authentication Directory Name or Object. + + Object + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + + Force + + Foreably remove the resource from the appliance. + + SwitchParameter + + + WhatIf + + + + SwitchParameter + + + Confirm + + + + SwitchParameter + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Confirm + + + + SwitchParameter + + SwitchParameter + + + + + Force + + Foreably remove the resource from the appliance. + + SwitchParameter + + SwitchParameter + + False + + + InputObject + + Configured authentication Directory Name or Object. + + Object + + Object + + + + + WhatIf + + + + SwitchParameter + + SwitchParameter + + + + + + + + + System.Collections.ArrayList + + + Collection of Directories + + + + + System.Management.Automation.PSCustomObject + + + Single Directory object + + + + + + + + System.Management.Automation.PSCustomObject + + + + Resource Removed Status + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Remove-OVLdapDirectory -Directory "My Directory1" + + Remove "My Directroy Group1" from the appliance. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Get-OVLdapDirectory | Remove-OVLdapDirectory + + Get all Directories and remove them from the default connected appliance. + + + + + + + + + + + + + Get-OVLdapDirectory + + + + New-OVLdapDirectory + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/security/remove-ovldapdirectory + + + + + + + + Remove-OVLdapGroup + + Remove Directory Group. + + Remove + OVLdapGroup + + + Remove Directory Group(s) from the appliance. Can provide Group Name or Object for removal. + + + + + Remove-OVLdapGroup + + InputObject + + Configured Directory Group Name. + + Object + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + + WhatIf + + + + SwitchParameter + + + Confirm + + + + SwitchParameter + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Confirm + + + + SwitchParameter + + SwitchParameter + + + + + InputObject + + Configured Directory Group Name. + + Object + + Object + + + + + WhatIf + + + + SwitchParameter + + SwitchParameter + + + + + + + + + System.Management.Automation.PSCustomObject + + + Single Group resource object + + + + + System.Collections.ArrayList + + + Collection of Group resource objects + + + + + + + + System.Management.Automation.PSCustomObject + + + + A PSCustomObject is returned indicating successful removal of the resource + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Remove-OVLdapGroup -Group "My Directory Group1" + + Remove "My Directroy Group1" from the appliance. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Get-OVLdapGroup | Remove-OVLdapGroup + + Get all groups and remove them from all connected appliances. + + + + + + + + + + + + + Get-OVLdapGroup + + + + New-OVLdapGroup + + + + Set-OVLdapGroupRole + + + + Show-OVLdapGroups + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/security/remove-ovldapgroup + + + + + + + + Remove-OVLdapServer + + Remove an existing LDAP Directory Server. + + Remove + OVLdapServer + + + This Cmdlet will remove an existing LDAP Directory Server resource from an existing LDAP Directory. + + + + + Remove-OVLdapServer + + InputObject + + The LDAP Directory Object from Get-OVLdapDirectory. + + Object + + + DirectoryServerName + + Directory server name. + + String + + + Username + + Directory Username to authenticate with in order to validate LDAP configuration. + + String + + + Password + + Directory User account password in order to validate LDAP configuration. Can be System.String or System.Security.SecureString object. + + Object + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. + + Object + + + WhatIf + + + + + + + Confirm + + + + + + + + Remove-OVLdapServer + + InputObject + + The LDAP Directory Object from Get-OVLdapDirectory. + + Object + + + DirectoryServerName + + Directory server name. + + String + + + Credential + + Use this parameter if you want to provide a PSCredential object instead. + + PSCredential + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. + + Object + + + WhatIf + + + + + + + Confirm + + + + + + + + + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Confirm + + + + + + + + + + + Credential + + Use this parameter if you want to provide a PSCredential object instead. + + PSCredential + + PSCredential + + + + + DirectoryServerName + + Directory server name. + + String + + String + + + + + InputObject + + The LDAP Directory Object from Get-OVLdapDirectory. + + Object + + Object + + + + + Password + + Directory User account password in order to validate LDAP configuration. Can be System.String or System.Security.SecureString object. + + Object + + Object + + + + + Username + + Directory Username to authenticate with in order to validate LDAP configuration. + + String + + String + + + + + WhatIf + + + + + + + + + + + + + + + HPEOneView.Appliance.AuthDirectory [System.Management.Automation.PSCustomObject] + + + Authentication Directory object that will have the LDAP Server added to. + + + + + + + + HPEOneView.Appliance.AuthDirectory [System.Management.Automation.PSCustomObject] + + + + Updated Authentication Directory. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVLdapDirectory -Name MyDirectory | Remove-OVLdapServer -DirectoryServerName servera.domain.com -Username MyAdminName -Password (ConvertTo-SecureString "MyPAssword" -AsPlanText -Force) + + Remove the specified LDAP Directory server from "MyDirectory". Will be prompted for confirmation. + + + + + + + + + + + + + Add-OVLdapServer + + + + New-OVLdapServer + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/security/remove-ovldapserver + + + + + + + + Remove-OVLicense + + REmove installed licenses on the appliance. + + Remove + OVLicense + + + This Cmdlet will remove licenses installed on the appliance. Removing installed licenses is only support via Windows PowerShell, Python or the HPE OneView REST API. However, if a license key is currently assigned to a resource, the license key cannot be removed. + + + + + Remove-OVLicense + + InputObject + + Provide the License URI or object to remove. + + HPEOneView.Appliance.License + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + + WhatIf + + + + SwitchParameter + + + Confirm + + + + SwitchParameter + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Confirm + + + + SwitchParameter + + SwitchParameter + + + + + InputObject + + Provide the License URI or object to remove. + + HPEOneView.Appliance.License + + HPEOneView.Appliance.License + + + + + WhatIf + + + + SwitchParameter + + SwitchParameter + + + + + + + + + HPEOneView.Appliance.License + + + HPE OneView License object + + + + + + + + System.Management.Automation.PSCustomObject + + + + Success message + + + + + System.Management.Automation.ErrorRecord + + + + Error message of in use license key + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + $LicenseKeys = Get-OVlicense +Remove-OVLicense -InputObject $LicenseKeys[0] + + Get all installed licenses saving them to $LicenseKeys, then calling Remove-OVLicense to remove the first key in the variable. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Get-OVlicense | Remove-OVLicense + + Get all installed licenses and remove them. + + + + + + + + + + + + + Get-OVLicense + + + + New-OVLicense + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/remove-ovlicense + + + + + + + + Remove-OVLogicalEnclosure + + Remove a Logical Enclosure. + + Remove + OVLogicalEnclosure + + + This Cmdlet willRemove a Logical Enclosure. Removing a Logical Enclosure is only supported with Synergy. If a C7000 Enclosure needs to be removed, use the Remove-OVEnclosure Cmdlet. + + + + + Remove-OVLogicalEnclosure + + InputObject + + Provide the Logical Enclosure name, URI or Object, or [System.Collections.ArrayList ] of names, URIs or Objects to remove. + + Object + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Array + + + Force + + Forcefully remove the Logical Enclosure resource. + + SwitchParameter + + + WhatIf + + + + SwitchParameter + + + Confirm + + + + SwitchParameter + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Array + + Array + + (${Global:ConnectedSessions} | ? Default) + + + Confirm + + + + SwitchParameter + + SwitchParameter + + + + + Force + + Forcefully remove the Logical Enclosure resource. + + SwitchParameter + + SwitchParameter + + False + + + InputObject + + Provide the Logical Enclosure name, URI or Object, or [System.Collections.ArrayList ] of names, URIs or Objects to remove. + + Object + + Object + + + + + WhatIf + + + + SwitchParameter + + SwitchParameter + + + + + + + + + HPEOneView.LogicalEnclosure [System.Management.Automation.PSCustomObject] + + + Single Logical Enclosure resource + + + + + System.Collections.ArrayList + + + Multiple Logical Enclosure resources + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + Async task Resource object + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVLogicalEnclosure LogicalEnclosure1 | Remove-OVLogicalEnclosure + + Remove "LogicalEnclosure1" Logical Enclosure resource. + + + + + + + + + + + + + Get-OVLogicalEnclosure + + + + New-OVLogicalEnclosure + + + + Set-OVLogicalEnclosure + + + + Update-OVLogicalEnclosure + + + + Update-OVLogicalEnclosureFirmware + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/servers/remove-ovlogicalenclosure + + + + + + + + Remove-OVLogicalInterconnectGroup + + Remove a Logical Interconnect Group. + + Remove + OVLogicalInterconnectGroup + + + Removes a Logical Interconnect Group from appliance management + + + + + Remove-OVLogicalInterconnectGroup + + InputObject + + The logical interconnect group object(s), name(s) or uris(s) to be removed from management. + + Object + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + + force + + Invoke switch force-delete the resource when OneView can no longer communicate with the resource and removal is needed. Force remove succeeds even if there are network connectivity issues or resource errors. -Force is not a PowerShell option, rather an HPE OneView API feature. This does not override the -Confirm PowerShell option. + + SwitchParameter + + + WhatIf + + + + SwitchParameter + + + Confirm + + + + SwitchParameter + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Confirm + + + + SwitchParameter + + SwitchParameter + + + + + InputObject + + The logical interconnect group object(s), name(s) or uris(s) to be removed from management. + + Object + + Object + + + + + WhatIf + + + + SwitchParameter + + SwitchParameter + + + + + force + + Invoke switch force-delete the resource when OneView can no longer communicate with the resource and removal is needed. Force remove succeeds even if there are network connectivity issues or resource errors. -Force is not a PowerShell option, rather an HPE OneView API feature. This does not override the -Confirm PowerShell option. + + SwitchParameter + + SwitchParameter + + False + + + + + + + System.String + + + Logical Interconnect Group Name or URI + + + + + System.Management.Automation.PSCustomObject + + + Logical Interconnect Group resource object + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + Removal Task + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + $lig = Get-OVLogicalInterconnectGroup -Name "My-LIG" +Remove-OVLogicalInterconnectGroup $lig -confirm:$false + + Remove the logical interconnect group specifed by $lig. Disable confirmation prompt. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Get-OVLogicalInterconnectGroup | Remove-OVLogicalInterconnectGroup + + Search for all logical interconnect groups and remove them from all connected appliances. + + + + + + + + + + + + + Get-OVLogicalInterconnectGroup + + + + New-OVLogicalInterconnectGroup + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/networking/remove-ovlogicalinterconnectgroup + + + + + + + + Remove-OVLogicalJBOD + + Create a new HPE Synergy Logical JBOD resource. + + Remove + OVLogicalJBOD + + + A logical JBOD is a group of physical drives that are dynamically defined as virtual drives. Logical JBOD uses the drives from the drive enclosures that are installed in the device bays of the enclosure and are associated with a SAS logical interconnect. You can assign or unassign a logical JBOD to a server hardware through the server profile. + +If the logical drive settings in the server profile indicate that the data in the logical JBOD is to be retained when you delete the server profile, then the data is retained and you can assign this logical JBOD to a different server profile. + +Using this Cmdlet will remove an existing logical JBOD on the connected appliance. You can delete a logical JBOD only after you unassign it from the server profile. If you have chosen to erase the drive data when you delete a logical JBOD, all the drive data will be erased. + +Minimum required privileges: Infrastructure administrator, server administrator, server profile architect, server profile administrator + + + + + Remove-OVLogicalJBOD + + InputObject + + The logical JBOD resource from Get-OVLogialJBOD Cmdlet. If the logical JBOD is associated with a server profile, it must first be unassociated from the server profile, then you can remove it. If the erase on delete option is enabled (or set to true), then data will be deleted from the drive. + + HPEOneView.Storage.LogicalJBOD[] + + + Force + + Force delete the resource. + + SwitchParameter + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + WhatIf + + + + SwitchParameter + + + Confirm + + + + SwitchParameter + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + SwitchParameter + + False + + + Confirm + + + + SwitchParameter + + SwitchParameter + + + + + Force + + Force delete the resource. + + SwitchParameter + + SwitchParameter + + + + + InputObject + + The logical JBOD resource from Get-OVLogialJBOD Cmdlet. If the logical JBOD is associated with a server profile, it must first be unassociated from the server profile, then you can remove it. If the erase on delete option is enabled (or set to true), then data will be deleted from the drive. + + HPEOneView.Storage.LogicalJBOD[] + + HPEOneView.Storage.LogicalJBOD[] + + + + + WhatIf + + + + SwitchParameter + + SwitchParameter + + + + + + + + + HPEOneView.Storage.LogicalJBOD[] + + + One or more logical JBOD resources from Get-OVLogicalJBOD. + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + Asynchronous task resource to monitor. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + $LogicalJBOD = Get-OVLogicalJBOD -Name MyLJbod1 +Remove-OVLogicalJBOD -InputObject $LogicalJBOD + + Remove the specified logical JBOD. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + # Get the logical JBOD we intend to remove +$LogicalJBOD = Get-OVLogicalJBOD -Name MyLJbod1 + +# Get the associated server profile associated with the logical JBOD +$ServerProfile = Get-OVServerProfile -Name $LogicalJBOD.UsedBy + +# Remove the logical JBOD from the profile +$ServerProfile.localStorage.sasLogicalJBODs = $ServerProfile.localStorage.sasLogicalJBODs | ? sasLogicalJBODUri -ne $ljbods[0].uri + +# Save the server profile +Save-OVServerProfile -InputObject $ServerProfile + +# Remove the logical JBOD resource +Remove-OVLogicalJBOD -InputObject $LogicalJBOD + + Remove the specified logical JBOD when it is associated with a server profile resource. + + + + + + + + + + + + + Get-OVDriveEnclosure + + + + Get-OVDriveEnclosureInventory + + + + Get-OVLogicalJBOD + + + + New-OVLogicalJBOD + + + + Set-OVLogicalJBOD + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/storage/remove-ovlogicaljbod + + + + + + + + Remove-OVLogicalSwitch + + Remove a new Logical Switch resource. + + Remove + OVLogicalSwitch + + + This Cmdlet will remove the configured Logical Switch from the requested appliance(s). When you delete a logical switch, HPE OneView no longer manages the physical switches associated with it. Minimum required privileges: Infrastructure administrator or Network administrator + + + + + Remove-OVLogicalSwitch + + InputObject + + The Logical Switch resource Name or Object to update. + + Object + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + + Force + + Force remove resource, even if there are communication problems. + + SwitchParameter + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + WhatIf + + + + + + + Confirm + + Bypass the confirmation prompt, and process all of the objects. + + SwitchParameter + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + SwitchParameter + + + + + Confirm + + Bypass the confirmation prompt, and process all of the objects. + + SwitchParameter + + SwitchParameter + + + + + Force + + Force remove resource, even if there are communication problems. + + SwitchParameter + + SwitchParameter + + + + + InputObject + + The Logical Switch resource Name or Object to update. + + Object + + Object + + + + + WhatIf + + + + + + + + + + + + + + + HPEOneView.Networking.LogicalSwitch [System.Management.Automation.PSCustomObject] + + + Logical Switch resource. + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + The async task resource object to monitor (if -Async was used) or results. + + + + + System.Collections.ArrayList <HPEOneView.Appliance.TaskResource> + + + + Collection of remove Logical Switch async task resources. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVLogicalSwitch | Remove-OVLogicalSwitch + + Remove all logical switch resources found on the default appliance connection. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Get-OVLogicalSwitch -Name "My Logical Switch 1" | Remove-OVLogicalSwitch -confirm:$false + + Remove the "My Logical Switch 1" resource. + + + + + + + + + + + + + Get-OVLogicalSwitch + + + + Get-OVLogicalSwitchGroup + + + + New-OVLogicalSwitch + + + + New-OVLogicalSwitchGroup + + + + Remove-OVLogicalSwitchGroup + + + + Update-OVLogicalSwitch + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/networking/remove-ovlogicalswitch + + + + + + + + Remove-OVLogicalSwitchGroup + + Remove a new Logical Switch Group resource. + + Remove + OVLogicalSwitchGroup + + + This Cmdlet will remove the configured Logical Switch Group from the requested appliance(s). You cannot delete a logical switch group while it is being used by one or more logical switches. To delete the logical switch group, first delete the logical switches using the logical switch group. Minimum required privileges: Infrastructure administrator or Network administrator + + + + + Remove-OVLogicalSwitchGroup + + InputObject + + The Logical Switch resource Name or Object to update. + + Object + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + + Force + + Force remove resource, even if there are communication problems. + + SwitchParameter + + + WhatIf + + + + + + + Confirm + + Bypass the confirmation prompt, and process all of the objects. + + SwitchParameter + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Confirm + + Bypass the confirmation prompt, and process all of the objects. + + SwitchParameter + + SwitchParameter + + + + + Force + + Force remove resource, even if there are communication problems. + + SwitchParameter + + SwitchParameter + + + + + InputObject + + The Logical Switch resource Name or Object to update. + + Object + + Object + + + + + WhatIf + + + + + + + + + + + + + + + HPEOneView.Networking.LogicalSwitchGroup [System.Management.Automation.PSCustomObject] + + + Logical Switch Group resource. + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + The async task resource object results. + + + + + System.Collections.ArrayList <HPEOneView.Appliance.TaskResource> + + + + Collection of remove Logical Switch async task resources. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVLogicalSwitchGroup | Remove-OVLogicalSwitchGroup + + Remove all logical switch group resources found on the default appliance connection. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Get-OVLogicalSwitchGroup -Name "My Logical Switch Group Policy 1" | Remove-OVLogicalSwitchGroup -confirm:$false + + Remove the "My Logical SwitchGroup Policy 1" resource. + + + + + + + + + + + + + Get-OVLogicalSwitchGroup + + + + New-OVLogicalSwitchGroup + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/networking/remove-ovlogicalswitchgroup + + + + + + + + Remove-OVNetwork + + Delete network from appliance configuration. + + Remove + OVNetwork + + + Delete a network and its corresponding default connection type. + + + + + Remove-OVNetwork + + InputObject + + The network object(s) or name(s) to be deleted. + + Object + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + + Force + + Forcefully remove the network object. + + SwitchParameter + + + WhatIf + + + + SwitchParameter + + + Confirm + + + + SwitchParameter + + + + + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Confirm + + + + SwitchParameter + + SwitchParameter + + + + + Force + + Forcefully remove the network object. + + SwitchParameter + + SwitchParameter + + False + + + InputObject + + The network object(s) or name(s) to be deleted. + + Object + + Object + + + + + WhatIf + + + + SwitchParameter + + SwitchParameter + + + + + + + + + System.String + + + Network Name or URI + + + + + System.Management.Automation.PSCustomObject + + + Network Resource Object + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + Async Removal task + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + $task = Remove-OVNetwork -network "yellow" +Wait-OVTaskComplete $task + + Remove the network specifed by name. Wait for remove to complete. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + $Net = Get-OVNetwork -name "yellow" +Remove-OVNetwork -network $net -confirm:$false + + Remove the network specifed by $net, and do not prompt for confirmation. + + + + + + + + + + -------------------------- EXAMPLE 3 -------------------------- + + + + Get-OVNetwork | Remove-OVNetwork + + Search for all networks and remove them from appliance. + + + + + + + + + + + + + Get-OVNetwork + + + + Get-OVNetworkSet + + + + New-OVNetwork + + + + New-OVNetworkSet + + + + Remove-OVNetworkSet + + + + Set-OVNetwork + + + + Set-OVNetworkSet + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/networking/remove-ovnetwork + + + + + + + + Remove-OVNetworkSet + + Remove a network set. + + Remove + OVNetworkSet + + + Delete a network set and its corresponding default connection type. + + + + + Remove-OVNetworkSet + + NetworkSet + + The network set object(s), name(s) or uri(s) to be deleted. If providing a URI, you must specify an Appliance Connection. + + Object + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + + WhatIf + + + + SwitchParameter + + + Confirm + + + + SwitchParameter + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Confirm + + + + SwitchParameter + + SwitchParameter + + + + + NetworkSet + + The network set object(s), name(s) or uri(s) to be deleted. If providing a URI, you must specify an Appliance Connection. + + Object + + Object + + + + + WhatIf + + + + SwitchParameter + + SwitchParameter + + + + + + + + + HPEOneView.Networking.NetworkSet [System.Management.Automation.PSCustomObject] + + + Network Set resource object + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + Removal task + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + $task = Remove-OVNetworkSet -networkSet "MyNetSet" +Wait-OVTaskComplete $task + + Remove the network set specifed by name. Wait for remove to complete. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + $netSet = Get-OVNetworkSet -name "MyNetSet" | Remove-OVNetwork + + Remove the specified network set. + + + + + + + + + + -------------------------- EXAMPLE 3 -------------------------- + + + + Get-OVNetworkSet | Remove-OVNetworkSet + + Search for all network sets and remove them from appliance. + + + + + + + + + + + + + Get-OVNetworkSet + + + + New-OVNetworkSet + + + + Set-OVNetworkSet + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/networking/remove-ovnetworkset + + + + + + + + Remove-OVOSDeploymentServer + + Remove an HPE Synergy Image Streamer OS Deployment server. + + Remove + OVOSDeploymentServer + + + Deleting an Image Streamer OS deployment server removes the management and storage networking configurations of all the Image Streamer appliances configured in HPE OneView. In addition, the Image Streamer appliances are reset to factory defaults, removing all OS deployment artifacts and all OS volumes. + +In order to successfully remove an OS Deployment Server, all associated Logical Enclosures must first be removed. If a Logical Enclosure does not contain an HPE Synergy Image Streamer appliance, then it does not need to be removed. + + + + + Remove-OVOSDeploymentServer + + InputObject + + OS Deployment Server object, from Get-OVOSDeploymentServer. + + HPEOneView.Appliance.OSDeploymentServer + + + Force + + Forceably remove an OS Deployment Server. + + SwitchParameter + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + WhatIf + + + + + + + Confirm + + + + + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + SwitchParameter + + False + + + Confirm + + + + + + + + + + + Force + + Forceably remove an OS Deployment Server. + + SwitchParameter + + SwitchParameter + + False + + + InputObject + + OS Deployment Server object, from Get-OVOSDeploymentServer. + + HPEOneView.Appliance.OSDeploymentServer + + HPEOneView.Appliance.OSDeploymentServer + + + + + WhatIf + + + + + + + + + + + + + + + HPEOneView.Appliance.OSDeploymentServer + + + HPE Synergy Image Streamer OS Deployment Server from Get-OVOSDeploymentServer + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + Resource removal async task. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVOSDeploymentServer | Remove-OVOSDeploymentServer + + Remove OS Deployment Servers from the appliance. + + + + + + + + + + + + + Get-OVOSDeploymentServer + + + + New-OVOSDeploymentServer + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/servers/remove-ovosdeploymentserver + + + + + + + + Remove-OVPendingUpdate + + Remove pending or staged appliance update. + + Remove + OVPendingUpdate + + + Remove a pending or staged appliance update that prevents the appliance from operating normally or the administrator would like to update the appliance with a different update file. + + + + + Remove-OVPendingUpdate + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + WhatIf + + + + SwitchParameter + + + Confirm + + + + SwitchParameter + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Confirm + + + + SwitchParameter + + SwitchParameter + + + + + WhatIf + + + + SwitchParameter + + SwitchParameter + + + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + None. You cannot pipe objects to this Cmdlet + + + + + + + + None. + + + + None + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Remove-OVPendingUpdate + + Remove any found pending update any connectioned appliances. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Remove-OVPendingUpdate + + Remove any found pending update specified appliance connection. + + + + + + + + + + + + + Get-OVPendingUpdate + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/remove-ovpendingupdate + + + + + + + + Remove-OVPowerDevice + + Remove power device (iPDU) + + Remove + OVPowerDevice + + + Removes a power device (iPDU) from appliance management. + + + + + Remove-OVPowerDevice + + InputObject + + The Power Device object(s), name(s) or uri(s) to be removed from management. + + Object + + + Force + + Set to $true to force-remove the power device. Force-removing will succeed even when there are connectivity issues or resource errors. + +When the request is accepted by the appliance, it does not return an Async Task Resource. + + SwitchParameter + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + + WhatIf + + + + SwitchParameter + + + Confirm + + + + SwitchParameter + + + + + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + SwitchParameter + + False + + + Confirm + + + + SwitchParameter + + SwitchParameter + + + + + Force + + Set to $true to force-remove the power device. Force-removing will succeed even when there are connectivity issues or resource errors. + +When the request is accepted by the appliance, it does not return an Async Task Resource. + + SwitchParameter + + SwitchParameter + + False + + + InputObject + + The Power Device object(s), name(s) or uri(s) to be removed from management. + + Object + + Object + + + + + WhatIf + + + + SwitchParameter + + SwitchParameter + + + + + + + + + HPEOneView.PowerDeliveryDevice [System.Management.Automation.PSCustomObject] + + + Power Device (iPDU) Resource Object + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + Async remove task + + + + + System.Management.Automation.PSCustomObject + + + + When using the -Force parameter, a PSCustomObject is returned indicating successful removal of the resource + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + $task = Remove-OVPowerDevice -PowerDevice "iPDU16" | Wait-OVTaskComplete + + Remove the power device specifed by name. Wait for remove to complete. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + $ipdu = Get-OVPowerDevice -name "iPDU24" +Remove-OVPowerDevice -PowerDevice $ipdu -force -confirm:$false + + Force-Remove the profile specifed by $ipdu. Disable confirmation prompt. + + + + + + + + + + -------------------------- EXAMPLE 3 -------------------------- + + + + Get-OVPowerDevice | Remove-OVPowerDevice + + Search for all power devices and remove them from appliance. + + + + + + + + + + + + + Add-OVPowerDevice + + + + Add-OVPowerDeviceConnection + + + + Get-OVPowerDevice + + + + New-OVPowerDevice + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/facilities/remove-ovpowerdevice + + + + + + + + Remove-OVRack + + Remove a rack resource. + + Remove + OVRack + + + A rack is a physical structure that contains IT equipment such as enclosures, servers, power delivery devices, and unmanaged devices (an unmanaged device uses slots in the rack and consumes power or exhausts heat, but it is not managed by the appliance). You can manage your racks and the equipment in them by adding them to the appliance. Having your racks managed by the appliance enables you to use the appliance for space and power planning. The appliance also gathers statistical data and monitors the power and temperature of the racks it manages. +When you add an enclosure to the appliance, it automatically creates a rack and places the enclosure in it. The appliance places into the rack all enclosures connected by management link cables. When enclosures are added, the appliance places them in the rack from top to bottom. When an enclosure is placed in an Intelligent Series Rack, the enclosure slots are automatically detected. For other racks, to accurately depict the layout of your enclosures within the rack you must edit the rack to place the enclosure in the proper slots. + +You can use the appliance to view and manage your rack configuration and power delivery topology. You can specify the physical dimensions of the rack (width, height, and depth), the number of U slots, and the location of each piece of equipment in the rack. You can specify the rack PDUs that provide power to the rack, and their physical position in the rack or on either side. You can also describe how the devices in the rack are connected to those PDUs. + +The appliance automatically discovers the rack height and rack model for a ProLiant server with Location Discovery Services and updates the physical locations of devices when they are relocated within and between racks for c7000 enclosures. + +This Cmdlet will remove an existing Rack resource. Removing a rack resource will not remove the associated rack members. + + + + + Remove-OVRack + + InputObject + + Rack object, from Get-OVRack. + + Object + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + WhatIf + + + + + + + Confirm + + + + + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Confirm + + + + + + + + + + + InputObject + + Rack object, from Get-OVRack. + + Object + + Object + + + + + WhatIf + + + + + + + + + + + + + + + HPEOneView.Facilities.Rack + + + Rack resource from Get-OVRack. + + + + + + + + System.Management.Automation.PSCustomObject + + + + Object with status confirmation the resource was deleted. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVRack -Name Rack-221 | Remove-OVRack + + Remove "Rack-221" rack resource from the appliance. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Get-OVRack | Remove-OVRack + + Remove rack resources from the appliance. + + + + + + + + + + + + + Add-OVRackManager + + + + Add-OVRackToDataCenter + + + + Get-OVRack + + + + Get-OVRackManager + + + + Get-OVRackMember + + + + New-OVRack + + + + Remove-OVRackManager + + + + Remove-OVRackMember + + + + Set-OVRackMemberLocation + + + + Update-OVRackManager + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/facilities/remove-ovrack + + + + + + + + Remove-OVRackManager + + Remove rack manager from appliance. + + Remove + OVRackManager + + + A rack manager platform is a multinode system. The nodes are housed within a rack or across racks, and are centrally managed by a management controller. The Rack Managers screen enables you to manage and visualize the physical location of rack manager platforms within a rack. This Cmdlet will remove a claimed rack manager resource from the appliance. Minimum required privileges: Infrastructure administrator or Server administrator. + + + + + Remove-OVRackManager + + InputObject + + An HPEOneView.Servers.RackManager resource from Get-OVRackManager. + + HPEOneView.Servers.RackManager + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + + Force + + Force remove resource, in cases where the device manager has been re-addressed and is no longer accessible, or there are other communication issues preventing the resource removal. + + SwitchParameter + + + WhatIf + + + + + + + Confirm + + + + + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + Array + + (${Global:ConnectedSessions} | ? Default) + + + Confirm + + + + + + + + + + + Force + + Force remove resource, in cases where the device manager has been re-addressed and is no longer accessible, or there are other communication issues preventing the resource removal. + + SwitchParameter + + SwitchParameter + + + + + InputObject + + An HPEOneView.Servers.RackManager resource from Get-OVRackManager. + + HPEOneView.Servers.RackManager + + HPEOneView.Servers.RackManager + + + + + WhatIf + + + + + + + + + + + + + + + HPEOneView.Servers.RackManager + + + An HPEOneView.Servers.RackManager resource from Get-OVRackManager. + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + Async task Resource object for configuring port monitoring on the requested logical intercinnect. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVRackManager -Name rackmanager2.domain.com -ErrorAction Stop | Remove-OVRackManager + + Remove the provided rack manager resource from the appliance. + + + + + + + + + + + + + Add-OVRackManager + + + + Get-OVRackManager + + + + Update-OVRackManager + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/servers/remove-ovrackmanager + + + + + + + + Remove-OVRackMember + + Remove a member resource from a rack. + + Remove + OVRackMember + + + A rack is a physical structure that contains IT equipment such as enclosures, servers, power delivery devices, and unmanaged devices (an unmanaged device uses slots in the rack and consumes power or exhausts heat, but it is not managed by the appliance). You can manage your racks and the equipment in them by adding them to the appliance. Having your racks managed by the appliance enables you to use the appliance for space and power planning. The appliance also gathers statistical data and monitors the power and temperature of the racks it manages. When you add an enclosure to the appliance, it automatically creates a rack and places the enclosure in it. The appliance places into the rack all enclosures connected by management link cables. When enclosures are added, the appliance places them in the rack from top to bottom. When an enclosure is placed in an Intelligent Series Rack, the enclosure slots are automatically detected. For other racks, to accurately depict the layout of your enclosures within the rack you must edit the rack to place the enclosure in the proper slots. You can use the appliance to view and manage your rack configuration and power delivery topology. You can specify the physical dimensions of the rack (width, height, and depth), the number of U slots, and the location of each piece of equipment in the rack. You can specify the rack PDUs that provide power to the rack, and their physical position in the rack or on either side. You can also describe how the devices in the rack are connected to those PDUs. The appliance automatically discovers the rack height and rack model for a ProLiant server with Location Discovery Services and updates the physical locations of devices when they are relocated within and between racks for c7000 enclosures. This Cmdlet will remove a member from an existing Rack resource. Removing a rack member resource will not delete or remove the resource from the appliance, just the association with the rack. + + + + + Remove-OVRackMember + + InputObject + + Rack object, from Get-OVRack. + + Object + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + WhatIf + + + + + + + Confirm + + + + + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Confirm + + + + + + + + + + + InputObject + + Rack object, from Get-OVRack. + + Object + + Object + + + + + WhatIf + + + + + + + + + + + + + + + HPEOneView.Facilities.RackMember + + + Rack member resource from Get-OVRackMember. + + + + + + + + HPEOneView.Appliance.TaskResource + + + + Async task object of updating the associated rack. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + $RackMember = Get-OVRack -Name Rack-221 -ErrorAction Stop | Get-OVRackMember -Name DL380-1 -ErrorAction Stop +Remove-OVRackMember -InputObject $Rack1Member + + Remove "Rack-221" rack resource from the appliance. + + + + + + + + + + + + + Get-OVRackMember + + + + Set-OVRackMemberLocation + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/facilities/remove-ovrackmember + + + + + + + + Remove-OVRemoteSupportContact + + Remove a Remote Support contact. + + Remove + OVRemoteSupportContact + + + Use this Cmdlet to remove an existing Remote Support Contact. The Default contact cannot be removed, and at least 1 contact must be configured before attempting to register the appliance with HPE support using the Set-OVRemoteSupport Cmdlet. + + + + + Remove-OVRemoteSupportContact + + InputObject + + The contacts first or given name. + + Object + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + WhatIf + + + + + + + Confirm + + + + + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Confirm + + + + + + + + + + + InputObject + + The contacts first or given name. + + Object + + Object + + + + + WhatIf + + + + + + + + + + + + + + + HPEOneView.Appliance.RemoteSupport.Contact [System.Management.Automation.PSCustomObject] + + + A Remote Support Contact from Get-OVRemoteSupportContact. + + + + + + + + System.Management.Automation.PSCustomObject + + + + Resource deleted response. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + New-OVRemoteSupportContact -Firstname Rebert -Lastname Jones -Email robert.jones@domain.local -PrimaryPhone 123-111-2222 -AlternatePhone 111-333-4444 -Language en -Default + + Configure a new user who is the default contact. + + + + + + + + + + + + + Get-OVRemoteSupportContact + + + + New-OVRemoteSupportContact + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/remove-ovremotesupportcontact + + + + + + + + Remove-OVRemoteSupportPartner + + Remove Remote Support support and reseller partners. + + Remove + OVRemoteSupportPartner + + + Use this Cmdlet to remove defined Remote Support partner from a specified or all appliances. + + + + + Remove-OVRemoteSupportPartner + + InputObject + + Remote Suport partner resource object, from Get-OVRemoteSupportPartner. + + Object + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + WhatIf + + + + + + + Confirm + + + + + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Confirm + + + + + + + + + + + InputObject + + Remote Suport partner resource object, from Get-OVRemoteSupportPartner. + + Object + + Object + + + + + WhatIf + + + + + + + + + + + + + + + HPEOneView.Appliance.RemoteSupport.Partner [System.Management.Automation.PSCustomObject] + + + Remote Suport partner resource from Get-OVRemoteSupportPartner. + + + + + + + + System.Management.Automation.PSCustomObject + + + + Object with status confirmation the resource was deleted. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVRemoteSupportPartner -Name "ABC IT Vendor" -ErrorAction Stop | Remove-OVRemoteSupportPartner + + Remove the specified remote support partner from the appliance. + + + + + + + + + + + + + Get-OVRemoteSupportPartner + + + + New-OVRemoteSupportPartner + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/remove-ovremotesupportpartner + + + + + + + + Remove-OVResource + + Remove existing resource(s). + + Remove + OVResource + + + Removes a resource identified by either the resource uri or a resource object. Remove-OVResource can be called with either -nameOrUri or -resource. + + *** This Cmdlet will not prompt for delete confirmation. Please use with caution. *** + + + + + Remove-OVResource + + InputObject + + A resource to be deleted. Value can be either resource object, Name or URI. + + Object + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + + force + + Invoke switch force-delete the resource when OneView can no longer communicate with the resource and removal is needed. -Force is not a PowerShell option, rather an HPE OneView API feature. This does not override the -Confirm PowerShell option. Not all resources support force-delete. + + SwitchParameter + + + + + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + InputObject + + A resource to be deleted. Value can be either resource object, Name or URI. + + Object + + Object + + + + + force + + Invoke switch force-delete the resource when OneView can no longer communicate with the resource and removal is needed. -Force is not a PowerShell option, rather an HPE OneView API feature. This does not override the -Confirm PowerShell option. Not all resources support force-delete. + + SwitchParameter + + SwitchParameter + + False + + + + + + + System.Management.Automation.PSCustomObject + + + A valid resource object first retrieved by a call to a Get-OV*** Cmdlet + + + + + + + + System.Management.Automation.PSCustomObject + + + + Removal async task + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Remove-OVResource -Resource "/rest/resource/1234-5678-9123" + + Removes the resource specified by the URI. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Remove-OVResource -nameOrUri "ServerProfile-A" + + Removes the resource named "ServerProfile-A". If multiple resources exist with the name "ServerProfile-A", an error is returned. + + + + + + + + + + -------------------------- EXAMPLE 3 -------------------------- + + + + $MyResourceObject = send-OVrequest "/rest/resource/1234-5678-9123" +Remove-OVResource -Resource $MyResourceObject + + Removes the resource $MyReSourceObject. + + + + + + + + + + + + + Add-OVResourceToLabel + + + + Add-OVResourceToRack + + + + Add-OVResourceToScope + + + + New-OVResource + + + + Remove-OVResourceFromLabel + + + + Remove-OVResourceFromScope + + + + Set-OVResource + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/library/remove-ovresource + + + + + + + + Remove-OVResourceFromLabel + + Remove association of resource with existing Label. + + Remove + OVResourceFromLabel + + + Labels identify resources so you can organize them into groups. For example, you might want to identify the servers that are used primarily by the Finance team, or identify the storage systems assigned to the Asia/Pacific division. + +This Cmdlet will remove the specified resource from the requested label. To remove the resource from all labels, use the -RemoveAllLabelsFromResource switch parameter. If there are no more associated resources with a label, the appliance will automatically delete the label. + + + + + Remove-OVResourceFromLabel + + Name + + The name of the Label associated with the resource. + + String + + + InputObject + + The resource to remove associatation with the label. + + Object + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + WhatIf + + + + + + + Confirm + + + + + + + + Remove-OVResourceFromLabel + + InputObject + + The resource to remove associatation with the label. + + Object + + + RemoveAllLabelsFromResource + + Use to remove all associated labels with the provide resource. + + SwitchParameter + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + WhatIf + + + + + + + Confirm + + + + + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Confirm + + + + + + + + + + + InputObject + + The resource to remove associatation with the label. + + Object + + Object + + + + + Name + + The name of the Label associated with the resource. + + String + + String + + + + + RemoveAllLabelsFromResource + + Use to remove all associated labels with the provide resource. + + SwitchParameter + + SwitchParameter + + + + + WhatIf + + + + + + + + + + + + + + + System.Management.Automation.PSCustomObject + + + Resource to remove label association. + + + + + + + + System.Management.Automation.PSCustomObject + + + + The created or modified Label resource. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVNetwork -Name Finance* | Remove-OVResourceFromLabel -Name Finance + + Remove the Finance network resources from the "Finance" label. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Get-OVNetwork | Remove-OVResourceFromLabel -RemoveAllLabelsFromResource + + Remove all label associations from network resources. + + + + + + + + + + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/remove-ovresourcefromlabel + + + + + + + + Remove-OVResourceFromScope + + Remove supported resource(s) from Scope. + + Remove + OVResourceFromScope + + + This Cmdlet will add supported resources to a specified Scope. All the resources in these categories can be added to or removed from a scope: + + * Enclosures + * Server Hardware + * Networks (Ethernet, FC, and FCoE) + * Network Sets + * Interconnects, excluding SAS resources + * Logical Interconnects, excluding SAS resources + * Logical Interconnect Groups, excluding SAS resources + * Switches + * Logical Switches + * Logical Switch Groups + +NOTE: Resources in other categories are considered to be included in all scopes, and they cannot be removed. + +Minimum required privileges: Infrastructure administrator + + + + + Remove-OVResourceFromScope + + Scope + + The Scope resource to add the resource(s) to. + + HPEOneView.Appliance.ScopeCollection + + + InputObject + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + Object + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. + + Array + + + + + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. + + Array + + Array + + (${Global:ConnectedSessions} | ? Default) + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + SwitchParameter + + + + + InputObject + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + Object + + Object + + + + + Scope + + The Scope resource to add the resource(s) to. + + HPEOneView.Appliance.ScopeCollection + + HPEOneView.Appliance.ScopeCollection + + + + + + + + + HPEOneView.Appliance.ScopeCollection + + + Scope resource object from Get-OVScope. + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + Asynchronous task resource that updates the Scope and associated resources. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + $Resources += Get-OVNetwork -Name ProdVLan* +$Resources += Get-OVServer -Name Encl1* +Get-OVScope -Name MyScope | Add-OVResourceToScope -InputObject $Resources + + Add the resources collected to the MyScope scope. + + + + + + + + + + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/remove-ovresourcefromscope + + + + + + + + Remove-OVSanManager + + Remove a SAN Manager. + + Remove + OVSanManager + + + This Cmdlet is used to remove the specified SAN Manager from the appliance. Before removing a SAN Manager, the Managed SAN resource must be removed from any configured FC or FCoE Network resources. + + + + + Remove-OVSanManager + + InputObject + + Managed SAN resource object or name to remove. + + Object + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Array + + + WhatIf + + + + SwitchParameter + + + Confirm + + + + SwitchParameter + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Array + + Array + + (${Global:ConnectedSessions} | ? Default) + + + Confirm + + + + SwitchParameter + + SwitchParameter + + + + + InputObject + + Managed SAN resource object or name to remove. + + Object + + Object + + + + + WhatIf + + + + SwitchParameter + + SwitchParameter + + + + + + + + + HPEOneView.Storage.SanManager [System.Management.Automation.PSCustomObject] + + + SAN Manager resource object(s) + + + + + + + + System.Management.Automation.PSCustomObject + + + + A PSCustomObject is returned indicating successful removal of the resource + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Remove-OVSanManager bna.contoso.com + + Remove the bna.contoso.com SAN Manager from the appliance. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Get-OVSanManager | Remove-OVSanManager + + Remove all SAN Managers from all connected appliances. + + + + + + + + + + + + + Add-OVSanManager + + + + Get-OVSanManager + + + + Set-OVSanManager + + + + Update-OVSanManager + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/storage/remove-ovsanmanager + + + + + + + + Remove-OVScmbCertificate + + Remove State Change Message Bus certificate from appliance. + + Remove + OVScmbCertificate + + + Remove the State Change Message Bus (SCMB) and Metric Streaming Message Bug (MSMB) read only account (rabbitmq_readonly) certificate key pair from an appliance. + + + + + Remove-OVScmbCertificate + + WhatIf + + + + + + + Confirm + + + + + + + + Remove-OVScmbCertificate + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + + WhatIf + + + + + + + Confirm + + + + + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + Array + + (${Global:ConnectedSessions} | ? Default) + + + Confirm + + + + + + + + + + + WhatIf + + + + + + + + + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + System.Management.Automation.PSCustomObject + + + + Resource deleted response. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Remove-OVScmbCertificates + + Remove the SCMB (rabbitmq_readonly) certificate key pair from an appliance. + + + + + + + + + + + + + Get-OVScmbCertificates + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/remove-ovscmbcertificate + + + + + + + + Remove-OVScope + + Remove Scope from appliance + + Remove + OVScope + + + This Cmdlet will remove a specific Scope. + +Minimum required privileges: Infrastructure administrator + + + + + Remove-OVScope + + Scope + + The Scope resource to add the resource(s) to. + + HPEOneView.Appliance.ScopeCollection + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. + + Array + + + WhatIf + + + + + + + Confirm + + + + + + + + + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. + + Array + + Array + + (${Global:ConnectedSessions} | ? Default) + + + Confirm + + + + + + + + + + + Scope + + The Scope resource to add the resource(s) to. + + HPEOneView.Appliance.ScopeCollection + + HPEOneView.Appliance.ScopeCollection + + + + + WhatIf + + + + + + + + + + + + + + + HPEOneView.Appliance.ScopeCollection + + + Scope resource object from Get-OVScope. + + + + + + + + System.Management.Automation.PSCustomObject + + + + Response indicating the resource was deleted successfully. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVScope MyScope | Remove-OVScope + + Remove the specified scope. + + + + + + + + + + + + + Get-OVScope + + + + New-OVScope + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/remove-ovscope + + + + + + + + Remove-OVServer + + Remove a rackmount server from the appliance. + + Remove + OVServer + + + Removes a physical server object from appliance management. + +The server object can be specified by its name or its full URI on the appliance by using the -Server parameter. It can also be supplied as an object by using the -resource parameter the object variable can be piped to Remove-OVServer. + +Blade servers can only be removed by removing the enclosure (Remove-OVEnclosure), or phyhsically removing the blade from the enclosure. + + + + + Remove-OVServer + + InputObject + + The Server object(s), name(s) or uri(s) to be removed from management. + + Object + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + + Force + + Use to force-remove the server. For example, if the server is gone or managed by a different appliance, force-remove will remove the server from this appliance without removing any of the HPE OneView applied configuration. + +When the request is accepted by the appliance, it does not return an Async Task Resource. + + SwitchParameter + + + WhatIf + + + + SwitchParameter + + + Confirm + + + + SwitchParameter + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Confirm + + + + SwitchParameter + + SwitchParameter + + + + + Force + + Use to force-remove the server. For example, if the server is gone or managed by a different appliance, force-remove will remove the server from this appliance without removing any of the HPE OneView applied configuration. + +When the request is accepted by the appliance, it does not return an Async Task Resource. + + SwitchParameter + + SwitchParameter + + False + + + InputObject + + The Server object(s), name(s) or uri(s) to be removed from management. + + Object + + Object + + + + + WhatIf + + + + SwitchParameter + + SwitchParameter + + + + + + + + + System.Management.Automation.PSCustomObject + + + Provide the Server Resource Object + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + Async removal task + + + + + System.Management.Automation.PSCustomObject + + + + When using the -Force parameter, a PSCustomObject is returned indicating successful removal of the resource + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + $task = Remove-OVServer -name "Server-1234" -force +Wait-OVTaskComplete $task + + + Force-remove the server specifed by name. Wait for remove to complete. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + $server = Get-OVServer -name "Server-1234" +Remove-OVServer $server -confirm:$false + + Remove the server specifed by $server. Disable confirmation prompt. + + + + + + + + + + -------------------------- EXAMPLE 3 -------------------------- + + + + $server = Get-OVServer -name "Server-1234" +Remove-OVServer $server -confirm:$false -force + + Remove the server specifed by $server. Disable confirmation prompt, and force remove the server. + + + + + + + + + + -------------------------- EXAMPLE 4 -------------------------- + + + + Get-OVServer | Remove-OVServer + + Search for all rackmount servers and remove them from appliance. + + + + + + + + + + + + + Add-OVServer + + + + Convert-OVServerProfile + + + + Convert-OVServerProfileTemplate + + + + ConvertTo-OVServerProfileTemplate + + + + Copy-OVServerProfile + + + + Get-OVServer + + + + Get-OVServerHardwareType + + + + Get-OVServerProfile + + + + Get-OVServerProfileConnectionList + + + + Get-OVServerProfileMessage + + + + Get-OVServerProfileTemplate + + + + Join-OVServerProfileToTemplate + + + + New-OVServerProfile + + + + New-OVServerProfileAssign + + + + New-OVServerProfileAttachVolume + + + + New-OVServerProfileConnection + + + + New-OVServerProfileLogicalDisk + + + + New-OVServerProfileLogicalDiskController + + + + New-OVServerProfileTemplate + + + + Remove-OVServerProfile + + + + Remove-OVServerProfileTemplate + + + + Restart-OVServer + + + + Save-OVServerProfile + + + + Save-OVServerProfileTemplate + + + + Set-OVServerHardwareType + + + + Set-OVServerPower + + + + Set-OVServerProfile + + + + Set-OVServerProfileTemplate + + + + Start-OVServer + + + + Stop-OVServer + + + + Update-OVServer + + + + Update-OVServerHardwareLicenseIntent + + + + Update-OVServerProfile + + + + Get-OVServerOneTimeBoot + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/servers/remove-ovserver + + + + + + + + Remove-OVServerProfile + + Delete Server Profile Resource(s). + + Remove + OVServerProfile + + + This Cmdlet will remove Server Profile resources from one or more appliance connections. Server Profile objects or names are supported. Server Profile resources can only be removed when the BladeSystem (BL) Server Hardware device is powered off. + + + + + Remove-OVServerProfile + + ServerProfile + + The server profile object(s), name(s) or URI(s) to be removed. + + Object + + + RetainStorageConfig + + Use this parameter to retain HPE OneView storage managed volumes. The default operation when deleting a server profile, the following activities take place: + +* Non-permanent private volumes are deleted from HPE OneView, SAN and the storage system. +* Permanent private volumes are not deleted from either HPE OneView, SAN or the storage system. +* SAN configuration is deleted from HPE OneView, SAN and the storage system. +* Shared volumes are not deleted from either HPE OneView, SAN or the storage system. + +If the -RetainStorageConfig parameter is used while deleting a server profile, the following activities take place: + +* All private volumes, including permanent and non permanent are removed only from HPE OneView. +* SAN configuration is deleted only in HPE OneView. +* No changes occur on the SAN and storage system, the server can continue to run and access its private and shared volume data. + + SwitchParameter + + + Force + + Set to force-delete the profile. For example, force-remove will successfully remove the profile, even when connectivity has been lost to the server or enclosure. + + SwitchParameter + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + + WhatIf + + + + SwitchParameter + + + Confirm + + + + SwitchParameter + + + + + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Confirm + + + + SwitchParameter + + SwitchParameter + + + + + Force + + Set to force-delete the profile. For example, force-remove will successfully remove the profile, even when connectivity has been lost to the server or enclosure. + + SwitchParameter + + SwitchParameter + + False + + + RetainStorageConfig + + Use this parameter to retain HPE OneView storage managed volumes. The default operation when deleting a server profile, the following activities take place: + +* Non-permanent private volumes are deleted from HPE OneView, SAN and the storage system. +* Permanent private volumes are not deleted from either HPE OneView, SAN or the storage system. +* SAN configuration is deleted from HPE OneView, SAN and the storage system. +* Shared volumes are not deleted from either HPE OneView, SAN or the storage system. + +If the -RetainStorageConfig parameter is used while deleting a server profile, the following activities take place: + +* All private volumes, including permanent and non permanent are removed only from HPE OneView. +* SAN configuration is deleted only in HPE OneView. +* No changes occur on the SAN and storage system, the server can continue to run and access its private and shared volume data. + + SwitchParameter + + SwitchParameter + + + + + ServerProfile + + The server profile object(s), name(s) or URI(s) to be removed. + + Object + + Object + + + + + WhatIf + + + + SwitchParameter + + SwitchParameter + + + + + + + + + HPEOneView.ServerProfile [System.Management.Automation.PSCustomObject] + + + Server Profile resource object. + + + + + System.String + + + Server Profile resource name. + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + A task resource that can be monitored for status of the profile deletion + + + + + System.Collections.ArrayList <HPEOneView.Appliance.TaskResource> + + + + Multiple Async task resources. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + $task = Remove-OVServerProfile -profile "Profile6" +Wait-OVTaskComplete $task.uri + + + Remove the profile specifed by name. Wait for remove to complete. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + $profile = Get-OVServerProfile -name "Profile2" +Remove-OVServerProfile $profile -confirm:$false + + Remove the profile specifed by $profile. Disable confirmation prompt. + + + + + + + + + + -------------------------- EXAMPLE 3 -------------------------- + + + + Get-OVServerProfile | Remove-OVServerProfile + + Search for all profiles and remove them from appliance. + + + + + + + + + + + + + Convert-OVServerProfile + + + + Convert-OVServerProfileTemplate + + + + ConvertTo-OVServerProfileTemplate + + + + Copy-OVServerProfile + + + + Get-OVServerProfile + + + + Get-OVServerProfileConnectionList + + + + Get-OVServerProfileMessage + + + + Get-OVServerProfileTemplate + + + + Join-OVServerProfileToTemplate + + + + New-OVServerProfile + + + + New-OVServerProfileAssign + + + + New-OVServerProfileAttachVolume + + + + New-OVServerProfileConnection + + + + New-OVServerProfileLogicalDisk + + + + New-OVServerProfileLogicalDiskController + + + + New-OVServerProfileTemplate + + + + Remove-OVServerProfileTemplate + + + + Save-OVServerProfile + + + + Save-OVServerProfileTemplate + + + + Set-OVServerProfile + + + + Set-OVServerProfileTemplate + + + + Update-OVServerProfile + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/servers/remove-ovserverprofile + + + + + + + + Remove-OVServerProfileTemplate + + Delete Server Profile Template Resource(s). + + Remove + OVServerProfileTemplate + + + Delete one or multiple Server Profile Template resource(s). A Server Profile Template cannot be removed if there are linked Server Profiles. + + + + + Remove-OVServerProfileTemplate + + InputObject + + The server profile template object(s) or name(s) to be removed. + + Object + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + + Force + + Set to force-delete the profile. For example, force-remove will successfully remove the profile, even when connectivity has been lost to the server or enclosure. + + SwitchParameter + + + WhatIf + + + + SwitchParameter + + + Confirm + + + + SwitchParameter + + + + + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Confirm + + + + SwitchParameter + + SwitchParameter + + + + + Force + + Set to force-delete the profile. For example, force-remove will successfully remove the profile, even when connectivity has been lost to the server or enclosure. + + SwitchParameter + + SwitchParameter + + False + + + InputObject + + The server profile template object(s) or name(s) to be removed. + + Object + + Object + + + + + WhatIf + + + + SwitchParameter + + SwitchParameter + + + + + + + + + HPEOneView.ServerProfileTemplate [System.Management.Automation.PSCustomObject] + + + Server Profile Template resource object. + + + + + System.String + + + Server Profile Template resource name. + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + A task resource that can be monitored for status of the profile deletion + + + + + System.Collections.ArrayList <HPEOneView.Appliance.TaskResource> + + + + Multiple Async task resources. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + $task = Remove-OVServerProfileTemplate -ServerProfileTemplate "My Template Profile" +Wait-OVTaskComplete -InputObject $task + + + Remove the profile template specifed by name. Wait for remove to complete. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + $spt = Get-OVServerProfileTemplate -name "My Template Profile" -ErrorAction Stop +Remove-OVServerProfileTemplate $spt -Confirm:$false + + Remove the profile template specifed by $spt. Disable confirmation prompt. + + + + + + + + + + -------------------------- EXAMPLE 3 -------------------------- + + + + Get-OVServerProfileTemplate | Remove-OVServerProfileTemplate + + Search for all profile template resources and remove them from appliance. + + + + + + + + + + + + + Convert-OVServerProfileTemplate + + + + ConvertTo-OVServerProfileTemplate + + + + Get-OVServerProfileTemplate + + + + New-OVServerProfileTemplate + + + + Save-OVServerProfileTemplate + + + + Set-OVServerProfileTemplate + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/servers/remove-ovserverprofiletemplate + + + + + + + + Remove-OVSmtpAlertEmailFilter + + Remove an existing SMTP email alert filter. + + Remove + OVSmtpAlertEmailFilter + + + Email alerting feature notifies specified recipients when a certain alert occurs. When this feature is configured and enabled, the appliance performs these steps in addition to posting the alert: + + * The appliance compares the alert to configured search criteria. + * If the alert matches, it creates an email message containing the text of the alert. + * The appliance sends the email message to designated recipients in both plain text and HTML MIME types. Sending in both types allows the recipient?s mail application to determine the display. + +You can enable or disable this email notification feature, or you can enable or disable individual filter notifications, as required. + +The appliance provides for as many as 100 recipient and filter combinations, and allows as many as 50 recipients in a single email message. This flexibility lets you fine-tune which alert messages are sent and to whom. For example, you can configure the appliance to send Warning alerts to one recipient and Critical alerts to another. + +This Cmdlet will remove configured email alert filters from the appliance. + +Minimum required privileges: Infrastructure administrator. + + + + + Remove-OVSmtpAlertEmailFilter + + InputObject + + The email alert filter from Get-OVSmtpAlertEmailFilter. + + Object + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + WhatIf + + + + + + + Confirm + + + + + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Confirm + + + + + + + + + + + InputObject + + The email alert filter from Get-OVSmtpAlertEmailFilter. + + Object + + Object + + + + + WhatIf + + + + + + + + + + + + + + + HPEOneView.Appliance.AlertEmailFilter [System.Management.Automation.PSCustomObject] + + + The configured email alert filter on the appliance. + + + + + + + + + HPEOneView.Appliance.TaskResource {System.Management.Automation.PSCustomObject} + + + + Returns an async task resource to monitor. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVSmtpAlertEmailFilter -Name "Monitor CPU Error and Warning conditions" | Remove-OVSmtpAlertEmailFilter + + Remove the specified email alert filter. + + + + + + + + + + + + + Get-OVSMTPConfig + + + + Set-OVSMTPConfig + + + + Test-OVEmailAlert + + + + Add-OVSmtpAlertEmailFilter + + + + Get-OVSmtpAlertEmailFilter + + + + Set-OVSmtpAlertEmailFilter + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/remove-ovsmtpalertemailfilter + + + + + + + + Remove-OVSnmpV3User + + Remove SNMPv3 user from appliance. + + Remove + OVSnmpV3User + + + HPE OneView can be used as a proxy to forward device traps from servers and enclosures (OA) to other SNMP-enabled applications on the network. HPE OneView can forward traps, as SNMPv3 or SNMPv1 traps, to configured destinations. + +Appliance SNMP settings allow you to add destinations to which the traps need to be forwarded. You can configure each destination as an SNMPv1 or SNMPv3 destination, depending on whether the traps are sent in SNMPv1 or SNMPv3 formats. + +Additionally, if you have Gen6 or Gen7 servers being monitored by HPE OneView in your environment, you can configure the read community string that HPE OneView uses for monitoring these servers with SNMPv1. + +NOTE: To configure SNMP trap forwarding for network devices (interconnects and switches), use the New-OVSnmpV3User and include it within the New-OVSnmpTrapDestination Cmdlet. + +Minimum required privileges: Infrastructure administrator + + + + + Remove-OVSnmpV3User + + InputObject + + SNMPv3 user account from Get-OVSnmpV3User. + + HPEOneView.Appliance.SnmpV3User + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + + WhatIf + + + + SwitchParameter + + + Confirm + + Override confirmation prompt. + + SwitchParameter + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + Array + + (${Global:ConnectedSessions} | ? Default) + + + Confirm + + Override confirmation prompt. + + SwitchParameter + + SwitchParameter + + + + + InputObject + + SNMPv3 user account from Get-OVSnmpV3User. + + HPEOneView.Appliance.SnmpV3User + + HPEOneView.Appliance.SnmpV3User + + + + + WhatIf + + + + SwitchParameter + + SwitchParameter + + + + + + + + + HPEOneView.Appliance.SnmpV3User + + + Appliance SNMPv3 user account from Get-OVSnmpV3User. + + + + + + + + System.Management.Automation.PSCustomObject + + + + Success message of deleted resource. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + $Snmpv3User = Get-OVSnmpV3User -Name Tr@pUser -ErrorAction Stop | Remove-OVSnmpV3User + + Remove the specific SNMPv3 user account on the appliance. + + + + + + + + + + + + + Get-OVSnmpV3User + + + + New-OVSnmpV3User + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/library/remove-ovsnmpv3user + + + + + + + + Remove-OVStandbyComposerNode + + Remove Standby Composer node. + + Remove + OVStandbyComposerNode + + + This Cmdlet will help remove the Standby Composer node from the Synergy management ring. In order to remove the Active node from the Synergy management ring, you first must use the Enable-OVComposerHANode Cmdlet to transition the Standby node to the Active role. + + + + + Remove-OVStandbyComposerNode + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. + + Object + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + WhatIf + + + + SwitchParameter + + + Confirm + + + + SwitchParameter + + + + + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. + + Object + + Object + + (${Global:ConnectedSessions} | ? Default -eq $true) + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + SwitchParameter + + False + + + Confirm + + + + SwitchParameter + + SwitchParameter + + + + + WhatIf + + + + SwitchParameter + + SwitchParameter + + + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + None. You cannot pipe objects to this Cmdlet + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + The Async task resource of the remove standby node request + + + + + System.Collections.ArrayList <HPEOneView.Appliance.TaskResource> + + + + Multiple Async task resources + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Remove-OVStandbyComposerNode + + Remove the Standby Composer node in the default Appliance Connection. + + + + + + + + + + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/remove-ovstandbycomposernode + + + + + + + + Remove-OVStoragePool + + Delete storage pool resource(s). + + Remove + OVStoragePool + + + Delete one or more storage pools from the appliance configuration. + + + + + Remove-OVStoragePool + + InputObject + + The network object(s) or name(s) to be removed on the appliance. + + Object + + + Force + + If specified, the Storage Pool resource will forceablly removed despite any problems with network connectivity or errors with the resource. + + SwitchParameter + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + + WhatIf + + + + SwitchParameter + + + Confirm + + + + SwitchParameter + + + + Remove-OVStoragePool + + InputObject + + The network object(s) or name(s) to be removed on the appliance. + + Object + + + StorageSystem + + Provide the Storage System Name, URI or Object when the StoragePool name is not unique. + + Object + + + Force + + If specified, the Storage Pool resource will forceablly removed despite any problems with network connectivity or errors with the resource. + + SwitchParameter + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + + WhatIf + + + + SwitchParameter + + + Confirm + + + + SwitchParameter + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Confirm + + + + SwitchParameter + + SwitchParameter + + + + + Force + + If specified, the Storage Pool resource will forceablly removed despite any problems with network connectivity or errors with the resource. + + SwitchParameter + + SwitchParameter + + False + + + InputObject + + The network object(s) or name(s) to be removed on the appliance. + + Object + + Object + + + + + StorageSystem + + Provide the Storage System Name, URI or Object when the StoragePool name is not unique. + + Object + + Object + + + + + WhatIf + + + + SwitchParameter + + SwitchParameter + + + + + + + + + HPEOneView.Storage.System.Pool [System.Management.Automation.PSCustomObject] + + + Single Storage Pool resource, typically retrieved with Get-OVStoragePool + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + Removal task + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + $task = Remove-OVStoragePool -storagePool "yellow" | Wait-OVTaskComplete $task + + Remove the storage pool specifed by name. Wait for remove to complete. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + $pool = Get-OVStoragePool -name "yellow" +Remove-OVStoragePool -storagePool $pool -confirm:$false + + Remove the network specifed by $pool, and do not prompt for confirmation. + + + + + + + + + + -------------------------- EXAMPLE 3 -------------------------- + + + + Get-OVStoragePool | Remove-OVStoragePool + + Search for all storage pools and remove them from appliance. + + + + + + + + + + + + + Add-OVStoragePool + + + + Get-OVStoragePool + + + + Set-OVStoragePool + + + + Update-OVStoragePool + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/storage/remove-ovstoragepool + + + + + + + + Remove-OVStorageSystem + + Remove a Storage System + + Remove + OVStorageSystem + + + This Cmdlet will assist with removing a discovered and managed storage system from the appliance. + + + + + Remove-OVStorageSystem + + InputObject + + Name or URI of the managed storage system. + + Object + + + force + + Switch to force removal of a storage system the appliance can no longer communicate with. + + SwitchParameter + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + + WhatIf + + + + SwitchParameter + + + Confirm + + + + SwitchParameter + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Confirm + + + + SwitchParameter + + SwitchParameter + + + + + InputObject + + Name or URI of the managed storage system. + + Object + + Object + + + + + WhatIf + + + + SwitchParameter + + SwitchParameter + + + + + force + + Switch to force removal of a storage system the appliance can no longer communicate with. + + SwitchParameter + + SwitchParameter + + False + + + + + + + HPEOneView.Storage.System [System.Management.Automation.PSCustomObject] + + + Storage System resource object + + + + + System.Collections.ArrayList <HPEOneView.Storage.System> + + + Collections of Storage System resource objects + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + Returns an async task resource to monitor. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Remove-OVStorageSystem HP3PAR_2 + + Remove "HP3PAR_2" storage system from the appliance. + + + + + + + + + + + + + Add-OVStorageSystem + + + + Get-OVStorageSystem + + + + Show-OVStorageSystemPerformancePolicy + + + + Update-OVStorageSystem + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/storage/remove-ovstoragesystem + + + + + + + + Remove-OVStorageVolume + + Remove a Storage Volume + + Remove + OVStorageVolume + + + This Cmdlet will remove storage volumes from the HPE OneView appliance. Volumes must first be removed from attached Server Profiles prior to deleting the Storage Volume. + + + + + Remove-OVStorageVolume + + InputObject + + Storage Volume Name, URI or Object. + + Object + + + ExportOnly + + Removes the volume from HPE OneView. The volume remains on the storage system, and must be managed manually until it is added back under management of HPE OneView. +Default: Delete Export AND Volume from storage system. + + SwitchParameter + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + + WhatIf + + + + SwitchParameter + + + Confirm + + + + SwitchParameter + + + + + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + SwitchParameter + + false + + + Confirm + + + + SwitchParameter + + SwitchParameter + + + + + ExportOnly + + Removes the volume from HPE OneView. The volume remains on the storage system, and must be managed manually until it is added back under management of HPE OneView. +Default: Delete Export AND Volume from storage system. + + SwitchParameter + + SwitchParameter + + False + + + InputObject + + Storage Volume Name, URI or Object. + + Object + + Object + + + + + WhatIf + + + + SwitchParameter + + SwitchParameter + + + + + + + + + HPEOneView.Storage.System.Volume [System.Management.Automation.PSCustomObject] + + + Storage Volume resource object + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + Async removal task + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + $VolumeToRemove = Get-OVStorageVolume -Name TestVol1 -ErrorAction Stop +Remove-OVStorageVolume -InputObject $VolumeToRemove + + Remove export and delete volume named "TestVol1". + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Get-OVStorageVolume -Name TestVol1 -ErrorAction Stop | Remove-OVStorageVolume -exportonly + + Remove export of volume named "TestVol1" only, which leaves the volume still provisioned on the array and is added back to the HPE OneView Storage Volumes pool. + + + + + + + + + + + + + Add-OVStorageVolume + + + + ConvertTo-OVStorageVolume + + + + Get-OVStorageVolume + + + + Get-OVStorageVolumeSet + + + + Get-OVStorageVolumeSnapShot + + + + Get-OVStorageVolumeTemplate + + + + Get-OVStorageVolumeTemplatePolicy + + + + New-OVStorageVolume + + + + New-OVStorageVolumeSnapshot + + + + New-OVStorageVolumeTemplate + + + + Remove-OVStorageVolumeSnapshot + + + + Remove-OVStorageVolumeTemplate + + + + Set-OVStorageVolume + + + + Set-OVStorageVolumeTemplate + + + + Set-OVStorageVolumeTemplatePolicy + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/storage/remove-ovstoragevolume + + + + + + + + Remove-OVStorageVolumeSnapshot + + Remove storage volume snapshot resource(s). + + Remove + OVStorageVolumeSnapshot + + + This Cmdlet will remove a storage volume snapshot from a storage volume resource object. Removal of a snapshot is a destructive operation of the snapshot only. + + + + + Remove-OVStorageVolumeSnapshot + + InputObject + + Provide the snapshot resource object to remove from the appliance. + + Object + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + +Default Value: ${Global:ConnectSessions} | ? Default + + Object + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + WhatIf + + + + SwitchParameter + + + Confirm + + + + SwitchParameter + + + + + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + +Default Value: ${Global:ConnectSessions} | ? Default + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + SwitchParameter + + false + + + Confirm + + + + SwitchParameter + + SwitchParameter + + + + + InputObject + + Provide the snapshot resource object to remove from the appliance. + + Object + + Object + + + + + WhatIf + + + + SwitchParameter + + SwitchParameter + + + + + + + + + HPEOneView.Storage.VolumeSnapshot [System.Management.Automation.PSCustomObject] + + + Storage Volume Snapshot resource + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + Async create task resource + + + + + System.Collections.ArrayList <HPEOneView.Appliance.TaskResource> + + + + Multiple task resources + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + $Snapshots = Get-OVStorageVolume -Name "Volume 1" -ErrorAction Stop | Get-OVStorageVolumeSnapshot +$Snapshots | ? { ((get-date) - (Get-Date $_.created)).days -ge 5 } | Remove-OVStorageVolumeSnapshot + + Get all of the available storage volume snapshots for "Volume 1", then remove any snapshots as old or older than 5 days. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Get-OVStorageVolume | Get-OVStorageVolumeSnapshot | Remove-OVStorageVolumeSnapshot + + Remove all Storage Volume Snapshots managed by HPE OneView. + + + + + + + + + + + + + Get-OVStorageVolumeSnapShot + + + + New-OVStorageVolumeSnapshot + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/storage/remove-ovstoragevolumesnapshot + + + + + + + + Remove-OVStorageVolumeTemplate + + Delete storage volume template(s) from appliance configuration. + + Remove + OVStorageVolumeTemplate + + + Delete one or more storage volume templates from the appliance configuration. + + + + + Remove-OVStorageVolumeTemplate + + InputObject + + Aliases [-name, -uri, -TemplateName., -Template] +The Storage Volume Template object(s), name(s) or URI(s) to be deleted. + + Object + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + +Default Value: ${Global:ConnectSessions} + + Object + + + Force + + Specify to remove the resource despite any problems with network connectivity or errors on the resource itself. + +When the request is accepted by the appliance, it does not return an Async Task Resource. + + SwitchParameter + + + WhatIf + + + + SwitchParameter + + + Confirm + + + + SwitchParameter + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + +Default Value: ${Global:ConnectSessions} + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Confirm + + + + SwitchParameter + + SwitchParameter + + + + + Force + + Specify to remove the resource despite any problems with network connectivity or errors on the resource itself. + +When the request is accepted by the appliance, it does not return an Async Task Resource. + + SwitchParameter + + SwitchParameter + + False + + + InputObject + + Aliases [-name, -uri, -TemplateName., -Template] +The Storage Volume Template object(s), name(s) or URI(s) to be deleted. + + Object + + Object + + + + + WhatIf + + + + SwitchParameter + + SwitchParameter + + + + + + + + + System.Management.Automation.PSCustomObject + + + Storage Volume Template resource object + + + + + System.Collections.ArrayList + + + Multiple Storage Volume Template resources + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + Removal async task + + + + + System.Management.Automation.PSCustomObject + + + + When using the -Force parameter, a PSCustomObject is returned indicating successful removal of the resource + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + $task = Remove-OVStorageVolumeTemplate -storagePool "yellow" | Wait-OVTaskComplete + + Remove the storage volume template specifed by name. Wait for remove to complete. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + $svt = Get-OVStorageVolumeTemplate -name "yellow" +Remove-OVStorageVolumeTemplate -name $svt -confirm:$false + + Remove the network specifed by $svt, and do not prompt for confirmation. + + + + + + + + + + -------------------------- EXAMPLE 3 -------------------------- + + + + Get-OVStoragVolumeTemplate | Remove-OVStorageVolumeTemplate + + Search for all storage volume templates and remove them from appliance. + + + + + + + + + + + + + Get-OVStorageVolumeTemplate + + + + Get-OVStorageVolumeTemplatePolicy + + + + New-OVStorageVolumeTemplate + + + + Set-OVStorageVolumeTemplate + + + + Set-OVStorageVolumeTemplatePolicy + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/storage/remove-ovstoragevolumetemplate + + + + + + + + Remove-OVUnmanagedDevice + + Remove an Unmanaged Device. + + Remove + OVUnmanagedDevice + + + Use this Cmdlet to remove an Unmanaged Device from the appliance. + + + + + Remove-OVUnmanagedDevice + + UnmanagedDevice + + Alias [-name, -uri] + +The Name, URI or Object of the Unmanaged Device to remove. + + Object + + + force + + Set to force-remove the resource. + +When the request is accepted by the appliance, it does not return an Async Task Resource. + + SwitchParameter + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + + WhatIf + + + + SwitchParameter + + + Confirm + + + + SwitchParameter + + + + + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Confirm + + + + SwitchParameter + + SwitchParameter + + + + + UnmanagedDevice + + Alias [-name, -uri] + +The Name, URI or Object of the Unmanaged Device to remove. + + Object + + Object + + + + + WhatIf + + + + SwitchParameter + + SwitchParameter + + + + + force + + Set to force-remove the resource. + +When the request is accepted by the appliance, it does not return an Async Task Resource. + + SwitchParameter + + SwitchParameter + + False + + + + + + + HPEOneView.UnmanagedResource [System.Management.Automation.PSCustomObject] + + + Unmanaged Device resource object + + + + + + + + System.Management.Automation.PSCustomObject + + + + When using the -Force parameter, a PSCustomObject is returned indicating successful removal of the resource + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Remove-OVUnmanagedDevice MyDevice + + Remove the Unmanaged Device "MyDevice" from the appliance. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Remove-OVUnmanagedDevice MyDevice -confirm:$false + + Remove the Unmanaged Device "MyDevice" from the appliance and do not prompt for confirmation. + + + + + + + + + + -------------------------- EXAMPLE 3 -------------------------- + + + + Get-OVUnmanagedDevice | Remove-OVUnmanagedDevice + + Get all Unmanaged Devices on the appliance and remove them. + + + + + + + + + + + + + Get-OVUnmanagedDevice + + + + New-OVUnmanagedDevice + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/facilities/remove-ovunmanageddevice + + + + + + + + Remove-OVUser + + Remove a user account. + + Remove + OVUser + + + Remove a specific local user account from the management appliance + + + + + Remove-OVUser + + InputObject + + The user account object to be removed. + + Object + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + + WhatIf + + + + SwitchParameter + + + Confirm + + + + SwitchParameter + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Confirm + + + + SwitchParameter + + SwitchParameter + + + + + InputObject + + The user account object to be removed. + + Object + + Object + + + + + WhatIf + + + + SwitchParameter + + SwitchParameter + + + + + + + + + HPEOneView.Appliance.User [System.Management.Automation.PSCustomObject] + + + HPE OneView User Account object created on an appliance + + + + + + + + System.Collections.Hashtable + + + + Success message if user was deleted + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVUser Sally | Remove-OVUser + + Retrieve "Sally" user account using Get-OVUser, then pipe it to Remove-OVUser. + + + + + + + + + + + + + Get-OVUser + + + + New-OVUser + + + + Set-OVUser + + + + Set-OVUserPassword + + + + Set-OVUserRole + + + + Show-OVUserSession + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/security/remove-ovuser + + + + + + + + Reset-OVEnclosureDevice + + Power reset or EFuse HPE Synergy Frame component. + + Reset + OVEnclosureDevice + + + This Cmdlet will assist server administrators in performing various power operations with HPE Synergy enclosure resources. The following resources are supported with their supported operation: + + * HPE Synergy Appliance Bay - EFuse + * HPE Synergy Frame Link Module - EFuse or Reset + * Device Bay - EFuse or Reset + * HPE Synergy Fabric Module Device - EFuse + +E-Fuse stands for Electronic Fuse. Setting the power state of a device to "E-Fuse" (or "Reset" for an Enclosure Manager) will reset the bay, but it will soon return to a normal running state. An E-Fuse will turn off power to the bay and then turn it back on. If the bay was powered off before the E-Fuse operation it will be powered on afterwards. A "Reset" will do a hard reset of the bay without affecting the power. E-Fuse on a device bay will power-cycle the whole blade including the iLO. + +A reset on the active Synergy Frame Link Module causes a failover to the standby Synergy Frame Link Module. The reset will fail if the Synergy Frame Link Module's firmware is being updated. An E-Fuse against an active Synergy Frame Link Module is not allowed. + +Minimum required privileges: Infrastructure administrator, Server administrator + + + + + Reset-OVEnclosureDevice + + InputObject + + The Synergy Frame resource from Get-OVEnclosure. + + Object + + + Component + + The embedded component to perform the action against. Allowed value: + +* FLM - Frame Link Module. Both EFuse and Reset are supported. +* Appliance - Management Appliance; Synergy Compser or Synergy Image Streamer. Only supported method is EFuse. +* ICM - Synergy Fabric Interconnect Module. Only supported method is EFuse. +* Device - Synergy Device (e.g. Compute Node populated in Bay 1). Both EFuse and Reset are supported. + + String + + + DeviceID + + The corrisponding bay ID. + + Int32 + + + Efuse + + EFuse will take away and then present power back to the device. Supported with all component types. + + SwitchParameter + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + +Default Value: ${Global:ConnectSessions} + + Object + + + WhatIf + + + + SwitchParameter + + + Confirm + + + + SwitchParameter + + + + Reset-OVEnclosureDevice + + InputObject + + The Synergy Frame resource from Get-OVEnclosure. + + Object + + + Component + + The embedded component to perform the action against. Allowed value: + +* FLM - Frame Link Module. Both EFuse and Reset are supported. +* Appliance - Management Appliance; Synergy Compser or Synergy Image Streamer. Only supported method is EFuse. +* ICM - Synergy Fabric Interconnect Module. Only supported method is EFuse. +* Device - Synergy Device (e.g. Compute Node populated in Bay 1). Both EFuse and Reset are supported. + + String + + + DeviceID + + The corrisponding bay ID. + + Int32 + + + Reset + + Reset power to the device. Only supported with certain component types. + + SwitchParameter + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + +Default Value: ${Global:ConnectSessions} + + Object + + + WhatIf + + + + SwitchParameter + + + Confirm + + + + SwitchParameter + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + +Default Value: ${Global:ConnectSessions} + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + SwitchParameter + + False + + + Component + + The embedded component to perform the action against. Allowed value: + +* FLM - Frame Link Module. Both EFuse and Reset are supported. +* Appliance - Management Appliance; Synergy Compser or Synergy Image Streamer. Only supported method is EFuse. +* ICM - Synergy Fabric Interconnect Module. Only supported method is EFuse. +* Device - Synergy Device (e.g. Compute Node populated in Bay 1). Both EFuse and Reset are supported. + + String + + String + + + + + Confirm + + + + SwitchParameter + + SwitchParameter + + + + + DeviceID + + The corrisponding bay ID. + + Int32 + + Int32 + + 0 + + + Efuse + + EFuse will take away and then present power back to the device. Supported with all component types. + + SwitchParameter + + SwitchParameter + + False + + + InputObject + + The Synergy Frame resource from Get-OVEnclosure. + + Object + + Object + + + + + Reset + + Reset power to the device. Only supported with certain component types. + + SwitchParameter + + SwitchParameter + + False + + + WhatIf + + + + SwitchParameter + + SwitchParameter + + + + + + + + + HPEOneView.Enclosure + + + Resource from Get-OVEnclosure. + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + Asynchronous task resource to monitor + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + $Enclosure = Get-OVEnclosure -Name Enclosure1 -ErrorAction Stop +Reset-OVEnclosureDevice -Enclosure $Enclosure -Component FLM -DeviceID 1 -EFuse + + Reset the FLM in slot 1 by performing an EFuse. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + $Enclosure = Get-OVEnclosure -Name Enclosure1 -ErrorAction Stop +Reset-OVEnclosureDevice -Enclosure $Enclosure -Component ICM -DeviceID 3 -EFuse + + Reset the ICM in interconnect bay 3 by performing an EFuse. + + + + + + + + + + -------------------------- EXAMPLE 3 -------------------------- + + + + $Task = Get-OVEnclosure -Name Enclosure1 -ErrorAction Stop | Reset-OVEnclosureDevice -Component Device -DeviceID 4 -Reset + + Reset the device in bay 4 by requesting it to reset itself. + + + + + + + + + + -------------------------- EXAMPLE 4 -------------------------- + + + + $Task = Get-OVEnclosure -Name Enclosure1 -ErrorAction Stop | Reset-OVEnclosureDevice -Component Appliance -DeviceID 1 -EFuse + + Reset the appliance device in bay 1 by performing an EFuse. + + + + + + + + + + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/servers/reset-ovenclosuredevice + + + Get-OVEnclosure + + + + Start-OVEnclosureAppliance + + + + + + + + + Reset-OVInterconnectNetOpPassword + + Reset HPE Synergy Virtual Connect NetOp account password. + + Reset + OVInterconnectNetOpPassword + + + *** THIS CMDLET SHOULD NOT BE EXECUTED WITHOUT GUIDANCE FROM HPE CUSTOMER SUPPORT CENTER *** + +This Cmdlet will reset the HPE Synergy Virtual Connect NetOp account password to the specified value. + +Minimum required privileges: Infrastructure administrator, Network administrator + + + + + Reset-OVInterconnectNetOpPassword + + InputObject + + The Interconnect from Get-OVInterconnect Cmdlet. + + Object + + + Password + + The password in System.Security.SecureString format. + + System.Security.SecureString + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + SwitchParameter + + False + + + InputObject + + The Interconnect from Get-OVInterconnect Cmdlet. + + Object + + Object + + + + + Password + + The password in System.Security.SecureString format. + + System.Security.SecureString + + System.Security.SecureString + + + + + + + + + HPEOneView.Networking.Interconnect [System.Management.Automation.PSCustomObject] + + + Interconnect resource from Get-OVInterconnect. + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + Async task that tracks the operation. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + $NetOpPassword = Read-Host -Message "New password: " -AsSecureString +$InterconnectObject = Get-OVInterconnect -Name MyEncl1-Ethernet-LIG1 +Reset-OVInterconnectNetOpPassword -InputObject $InterconnectObject -Password $NetOpPassword + + Set the NetOp password to the new value, for the specific Interconnect. + + + + + + + + + + + + + Get-OVInterconnect + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/networking/reset-ovinterconnectnetoppassword + + + + + + + + Restart-OVAppliance + + Restart an HPE OneView appliance. + + Restart + OVAppliance + + + This Cmdlet will allow the administrator to restart/reboot the appliance. Restarting the appliance will cause all users to be disconnected and all ongoing tasks to be interrupted. + +Only the Infrastructure (Full) Administrator may restart the appliance. + + + + + Restart-OVAppliance + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + + WhatIf + + + + SwitchParameter + + + Confirm + + + + SwitchParameter + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + Array + + (${Global:ConnectedSessions} | ? Default) + + + Confirm + + + + SwitchParameter + + SwitchParameter + + + + + WhatIf + + + + SwitchParameter + + SwitchParameter + + + + + + + + + HPEOneView.Appliance.Connection + + + Appliance Connection object + + + + + System.Collections.ArrayList + + + Collection of HPEOneView.Appliance.Connection objects + + + + + + + + System.String + + + + Warning message the appliance is stopping + + + + + Management.Automation.ErrorRecord + + + + Generated error message + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Connect-OVMgmt appliance.contoso.com Administrator P@ssw0rd +Restart-OVAppliance + + Restart the appliance + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Restart-OVAppliance -confirm:$false + + Restart all connected appliances without confirmation. + + + + + + + + + + + + + Add-OVApplianceTrustedCertificate + + + + Disable-OVApplianceComplexPasswords + + + + Disable-OVApplianceServiceConsoleAccess + + + + Disable-OVApplianceSshAccess + + + + Disable-OVApplianceTwoFactorAuthentication + + + + Enable-OVApplianceComplexPasswords + + + + Enable-OVApplianceServiceConsoleAccess + + + + Enable-OVApplianceSshAccess + + + + Get-OVApplianceAuditLogForwarding + + + + Get-OVApplianceAvailableSecurityMode + + + + Get-OVApplianceCertificateStatus + + + + Get-OVApplianceCurrentSecurityMode + + + + Get-OVApplianceDateTime + + + + Get-OVApplianceGlobalSetting + + + + Get-OVApplianceNetworkConfig + + + + Get-OVApplianceProxy + + + + Get-OVApplianceSecurityProtocol + + + + Get-OVApplianceServiceConsoleAccess + + + + Get-OVApplianceSnmpV3EngineId + + + + Get-OVApplianceSshAccess + + + + Get-OVApplianceTrapDestination + + + + Get-OVApplianceTrustedCertificate + + + + Get-OVApplianceTwoFactorAuthentication + + + + Install-OVApplianceCertificate + + + + New-OVApplianceCsr + + + + New-OVApplianceSelfSignedCertificate + + + + New-OVApplianceTrapDestination + + + + Pop-OVAppliancePermission + + + + Push-OVAppliancePermission + + + + Remove-OVApplianceProxy + + + + Remove-OVApplianceTrapDestination + + + + Remove-OVApplianceTrustedCertificate + + + + Set-OVApplianceAuditLogForwarding + + + + Set-OVApplianceCurrentSecurityMode + + + + Set-OVApplianceDateTime + + + + Set-OVApplianceDefaultConnection + + + + Set-OVApplianceGlobalSetting + + + + Set-OVApplianceNetworkConfig + + + + Set-OVApplianceProxy + + + + Set-OVApplianceSecurityProtocol + + + + Set-OVApplianceSnmpV3EngineId + + + + Set-OVApplianceTwoFactorAuthentication + + + + Show-OVApplianceSecurityModeCompatibilityReport + + + + Stop-OVAppliance + + + + Test-OVApplianceAuditLogForwarding + + + + Update-OVApplianceTrustedAuthorityCrl + + + + Wait-OVApplianceStart + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/restart-ovappliance + + + + + + + + Restart-OVServer + + Restart Server Resource. + + Restart + OVServer + + + Restart the power state of the server using the virtual power button. By default, the Cmdlet will request a "Reset" request to initiate a server to restart. Using the ColdBoot will take away and present power back to the server resource. + + + + + Restart-OVServer + + Server + + A Server hardware or Server Profile resource object. + + Object + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + + WhatIf + + + + SwitchParameter + + + Confirm + + + + SwitchParameter + + + + Restart-OVServer + + Server + + A Server hardware or Server Profile resource object. + + Object + + + ColdBoot + + Use this parameter to request power be forcably removed then represented to the server resource. + + SwitchParameter + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + + WhatIf + + + + SwitchParameter + + + Confirm + + + + SwitchParameter + + + + + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + SwitchParameter + + False + + + ColdBoot + + Use this parameter to request power be forcably removed then represented to the server resource. + + SwitchParameter + + SwitchParameter + + False + + + Confirm + + + + SwitchParameter + + SwitchParameter + + + + + Server + + A Server hardware or Server Profile resource object. + + Object + + Object + + + + + WhatIf + + + + SwitchParameter + + SwitchParameter + + + + + + + + + HPEOneView.ServerHardware [System.Management.Automation.PSCustomObject] + + + Server Hardware Resource + + + + + HPEOneView.ServerProfile [System.Management.Automation.PSCustomObject] + + + Server Profile Resource + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + Async task that tracks the power state change + + + + + System.Collections.ArrayList <HPEOneView.Appliance.TaskResource> + + + + Multiple Async tasks + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVServer -Name "Encl1, Bay 1" | Restart-OVServer | Wait-OVTaskComplete + + Restart the specific server device by passing the Server Object via pipeline. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Get-OVServerProfile -Name "MyWebServer 1" | Restart-OVServer | Wait-OVTaskComplete + + Restart the specific server device by passing the Server Profile Object via pipeline. + + + + + + + + + + -------------------------- EXAMPLE 3 -------------------------- + + + + Get-OVServer -Name "Encl1, Bay 1" | Restart-OVServer -ColdBoot | Wait-OVTaskComplete + + Restart the specific server device by passing the Server Object via pipeline, and issue a cold boot request. + + + + + + + + + + + + + Add-OVServer + + + + Convert-OVServerProfile + + + + Convert-OVServerProfileTemplate + + + + ConvertTo-OVServerProfileTemplate + + + + Copy-OVServerProfile + + + + Get-OVServer + + + + Get-OVServerHardwareType + + + + Get-OVServerProfile + + + + Get-OVServerProfileConnectionList + + + + Get-OVServerProfileMessage + + + + Get-OVServerProfileTemplate + + + + Join-OVServerProfileToTemplate + + + + New-OVServerProfile + + + + New-OVServerProfileAssign + + + + New-OVServerProfileAttachVolume + + + + New-OVServerProfileConnection + + + + New-OVServerProfileLogicalDisk + + + + New-OVServerProfileLogicalDiskController + + + + New-OVServerProfileTemplate + + + + Remove-OVServer + + + + Remove-OVServerProfile + + + + Remove-OVServerProfileTemplate + + + + Save-OVServerProfile + + + + Save-OVServerProfileTemplate + + + + Set-OVServerHardwareType + + + + Set-OVServerPower + + + + Set-OVServerProfile + + + + Set-OVServerProfileTemplate + + + + Start-OVServer + + + + Stop-OVServer + + + + Update-OVServer + + + + Update-OVServerHardwareLicenseIntent + + + + Update-OVServerProfile + + + + Get-OVServerOneTimeBoot + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/servers/restart-ovserver + + + + + + + + Restore-OVCustomBaseline + + Restore a Custom Baseline after Restore of a Backup File. + + Restore + OVCustomBaseline + + + This Cmdlet provides the ability to restore custom SPP Baselines that were created with component hotfixes on the appliance after a backup file restore procedure has completed. It will search for any custom Baseline resources that are in the "Removed" state, and rebuild the baseline with the associated hotfixes. + +The source baseline and associated hotfixes must be present within the Baseline repository. Use the Add-OVBaseline to upload the starting Baseline and hotfixes after restoring the Appliance Backup file, then use this Cmdlet to rebuild the Custom Baseline. + + + + + Restore-OVCustomBaseline + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + None. You cannot pipe objects to this Cmdlet + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + The progress of in-progress or completion result + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Restore-OVCustomBaseline + + Restore all Custom Baselines that were previously created on all connected appliances. + + + + + + + + + + + + + New-OVCustomBaseline + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/restore-ovcustombaseline + + + + + + + + Save-OVApplianceDataAtRestEncryptionKey + + Generate a new HPE Synergy Composer appliance encryption key. + + Save + OVApplianceDataAtRestEncryptionKey + + + HPE OneView encrypts sensitive data, such as managed device credentials, when it is stored on-disk in the appliance. The HPE OneView appliance encryption key (AEK) is used internally to encrypt the credentials for managed devices (such as, iLO, onboard administrator, frame link module). By default, the AEK is stored on the HPE Synergy Composer disk and also included in the appliance backup. This could pose a security risk in case the disk is stolen. + +The secure data-at-rest option, when enabled, stores the AEK off-disk in Composer NVRAM, and does not include the key in the appliance backup. Enabling this option requires the administrator to save a copy of the AEK (recovery AEK) for use in the following circumstances: + +* When restoring a backup taken when a different AEK was in effect. +* To successfully boot the system in the unlikely event that the system copy of the key is corrupted. +* A backup is being restored to a different new Composer or to the same Composer that has been factory reset. + +The administrator must store the recovery AEK in a secure location, where it can be only accessed by authorized personnel. In the rare circumstance where the key cannot be read from the Composer NVRAM or the key gets corrupted, the administrator must use the appliance maintenance console to upload the AEK recovery copy, based on the error resolution message displayed. In the rare circumstance where the Composer NVRAM itself becomes inaccessible, users can choose to disable secure-data-at-rest option until the hardware issue itself is resolved. + +If the downloaded recovery key and the AEK stored in the Composer NVRAM are both lost, the appliance data cannot be recovered. + +This Cmdlet will generate a new encryption key, if the existing encryption key is lost or unknown. Any existing backups that were created with the prior encryption key will become invalid. After creating a new encryption key, it is highly recommended to create a new backup using New-OVBackup and save it, along with the new encryption key file that can be generated by this Cmdlet by using the -Location parameter, to a secure and safe location. This Cmdlet can only be used when data at rest encryption has been enabled. + + + + + Save-OVApplianceDataAtRestEncryptionKey + + Location + + Specify the directory where to save the appliance encryption key (AEK). If no location is provided, the current working directory is used. + + String + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Location + + Specify the directory where to save the appliance encryption key (AEK). If no location is provided, the current working directory is used. + + String + + String + + (Get-Location).Path + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + System.IO.FileInfo + + + + The saved appliance encryption key (AEK). + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Save-OVApplianceDataAtRestEncryptionKey + + Save the appliance data at rest encryption key off the appliance. + + + + + + + + + + + + + New-OVApplianceDataAtRestEncryptionKey + + + + Enable-OVApplianceDataAtRestEncryption + + + + Disable-OVApplianceDataAtRestEncryption + + + + Get-OVApplianceDataAtRestEncryption + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/security/save-ovappliancedataatrestencryptionkey + + + + + + + + Save-OVBackup + + Save existing backups on an appliance. + + Save + OVBackup + + + HPE OneView provides the ability to save your configuration settings and management data to a backup file and enables you to use that backup to restore a corrupted appliance in the event of a catastrophic failure. + +The backup process involves creating a backup file and then downloading that file so that you can store it to a safe and secure (off-appliance) location for future use. You can schedule automatic backup operations and designate a remote location for the backup file. + +Use this Cmdlet to save the created appliance backup files. Use the -SaveRemoteOnly parameter to save the backup file(s) to the remote location if configured on the appliance. + + + + + Save-OVBackup + + Location + + Specify the directory or UNC path where to save the backup file(s) to. + + String + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + + + Save-OVBackup + + SaveRemoteOnly + + When appliance automatic backup is configured, use this parameter to specify the backup file(s) should be saved in the remote location, instead of the local PC. + + SwitchParameter + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + Array + + (${Global:ConnectedSessions} | ? Default) + + + Location + + Specify the directory or UNC path where to save the backup file(s) to. + + String + + String + + + + + SaveRemoteOnly + + When appliance automatic backup is configured, use this parameter to specify the backup file(s) should be saved in the remote location, instead of the local PC. + + SwitchParameter + + SwitchParameter + + + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + Async Task resource to monitor progress of the backup file saved to the remote location. + + + + + System.IO.FileInfo + + + + The saved backup file located on the PC. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Save-OVBackup + + Save the found backup file + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Save-OVBackup -Location \\Server\BackupShare\HPOneView + + Save the found backup file to the specified location. + + + + + + + + + + + + + Get-OVBackup + + + + New-OVBackup + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/save-ovbackup + + + + + + + + Save-OVServerProfile + + Save the contents of a Server Profile to the appliance. + + Save + OVServerProfile + + + This Cmdlet allows administrators to save the modified Server Profile object within the current PowerShell session to the target appliance. + + + + + Save-OVServerProfile + + InputObject + + Server Profile object to be saved. + + Object + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + Array + + (${Global:ConnectedSessions} | ? Default) + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + SwitchParameter + + False + + + InputObject + + Server Profile object to be saved. + + Object + + Object + + + + + + + + + HPEOneView.ServerProfile + + + A Server Profile resource object from Get-OVServerProfile that was modified and needs to be saved. + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + Async task Resource object for monitoring the enclosure import process. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + $MyProfile = Get-OVServerProfile -Name "My Profile 1" -ErrorAction Stop +$MyProfile.name = "My Profile NewName 1" +Save-OVServerProfile -InputObject $MyProfile + + Get a Server Profile, update its name, then save. + + + + + + + + + + + + + Convert-OVServerProfile + + + + Convert-OVServerProfileTemplate + + + + ConvertTo-OVServerProfileTemplate + + + + Copy-OVServerProfile + + + + Get-OVServerProfile + + + + Get-OVServerProfileConnectionList + + + + Get-OVServerProfileMessage + + + + Get-OVServerProfileTemplate + + + + Join-OVServerProfileToTemplate + + + + New-OVServerProfile + + + + New-OVServerProfileAssign + + + + New-OVServerProfileAttachVolume + + + + New-OVServerProfileConnection + + + + New-OVServerProfileLogicalDisk + + + + New-OVServerProfileLogicalDiskController + + + + New-OVServerProfileTemplate + + + + Remove-OVServerProfile + + + + Remove-OVServerProfileTemplate + + + + Save-OVServerProfileTemplate + + + + Set-OVServerProfile + + + + Set-OVServerProfileTemplate + + + + Update-OVServerProfile + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/servers/save-ovserverprofile + + + + + + + + Save-OVServerProfileTemplate + + Save the contents of a Server Profile Template to the appliance. + + Save + OVServerProfileTemplate + + + This Cmdlet allows administrators to save the modified Server Profile Template object within the current PowerShell session to the target appliance. + + + + + Save-OVServerProfileTemplate + + InputObject + + Server Profile Template object to be saved. + + Object + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + Array + + (${Global:ConnectedSessions} | ? Default) + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + SwitchParameter + + False + + + InputObject + + Server Profile Template object to be saved. + + Object + + Object + + + + + + + + + HPEOneView.ServerProfileTemplate + + + A Server Profile Template resource object from Get-OVServerProfileTemplate that was modified and needs to be saved. + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + Async task Resource object for monitoring the enclosure import process. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + $MyProfileTemplate = Get-OVServerProfileTemplate -Name "My Profile Template 1" -ErrorAction Stop +$MyProfileTemplate.name = "My Profile Template NewName 1" +Save-OVServerProfileTemplate -InputObject $MyProfileTemplate + + Get a Server Profile Template, update its name, then save. + + + + + + + + + + + + + Convert-OVServerProfileTemplate + + + + ConvertTo-OVServerProfileTemplate + + + + Get-OVServerProfileTemplate + + + + New-OVServerProfileTemplate + + + + Remove-OVServerProfileTemplate + + + + Set-OVServerProfileTemplate + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/servers/save-ovserverprofiletemplate + + + + + + + + Search-OVAssociations + + Search the association index. + + Search + OVAssociations + + + Search the association index for any associations that match the specified name or uri. + + + + + Search-OVAssociations + + AssociationName + + The association name to be matched, if specified. Valid association names are + + * server_profiles_to_server_hardware + * PROFILE_TO_SERVER_HARDWARE_TYPE + * RACK_TO_PHYSICAL_DEVICE + * BLADE_TO_INTERCONNECT + * ENCLOSURE_GROUP_TO_ENCLOSURE + * ENCLOSURE_GROUP_TO_LOGICAL_INTERCONNECT_GROUP + * ENCLOSURE_TO_BLADE + * ENCLOSURE_TO_SWITCH + * LOGICAL_SWITCH_TO_LOGICAL_UPLINK + * SWITCH_TO_LOGICAL_SWITCH + * SERVER_PROFILES_TO_FC_NETWORKS + * SERVER_PROFILES_TO_NETWORKS + * STORAGE_SYSTEM_TO_STORAGE_POOL + * FC_NETWORK_TO_STORAGE_SYSTEM + * STORAGE_POOL_TO_VOLUME + * STORAGE_POOL_TO_VOLUME_TEMPLATE + + String + + + Parent + + The object which is the parent resource of an association. + + Object + + + Child + + The object which is the child resource of an association. + + Object + + + Count + + The maximum number of association index entries to be returned. Defaults to 50. + + Int32 + + + Start + + The index of the first association index to be returned, defaults to 0. + + Int32 + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + AssociationName + + The association name to be matched, if specified. Valid association names are + + * server_profiles_to_server_hardware + * PROFILE_TO_SERVER_HARDWARE_TYPE + * RACK_TO_PHYSICAL_DEVICE + * BLADE_TO_INTERCONNECT + * ENCLOSURE_GROUP_TO_ENCLOSURE + * ENCLOSURE_GROUP_TO_LOGICAL_INTERCONNECT_GROUP + * ENCLOSURE_TO_BLADE + * ENCLOSURE_TO_SWITCH + * LOGICAL_SWITCH_TO_LOGICAL_UPLINK + * SWITCH_TO_LOGICAL_SWITCH + * SERVER_PROFILES_TO_FC_NETWORKS + * SERVER_PROFILES_TO_NETWORKS + * STORAGE_SYSTEM_TO_STORAGE_POOL + * FC_NETWORK_TO_STORAGE_SYSTEM + * STORAGE_POOL_TO_VOLUME + * STORAGE_POOL_TO_VOLUME_TEMPLATE + + String + + String + + + + + Child + + The object which is the child resource of an association. + + Object + + Object + + + + + Count + + The maximum number of association index entries to be returned. Defaults to 50. + + Int32 + + Int32 + + 50 + + + Parent + + The object which is the parent resource of an association. + + Object + + Object + + + + + Start + + The index of the first association index to be returned, defaults to 0. + + Int32 + + Int32 + + 0 + + + + + + + System.Management.Automation.PSCustomObject + + + Resource Object to find associated resources + + + + + + + + System.Management.Automation.PSCustomObject + + + + Single association index entry + + + + + System.Collections.ArrayList + + + + Multiple association index entries The matching index entries + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Search-OVAssociations -AssociationName server_profiles_to_server_hardware -Parent (Get-OVServerProfile -Name "My Profile1") + + Return server_profiles_to_server_hardware that have an association with the specified object. + + + + + + + + + + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/search-ovassociations + + + + + + + + Search-OVIndex + + Search the resource index. + + Search + OVIndex + + + Search the resource index for any objects that match the specified search string or category + + + + + Search-OVIndex + + Search + + The search query, text to be found in the index. + + String + + + Category + + The resource category to be matched, if specified. Valid resource categories are: + + * domains + * users + * racks + * enclosure-groups + * enclosures + * uplink-sets + * logical-interconnect-groups + * logical-interconnects + * interconnect-types + * interconnects + * networks + * firmware-drivers + * server-hardware-types + * server-hardware + * server-profiles + * alerts + * storage-volumes + * storage-systems + + String + + + Count + + The maximum number of resource index entries to be returned. Defaults to 50. + + Int32 + + + Start + + The index of the first resource index to be returned, defaults to 0. + + Int32 + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Category + + The resource category to be matched, if specified. Valid resource categories are: + + * domains + * users + * racks + * enclosure-groups + * enclosures + * uplink-sets + * logical-interconnect-groups + * logical-interconnects + * interconnect-types + * interconnects + * networks + * firmware-drivers + * server-hardware-types + * server-hardware + * server-profiles + * alerts + * storage-volumes + * storage-systems + + String + + String + + + + + Count + + The maximum number of resource index entries to be returned. Defaults to 50. + + Int32 + + Int32 + + 50 + + + Search + + The search query, text to be found in the index. + + String + + String + + + + + Start + + The index of the first resource index to be returned, defaults to 0. + + Int32 + + Int32 + + 0 + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + None. You cannot pipe objects to this Cmdlet + + + + + + + + System.Collections.ArrayList + + + + The matching index entries + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Search-OVIndex -Search "Profile1" + + Return all the index entries which include this string. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Search-OVIndex -Categroy uplink-sets + + Search for all Uplink Set resources. + + + + + + + + + + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/search-ovindex + + + + + + + + Send-OVRequest + + Sends a request to the management appliance + + Send + OVRequest + + + Receives the request input, properly constructs and formats the request header and body and sends the request to the management appliance. This is the main Cmdlet that interacts with the appliance. + +The message body can contain valid JSON data, with the correct URI and accepted HTTP method accepted by the target resource manager. Please see the online appliance Resource Model for more information (https://[appliance_IP]/help/cic/en/content/images/api/.) + + + + + Send-OVRequest + + uri + + The uri that identifies the required resource on the appliance. + + String + + + method + + The request HTTP Method. + + * "GET" (default) to get a resource from the appliance (read) + * "POST" to create a new resource + * "PUT" to modify a resource (write) + * "PATCH" to modify a resource (write), with specific attributes set to values, other attributes should be set to $null. + * "DELETE" to delete a resource + + String + + + body + + Body for the request. Required if the method is POST or PUT. + + Object + + + start + + For GETs on resource collections, this specifies the starting index in the collection. +If not specified, collection members starting from the beginning are returned. + + Int32 + + + count + + For GETs on resource collections, this specifies the number of collection members to return. +If not specified, all members of the collection are returned from this function. + + Int32 + + + AddHeader + + If additional headers are needed/required than the defaults, include header names and values within a Hashtable. + + Hashtable + + + OverrideContentType + + Workaround to override ContentType where needed (e.g. PATCH /rest/scopes/{GUID}. + + String + + + OverrideTimeout + + Specify to override the HttpWebRequest syncronous timeout being made. + + Int + + + Hostname + + The destination appliance to process the request. When specifying a Value, it must match the HostName attribute of a valid HPEOneView.Appliance.Connection object within the Global $ConnectedSessions variable. If no match is found, or no HPEOneView.Appliance.Connection objects exist, an error will be thrown. + +Default Value: All valid Appliance Connections within $Global:ConnectedSessions + + Object + + + + + + + AddHeader + + If additional headers are needed/required than the defaults, include header names and values within a Hashtable. + + Hashtable + + Hashtable + + + + + Hostname + + The destination appliance to process the request. When specifying a Value, it must match the HostName attribute of a valid HPEOneView.Appliance.Connection object within the Global $ConnectedSessions variable. If no match is found, or no HPEOneView.Appliance.Connection objects exist, an error will be thrown. + +Default Value: All valid Appliance Connections within $Global:ConnectedSessions + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + OverrideContentType + + Workaround to override ContentType where needed (e.g. PATCH /rest/scopes/{GUID}. + + String + + String + + + + + OverrideTimeout + + Specify to override the HttpWebRequest syncronous timeout being made. + + Int + + Int + + + + + body + + Body for the request. Required if the method is POST or PUT. + + Object + + Object + + + + + count + + For GETs on resource collections, this specifies the number of collection members to return. +If not specified, all members of the collection are returned from this function. + + Int32 + + Int32 + + 0 + + + method + + The request HTTP Method. + + * "GET" (default) to get a resource from the appliance (read) + * "POST" to create a new resource + * "PUT" to modify a resource (write) + * "PATCH" to modify a resource (write), with specific attributes set to values, other attributes should be set to $null. + * "DELETE" to delete a resource + + String + + String + + GET + + + start + + For GETs on resource collections, this specifies the starting index in the collection. +If not specified, collection members starting from the beginning are returned. + + Int32 + + Int32 + + 0 + + + uri + + The uri that identifies the required resource on the appliance. + + String + + String + + + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + System.Collections.ArrayList + + + + If collection of resources (.i.e. GET /rest/ethernet-networks) + + + + + System.Management.Automation.PSCustomObject + + + + Single object returned from appliance + + If Async task, a Hashtable is returned with the following contents: + + @{ + uri = TaskUri; + category = "tasks"; + type = "TaskResourceV2"; + taskState = "New"; + resource = @{}; + } + + + + + System.Management.Automation.PSCustomObject + + + + If no resources are found, a PsCustomObject is returned that contains: + + @{ + statusCode = [int]HTTP Status Code; + statusMessage = [string]HTTP Status Message; + lastCall = [string]URI; + } + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Send-OVRequest "/rest/enclosures" + + Returns all the enclosure objects managed by the appliance. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + $e = Send-OVRequest "/rest/enclosures/SGH2X6J1" -Appliance MyAppliance.domain.com +$e.name = "New Name" +Send-OVRequest $e.uri "PUT" $e -Appliance MyAppliance.domain.com + + Updates the name of the enclosure object specified by the uri and Appliance Connection name. + + + + + + + + + + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/library/send-ovrequest + + + + + + + + Set-OVAddressPoolSubnet + + Update an IPv4 Subnet Pool configuration. + + Set + OVAddressPoolSubnet + + + This Cmdlet will assist with updating an existing IPv4 address pool. When updating an IPv4 Address Subnet, you must provide the Subnet Object or Name to modify. Only the Gateway, Domain Name, and DNS Servers can be updated once an IPv4 Subnet has been assigned to a resource. + + + + + Set-OVAddressPoolSubnet + + InputObject + + Aliases [-Subnet, -IPv4Subnet] + +The IPv4 Subnet resource object to update. + + Object + + + SubnetMask + + IPv4 Subnet Mask of the subnet. Please know that if the Subnet is associated with another resource (Ethernet Network, Logical Enclosure or Deployment Server), there will be an error as the mask cannot be changed until it is unassociated with the resource. + + IPAddress + + + Gateway + + IPv4 Address of the default gateway for the subnet. + + IPAddress + + + Domain + + DNS Domain Name of the subnet. + + String + + + DNSServers + + An array of DNS Server IPv4 Addresses. + + Array + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + DNSServers + + An array of DNS Server IPv4 Addresses. + + Array + + Array + + + + + Domain + + DNS Domain Name of the subnet. + + String + + String + + + + + Gateway + + IPv4 Address of the default gateway for the subnet. + + IPAddress + + IPAddress + + + + + InputObject + + Aliases [-Subnet, -IPv4Subnet] + +The IPv4 Subnet resource object to update. + + Object + + Object + + + + + SubnetMask + + IPv4 Subnet Mask of the subnet. Please know that if the Subnet is associated with another resource (Ethernet Network, Logical Enclosure or Deployment Server), there will be an error as the mask cannot be changed until it is unassociated with the resource. + + IPAddress + + IPAddress + + + + + + + + + HPEOneView.Appliance.IPAddressSubnet [System.Management.Automation.PSCustomObject] + + + IPv4 Address Subnet + + + + + + + + HPEOneView.Appliance.IPAddressSubnet [System.Management.Automation.PSCustomObject] + + + + Updated IPv4 Address Subnet + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + PS C:> Get-OVAddressPoolSubnet 192.168.20.0 | Set-OVAddressPoolSubnet -Gateway 192.168.20.1 + + Update the IPv4 Subnet address pool"s default gateway to the new address. + + + + + + + + + + + + + Get-OVAddressPoolSubnet + + + + New-OVAddressPoolSubnet + + + + Remove-OVAddressPoolSubnet + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/set-ovaddresspoolsubnet + + + + + + + + Set-OVAlert + + Change status of an alert. + + Set + OVAlert + + + The appliance uses alert messages to report issues with the resources it manages and monitors. The resources generate alerts to notify you that some meaningful event occurred and that an action might be required. + +An event describes a single problem or change that occurred on a resource. For example, an event might be an SNMP trap received from a server's (iLO) management processor. + +Each alert includes the following information about the event it reports: severity, state, description, and urgency. You can clear alerts, assign owners to alerts, and add notes to alerts. + +While alerts have an active or locked state, they contribute to the overall displayed status for a resource. After you change their state to Cleared, they no longer affect the displayed status. + +You can filter the display of the activity list to help you locate and view specific activities. However, you cannot customize filters to otherwise manage the display of the activities. + +This Cmdlet allows the administrator to change the status of an alert to either Active or Cleared. Notes can also be added to an alert, which will appear with in the alert contents. If an alert should be owned by a specific user, use the -AssignToUser and provide their name. This does not correlate with any user login name. + +In order for an Administrator to change the status of an Alert, the Administrator must be scoped or have use rights to the respective resource role (Network, Server, Storage, or Infrastructure.) + + + + + Set-OVAlert + + InputObject + + The alert to be cleared. Can be URI or resource object. + + Object + + + AssignToUser + + The users name in String value to assign the alert to. The user name does not require, nor is mapped to, a local user account. + + String + + + Notes + + Notes of the action for the alert. + + String + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + + + Set-OVAlert + + InputObject + + The alert to be cleared. Can be URI or resource object. + + Object + + + Active + + Change the alert to "Active" status. + + SwitchParameter + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + + + Set-OVAlert + + InputObject + + The alert to be cleared. Can be URI or resource object. + + Object + + + Cleared + + Change the alert to "Cleared" status. + + SwitchParameter + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + + + + + + Active + + Change the alert to "Active" status. + + SwitchParameter + + SwitchParameter + + False + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + AssignToUser + + The users name in String value to assign the alert to. The user name does not require, nor is mapped to, a local user account. + + String + + String + + + + + Cleared + + Change the alert to "Cleared" status. + + SwitchParameter + + SwitchParameter + + False + + + InputObject + + The alert to be cleared. Can be URI or resource object. + + Object + + Object + + + + + Notes + + Notes of the action for the alert. + + String + + String + + + + + + + + + System.String + + + Alert URI + + + + + HPEOneView.Alert [System.Management.Automation.PSCustomObject] + + + Alert resource object (i.e. Get-OVAlert) + + + + + + + + HPEOneView.Alert [System.Management.Automation.PSCustomObject] + + + + The updated alert + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Set-OVAlert -InputObject $Alert -Cleared + + Clears the alert. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Get-OVAlert -AlertState Active | Set-OVAlert -Cleared + + Get all alerts in an "Active" state, and set their state to "Cleared". + + + + + + + + + + -------------------------- EXAMPLE 3 -------------------------- + + + + Get-OVServer -name "Encl1, bay 1*" | Get-OVAlert -State active | Set-OVAlert -Cleared + + Get aassociated alerts to the servers in an "Active" state, and set their state to "Cleared". + + + + + + + + + + + + + Clear-OVAlert + + + + Get-OVAlert + + + + Remove-OVAlert + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/set-ovalert + + + + + + + + Set-OVApplianceAuditLogForwarding + + Modify remote Syslog audit log forwarding. + + Set + OVApplianceAuditLogForwarding + + + HPE OneView can forward the internal audit log entries to a remote syslog server, in standard Syslog format. This Cmdlet will chnage the current status, remote Syslog destination and port to be configured on the appliance. + +Minimum required privileges: Infrastructure administrator + + + + + Set-OVApplianceAuditLogForwarding + + Enable + + Using this parameter will enable remote Syslog audit log forwarding on the specified appliance. + + SwitchParameter + + + ComputerName + + The target remote Syslog server IP Address or FQDN. + + String[] + + + Port + + The target remote Syslog server port if not using the default 514/UDP port. + + Int + + + RemoveComputerName + + Specify one or more remote Syslog server IP Address or FQDN to remove from the configuration. + + String[] + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + Set-OVApplianceAuditLogForwarding + + Disable + + Using this parameter will disable remote Syslog audit log forwarding on the specified appliance. + + SwitchParameter + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + ComputerName + + The target remote Syslog server IP Address or FQDN. + + String[] + + String[] + + + + + Disable + + Using this parameter will disable remote Syslog audit log forwarding on the specified appliance. + + SwitchParameter + + SwitchParameter + + + + + Enable + + Using this parameter will enable remote Syslog audit log forwarding on the specified appliance. + + SwitchParameter + + SwitchParameter + + + + + Port + + The target remote Syslog server port if not using the default 514/UDP port. + + Int + + Int + + + + + RemoveComputerName + + Specify one or more remote Syslog server IP Address or FQDN to remove from the configuration. + + String[] + + String[] + + + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + HPEOneView.Appliance.AuditLogForwardingConfig + + + + The appliance audit log forwarding configuration. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Set-OVApplianceAuditLogForwarding -Enable -ComputerName MyTargetHost1.domain.com + + Enable appliance remote Syslog audit log forwarding to the specified host. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Set-OVApplianceAuditLogForwarding -Enable -ComputerName MyTargetHost1.domain.com, MyTargetHost2.domain.com -Port 5514 + + Enable appliance remote Syslog audit log forwarding to the specified hosts and custom UDP target port. + + + + + + + + + + -------------------------- EXAMPLE 3 -------------------------- + + + + Set-OVApplianceAuditLogForwarding -RemoveComputerName MyTargetHost2.domain.com + + Remove the specified host from the existing remote Syslog audit log forwarding configuration. + + + + + + + + + + -------------------------- EXAMPLE 4 -------------------------- + + + + Set-OVApplianceAuditLogForwarding -Disable + + Disable remote Syslog audit log forwarding configuration. + + + + + + + + + + + + + Get-OVApplianceAuditLogForwarding + + + + Test-OVApplianceAuditLogForwarding + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/set-ovapplianceauditlogforwarding + + + + + + + + Set-OVApplianceCurrentSecurityMode + + Change the appliance current security mode. + + Set + OVApplianceCurrentSecurityMode + + + Use this Cmdlet to change the current security mode (Legacy, FIPS or CNSA) of the appliance. Before modifying the appliance security mode, a compatibility report should be run using the Show-OVApplianceSecurityModeCompatibilityReport. When changing active security mode will require an immediate appliance reboot. + + + + + Set-OVApplianceCurrentSecurityMode + + SecurityMode + + Specify the Security Mode to change the appliance to by using Get-OVApplianceAvailableSecurityMode. + + HPOVApplianceAvailableSecurityMode + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + + WhatIf + + + + + + + Confirm + + + + + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + Array + + (${Global:ConnectedSessions} | ? Default) + + + Confirm + + + + + + + + + + + SecurityMode + + Specify the Security Mode to change the appliance to by using Get-OVApplianceAvailableSecurityMode. + + HPOVApplianceAvailableSecurityMode + + HPOVApplianceAvailableSecurityMode + + + + + WhatIf + + + + + + + + + + + + + + + HPEOneView.Appliance.SecurityMode + + + The specified appliance security mode from Get-OVApplianceAvailableSecurityMode. + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + Async task resource to monitor. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVApplianceAvailableSecurityMode -ModeName CNSA | Set-OVApplianceCurrentSecurityMode + + Put the appliance into CNSA mode. After confirmation prompt, appliance will immediately reboot. + + + + + + + + + + + + + Get-OVApplianceAvailableSecurityMode + + + + Get-OVApplianceCurrentSecurityMode + + + + Show-OVApplianceSecurityModeCompatibilityReport + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/set-ovappliancecurrentsecuritymode + + + + + + + + Set-OVApplianceDateTime + + Update Appliance Date/Time Configuration. + + Set + OVApplianceDateTime + + + Update the appliance Date and Time configuration, including Locale, NTP Servers, and NTP Polling. + +Using the -SyncWithHost parameter will set the NTPServers property to null, and is only applicable to a virtual machine applinace. + +Minimum required privileges: Infrastructure administrator + + + + + Set-OVApplianceDateTime + + SyncWithHost + + Specify to configure the embedded hypervisor integration agent to sync time with the hypervisor host. Only used with a virtual machine appliance. + + SwitchParameter + + + Locale + + Specify the language local for the appliance + + * en_US - US English + * zh_CN - Simplified Chinese + * ja_JP - Japanese + + String + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + +Default Value: ${Global:ConnectSessions} | ? Default + + Object + + + + Set-OVApplianceDateTime + + NTPServers + + An array of IPv4 Addresses or Fully Qualified Domain Names. You must ensure DNS is configured on the appliance correctly.. + + Array + + + PollingInterval + + The polling interval in seconds the NTP client will use to verify time drift. + + Int32 + + + Locale + + Specify the language local for the appliance + + * en_US - US English + * zh_CN - Simplified Chinese + * ja_JP - Japanese + + String + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + +Default Value: ${Global:ConnectSessions} | ? Default + + Object + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + +Default Value: ${Global:ConnectSessions} | ? Default + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Locale + + Specify the language local for the appliance + + * en_US - US English + * zh_CN - Simplified Chinese + * ja_JP - Japanese + + String + + String + + + + + NTPServers + + An array of IPv4 Addresses or Fully Qualified Domain Names. You must ensure DNS is configured on the appliance correctly.. + + Array + + Array + + + + + PollingInterval + + The polling interval in seconds the NTP client will use to verify time drift. + + Int32 + + Int32 + + 0 + + + SyncWithHost + + Specify to configure the embedded hypervisor integration agent to sync time with the hypervisor host. Only used with a virtual machine appliance. + + SwitchParameter + + SwitchParameter + + False + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + Asynchronous task resource to monitor + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Set-OVApplianceDateTime -NTPServers 10.55.1.1, 10.54.1.1 -PollingInterval 60 + + This example passes in updated values to set for the appliance networking configuration. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Set-OVApplianceDateTime -SyncWithHost + + This example passes in updated values to set for the appliance networking configuration. + + + + + + + + + + + + + Get-OVApplianceDateTime + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/set-ovappliancedatetime + + + + + + + + Set-OVApplianceDefaultConnection + + Set the Default Appliance Connection. + + Set + OVApplianceDefaultConnection + + + When establishing multiple Appliance Connections, this Cmdlet will help set one of the appliance connections stored in the ${Global:ConnectedSessions} variable to the default connection. All Cmdlets that require a specific Appliance Connection will use the default. + + + + + Set-OVApplianceDefaultConnection + + ApplianceConnection + + [Aliases -Connection] + +Either the HPEOneView.Appliance.Connection object, full or partial value of the connection objects Name property. + + Object + + + + + + + ApplianceConnection + + [Aliases -Connection] + +Either the HPEOneView.Appliance.Connection object, full or partial value of the connection objects Name property. + + Object + + Object + + + + + + + + + HPEOneView.Appliance.Connection + + + The Appliance Connection object either provided from the Connect-OVMgmt output or ${Global:ConnectedSessions} variable + + + + + + + + System.Collections.ArrayList <HPEOneView.Appliance.Connection> + + + + Updated collection of [HPEOneView.Appliance.Connection] Objects + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + $ConnectedSessions +ConnectionID Name UserName AuthLoginDomain Default Connection +------------ ---- -------- --------------- ------------------ +1 Appliance1.domain.local administrator LOCAL True +2 Appliance2.domain.local administrator LOCAL False + +Set-OVApplianceDefaultConnection "Appliance2" + +ConnectionID Name UserName AuthLoginDomain Default Connection +------------ ---- -------- --------------- ------------------ +1 Appliance1.domain.local administrator LOCAL False +2 Appliance2.domain.local administrator LOCAL True + + Display the current appliance connections, then set the new default to "Appliance2" using the parital name value. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + $ConnectedSessions +ConnectionID Name UserName AuthLoginDomain Default Connection +------------ ---- -------- --------------- ------------------ +1 Appliance1.domain.local administrator LOCAL True +2 Appliance2.domain.local administrator LOCAL False + +$ConnectedSessions[1] | Set-OVApplianceDefaultConnection + +ConnectionID Name UserName AuthLoginDomain Default Connection +------------ ---- -------- --------------- ------------------ +1 Appliance1.domain.local administrator LOCAL False +2 Appliance2.domain.local administrator LOCAL True + + Display the current appliance connections, then set the new default to "Appliance2" using the pipline by passing the HPEOneView.Appliance.Connection object. + + + + + + + + + + + + + Connect-OVMgmt + + + + Disconnect-OVMgmt + + + + about_Appliance_Connection_Permissions + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/library/set-ovappliancedefaultconnection + + + [${Global:ConnectedSessions}] + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/library/set-ovappliancedefaultconnection + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/library/set-ovappliancedefaultconnection + + + + + + + + Set-OVApplianceGlobalSetting + + (Reserved for future use) Update appliance global settings. + + Set + OVApplianceGlobalSetting + + + (Reserved for future use) Updates the value for an existing global parameter. + + + + + Set-OVApplianceGlobalSetting + + Name + + The name of the global parameter. + + String + + + Value + + The updated value for the global parameter. + + String + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + Set-OVApplianceGlobalSetting + + InputObject + + Aliases [-Object] + +The Appliance Global Setting object from Get-OVApplianceGlobalSetting. + + HPEOneView.Appliance.GlobalSetting + + + Value + + The updated value for the global parameter. + + String + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + InputObject + + Aliases [-Object] + +The Appliance Global Setting object from Get-OVApplianceGlobalSetting. + + HPEOneView.Appliance.GlobalSetting + + HPEOneView.Appliance.GlobalSetting + + + + + Name + + The name of the global parameter. + + String + + String + + + + + Value + + The updated value for the global parameter. + + String + + String + + + + + + + + + HPEOneView.Appliance.GlobalSetting + + + Appliance global setting from Get-OVApplianceGlobalSetting. + + + + + + + + The setting object with updated parameters. + + + + + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Set-OVApplianceGlobalSetting alertMax 75000 + + Returns the "alertMax" setting object with the updated value of 75000 + + + + + + + + + + + + + Get-OVApplianceGlobalSetting + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/set-ovapplianceglobalsetting + + + + + + + + Set-OVApplianceNetworkConfig + + Updates the configuration parameters for the primary network interface on the appliance. + + Set + OVApplianceNetworkConfig + + + Updates any or all configuration parameters for the primary network interface on the appliance. All parameters are Current settings will be retained for any parameters NOT specified. + + + + + Set-OVApplianceNetworkConfig + + Hostname + + Fully-qualified hostname for the appliance + + String + + + IPv4Type + + "DHCP", "STATIC" or "UNCONFIGURE" + + String + + + IPv4Addr + + "www.xxx.yyy.zzz" (leave blank for DHCP) + + IPAddress + + + IPv4Subnet + + "www.xxx.yyy.zzz" (leave blank for DHCP) + + String + + + IPv4Gateway + + "www.xxx.yyy.zzz" (leave blank for DHCP) + + IPAddress + + + IPv6Type + + "DHCP", "STATIC" or "UNCONFIGURE" + + String + + + IPv6Addr + + "ssss:tttt:uuuu:vvvv:wwww:xxxx:yyyy:zzzz" (leave blank for DHCP) + + IPAddress + + + IPv6Subnet + + "ffff:ffff:ffff:ffff:0:0:0:0" (leave blank for DHCP) + + String + + + IPv6Gateway + + "ssss:tttt:uuuu:vvvv:wwww:xxxx:yyyy:zzzz" (leave blank for DHCP) + + String + + + OverrideIPv4DhcpDns + + Switch to override DHCP provided DNS Servers + + SwitchParameter + + + OverrideIPv6DhcpDns + + Switch to override DHCPv6 provided DNS Servers + + SwitchParameter + + + DomainName + + DNS domain name for the appliance: "my.com" + + String + + + SearchDomains + + Array of DNS search domains: "my.com", "other.com" + + Array + + + IPv4NameServers + + Array of DNS servers: "www.xxx.yyy.zzz", "sss.ttt.uuu.vvv" + + Array + + + IPv6NameServers + + Array of DNS servers: "fe80::200:f8ff:fe21:67cf", "fe80::200:f8ff:fe21:89cb" + + Array + + + NtpServers + + Deprecated parameter. NTP Server configuration is now controlled in the Set-OVApplianceDateTime Cmdlet. Please update your scripts accordingly. + + Object + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. + + Object + + + + Set-OVApplianceNetworkConfig + + Hostname + + Fully-qualified hostname for the appliance + + String + + + IPv4Addr + + "www.xxx.yyy.zzz" (leave blank for DHCP) + + IPAddress + + + IPv4Subnet + + "www.xxx.yyy.zzz" (leave blank for DHCP) + + String + + + IPv4Gateway + + "www.xxx.yyy.zzz" (leave blank for DHCP) + + IPAddress + + + ServiceIPv4Node1 + + Reserved for Synergy. + + IPAddress + + + ServiceIPv4Node2 + + Reserved for Synergy. + + IPAddress + + + IPv4Type + + "DHCP", "STATIC" or "UNCONFIGURE" + + String + + + IPv6Type + + "DHCP", "STATIC" or "UNCONFIGURE" + + String + + + IPv6Addr + + "ssss:tttt:uuuu:vvvv:wwww:xxxx:yyyy:zzzz" (leave blank for DHCP) + + IPAddress + + + IPv6Subnet + + "ffff:ffff:ffff:ffff:0:0:0:0" (leave blank for DHCP) + + String + + + IPv6Gateway + + "ssss:tttt:uuuu:vvvv:wwww:xxxx:yyyy:zzzz" (leave blank for DHCP) + + String + + + ServiceIPv6Node1 + + Reserved for Synergy. + + IPAddress + + + ServiceIPv6Node2 + + Reserved for Synergy. + + IPAddress + + + OverrideIPv4DhcpDns + + Switch to override DHCP provided DNS Servers + + SwitchParameter + + + OverrideIPv6DhcpDns + + Switch to override DHCPv6 provided DNS Servers + + SwitchParameter + + + DomainName + + DNS domain name for the appliance: "my.com" + + String + + + SearchDomains + + Array of DNS search domains: "my.com", "other.com" + + Array + + + IPv4NameServers + + Array of DNS servers: "www.xxx.yyy.zzz", "sss.ttt.uuu.vvv" + + Array + + + IPv6NameServers + + Array of DNS servers: "fe80::200:f8ff:fe21:67cf", "fe80::200:f8ff:fe21:89cb" + + Array + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. + + Object + + + + Set-OVApplianceNetworkConfig + + importFile + + File containing JSON formatted input values for the appliance network configuration parameters. + + Object + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. + + Object + + + + + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + DomainName + + DNS domain name for the appliance: "my.com" + + String + + String + + + + + Hostname + + Fully-qualified hostname for the appliance + + String + + String + + + + + IPv4Addr + + "www.xxx.yyy.zzz" (leave blank for DHCP) + + IPAddress + + IPAddress + + + + + IPv4Gateway + + "www.xxx.yyy.zzz" (leave blank for DHCP) + + IPAddress + + IPAddress + + + + + IPv4NameServers + + Array of DNS servers: "www.xxx.yyy.zzz", "sss.ttt.uuu.vvv" + + Array + + Array + + + + + IPv4Subnet + + "www.xxx.yyy.zzz" (leave blank for DHCP) + + String + + String + + + + + IPv4Type + + "DHCP", "STATIC" or "UNCONFIGURE" + + String + + String + + STATIC + + + IPv6Addr + + "ssss:tttt:uuuu:vvvv:wwww:xxxx:yyyy:zzzz" (leave blank for DHCP) + + IPAddress + + IPAddress + + + + + IPv6Gateway + + "ssss:tttt:uuuu:vvvv:wwww:xxxx:yyyy:zzzz" (leave blank for DHCP) + + String + + String + + + + + IPv6NameServers + + Array of DNS servers: "fe80::200:f8ff:fe21:67cf", "fe80::200:f8ff:fe21:89cb" + + Array + + Array + + + + + IPv6Subnet + + "ffff:ffff:ffff:ffff:0:0:0:0" (leave blank for DHCP) + + String + + String + + + + + IPv6Type + + "DHCP", "STATIC" or "UNCONFIGURE" + + String + + String + + UNCONFIGURE + + + NtpServers + + Deprecated parameter. NTP Server configuration is now controlled in the Set-OVApplianceDateTime Cmdlet. Please update your scripts accordingly. + + Object + + Object + + + + + OverrideIPv4DhcpDns + + Switch to override DHCP provided DNS Servers + + SwitchParameter + + SwitchParameter + + False + + + OverrideIPv6DhcpDns + + Switch to override DHCPv6 provided DNS Servers + + SwitchParameter + + SwitchParameter + + False + + + SearchDomains + + Array of DNS search domains: "my.com", "other.com" + + Array + + Array + + + + + ServiceIPv4Node1 + + Reserved for Synergy. + + IPAddress + + IPAddress + + + + + ServiceIPv4Node2 + + Reserved for Synergy. + + IPAddress + + IPAddress + + + + + ServiceIPv6Node1 + + Reserved for Synergy. + + IPAddress + + IPAddress + + + + + ServiceIPv6Node2 + + Reserved for Synergy. + + IPAddress + + IPAddress + + + + + importFile + + File containing JSON formatted input values for the appliance network configuration parameters. + + Object + + Object + + + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + System.Management.Automation.PSCustomObject + + + + Final Task status (for asynchronous appliance config) + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Set-OVApplianceNetworkConfig -hostname "appliance1.my.com" -IPv4Type "DHCP" -IPv6Type "UNCONFIGURE" -domainName "my.com" + + This example passes in updated values to set for the appliance networking configuration. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Set-OVApplianceNetworkConfig -importFile "c:\myNetworkInput.json" + + This example passes the name of an input file containing JSON formatted properties and values for the appliance network configuration. + + + + + + + + + + + + + Get-OVApplianceNetworkConfig + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/set-ovappliancenetworkconfig + + + + + + + + Set-OVApplianceProxy + + Configure appliance web proxy. + + Set + OVApplianceProxy + + + When configuring Remote Support, a Web Proxy may be required. This Cmdlet will assist in defining an HTTPS web proxy for Remote Support outbound connectivity. Proxy configuration does not support SOCKS. + + + + + Set-OVApplianceProxy + + Hostname + + The FQDN or IP Address of the HTTPS Proxy server. + + String + + + Port + + The web proxy TCP port to connect to. + + Int + + + Https + + Specify if target proxy server requires HTTPS. The target SSL/TSL certificate must be added to the appliance using the Add-OVApplianceTrustedCertificate Cmdlet. + + SwitchParameter + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + Set-OVApplianceProxy + + Hostname + + The FQDN or IP Address of the HTTPS Proxy server. + + String + + + Port + + The web proxy TCP port to connect to. + + Int + + + Username + + The user name of your proxy server to authenticate with. + + String + + + Password + + The proxy server account password. + + System.Security.SecureString + + + Https + + Specify if target proxy server requires HTTPS. The target SSL/TSL certificate must be added to the appliance using the Add-OVApplianceTrustedCertificate Cmdlet. + + SwitchParameter + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + SwitchParameter + + False + + + Hostname + + The FQDN or IP Address of the HTTPS Proxy server. + + String + + String + + + + + Https + + Specify if target proxy server requires HTTPS. The target SSL/TSL certificate must be added to the appliance using the Add-OVApplianceTrustedCertificate Cmdlet. + + SwitchParameter + + SwitchParameter + + + + + Password + + The proxy server account password. + + System.Security.SecureString + + System.Security.SecureString + + + + + Port + + The web proxy TCP port to connect to. + + Int + + Int + + 0 + + + Username + + The user name of your proxy server to authenticate with. + + String + + String + + + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + Async task Resource object for monitoring. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Set-OVApplianceProxy -Hostname MyProxy.domain.com -Port 8080 + + Configure the appliance proxy server by providing the required Hostname and Port values. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Set-OVApplianceProxy -Hostname MyProxy.domain.com -Port 8080 -Username MyUserAccount -Password (ConvertTo-SecureString -String MyPassword -AsPlainText -Force) + + Configure the appliance proxy server by providing the required Hostname and Port values, and using proxy authentication. + + + + + + + + + + + + + Get-OVApplianceProxy + + + + Remove-OVApplianceProxy + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/set-ovapplianceproxy + + + + + + + + Set-OVApplianceSecurityProtocol + + Change the appliance current security protocols. + + Set + OVApplianceSecurityProtocol + + + Use this Cmdlet to change the enabled security protocol(s) on the appliance. The security protocols that can be changed on an HPE OneView appliance are TLS protocol versions. Please be aware of the following rules: + + * Enabling or disabling TLS protocols is allowed only for the current cryptography mode. For example, disabling TLSv1.1 in legacy mode of the appliance will not disable TLSv1.1 when the appliance is switched to FIPS mode. + * Enabling an unsupported protocol for the current cryptography mode of the appliance is not allowed. For example, enabling TLSv1 is not allowed in the FIPS mode. + * TLSv1.2 protocol cannot be disabled + * Disabling all the protocols is not allowed. + +Warning: Changing active security protocol(s) will require an immediate appliance reboot. + +Minimum required privileges: Infrastructure administrator + + + + + Set-OVApplianceSecurityProtocol + + EnableTlsVersion + + Specify 1 or more security protocols to enable. Allowed values: + + * TLSv1 + * TLSv1.1 + * TLSv1.2 + + String[] + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + + WhatIf + + + + + + + Confirm + + + + + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + Array + + (${Global:ConnectedSessions} | ? Default) + + + Confirm + + + + + + + + + + + EnableTlsVersion + + Specify 1 or more security protocols to enable. Allowed values: + + * TLSv1 + * TLSv1.1 + * TLSv1.2 + + String[] + + String[] + + + + + WhatIf + + + + + + + + + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + HPEOneView.Appliance.SecurityProtocol + + + + After appliance reboots, the updated security protocol configuration is returned. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Set-OVApplianceSecurityProtocol -EnableTlsVersion Tlsv1.2 + + Set the appliance to only enable TLSv1.2. After confirmation prompt, appliance will immediately reboot. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Set-OVApplianceSecurityProtocol -EnableTlsVersion Tlsv1, Tlsv1.1, Tlsv1.2 + + Set the appliance to enable all three supported TLS protocol versions. After confirmation prompt, appliance will immediately reboot. + + + + + + + + + + + + + Get-OVApplianceSecurityProtocol + + + + Show-OVApplianceSecurityModeCompatibilityReport + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/set-ovappliancesecurityprotocol + + + + + + + + Set-OVApplianceSnmpV3EngineId + + Change the appliance SNMPv3 Engine ID + + Set + OVApplianceSnmpV3EngineId + + + Change or update the appliance SNMPv3 engine ID. + +Minimum required privileges: Infrastructure administrator + + + + + Set-OVApplianceSnmpV3EngineId + + EngineID + + A 16 hexacharacter value. E.g. "0x73cb660f279b9e" + + String + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + EngineID + + A 16 hexacharacter value. E.g. "0x73cb660f279b9e" + + String + + String + + + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + HPEOneView.Appliance.SnmpV3EngineId + + + + The appliance SNMPv3 engine ID. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Set-OVApplianceSnmpV3EngineId -EngineID 0x73cb660f279b9e + + Default example + + + + + + + + + + + + + Get-OVApplianceSnmpV3EngineId + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/set-ovappliancesnmpv3engineid + + + + + + + + Set-OVApplianceStaticRoute + + Update a configured static routes on an appliance. + + Set + OVApplianceStaticRoute + + + When configuring a second NIC on a virtual machine appliance, static routes can be configured as only a single appliance NIC can be configured with a default gateway. Both IPv4 and IPv6 static routes are supported. Use Get-OVApplianceIPAddress to display the configured NIC interfaces, and supply the interface name with the -Interface parameter. + +Minimum required privileges: Infrastructure administrator + + + + + Set-OVApplianceStaticRoute + + InputObject + + Static route object from Get-OVApplianceStaticRoute. + + StaticRoute + + + Destination + + IP Address of the destination subnet. Format must follow {address}/{bits}. Can either be IPv4 or IPv6 address type. + + String + + + Gateway + + The IP address of the router. Can either be an IPv4 or IPv6 address, but must match the type provided in the -Destination parameter. + + IPAddress + + + Interface + + Interface name of the NIC the static route will be configured for. + + String + + + Metric + + Route weight value if multiple next hop routes will be configured for the same subnet. If no value provided, the route weight will be set to 100. + + int + + + ApplianceConnection + + Specify one or more HPEOneView.Appliance.Connection object(s) or Name property value(s). + +Default Value: ${Global:ConnectedSessions} | ? Default + + Object + + + WhatIf + + + + + + + Confirm + + + + + + + + + + + ApplianceConnection + + Specify one or more HPEOneView.Appliance.Connection object(s) or Name property value(s). + +Default Value: ${Global:ConnectedSessions} | ? Default + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Confirm + + + + + + + + + + + Destination + + IP Address of the destination subnet. Format must follow {address}/{bits}. Can either be IPv4 or IPv6 address type. + + String + + String + + + + + Gateway + + The IP address of the router. Can either be an IPv4 or IPv6 address, but must match the type provided in the -Destination parameter. + + IPAddress + + IPAddress + + + + + InputObject + + Static route object from Get-OVApplianceStaticRoute. + + StaticRoute + + StaticRoute + + + + + Interface + + Interface name of the NIC the static route will be configured for. + + String + + String + + + + + Metric + + Route weight value if multiple next hop routes will be configured for the same subnet. If no value provided, the route weight will be set to 100. + + int + + int + + + + + WhatIf + + + + + + + + + + + + + + + HPEOneView.Appliance.StaticRoute + + + Configured static route object from Get-OVApplianceStaticRoute. + + + + + + + + HPOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + Async task resource to monitor. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVapplianceStaticRoute -Destination 192.168.78.0/24 | Set-OVApplianceStaticRoute -Gateway 192.168.12.254 + + + Update the specific static route with a new gateway address. + + + + + + + + + + + + + Get-OVApplianceStaticRoute + + + + New-OVApplianceStaticRoute + + + + Remove-OVApplianceStaticRoute + + + + Online: + https://hpe-docs.gitbook.io/posh-hpeoneview/cmdlets/v9.00/appliance/set-ovappliancestaticroute + + + + + + + + Set-OVApplianceTwoFactorAuthentication + + Configure appliance two-factor authentication settings. + + Set + OVApplianceTwoFactorAuthentication + + + Enabling two-factor authentication allows you to use smart cards � for example, Common Access Cards (CAC), or Personal Identity Verification (PIV) cards � to authenticate within HPE OneView. The client certificate embedded in the smart card is presented to HPE OneView by the library. The client certificate must be signed by a root or intermediate Certificate Authority (CA) that has been previously imported into the HPE OneView appliance. The appliance authenticates the client certificate to validate that the user name specified in the certificate is that of a valid user recognized by the directory server configuration in HPE OneView. + +When two-factor authentication is enabled, HPE OneView uses a Microsoft Active Directory service account set up and owned by the user to access an Active Directory entry for the user, rather than using an account associated with the user name received during first time login. + +Use this Cmdlet to configure two factor authentication state of the connected appliance. An Active Directory authentication directory must be configured, with a Service Account, and the root or issuing certificate authority Base64 certificate must be uploaded to appliance. + +Required: Infrastructure administrator + + + + + Set-OVApplianceTwoFactorAuthentication + + SmartCardLoginOnly + + Use to enforce smart card authentication only. Enabling Smart card only login disables the authentication using a user name and password. User name and password login is still available through the appliance console. You will be prompted to confirm the use of this parameter. Use the -Confirm to override prompt. + + Bool + + + EnableEmergencyLocalLogin + + [DEPRECATED] This parameter is now part of both Disable-OVLdapLocalLogin and Set-OVLdapDefaultDirectory. + +Boolean value to enable ($true) or disable ($false) emergency local login. Must be set to $false when -SmartCardLoginOnly is used. + + Bool + + + EmergencyLoginAllowType + + [DEPRECATED] This parameter is now part of both Disable-OVLdapLocalLogin and Set-OVLdapDefaultDirectory. + +Allow emergency login access if the configured authentication directory(ies) are unavailable. Highest security is obtained by restricting the local administrator account to "ApplianceConsoleOnly". Choose "NetworkAndApplianceConsole" to allow emergency access via the network. + + String + + + SubjectAlternativeNamePatterns + + By default, the attribute entry associated with the "Subject Alternative Name" item, within the "Certificate owner" entry, contains OtherName.UPN=(.*). This tells HPE OneView to extract the user name from the "OtherName.UPN" attribute within the Subject Alternative Name field of the certificate on the smart card. This is the user name that HPE OneView uses to query the enterprise directory. + +You can edit the value to enable HPE OneView to search for the user name within other additional attributes within Subject Alternative Name. The options include: + * OtherName.UPN=(.*) + The Microsoft certificate viewer displays "OtherName.UPN" underSubject Alternative Name as: + Other Name: + Principal Name=John.Doe@test.com + + * OtherName.RFC822Name=(.*) + The Microsoft certificate viewer displays OtherName.RFC822Name as: + Other Name: + RFC822 Name=John.Doe@test.com + + * RFC822Name=(.*) + The Microsoft certificate viewer displays RFC822Name as: + RFC822 Name=John.Doe@test.com + + * DirName=(.*) + The Microsoft certificate viewer displays "DirName" under Subject Alternative Name as: + Directory Address: + CN=John Doe + OU=Test Group + O=Test Org + C=US + DC=test + DC=com + +Use a comma-separated list to include multiple values in the entry field, allowing HPE OneView to search multiple Subject Alternative Name attributes for a valid user name. + +NOTE: You can instruct HPE OneView to search for the user name within the attributes of the "Subject" field of the smart card certificate (either in addition to, or instead of, searching within "Subject Alternative Name" attributes). See subject entry in the "Certificate owner" field for details. + +Subject Alternative Name multiple attribute entry example +OtherName.UPN=(.*),OtherName.RFC822Name=(.*),RFC822Name=(.*),DirName=(.*) + + Array + + + SubjectPatterns + + By default, the attribute entry box associated with the "Subject" entry, within the "Certificate owner" field, contains CN=(.*). With this value, HPE OneView extracts the first user name it encounters within a "CN" attribute within the "Subject" field in the smart card certificate. You can edit the regular expression for the "CN" attribute using regular expressions to refine the list of acceptable values. +You can edit the value if you need HPE OneView to search for the user name within other additional attributes within the certificate "Subject" field. The choices include: + + * CN=(.*) + * E=(.*) + * UID=(.*) + * DN=(.*) +Microsoft Active Directory users must note that the DN is extracted as an aggregate of the subject attributes from the certificate. This should match the DN value configured for the user in the Active Directory. If this is not an exact match, the login operation fails. + +Use a comma separated list to include multiple values in the entry field, allowing HPE OneView to search multiple Subject attributes for a valid user name. + +NOTE: You can instruct HPE OneView to search for the user name within the attributes of the "Subject" field of the smart card certificate (either in addition to, or instead of, searching within "Subject Alternative Name" attributes). + +Subject multiple attribute entry example + * CN=(.*),E=(.*),UID=(.*),DN=(.*) + +Variations for the CN attribute: examples + To match only user names starting with "J_" use CN=(^J_.*$) + To match names in "LastName, FirstName" format use CN=(^[a-zA-Z]*, [a-zA-Z]+$) + To match user names containing only numbers CN=(^[0-9]+$) + +NOTE: This is applicable when there are multiple CN attributes configured in a certificate and the user wants to specify a specific attribute rather than the first available in the CN attribute. It is recommended to use patterns that begin with "^" and ends with "$" so that the system can perform an exact match. + + String + + + ValidationOids + + This parameter allows you to configure who can access HPE OneView by specifying the Key Usage, Extended Key Usage and Policy ID Object Identifiers (OIDs) that must be present within a smart card certificate in order for the user associated with the card to be authenticated. You can configure up to five OID combinations to accommodate different groups of users within your organization. + +By default, one combination is configured, containing the OID combination Smart Card Logon (1.3.6.1.4.1.311.20.2.2), Client Authentication (1.3.6.1.5.5.7.3.2). This combination requires the certificate on the smart card to be configured to allow the certificate to be used for smart card logon and for client authentication. It should work for most installations. You can edit this field to opt for a different combination of OIDs, or to add additional OIDs. A maximum of ten OIDs can be configured in a single string. + +NOTE: If you specify multiple OID combinations and one is a super-set of another, configure the more restrictive combination first. + + Array + + + DirectoryDomainType + + The Directory domain control allows you to specify which domain or directory to use when searching for the user in an enterprise directory. The domain name must match the Base DN of at least one of the directories added to HPE OneView. The options include: + + * Subject + * Subject Alternative Name + * Issuer + * Manually specify + +After you select which certificate field HPE OneView must use to extract the domain name, the name is extracted from the DC attributes specified therein. The DC=(.*) configuration extracts the first domain component from the field. The administrator can only specify DC=(.*) here. + +If you select Manually specify, you can enter a specific domain using dot notation, or an alternate certificate location from which to retrieve domain information to use when querying the directory. You can specify multiple entries or domains in the configuration using ",". Additionally, you can specify the subject, subject alternative name and Issuer DC attributes to support multiple card configuration. + + String + + + DirectoryDomain + + Selection values for the "Manually specify" control + +In the fields of a certificate, the domain components are usually represented by multiple "DC=" entries. A domain BaseDN, like abc.example.com, is represented by the three entries "DC=abc", "DC=example", and "DC=com". + +Use "example.com" as the domain to use when searching for users in an enterprise directory: + +example.com + +Configure HPE OneView to look in multiple certificate locations for domain information. HPE OneView tries each item in order until it finds a successful user entry in the enterprise directory. + +Subject.DC=(.*),Issuer.DC=(.*),SubjectAlternativeName.DirName.DC=(.*),groupA.example.com,groupB.example.com + + String + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + + WhatIf + + + + SwitchParameter + + + Confirm + + Override confirmation prompt when using -SmartCardLoginOnly parameter. + + SwitchParameter + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + Array + + (${Global:ConnectedSessions} | ? Default) + + + Confirm + + Override confirmation prompt when using -SmartCardLoginOnly parameter. + + SwitchParameter + + SwitchParameter + + + + + DirectoryDomain + + Selection values for the "Manually specify" control + +In the fields of a certificate, the domain components are usually represented by multiple "DC=" entries. A domain BaseDN, like abc.example.com, is represented by the three entries "DC=abc", "DC=example", and "DC=com". + +Use "example.com" as the domain to use when searching for users in an enterprise directory: + +example.com + +Configure HPE OneView to look in multiple certificate locations for domain information. HPE OneView tries each item in order until it finds a successful user entry in the enterprise directory. + +Subject.DC=(.*),Issuer.DC=(.*),SubjectAlternativeName.DirName.DC=(.*),groupA.example.com,groupB.example.com + + String + + String + + + + + DirectoryDomainType + + The Directory domain control allows you to specify which domain or directory to use when searching for the user in an enterprise directory. The domain name must match the Base DN of at least one of the directories added to HPE OneView. The options include: + + * Subject + * Subject Alternative Name + * Issuer + * Manually specify + +After you select which certificate field HPE OneView must use to extract the domain name, the name is extracted from the DC attributes specified therein. The DC=(.*) configuration extracts the first domain component from the field. The administrator can only specify DC=(.*) here. + +If you select Manually specify, you can enter a specific domain using dot notation, or an alternate certificate location from which to retrieve domain information to use when querying the directory. You can specify multiple entries or domains in the configuration using ",". Additionally, you can specify the subject, subject alternative name and Issuer DC attributes to support multiple card configuration. + + String + + String + + + + + EmergencyLoginAllowType + + [DEPRECATED] This parameter is now part of both Disable-OVLdapLocalLogin and Set-OVLdapDefaultDirectory. + +Allow emergency login access if the configured authentication directory(ies) are unavailable. Highest security is obtained by restricting the local administrator account to "ApplianceConsoleOnly". Choose "NetworkAndApplianceConsole" to allow emergency access via the network. + + String + + String + + + + + EnableEmergencyLocalLogin + + [DEPRECATED] This parameter is now part of both Disable-OVLdapLocalLogin and Set-OVLdapDefaultDirectory. + +Boolean value to enable ($true) or disable ($false) emergency local login. Must be set to $false when -SmartCardLoginOnly is used. + + Bool + + Bool + + + + + SmartCardLoginOnly + + Use to enforce smart card authentication only. Enabling Smart card only login disables the authentication using a user name and password. User name and password login is still available through the appliance console. You will be prompted to confirm the use of this parameter. Use the -Confirm to override prompt. + + Bool + + Bool + + + + + SubjectAlternativeNamePatterns + + By default, the attribute entry associated with the "Subject Alternative Name" item, within the "Certificate owner" entry, contains OtherName.UPN=(.*). This tells HPE OneView to extract the user name from the "OtherName.UPN" attribute within the Subject Alternative Name field of the certificate on the smart card. This is the user name that HPE OneView uses to query the enterprise directory. + +You can edit the value to enable HPE OneView to search for the user name within other additional attributes within Subject Alternative Name. The options include: + * OtherName.UPN=(.*) + The Microsoft certificate viewer displays "OtherName.UPN" underSubject Alternative Name as: + Other Name: + Principal Name=John.Doe@test.com + + * OtherName.RFC822Name=(.*) + The Microsoft certificate viewer displays OtherName.RFC822Name as: + Other Name: + RFC822 Name=John.Doe@test.com + + * RFC822Name=(.*) + The Microsoft certificate viewer displays RFC822Name as: + RFC822 Name=John.Doe@test.com + + * DirName=(.*) + The Microsoft certificate viewer displays "DirName" under Subject Alternative Name as: + Directory Address: + CN=John Doe + OU=Test Group + O=Test Org + C=US + DC=test + DC=com + +Use a comma-separated list to include multiple values in the entry field, allowing HPE OneView to search multiple Subject Alternative Name attributes for a valid user name. + +NOTE: You can instruct HPE OneView to search for the user name within the attributes of the "Subject" field of the smart card certificate (either in addition to, or instead of, searching within "Subject Alternative Name" attributes). See subject entry in the "Certificate owner" field for details. + +Subject Alternative Name multiple attribute entry example +OtherName.UPN=(.*),OtherName.RFC822Name=(.*),RFC822Name=(.*),DirName=(.*) + + Array + + Array + + + + + SubjectPatterns + + By default, the attribute entry box associated with the "Subject" entry, within the "Certificate owner" field, contains CN=(.*). With this value, HPE OneView extracts the first user name it encounters within a "CN" attribute within the "Subject" field in the smart card certificate. You can edit the regular expression for the "CN" attribute using regular expressions to refine the list of acceptable values. +You can edit the value if you need HPE OneView to search for the user name within other additional attributes within the certificate "Subject" field. The choices include: + + * CN=(.*) + * E=(.*) + * UID=(.*) + * DN=(.*) +Microsoft Active Directory users must note that the DN is extracted as an aggregate of the subject attributes from the certificate. This should match the DN value configured for the user in the Active Directory. If this is not an exact match, the login operation fails. + +Use a comma separated list to include multiple values in the entry field, allowing HPE OneView to search multiple Subject attributes for a valid user name. + +NOTE: You can instruct HPE OneView to search for the user name within the attributes of the "Subject" field of the smart card certificate (either in addition to, or instead of, searching within "Subject Alternative Name" attributes). + +Subject multiple attribute entry example + * CN=(.*),E=(.*),UID=(.*),DN=(.*) + +Variations for the CN attribute: examples + To match only user names starting with "J_" use CN=(^J_.*$) + To match names in "LastName, FirstName" format use CN=(^[a-zA-Z]*, [a-zA-Z]+$) + To match user names containing only numbers CN=(^[0-9]+$) + +NOTE: This is applicable when there are multiple CN attributes configured in a certificate and the user wants to specify a specific attribute rather than the first available in the CN attribute. It is recommended to use patterns that begin with "^" and ends with "$" so that the system can perform an exact match. + + String + + String + + + + + ValidationOids + + This parameter allows you to configure who can access HPE OneView by specifying the Key Usage, Extended Key Usage and Policy ID Object Identifiers (OIDs) that must be present within a smart card certificate in order for the user associated with the card to be authenticated. You can configure up to five OID combinations to accommodate different groups of users within your organization. + +By default, one combination is configured, containing the OID combination Smart Card Logon (1.3.6.1.4.1.311.20.2.2), Client Authentication (1.3.6.1.5.5.7.3.2). This combination requires the certificate on the smart card to be configured to allow the certificate to be used for smart card logon and for client authentication. It should work for most installations. You can edit this field to opt for a different combination of OIDs, or to add additional OIDs. A maximum of ten OIDs can be configured in a single string. + +NOTE: If you specify multiple OID combinations and one is a super-set of another, configure the more restrictive combination first. + + Array + + Array + + + + + WhatIf + + + + SwitchParameter + + SwitchParameter + + + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + System.Management.Automation.PSCustomObject + + + + Appliance global security settings. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Set-OVApplianceTwoFactorAuthentication -ValidationOids @(@{"1.3.6.1.4.1.311.20.2.2" = "Smart Card Logon"; "1.3.6.1.5.5.7.3.2" = "Client Authentication"}) + + Configured two-factory authentication using default validation OIDs. + + + + + + + + + + + + + Disable-OVApplianceTwoFactorAuthentication + + + + Get-OVApplianceTwoFactorAuthentication + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/set-ovappliancetwofactorauthentication + + + + + + + + Set-OVAutomaticBackupConfig + + Configure automatic appliance backup. + + Set + OVAutomaticBackupConfig + + + Introduced in HPE OneView 3.0, an automatic appliance backup schedule can be configured. The automatic backup process will generate the backup file, then transfer it to a host that supports SCP or SFTP. The hosts public SSH key will be needed in order to successfuly configure. + +During the configuration process, a test file will be created and stored on the host. This file can be safely deleted once the async task has successfully completed. + + + + + Set-OVAutomaticBackupConfig + + Hostname + + The IP Address or FQDN of the target SCP or SFTP host. + + String + + + Username + + The username to authenticate to the SCP/SFTP host with. + + String + + + Password + + The password of the user. + +Specify the Logical Interconnect URI or Object the Support Dump will be generated for, from pipeline. + + System.Security.SecureString + + + Passphrase + + A secure Passphrase is required to encrypt the appliance backup. An exception will be generated if this parameter is used and the target appliance doesn't meet the minimum required version. + + SecureString + + + Port + + The target port of the destination service. By default, this is 22/TCP. Only TCP ports are supported. + + int + + + Directory + + The remote directory on the host where the file will be saved to. Omit to sepcify the root or default directory the user account is associated with. + + String + + + HostSSHKey + + The SCP/SFTP hosts public key, in OpenSSH String format. + + String + + + Protocol + + The protocol to connect to the remote host with. Supported values are: + + * SCP + * SFTP + +Default: SCP + + String + + + Interval + + The frequency the backup will be generated. Supported values are: + + * Daily + * Weekly + + String + + + Days + + If specifying a Weekly backup, provide the days in an Array. Accepted values are: + + * SU or SUN or Sunday + * MO or MON or Monday + * TU or TUE or Tuesday + * WE or WED or Wednesday + * TH or THUR or Thursday + * FR or FRI or Friday + * SA or SAT or Saturday + + Array + + + Time + + The time to execute, in 24hr clock. + + String + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Array + + + WhatIf + + + + SwitchParameter + + + Confirm + + + + SwitchParameter + + + + Set-OVAutomaticBackupConfig + + Disabled + + Disable the automatic backup schedule. + + SwitchParameter + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Array + + + WhatIf + + + + SwitchParameter + + + Confirm + + + + SwitchParameter + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Array + + Array + + (${Global:ConnectedSessions} | ? Default) + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + SwitchParameter + + False + + + Confirm + + + + SwitchParameter + + SwitchParameter + + + + + Days + + If specifying a Weekly backup, provide the days in an Array. Accepted values are: + + * SU or SUN or Sunday + * MO or MON or Monday + * TU or TUE or Tuesday + * WE or WED or Wednesday + * TH or THUR or Thursday + * FR or FRI or Friday + * SA or SAT or Saturday + + Array + + Array + + + + + Directory + + The remote directory on the host where the file will be saved to. Omit to sepcify the root or default directory the user account is associated with. + + String + + String + + + + + Disabled + + Disable the automatic backup schedule. + + SwitchParameter + + SwitchParameter + + False + + + HostSSHKey + + The SCP/SFTP hosts public key, in OpenSSH String format. + + String + + String + + + + + Hostname + + The IP Address or FQDN of the target SCP or SFTP host. + + String + + String + + + + + Interval + + The frequency the backup will be generated. Supported values are: + + * Daily + * Weekly + + String + + String + + + + + Passphrase + + A secure Passphrase is required to encrypt the appliance backup. An exception will be generated if this parameter is used and the target appliance doesn't meet the minimum required version. + + SecureString + + SecureString + + + + + Password + + The password of the user. + +Specify the Logical Interconnect URI or Object the Support Dump will be generated for, from pipeline. + + System.Security.SecureString + + System.Security.SecureString + + + + + Port + + The target port of the destination service. By default, this is 22/TCP. Only TCP ports are supported. + + int + + int + + + + + Protocol + + The protocol to connect to the remote host with. Supported values are: + + * SCP + * SFTP + +Default: SCP + + String + + String + + SCP + + + Time + + The time to execute, in 24hr clock. + + String + + String + + + + + Username + + The username to authenticate to the SCP/SFTP host with. + + String + + String + + + + + WhatIf + + + + SwitchParameter + + SwitchParameter + + + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + Appliance async task to monitor + + + + + System.Collections.Arraylist <HPEOneView.Appliance.TaskResource> + + + + Multiple appliance async task to monitor + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + $HostSSHKey = Get-Content C:\host.key +Set-OVAutomaticBackupConfig -Hostname scphost.domain.com -Username backupadmin -Password (ConvertTo-SecureString password -AsPlainText -Force) -HostSSHKey $HostSSHKey -Protocol SCP -Interval Weekly -Days "MON","WED","FRI" -Time 18:00 + + This command will configure automatic appliance backup, based on a weekly Monday, Wednesday and Friday schedule to execute at 18:00 (6:00PM). + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + $HostSSHKey = Get-Content C:\host.key +Set-OVAutomaticBackupConfig -Hostname scphost.domain.com -Username backupadmin -Password (ConvertTo-SecureString password -AsPlainText -Force) -HostSSHKey $HostSSHKey -Protocol SCP -Interval Weekly -Days "MON","WED","FRI" -Time 18:00 +New-OVBackup + + This command will configure automatic appliance backup, based on a weekly Monday, Wednesday and Friday schedule to execute at 18:00 (6:00PM). Then, a call to New-OVBackup will be made, which will generate and copy the backup file to the remote location configured. + + + + + + + + + + + + + Get-OVAutomaticBackupConfig + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/set-ovautomaticbackupconfig + + + + + + + + Set-OVCertificateRevocationInterval + + Change the interval of Certificate Revocation List download. + + Set + OVCertificateRevocationInterval + + + Certificate Revocation List (CRL) associated with a CA certificate typically gets expired on a weekly or monthly interval. When you receive the CRL expiration alert, manually upload the new CRL to HPE OneView. You can configure HPE OneView 5.2 and later versions and automatically download CRLs. When the Automatic CRL downloading setting is enabled, a scheduled automatic CRL downloader on the appliance checks the validity of all the CRLs that are available in the appliance, and updates the CRLs that have expired or are about to expire. The downloader also downloads new CRLs during this process if the CRLs were not previously downloaded. The scheduled time for running the job is set to 12AM UTC. The appliance checks for CRLs every day that are about to expire. If any of the CRLs are about to expire in three days, the appliance downloads the latest available CRL. This prevents the expiration of CRLs on the appliance. You can configure the schedule for downloading the latest available CRLs using a global setting variable global.daysBeforeToTriggerCRLDownload using the REST API /rest/certificates/validator-configuration. If there is a failure during the CRL download, the appliance retries the operation three times before raising an alert. + +NOTE: Irrespective of the number of days before the download is triggered, the CRL infrastructure has a potential lag. When a CA uploads a new CRL, the CA does not have the capability to inform about the update. Due to this lag in the CRL infrastructure, a new revoked certificate will not be picked up until next refresh. This is not an HPE OneView specific issue rather a limitation with the CRL ecosystem. + +If the scheduled run for a specific day is missed due to reasons such as the appliance is down on the scheduled day, HPE OneView will initiate the CRL downloader post reboot. + +See the online help Certificate Revocation Lists discussion topic for more information. + +Minimum required privileges: Infrastructure administrator + + + + + Set-OVCertificateRevocationInterval + + AutoCRLDownloadInterval + + The number of days to perform CRL download, if CRL is defined within leaf certificate. + + int + + + ApplianceConnection + + Specify one or more HPEOneView.Appliance.Connection object(s) or Name property value(s). + +Default Value: ${Global:ConnectedSessions} | ? Default + + Object + + + WhatIf + + + + SwitchParameter + + + Confirm + + + + SwitchParameter + + + + + + + ApplianceConnection + + Specify one or more HPEOneView.Appliance.Connection object(s) or Name property value(s). + +Default Value: ${Global:ConnectedSessions} | ? Default + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + AutoCRLDownloadInterval + + The number of days to perform CRL download, if CRL is defined within leaf certificate. + + int + + int + + + + + Confirm + + + + SwitchParameter + + SwitchParameter + + + + + WhatIf + + + + SwitchParameter + + SwitchParameter + + + + + + + + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Set-OVCertificateRevocationInterval + + + Default example + + + + + + + + + + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/library/set-ovcertificaterevocationinterval + + + + + + + + Set-OVClusterManager + + Modify an existing hypervisor manager. + + Set + OVClusterManager + + + You can register a new hypervisor manager with HPE OneView by providing the hostname and credentials. The registered hypervisor manager contains preferences, which are used as default hypervisor or cluster settings during hypervisor cluster profile creation. You can modify the hypervisor manager preferences using the edit operation. You can override these values in a hypervisor cluster profile. + +A valid hypervisor manager certificate must be added to HPE OneView trust store to be able to successfully communicate with a hypervisor manager. + +The user must have an infrastructure administrator privilege to register or update the hypervisor manager resource in HPE OneView. You can assign scopes to the hypervisor manager resource in HPE OneView. + + + + + Set-OVClusterManager + + InputObject + + The cluster manager resource object from Get-OVClusterManager. + + HypervisorManager + + + Hostname + + Use to update the IP or FQDN address of the target cluster manager. + + String + + + DisplayName + + Change the display name of the cluster manager. + + String + + + Port + + Use to update the TCP port of the cluster manager. + + Int + + + Credential + + Use this parameter if you want to provide a PSCredential object. Using this parameter will update the authentication credentials needed to communicate with the cluster manager. + + PSCredential + + + VirtualSwitchType + + Use to adjust the virtual switch for hypervisor clsuters with the specified type. Allowed values: + + * Standard - A virtual switch configured and managed at the hypervisor level; provides networking to virtual machines and VM kernels. + * Distributed - A virtual switch configured and managed at data center level and configured for each hypervisor to provide networking to virtual machines and VM Kernels. + + String + + + DistributedSwitchUsage + + Applicable only when vSwitch type is Distributed. This specifies which networks should be configured for distributed switches. Allowed values: + + * AllNetworks - Configures all the networks in the hypervisor cluster profile with distributed virtual switches. All networks include Management, special purpose and general purpose networks. The special purpose networks comprise VM Migration, iSCSI and Fault Tolerance. + * GeneralNetworks - Configures the general purpose networks in the hypervisor cluster profile with distributed virtual switches. + + String + + + DistributedSwitchVersion + + Applicable only when vSwitch type is of type distributed. Configures distributed virtual switch with the specified version, and must be supported by the Hypervisor Manager. + + String + + + HAEnabled + + Use to enable or disable VMware HA. + + Bool + + + DRSEnabled + + Use to enable or disable VMware DRS default settings for clusters. + + Bool + + + MultiNicVMotionEnabled + + Use to enable or disable VMware VMotion multi-NIC vmotion. + + Bool + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + SwitchParameter + + False + + + Credential + + Use this parameter if you want to provide a PSCredential object. Using this parameter will update the authentication credentials needed to communicate with the cluster manager. + + PSCredential + + PSCredential + + + + + DRSEnabled + + Use to enable or disable VMware DRS default settings for clusters. + + Bool + + Bool + + + + + DisplayName + + Change the display name of the cluster manager. + + String + + String + + + + + DistributedSwitchUsage + + Applicable only when vSwitch type is Distributed. This specifies which networks should be configured for distributed switches. Allowed values: + + * AllNetworks - Configures all the networks in the hypervisor cluster profile with distributed virtual switches. All networks include Management, special purpose and general purpose networks. The special purpose networks comprise VM Migration, iSCSI and Fault Tolerance. + * GeneralNetworks - Configures the general purpose networks in the hypervisor cluster profile with distributed virtual switches. + + String + + String + + + + + DistributedSwitchVersion + + Applicable only when vSwitch type is of type distributed. Configures distributed virtual switch with the specified version, and must be supported by the Hypervisor Manager. + + String + + String + + + + + HAEnabled + + Use to enable or disable VMware HA. + + Bool + + Bool + + + + + Hostname + + Use to update the IP or FQDN address of the target cluster manager. + + String + + String + + + + + InputObject + + The cluster manager resource object from Get-OVClusterManager. + + HypervisorManager + + HypervisorManager + + + + + MultiNicVMotionEnabled + + Use to enable or disable VMware VMotion multi-NIC vmotion. + + Bool + + Bool + + + + + Port + + Use to update the TCP port of the cluster manager. + + Int + + Int + + + + + VirtualSwitchType + + Use to adjust the virtual switch for hypervisor clsuters with the specified type. Allowed values: + + * Standard - A virtual switch configured and managed at the hypervisor level; provides networking to virtual machines and VM kernels. + * Distributed - A virtual switch configured and managed at data center level and configured for each hypervisor to provide networking to virtual machines and VM Kernels. + + String + + String + + + + + + + + + HPEOneView.Cluster.ClusterManager + + + The cluster manager from Get-OVClusterManager. + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + Asynchronous task resource to monitor. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Set-OVClusterManager + + Default example + + + + + + + + + + + + + Add-OVClusterManager + + + + Get-OVClusterManager + + + + Remove-OVClusterManager + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/cluster/set-ovclustermanager + + + + + + + + Set-OVComposerIlo + + Modify the existing HPE Synergy Composer2 iLO configuration. + + Set + OVComposerIlo + + + You can configure the HPE Synergy Composer2 for remote access through its embedded management processor (iLO). This configuration enables you to manage the Composer2 remotely and perform specific Composer2 management operations that previously required accessing the Composer console locally in the data center. + +After remote access to a Composer2 iLO is configured, you can: + + * Use the iLO Integrated Remote Console (iLO IRC) to access the Composer2 physical console. The physical console provides access to the HPE OneView maintenance console. The Composer2 iLO has an independent IPaddress and is accessible even when the Composer2 is not available. + * Mount a virtual USB drive on the Composer2 through iLO and perform critical operations such as reimage,restore, backup, and create support dump without physically accessing the appliance. + * Power on or off the appliance. + +You can configure the iLO of the HPE Synergy Composer2 for remote access using this Cmdlet. All the Composer2 nodes that are present in the enclosures managed by HPE OneView can be configured, including standby or standalone Composer2 nodes. The following are the settings that you can configure for the Composer2 iLO in HPE OneView: + + * The iLO user account and password that are required to log in to the Composer2 iLO. + * Network parameters that allow you to access the Composer2 iLO from an external browser. The network parameters include iLO hostname, iLO IP address, subnet mask, gateway, and DNS server names. Both IPv4 and IPv6 addresses are supported. + +Supported operations on the Composer2 through the iLO Integrated Remote Console + +You can perform the following operations when using the HPE Synergy Composer2 iLO Integrated Remote Console (iLO IRC): + + * Switch between the graphical console or the Composer2 maintenance console. By default, the Composer2 console displays a graphical browser interface. Use Ctrl+Alt+F1 and Ctrl+Alt+F2 to switch between the graphical interface and the maintenance console. + * For the first-time setup, Hewlett Packard Enterprise recommends that you configure the appliance network before the hardware discovery process starts. + * Power on and off the appliance using the integrated power control options on the iLO remote console. + * Use the Composer2 iLO virtual media feature to have a USB drive on your local workstation mounted as a virtual USB drive on the Composer2. + +Virtually mounting the USB drive allows you to: + + * Reimage the Composer2 from a DD image on the virtual USB drive. + * Create a support dump file on the virtual USB drive. + + NOTE: If both virtual USB drive and local USB drive are plugged into the Composer2, by default the virtual USB drive is selected. To choose the USB drive that is plugged into the Composer2, unmount the virtual USB drive. In the iLO IRC, select Virtual Drives and clear the virtual drive selection to unmount the virtual USB drive. You can also unmount the virtual USB drive from the maintenance console of HPE OneView. + + * Restore the Composer2 from a backup image on the virtual USB drive. + +Requirements + + * A single iLO user account is supported. Creating a user account replaces any existing user account. + * The iLO username cannot be Administrator or start with an _. + +NOTE: The iLO user account is assigned a predefined set of privileges that allows the user to perform a restricted set of iLO operations. Specifically, the iLO account has permissions to control power, use the iLO Integrated Remote Console (iLO IRC), and use the iLO Virtual Media. + +Use this Cmdlet to change the existing iLO configuration. This Cmdlet supports changing the iLO Hostname, user account, its password, configured IPv4 or IPv6 addresses. + +Minimum required privileges: Infrastructure Administrator + + + + + + Set-OVComposerIlo + + InputObject + + The object from Get-OVComposerIloStatus. + + Object + + + Username + + Use to specify a new account name to configure. The original account will be removed from the iLO. + + String + + + Password + + Use to specify a new password for the configured iLO user account. + + SecureString + + + IPv4Address + + Use to specify a new IPv4 Address for the HPE Synergy Composer2 iLO. + + IPAddress + + + IPv4SubnetMask + + Use to optionally update the IPv4 subnet mask for the new IPv4 address. Can either be the full subnet mask in decimal noted or CIDR format. + + String + + + IPv4Gateway + + Use to optionally specify the default gateway for the new IPv4 address. + + IPAddress + + + IPv4DnsServer + + Use to optionally set 1 or 2 IPv4 DNS Servers. + + IPAddress[] + + + IPv6Address + + Use to specify a new IPv6 Address for the HPE Synergy Composer2 iLO. + + IPAddress + + + IPv6SubnetMask + + Use to optionally specify the default gateway for the new IPv6 address. Can either be the full subnet mask in colon noted or CIDR format. + + String + + + IPv6Gateway + + Use to optionally specify the default gateway for the new IPv6 address. + + String + + + IPv6DnsServer + + Use to optionally set 1 or 2 IPv6 DNS Servers. + + IPAddress[] + + + IloHostname + + Use to optionally specify a new iLO subsystem hostname. + + String + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + ApplianceConnection + + Specify one or more HPEOneView.Appliance.Connection object(s) or Name property value(s). + +Default Value: ${Global:ConnectedSessions} | ? Default + + Object + + + WhatIf + + + + SwitchParameter + + + Confirm + + + + SwitchParameter + + + + + + + ApplianceConnection + + Specify one or more HPEOneView.Appliance.Connection object(s) or Name property value(s). + +Default Value: ${Global:ConnectedSessions} | ? Default + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + SwitchParameter + + False + + + Confirm + + + + SwitchParameter + + SwitchParameter + + + + + IPv4Address + + Use to specify a new IPv4 Address for the HPE Synergy Composer2 iLO. + + IPAddress + + IPAddress + + + + + IPv4DnsServer + + Use to optionally set 1 or 2 IPv4 DNS Servers. + + IPAddress[] + + IPAddress[] + + + + + IPv4Gateway + + Use to optionally specify the default gateway for the new IPv4 address. + + IPAddress + + IPAddress + + + + + IPv4SubnetMask + + Use to optionally update the IPv4 subnet mask for the new IPv4 address. Can either be the full subnet mask in decimal noted or CIDR format. + + String + + String + + + + + IPv6Address + + Use to specify a new IPv6 Address for the HPE Synergy Composer2 iLO. + + IPAddress + + IPAddress + + + + + IPv6DnsServer + + Use to optionally set 1 or 2 IPv6 DNS Servers. + + IPAddress[] + + IPAddress[] + + + + + IPv6Gateway + + Use to optionally specify the default gateway for the new IPv6 address. + + String + + String + + + + + IPv6SubnetMask + + Use to optionally specify the default gateway for the new IPv6 address. Can either be the full subnet mask in colon noted or CIDR format. + + String + + String + + + + + IloHostname + + Use to optionally specify a new iLO subsystem hostname. + + String + + String + + + + + InputObject + + The object from Get-OVComposerIloStatus. + + Object + + Object + + + + + Password + + Use to specify a new password for the configured iLO user account. + + SecureString + + SecureString + + + + + Username + + Use to specify a new account name to configure. The original account will be removed from the iLO. + + String + + String + + + + + WhatIf + + + + SwitchParameter + + SwitchParameter + + + + + + + + + HPEOneView.Appliance.HardwareConfig [System.Management.Automation.PSCustomObject] + + + The appliance hardware configuration object from Get-OVComposerIloStatus. + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + Async task resource to monitor. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + $UpdatedSecurePassword = Read-Host "Password" -AsSecureString +$ComposerAppliance = Get-OVComposerIloStatus +Set-OVComposerIlo -InputObject $ComposerAppliance -Hostname Myilohost.domian.com -Password $UpdatedSecurePassword + + + Change the existing iLO user account password to the value provided for the specific HPE Synergy Composer 2 iLO. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + $ComposerAppliance = Get-OVComposerIloStatus | Where-Object Role -eq "Active" +Set-OVComposerIlo -InputObject $ComposerAppliance -IPv4Address 10.16.1.102 -IPv4SubnetMask 23 -IPv4Gateway 10.16.0.1 + + + Change the IPv4 address to the new value for the Active (Primary) HPE Synergy Composer 2 iLO. + + + + + + + + + + -------------------------- EXAMPLE 3 -------------------------- + + + + $ComposerAppliance = Get-OVComposerIloStatus | Where-Object Role -eq "Standby" +Set-OVComposerIlo -InputObject $ComposerAppliance -IPv4Address 10.16.1.103 -IPv4SubnetMask 23 -IPv4Gateway 10.16.0.1 + + + Change the IPv4 address to the new value for the Standby (Secondary) HPE Synergy Composer 2 iLO. + + + + + + + + + + + + + Disable-OVComposerIlo + + + + Enable-OVComposerIlo + + + + Get-OVComposerIloStatus + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/set-ovcomposerilo + + + + + + + + Set-OVComputeOpsManagement + + Configure a new activation key for the appliance Compute Ops Management configuration. + + Set + OVComputeOpsManagement + + + HPE GreenLake for Compute Ops Management is a cloud-based as-a-Service application that manages various operations of HPE OneView appliances. By integrating HPE OneView with HPE GreenLake for Compute Ops Management will unify server inventory and centralize management to a single console. To enable the cloud management service for HPE OneView, you must onboard the appliance in the Compute Ops Management application in HPE GreenLake by using this Cmdlet to first generate the appliance ID. Once the Cmdlet completes successfully, use the Get-OVComputeOpsManagement Cmdlet to retreive the appliance ID needed in the HPE GreenLake for Compute Ops Management to generate an activation key. You can use this same Cmdlet with the -ActivationKey parameter, or Set-OVComputeOpsManagement Cmdlet to set the activation key for the appliance. + +Minimum required privileges: Infrastructure administrator + + + + + Set-OVComputeOpsManagement + + ActivationKey + + String value of the appliance unique activation key from the HPE GreenLake for Compute Ops Management portal. + + string + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + ApplianceConnection + + Specify one or more HPEOneView.Appliance.Connection object(s) or Name property value(s). + +Default Value: ${Global:ConnectedSessions} | ? Default + + Object + + + + + + + ActivationKey + + String value of the appliance unique activation key from the HPE GreenLake for Compute Ops Management portal. + + string + + string + + + + + ApplianceConnection + + Specify one or more HPEOneView.Appliance.Connection object(s) or Name property value(s). + +Default Value: ${Global:ConnectedSessions} | ? Default + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + SwitchParameter + + False + + + + + + + None. You cannot pipe objects to this cmdlet. + + + + + + + + + + + HPOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + Async task resource to monitor. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + # Create the appliance ApplianceID. An async task is returned. +[PS] C:\> Enable-OVComputeOpsManagement +Appliance Name Owner Created Duration +--------- ---- ----- ------- --- +appliance.domain.com Edit Compute Ops Management settings Administrator 9/20/2023 6:42:02 PM 00 + +# Get the appliance ApplianceID in order to generate an activation key within the HPE GreenLake for Compute Ops Management console. +[PS] C:\> Get-OVComputeOpsManagement + +Management : Enabled +ApplianceID : ed0538b9-011e-48d4-a70a-5b108e029ed1 +AccountID : +ConnectionState : Disconnected +Region : +Url : +ApplianceConnection : appliance.domain.com + +# Set the activation key on the appliance +[PS] C:\> Set-OVComputeOpsManagement -ActivationKey "STRING" +Appliance Name Owner Created Duration +--------- ---- ----- ------- --- +appliance.domain.com Edit Compute Ops Management settings Administrator 9/20/2023 6:47:34 PM 00:10 + +# Get the status of the appliance +[PS] C:\> Get-OVComputeOpsManagement + +Management : Enabled +ApplianceID : ed0538b9-011e-48d4-a70a-5b108e029ed1 +AccountID : a23cb1d4ecbe0aeca28966cc2ae80cb3 +ConnectionState : Connected +Region : us-west +Url : https://us-west2.compute.cloud.hpe.com/ +ApplianceConnection : appliance.domain.com + + Enable the Compute Ops Management agent on the appliance, generating the appliance ID, then activating. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + $ActivationKey = "string" +Set-OVComputeOpsManagement -ActivationKey $ActivationKey + + Configure the applinace with a new activatation key. + + + + + + + + + + + + + Connect-OVComputeOpsManagement + + + + Disable-OVComputeOpsManagement + + + + Enable-OVComputeOpsmanagement + + + + Get-OVComputeOpsManagement + + + + Set-OVApplianceProxy + + + + Online: + https://hpe-docs.gitbook.io/posh-hpeoneview/cmdlets/v9.00/appliance/set-ovcomputeopsmanagement + + + + + + + + Set-OVDataCenter + + Modify an existing Datacenter resource. + + Set + OVDataCenter + + + A data center represents a physically contiguous area in which racks containing IT equipment are located. +For example, you have IT equipment in two rooms or on separate floors. You could create a data center for each of these areas. +Each server, enclosure, or power distribution device in your data center can report its power requirements, but it can be difficult to understand the power and cooling requirements for your data center as a whole. The appliance enables you to bring power and cooling management of your servers, enclosures, and power delivery devices together in a single management system. +When you initialize the appliance for the first time, it creates a data center named Datacenter 1. The appliance provides this data center as a place to visualize your racks. You can rename or edit this data center to match the values and layout of your data center, you can use it as the basis for a planned data center model, or you can delete this data center without adverse effects. + +This Cmdlet will create a new datacenter. You will need to specify the Name and dimensions. Optionally, you can override the default Electrical Derating, default voltage, local currency (which will aid in power calculation costs) and power cooling capacity. Remote Support settings can only be set when Remote Support has been enabled and configured on the appliance. If omitting Remote Support location settings, then the datacenter will default to the default location set. + + + + + Set-OVDataCenter + + InputObject + + Datacenter object from Get-OVDataCenter. + + Object + + + Name + + A name to identify the data center. Must not exceed 255 characters; no leading spaces. + + String + + + Width + + Width of the datacenter, in (US) Feet. Maximum of 50 meters (164.042 feet). Millimeters can be used, which requires the -Millimeters switch parameter. + + Float + + + Depth + + Depth of the datacenter, in (US) Feet. Maximum of 50 meters (164.042 feet). Millimeters can be used, which requires the -Millimeters switch parameter. + + Float + + + Millimeters + + If specifying millimeter value for Width and Depth, this parameter is required. + + SwitchParameter + + + ElectricalDerating + + If Custom ElectricalDetratingType is set to Custom, specify a value between 20-100%. + +Default: 20% + + Int + + + ElectricalDeratingType + + The percentage below the rated maximum power dissipation at which the devices are operated, accounting for case/body temperature, ambient temperature, and type of cooling. + +You can specify a derating percentage by choosing Custom, or you can choose not to apply derating to the rated maximum power dissipation by specifying None. + +Default: NA/Jp + + String + + + DefaultVoltage + + The default power line voltage for the data center. + +Default: 220 + + Int + + + Currency + + The currency unit for energy costs. + + String + + + PowerCosts + + The energy cost per kWh, specified by the Currency. + + Float + + + CoolingCapacity + + The maximum cooling capacity for the data center, in KW. The appliance analyzes heat generation using this value. + + Int + + + CoolingMultiplier + + The ratio of cooling cost to power cost for the data center. + +This value represents the relative cost of cooling the system compared to the cost of powering the system. The default value of 1.5 indicates that it costs 1.5 times as much to cool the system as it does to power the system. + +Default: 1.5 + + Float + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + CoolingCapacity + + The maximum cooling capacity for the data center, in KW. The appliance analyzes heat generation using this value. + + Int + + Int + + + + + CoolingMultiplier + + The ratio of cooling cost to power cost for the data center. + +This value represents the relative cost of cooling the system compared to the cost of powering the system. The default value of 1.5 indicates that it costs 1.5 times as much to cool the system as it does to power the system. + +Default: 1.5 + + Float + + Float + + 1.5 + + + Currency + + The currency unit for energy costs. + + String + + String + + USD + + + DefaultVoltage + + The default power line voltage for the data center. + +Default: 220 + + Int + + Int + + 220 + + + Depth + + Depth of the datacenter, in (US) Feet. Maximum of 50 meters (164.042 feet). Millimeters can be used, which requires the -Millimeters switch parameter. + + Float + + Float + + + + + ElectricalDerating + + If Custom ElectricalDetratingType is set to Custom, specify a value between 20-100%. + +Default: 20% + + Int + + Int + + 20 + + + ElectricalDeratingType + + The percentage below the rated maximum power dissipation at which the devices are operated, accounting for case/body temperature, ambient temperature, and type of cooling. + +You can specify a derating percentage by choosing Custom, or you can choose not to apply derating to the rated maximum power dissipation by specifying None. + +Default: NA/Jp + + String + + String + + NA/Jp + + + InputObject + + Datacenter object from Get-OVDataCenter. + + Object + + Object + + + + + Millimeters + + If specifying millimeter value for Width and Depth, this parameter is required. + + SwitchParameter + + SwitchParameter + + + + + Name + + A name to identify the data center. Must not exceed 255 characters; no leading spaces. + + String + + String + + + + + PowerCosts + + The energy cost per kWh, specified by the Currency. + + Float + + Float + + + + + Width + + Width of the datacenter, in (US) Feet. Maximum of 50 meters (164.042 feet). Millimeters can be used, which requires the -Millimeters switch parameter. + + Float + + Float + + + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + HPEOneView.Facilities.DataCenter + + + + Newly created datacenter. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + $DataCenter1Name = "LA DC 12" + +$DataCenter1Width = 30 + +$DataCenter1Depth = 30 + +$DataCenter1Voltage = 220 + +$DataCenter1PowerCosts = 0.07 + +$DataCenter1CoolingCapacity = 250 + +New-OVDataCenter -Name $DataCenter1Name -Width $DataCenter1Width -Depth $DataCenter1Depth -DefaultVoltage $DataCenter1Voltage -PowerCosts $DataCenter1PowerCosts -CoolingCapacity $DataCenter1CoolingCapacity + + Create new "LA DC 12" datacenter. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + $NewDCParams = @{ + +Name = "Houston DC1"; + Width = 10668; + Depth = 13716; + Millimeters = $True; + DefaultVoltage = 240e; + PowerCosts = 0.10; + CoolingCapacity = 350; + Address1 = "123 Main Place"; + Address2 = "Suite 400"; + City = "Houston; + State = "TX"; + Country = "US"; + PostCode = "77002"; + TimeZone = "US/Central"; + PrimaryContact = (Get-OVRemoteSupportContact -Name "Joe Ellis" -EA Stop) + SecondaryContact = (Get-OVRemoteSupportContact -Name "Brandon Pear" -EA Stop) + +} +New-OVDataCenter @NewDC2Params + + Create a new datacenter with Remote Support settings. + + + + + + + + + + + + + Get-OVDataCenter + + + + New-OVDataCenter + + + + Remove-OVDataCenter + + + + Set-OVDataCenterRemoteSupport + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/facilities/set-ovdatacenter + + + + + + + + Set-OVDataCenterRemoteSupport + + Modify an existing Datacenter Remote Support setting. + + Set + OVDataCenterRemoteSupport + + + A data center represents a physically contiguous area in which racks containing IT equipment are located. +For example, you have IT equipment in two rooms or on separate floors. You could create a data center for each of these areas. +Each server, enclosure, or power distribution device in your data center can report its power requirements, but it can be difficult to understand the power and cooling requirements for your data center as a whole. The appliance enables you to bring power and cooling management of your servers, enclosures, and power delivery devices together in a single management system. +When you initialize the appliance for the first time, it creates a data center named Datacenter 1. The appliance provides this data center as a place to visualize your racks. You can rename or edit this data center to match the values and layout of your data center, you can use it as the basis for a planned data center model, or you can delete this data center without adverse effects. + +This Cmdlet will help modify an existing DataCenters Remote Support location and contacts. In order to set a DataCenter Remote Support location, the appliance must be configured and regsitered with Remote Support. + + + + + Set-OVDataCenterRemoteSupport + + InputObject + + The DataCenter to modify. + + Object + + + PrimaryContact + + Primary Remote Support Contact object from Get-OVRemoteSupportContact defined on the appliance. + + Object + + + SecondaryContact + + Secondary Remote Support Contact object from Get-OVRemoteSupportContact defined on the appliance. Must not be the same value as the Primary Contact. + + Object + + + Address1 + + Address of datacenter. + + String + + + Address2 + + Optional address line. + + String + + + City + + City of residence for the datacenter. + + String + + + State + + State/province of residence for the datacenter. + + String + + + PostCode + + Postal code for the datacenter. + + String + + + Country + + Country of residence for the datacenter. + + String + + + TimeZone + + Time Zone of residence for the datacenter. + + String + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + + + + Address1 + + Address of datacenter. + + String + + String + + + + + Address2 + + Optional address line. + + String + + String + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + SwitchParameter + + + + + City + + City of residence for the datacenter. + + String + + String + + + + + Country + + Country of residence for the datacenter. + + String + + String + + + + + InputObject + + The DataCenter to modify. + + Object + + Object + + + + + PostCode + + Postal code for the datacenter. + + String + + String + + + + + PrimaryContact + + Primary Remote Support Contact object from Get-OVRemoteSupportContact defined on the appliance. + + Object + + Object + + + + + SecondaryContact + + Secondary Remote Support Contact object from Get-OVRemoteSupportContact defined on the appliance. Must not be the same value as the Primary Contact. + + Object + + Object + + + + + State + + State/province of residence for the datacenter. + + String + + String + + + + + TimeZone + + Time Zone of residence for the datacenter. + + String + + String + + + + + + + + + HPEOneView.Facilities.DataCenter + + + DataCenter facility object from Get-OVDataCenter. + + + + + + + + HPEOneView.Appliance.AyncTask + + + + Modified datacenter Remote Support location Asynchronous task. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + $NewPrimaryConact = Get-OVRemoteSupportContact -Name "Vivian Waters" -ErrorAction Stop +Get-OVDataCenter -Name "LA DC 12" -ErrorAction Stop | Set-OVDataCenterRemoteSupport -PrimaryContact $NewPrimaryConact + + Modify "LA DC 12" datacenter with new Primary Contact. + + + + + + + + + + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/set-ovdatacenterremotesupport + + + + + + + + Set-OVEnclosure + + Rename Synergy Frame Name or Rack Name. + + Set + OVEnclosure + + + This Cmdlet provides the ability to set a Synergy Frame/Enclosure Name and/or the Synergy Rack Name to provided values. Each requires a seperate async task to complete. + + + + + Set-OVEnclosure + + InputObject + + A Syngery Frame/Enclosure Object. + + Object + + + Name + + The new name of a Synergy Frame. + + String + + + RackName + + The new name of ta Synergy Rack. + + String + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + + + + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + InputObject + + A Syngery Frame/Enclosure Object. + + Object + + Object + + + + + Name + + The new name of a Synergy Frame. + + String + + String + + + + + RackName + + The new name of ta Synergy Rack. + + String + + String + + + + + + + + + HPEOneView.Enclosure [System.Management.Automation.PSCustomObject] + + + Single Syngery Enclosure resource + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + Single async task resource for resource name update + + + + + System.Collections.ArrayList <HPEOneView.Appliance.TaskResource> + + + + Collection of async tasks + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVEnclosure -Name "0000A66101" -ErrorAction Stop | Set-OVEnclosure -Name "MyEnclName1" | Wait-OVTaskComplete + + Set the provided Synergy Frame resource Name to a new value. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Get-OVEnclosure -Name "0000A66101" -ErrorAction Stop | Set-OVEnclosure -Name "MyEnclName1" -RackName "DC11-Rack4A" | Wait-OVTaskComplete + + Set the provided Synergy Frame resource Name and RackName to a new value. + + + + + + + + + + + + + Add-OVEnclosure + + + + Get-OVEnclosure + + + + Get-OVEnclosureGroup + + + + New-OVEnclosureGroup + + + + Remove-OVEnclosure + + + + Remove-OVEnclosureGroup + + + + Reset-OVEnclosureDevice + + + + Set-OVEnclosureActiveFLM + + + + Set-OVEnclosureGroup + + + + Update-OVEnclosure + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/servers/set-ovenclosure + + + + + + + + Set-OVEnclosureActiveFLM + + Power reset Enclosure component. + + Set + OVEnclosureActiveFLM + + + Obtain a collection of enclosure hardware resources which have the specified name. + + + + + Set-OVEnclosureActiveFLM + + Enclosure + + The Synergy Frame resource from Get-OVEnclosure. + + Object + + + BayID + + BAYID + + Int32 + + + Force + + FORCE + + SwitchParameter + + + WhatIf + + + + SwitchParameter + + + Confirm + + + + SwitchParameter + + + + + + + BayID + + BAYID + + Int32 + + Int32 + + 0 + + + Confirm + + + + SwitchParameter + + SwitchParameter + + + + + Enclosure + + The Synergy Frame resource from Get-OVEnclosure. + + Object + + Object + + + + + Force + + FORCE + + SwitchParameter + + SwitchParameter + + False + + + WhatIf + + + + SwitchParameter + + SwitchParameter + + + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + System.Object + + + + Enclosure Report + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + Async task resource to monitor + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + EXAMPLE1 + + Return all the enclosure hardware managed by this appliance. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Example2 + + Return the enclosure hardware resource with name "A". + + + + + + + + + + -------------------------- EXAMPLE 3 -------------------------- + + + + EXAMPLE3 + + Display a brief list of the enclosures managed or monitored by the appliance. + + + + + + + + + + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/servers/set-ovenclosureactiveflm + + + + + + + + Set-OVEnclosureGroup + + Modify an existing enclosure group policy. + + Set + OVEnclosureGroup + + + An enclosure group is a logical resource that defines a standard configuration for member logical enclosures. Use this Cmdlet to update the configuration policy for a specific enclosure group resource. + +Minimum required privileges: Server administrator or Infrastructure administrator + + + + + Set-OVEnclosureGroup + + InputObject + + An enclosure group resource from Get-OVEnclosureGroup. + + Object + + + Name + + Specify a new resource name. + + String + + + LogicalInterconnectGroupMapping + + An Enclosure Group can reference multiple Logical Interconnect Groups, once per Interconnect Bay. If a Single Logical Interconnect Group object is provided (either via parameter variable or via Pipeline), the Logical Interconnect Group objects Logical Interconnect Bay configuration will be used. + +To specify a specific C-Class Logical Interconnect Group(s) for one or more Interconnect Bays, use a Hashtable, with the Bay ID as the Key, and Logical Interconnect Group Name, URI or Object as the Value. Example: + +$LogicalInterConnectGroupMapping = @{ 1 = "MyLIg1"; 2 = "MyLig1"; 5 = "OtherLIG"; 6 = "OtherLIG"} + +$MyLig1 = Get-OVLogicalInterconnectGroup -Name MyLig1 +$OtherLIG = Get-OVLogicalInterconnectGroup OtherLIG +$LogicalInterConnectGroupMapping = @{ 1 = $MyLig1; 2 = $MyLig1; 5 = $OtherLIG; 6 = $OtherLIG" + +When attempting to define a Syenrgy-based Enclosure Group, either an Array or Hashtable is allowed. If an Array of Logical Interconnect Groups are provided, the Cmdlet will determine the Interconnect placement automatically. Example: + +$MySynergyLig1 = Get-OVLogicalInterconnectGroup -Name MySynergyLig1 +$LogicalInterConnectGroupMapping = $MySynergyLig1 +#or +$MySynergyLig1 = Get-OVLogicalInterconnectGroup -Name MySynergyLig1 +$MySynergyLig2 = Get-OVLogicalInterconnectGroup -Name MySynergyLig2 +$LogicalInterConnectGroupMapping = $MySynergyLig1,$MySynergyLig2 + + +Do know that SAS and VC FC LIGs are bound to a single frame, and will not reference other Frames if FrameCount is greater than 1. + +Use a Hashtable to bind specific LIGs to specific Frames. The Interconnect placement will be determined automatically based on either the Hashtable Key name "Frame#" (where # is the numerical value of the Frame) or Enclosure Index value (depending if a SAS or Synergy VC FC LIG). Example: + +$3FrameVCLIG = Get-OVLogicalInterconnectGroup -Name "My MultiFrame Synergy LIG 1" +$SasLIG = Get-OVLogicalInterconnectGroup -Name "My Synergy Sas LIG 1" +$LogicalInterconnectGroupMapping = @{Frame1 = $3FrameVCLIG,$SasLIG; Frame2 = $3FrameVCLIG,$SasLIG; Frame3 = $3FrameVCLIG } + + Object + + + PowerRedundantMode + + The Power Redundancy Mode to set when an Enclosure is added to the appliance. + +Allowed Values: + + * RedundantPowerFeed - Provides N+N Power Redundancy Configuration + * RedundantPowerSupply - Provided N+1 Power Redundancy Configuration + + String + + + IPv4AddressType + + Use to specify how the IPv4 Addresses will be assigned to Synergy resources management interface(s). Allowed values: + + * External - The IPv4 address is managed externally, static assignment. + * DHCP - The IPv4 address is assigned using DHCP. + * AddressPool - The IPv4 address is assigned from a pool of IP addresses specified by the AddressPool parameter, similar to HPE BladeSystem C-Class "Enclosure Bay IP Addressing" (aka EBIPA). + +Default: DHCP + + String + + + IPv4AddressRange + + The IPv4 address pool object from Get-OVAddressPoolRange. + + Object + + + IPv6AddressType + + Use to specify how the IPv6 Addresses will be assigned to Synergy resources management interface(s). Allowed values: + + * External - The IPv4 address is managed externally, static assignment. + * DHCP - The IPv4 address is assigned using DHCP. + * AddressPool - The IPv4 address is assigned from a pool of IP addresses specified by the AddressPool parameter, similar to HPE BladeSystem C-Class "Enclosure Bay IP Addressing" (aka EBIPA). + +Default: None + + String + + + IPv6AddressRange + + The IPv6 address pool object from Get-OVAddressPoolRange. + + Object + + + DeploymentNetworkType + + Specify the Synergy Image Stream deployment network type. Allowed values: + + * Internal - Deployment network is an internal, managed by the Frame links, which Logical Intercoonect Group must have an ImageStreamer Uplink Set. + * External - Deployment network is connected to an External management switch. + * None - No deployment network will be configured. + +Default: None + + String + + + DeploymentNetwork + + The Ethernet Network with the purpose property set to Management. Must also include DeploymentNetworkType parameter, value must be "External", with the Ethernet Network associated with a non-ImageStreamer Uplink Set. + + Object + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + DeploymentNetwork + + The Ethernet Network with the purpose property set to Management. Must also include DeploymentNetworkType parameter, value must be "External", with the Ethernet Network associated with a non-ImageStreamer Uplink Set. + + Object + + Object + + + + + DeploymentNetworkType + + Specify the Synergy Image Stream deployment network type. Allowed values: + + * Internal - Deployment network is an internal, managed by the Frame links, which Logical Intercoonect Group must have an ImageStreamer Uplink Set. + * External - Deployment network is connected to an External management switch. + * None - No deployment network will be configured. + +Default: None + + String + + String + + None + + + IPv4AddressRange + + The IPv4 address pool object from Get-OVAddressPoolRange. + + Object + + Object + + + + + IPv4AddressType + + Use to specify how the IPv4 Addresses will be assigned to Synergy resources management interface(s). Allowed values: + + * External - The IPv4 address is managed externally, static assignment. + * DHCP - The IPv4 address is assigned using DHCP. + * AddressPool - The IPv4 address is assigned from a pool of IP addresses specified by the AddressPool parameter, similar to HPE BladeSystem C-Class "Enclosure Bay IP Addressing" (aka EBIPA). + +Default: DHCP + + String + + String + + DHCP + + + IPv6AddressRange + + The IPv6 address pool object from Get-OVAddressPoolRange. + + Object + + Object + + + + + IPv6AddressType + + Use to specify how the IPv6 Addresses will be assigned to Synergy resources management interface(s). Allowed values: + + * External - The IPv4 address is managed externally, static assignment. + * DHCP - The IPv4 address is assigned using DHCP. + * AddressPool - The IPv4 address is assigned from a pool of IP addresses specified by the AddressPool parameter, similar to HPE BladeSystem C-Class "Enclosure Bay IP Addressing" (aka EBIPA). + +Default: None + + String + + String + + + + + InputObject + + An enclosure group resource from Get-OVEnclosureGroup. + + Object + + Object + + + + + LogicalInterconnectGroupMapping + + An Enclosure Group can reference multiple Logical Interconnect Groups, once per Interconnect Bay. If a Single Logical Interconnect Group object is provided (either via parameter variable or via Pipeline), the Logical Interconnect Group objects Logical Interconnect Bay configuration will be used. + +To specify a specific C-Class Logical Interconnect Group(s) for one or more Interconnect Bays, use a Hashtable, with the Bay ID as the Key, and Logical Interconnect Group Name, URI or Object as the Value. Example: + +$LogicalInterConnectGroupMapping = @{ 1 = "MyLIg1"; 2 = "MyLig1"; 5 = "OtherLIG"; 6 = "OtherLIG"} + +$MyLig1 = Get-OVLogicalInterconnectGroup -Name MyLig1 +$OtherLIG = Get-OVLogicalInterconnectGroup OtherLIG +$LogicalInterConnectGroupMapping = @{ 1 = $MyLig1; 2 = $MyLig1; 5 = $OtherLIG; 6 = $OtherLIG" + +When attempting to define a Syenrgy-based Enclosure Group, either an Array or Hashtable is allowed. If an Array of Logical Interconnect Groups are provided, the Cmdlet will determine the Interconnect placement automatically. Example: + +$MySynergyLig1 = Get-OVLogicalInterconnectGroup -Name MySynergyLig1 +$LogicalInterConnectGroupMapping = $MySynergyLig1 +#or +$MySynergyLig1 = Get-OVLogicalInterconnectGroup -Name MySynergyLig1 +$MySynergyLig2 = Get-OVLogicalInterconnectGroup -Name MySynergyLig2 +$LogicalInterConnectGroupMapping = $MySynergyLig1,$MySynergyLig2 + + +Do know that SAS and VC FC LIGs are bound to a single frame, and will not reference other Frames if FrameCount is greater than 1. + +Use a Hashtable to bind specific LIGs to specific Frames. The Interconnect placement will be determined automatically based on either the Hashtable Key name "Frame#" (where # is the numerical value of the Frame) or Enclosure Index value (depending if a SAS or Synergy VC FC LIG). Example: + +$3FrameVCLIG = Get-OVLogicalInterconnectGroup -Name "My MultiFrame Synergy LIG 1" +$SasLIG = Get-OVLogicalInterconnectGroup -Name "My Synergy Sas LIG 1" +$LogicalInterconnectGroupMapping = @{Frame1 = $3FrameVCLIG,$SasLIG; Frame2 = $3FrameVCLIG,$SasLIG; Frame3 = $3FrameVCLIG } + + Object + + Object + + + + + Name + + Specify a new resource name. + + String + + String + + + + + PowerRedundantMode + + The Power Redundancy Mode to set when an Enclosure is added to the appliance. + +Allowed Values: + + * RedundantPowerFeed - Provides N+N Power Redundancy Configuration + * RedundantPowerSupply - Provided N+1 Power Redundancy Configuration + + String + + String + + + + + + + + + HPEOneView.Servers.EnclosureGroup [System.Management.Automation.PSCustomObject] + + + Enclosure group resource from Get-OVEnclosureGroup. + + + + + + + + HPEOneView.Servers.EnclosureGroup [System.Management.Automation.PSCustomObject] + + + + The updated enclosure group resource. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + $EnclosureGroup = Get-OVEnclosureGroup -Name ProdEG1 -ErrorAction Stop Set-OVEnclosureGroup -InputObject $EnclosureGroup -Name VirtProdEG1 + + Change the name of the provided enclosure group resource. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + $UpdatedConfigScript = 'REMOVE USER "admin" +ADD USER "ops" "*********" +SET USER CONTACT "ops" "MySecretPassword" +SET USER FULLNAME "ops" "" +SET USER ACCESS "ops" OPERATOR +ASSIGN SERVER 1-16 "ops" +ENABLE USER "ops" +hponcfg all >> end_marker +<RIBCL VERSION="2.0"> +<LOGIN USER_LOGIN="ops" PASSWORD="passthrough"> + <USER_INFO MODE="write"> + <ADD_USER + USER_NAME="ops" + USER_LOGIN="ops" + PASSWORD="Supersecretpassword"> + <ADMIN_PRIV value ="N"/> + <REMOTE_CONS_PRIV value ="Y"/> + <RESET_SERVER_PRIV value ="N"/> + <VIRTUAL_MEDIA_PRIV value ="N"/> + <CONFIG_ILO_PRIV value="Yes"/> + </ADD_USER> + </USER_INFO> +</LOGIN> +</RIBCL> +end_marker' Get-OVEnclosureGroup -Name EG1 -ErrorAction Stop | Set-OVEnclosureGroup -ConfigurationScript $UpdatedConfigScript + + Update the configuration script of the provided enclosure group. + + + + + + + + + + + + + Get-OVEnclosureGroup + + + + New-OVEnclosureGroup + + + + Remove-OVEnclosureGroup + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/servers/set-ovenclosuregroup + + + + + + + + Set-OVEulaStatus + + Accept the EULA and set support access for the specified appliance. + + Set + OVEulaStatus + + + Accept the EULA and set support access for the specified appliance. + + + + + Set-OVEulaStatus + + Appliance + + The FQDN or IP Address of an HPE OneView appliance or HPEOneView.Appliance.Connection must be provided. + + Object + + + SupportAccess + + Set to "yes" to allow HP suport access to the appliance, otherwise set to "no". + + String + + + + + + + Appliance + + The FQDN or IP Address of an HPE OneView appliance or HPEOneView.Appliance.Connection must be provided. + + Object + + Object + + + + + SupportAccess + + Set to "yes" to allow HP suport access to the appliance, otherwise set to "no". + + String + + String + + + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + System.Management.Automation.PSCustomObject + + + + Version and current support access state + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Set-OVEulaStatus -Appliance appliance.contoso.com -supportAccess "yes" + + Connects to a specific appliance, accepting the EULA and enable Support Access. + + + + + + + + + + + + + Get-OVEulaStatus + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/set-oveulastatus + + + + + + + + Set-OVExternalRepository + + Modify an existing external baseline repository. + + Set + OVExternalRepository + + + A firmware repository enables you to store firmware bundles and deploy them across your environment. An externally managed HTTP/HTTPS web server can be added to the appliance as a repository. It is a user-maintained HTTP/HTTPS web server. You can upload firmware bundles in a specific directory and then register the HTTP/HTTPS server with HPE OneView. This functionality is supported for Linux and Windows systems. + +The recommended types of external web servers to use with the repository follow: + + * Apache + * Internet Information Services (IIS) + +NOTE: Only one external repository can be added. + +This Cmdlet supports modifying an existing external repository. Use this Cmdlet to modify the Name, authentication credentials and/or HTTP SSL certificate. + + + + + Set-OVExternalRepository + + InputObject + + Provide the external repository object to modify. + + Object + + + Name + + Update the configured repository with the new name. + + String + + + Username + + Provide the username to authenticate to the target web server with if required. + + String + + + Password + + Provide the password of the username using a System.Security.SecureString. + + System.Security.SecureString + + + Certificate + + The Base64 Certificate of the target web server. Must be specified if the -HTTP parameter is not used. + + String + + + NFSPath + + Specify the NFS path for Superdome Flex RMC firmware updates. + + string + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + WhatIf + + + + + + + Confirm + + + + + + + + Set-OVExternalRepository + + InputObject + + Provide the external repository object to modify. + + Object + + + Name + + Update the configured repository with the new name. + + String + + + Credential + + Provide a PSCredential object if the target web server requires authentication. By default, HTTPS will be used and basic authentication is used to communicate with the target web server. + + String + + + Certificate + + The Base64 Certificate of the target web server. Must be specified if the -HTTP parameter is not used. + + String + + + NFSPath + + Specify the NFS path for Superdome Flex RMC firmware updates. + + string + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + WhatIf + + + + + + + Confirm + + + + + + + + Set-OVExternalRepository + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + + WhatIf + + + + + + + Confirm + + + + + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + Array + + (${Global:ConnectedSessions} | ? Default) + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + SwitchParameter + + + + + Certificate + + The Base64 Certificate of the target web server. Must be specified if the -HTTP parameter is not used. + + String + + String + + + + + Confirm + + + + + + + + + + + Credential + + Provide a PSCredential object if the target web server requires authentication. By default, HTTPS will be used and basic authentication is used to communicate with the target web server. + + String + + String + + + + + InputObject + + Provide the external repository object to modify. + + Object + + Object + + + + + NFSPath + + Specify the NFS path for Superdome Flex RMC firmware updates. + + string + + string + + + + + Name + + Update the configured repository with the new name. + + String + + String + + + + + Password + + Provide the password of the username using a System.Security.SecureString. + + System.Security.SecureString + + System.Security.SecureString + + + + + Username + + Provide the username to authenticate to the target web server with if required. + + String + + String + + + + + WhatIf + + + + + + + + + + + + + + + HPEOneView.Appliance.BaselineRepository [System.Management.Automation.PSCustomObject] + + + The external repository object from Get-OVBaselineRepository + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + The async task for the caller to monitor. + + + + + System.Collections.ArrayList <HPEOneView.Appliance.TaskResource> + + + + Multiple async task resource objects. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVBaselineRepository -Name MyRepoName -ErrorAction Stop | Set-OVExternalRepository -Name UpdatedRepoName + + Modify an existing external repository with a new name. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Get-OVBaselineRepository -Name MyRepoName MyRepoName -ErrorAction Stop | Set-OVExternalRepository -Credential (Get-PSCredential -Username "Domain\MyUpdatedAccountName") + + Modify an existing repository with new credentials. + + + + + + + + + + -------------------------- EXAMPLE 3 -------------------------- + + + + $UpdatedSslCertificate = Get-Content C:\Dir\UpdatedCert.cer -raw +Get-OVBaselineRepository -Name MyRepoName -ErrorAction Stop | Set-OVExternalRepository -Certificate $UpdatedSslCertificate + + Modify an existing repository with new Base64 SSL public certificate. + + + + + + + + + + + + + New-OVExternalRepository + + + + Remove-OVExternalRepository + + + + Update-OVExternalRepository + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/set-ovexternalrepository + + + + + + + + Set-OVFirmwareBundleUpdateSchedule + + Change the appliance update configuration and schedule state. + + Set + OVFirmwareBundleUpdateSchedule + + + You can enable HPE OneView to automatically check for new service pack updates and notify you when they are available. A connected notification alert is generated when a scheduled or manual check for updates is run and a new service pack update is available from the HPE software depot. + +This Cmdlet will help you enable or disable the appliance update condition. If enabling, ensure that the appliance has the necessary networking policies to allow it to connect to the HPE Software depot. For pre-requisites, please visit the online help discussion topic "Prerequisites for HPE Software depot connectivity". + +To specify an automatic update schedule, you will need to provide the weekly frequency (1-52), day of the week and time of day (will be converted to UTC time). + +The HPE support center user token uniquely identifies your HPESC user profile. The token is required to enable inventory-based firmware downloads and used to verify access to the software and firmware components. You must generate a token on the HPE Support Center Portal (https://support.hpe.com/hpesc/swd/entitlement-token-service/generate) and then use the -ActivationKey parameter to complete the configuration on the appliance. + +Minimum required privileges: Infrastructure administrator, Server administrator, and Network administrator + + + + + Set-OVFirmwareBundleUpdateSchedule + + WeeklyInterval + + Use to enable and specify automatic update checking for the appliance based on the schedule defined. + + SwitchParameter + + + Weeks + + The interval of number of weeks the update check will be performed. Allowed values are 1 through 52. + + int + + + Day + + Specify the day of the week the scheduled task will be performed. + + String + + + Time + + A timespan object that represents the HOUR and MINUTES of the day. Time will be converted to UTC. + + timespan + + + ActivationKey + + A token is required to enable inventory-based firmware downloads and used to verify access to the software and firmware components. After generating the token on the HPE Support Center Portal (https://support.hpe.com/hpesc/swd/entitlement-token-service/generate), use this parameter to specify the activation key. + + String + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + ApplianceConnection + + Specify one or more HPEOneView.Appliance.Connection object(s) or Name property value(s). + +Default Value: ${Global:ConnectedSessions} | ? Default + + Object + + + WhatIf + + + + + + + Confirm + + + + + + + + Set-OVFirmwareBundleUpdateSchedule + + Disabled + + Disable the ability for the appliance to connect to the external service for available updates. Check for updates cannot be manually invoked when the feature is disabled. + + SwitchParameter + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + ApplianceConnection + + Specify one or more HPEOneView.Appliance.Connection object(s) or Name property value(s). + +Default Value: ${Global:ConnectedSessions} | ? Default + + Object + + + WhatIf + + + + + + + Confirm + + + + + + + + Set-OVFirmwareBundleUpdateSchedule + + ManualInterval + + Switch parameter to indicate update checking will be performed manually. Use the Get-OVAvailableUpdate -GetLatestUpdates Cmdlet to check for current updates. + + SwitchParameter + + + ActivationKey + + A token is required to enable inventory-based firmware downloads and used to verify access to the software and firmware components. After generating the token on the HPE Support Center Portal (https://support.hpe.com/hpesc/swd/entitlement-token-service/generate), use this parameter to specify the activation key. + + String + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + ApplianceConnection + + Specify one or more HPEOneView.Appliance.Connection object(s) or Name property value(s). + +Default Value: ${Global:ConnectedSessions} | ? Default + + Object + + + WhatIf + + + + + + + Confirm + + + + + + + + + + + ActivationKey + + A token is required to enable inventory-based firmware downloads and used to verify access to the software and firmware components. After generating the token on the HPE Support Center Portal (https://support.hpe.com/hpesc/swd/entitlement-token-service/generate), use this parameter to specify the activation key. + + String + + String + + + + + ApplianceConnection + + Specify one or more HPEOneView.Appliance.Connection object(s) or Name property value(s). + +Default Value: ${Global:ConnectedSessions} | ? Default + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + SwitchParameter + + False + + + Confirm + + + + + + + + + + + Day + + Specify the day of the week the scheduled task will be performed. + + String + + String + + + + + Disabled + + Disable the ability for the appliance to connect to the external service for available updates. Check for updates cannot be manually invoked when the feature is disabled. + + SwitchParameter + + SwitchParameter + + + + + ManualInterval + + Switch parameter to indicate update checking will be performed manually. Use the Get-OVAvailableUpdate -GetLatestUpdates Cmdlet to check for current updates. + + SwitchParameter + + SwitchParameter + + + + + Time + + A timespan object that represents the HOUR and MINUTES of the day. Time will be converted to UTC. + + timespan + + timespan + + + + + WeeklyInterval + + Use to enable and specify automatic update checking for the appliance based on the schedule defined. + + SwitchParameter + + SwitchParameter + + + + + Weeks + + The interval of number of weeks the update check will be performed. Allowed values are 1 through 52. + + int + + int + + + + + WhatIf + + + + + + + + + + + + + + + None. You cannot pipe objects to this cmdlet. + + + + + + + + + + + HPOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + Async task resource to monitor. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Set-OVFirmwareBundleUpdateSchedule -WeeklyInterval -Weeks 1 -Day Monday -Time (New-TimeSpan -Hours 15 -Minutes 45) + + Enable appliance automatic update checks every week, on Monday at 3:45pm local time. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Set-OVFirmwareBundleUpdateSchedule -ManualInterval + +Get-OVApplianceUpdate -GetLatestUpdates + + Enable appliance update manual checks, then immediately check for updates. + + + + + + + + + + -------------------------- EXAMPLE 3 -------------------------- + + + + Set-OVFirmwareBundleUpdateSchedule -Disabled + + Disable appliance update checks. + + + + + + + + + + + + + Get-OVApplianceUpdate + + + + Get-OVApplianceUpdateSchedule + + + + Online: + https://hpe-docs.gitbook.io/posh-hpeoneview/cmdlets/v9.00/appliance/set-ovfirmwarebundleupdateschedule + + + + + + + + Set-OVInitialPassword + + Change the initial password of the Administrator user account. + + Set + OVInitialPassword + + + Changes the initial default password of the Administrator local appliance account to the supplied new password during first time setup (FTS.) + + + + + Set-OVInitialPassword + + OldPassword + + Current default password for this account. Will prompt for password if not supplied. + + String + + + NewPassword + + New password for this account. Will prompt for password if not supplied. + + String + + + Appliance + + Specify Appliance FQDN, Name or IP Address. If no valid Appliance Connection is found, a temporary connection is created for the specified appliance. + + Object + + + + + + + Appliance + + Specify Appliance FQDN, Name or IP Address. If no valid Appliance Connection is found, a temporary connection is created for the specified appliance. + + Object + + Object + + + + + NewPassword + + New password for this account. Will prompt for password if not supplied. + + String + + String + + + + + OldPassword + + Current default password for this account. Will prompt for password if not supplied. + + String + + String + + + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + None. You cannot pipe objects to this Cmdlet + + + + + + + + None. + + + + None + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Set-OVInitialPassword -Appliance MyAppliance.domain.com + + Change the Administrator password, and prompted for both the original and new password. + + + + + + + + + + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/set-ovinitialpassword + + + + + + + + Set-OVInterconnectName + + Set HPE Synergy Virtual Connect SE module hostname. + + Set + OVInterconnectName + + + This Cmdlet will help change the host name of an interconnect. You can change the default host name for the following interconnect modules: + +* HPE Virtual Connect SE 16Gb FC Module for HPE Synergy +* HPE Virtual Connect SE 32Gb FC Module for HPE Synergy +* HPE Virtual Connect SE 40Gb F8 Module for HPE Synergy +* HPE Virtual Connect SE 100Gb F32 Module for HPE Synergy + +The name format must adhere to the following rules: + +* Must be no more than 30 characters. +* Must start with a letter or number. +* Must contain a letter or dash. +* Must not contain characters besides letters, numbers, or a dash. + +Changing the host name of an interconnect has several impacts on the Domain Name System (DNS) server. + +* For HPE Virtual Connect SE 100Gb F32 Module for HPE Synergy interconnect, if the host name is changed, the Dynamic DNS (DDNS) in the logical interconnect must be enabled to update the DNS server. +* An interconnect reboot does not change the host name on the DNS server. + +To reset the host name to factory default, use the -ResetNameToFactoryDefault parameter. If an interconnect is removed from the bay location, the custom host name resets to factory set host name. + +Minimum required privileges: Infrastructure administrator, Network administrator + + + + + Set-OVInterconnectName + + InputObject + + Interconnect from Get-OVInterconnect object to change the fabric module hostname. + + Object + + + Name + + The new name for the provided fabric module. The name format must adhere to the following rules: + +* Must be no more than 30 characters. +* Must start with a letter or number. +* Must contain a letter or dash. +* Must not contain characters besides letters, numbers, or a dash. + + string + + + ApplianceConnection + + Specify one or more HPEOneView.Appliance.Connection object(s) or Name property value(s). + +Default Value: ${Global:ConnectedSessions} | ? Default + + Object + + + WhatIf + + + + SwitchParameter + + + Confirm + + + + SwitchParameter + + + + Set-OVInterconnectName + + InputObject + + Interconnect from Get-OVInterconnect object to change the fabric module hostname. + + Object + + + ResetNameToFactoryDefault + + Use parameter to reset fabric module back to factory default name. + + SwitchParameter + + + ApplianceConnection + + Specify one or more HPEOneView.Appliance.Connection object(s) or Name property value(s). + +Default Value: ${Global:ConnectedSessions} | ? Default + + Object + + + WhatIf + + + + SwitchParameter + + + Confirm + + + + SwitchParameter + + + + + + + ApplianceConnection + + Specify one or more HPEOneView.Appliance.Connection object(s) or Name property value(s). + +Default Value: ${Global:ConnectedSessions} | ? Default + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Confirm + + + + SwitchParameter + + SwitchParameter + + + + + InputObject + + Interconnect from Get-OVInterconnect object to change the fabric module hostname. + + Object + + Object + + + + + Name + + The new name for the provided fabric module. The name format must adhere to the following rules: + +* Must be no more than 30 characters. +* Must start with a letter or number. +* Must contain a letter or dash. +* Must not contain characters besides letters, numbers, or a dash. + + string + + string + + + + + ResetNameToFactoryDefault + + Use parameter to reset fabric module back to factory default name. + + SwitchParameter + + SwitchParameter + + + + + WhatIf + + + + SwitchParameter + + SwitchParameter + + + + + + + + + HPEOneView.Networking.Interconnect [System.Management.Automation.PSCustomObject] + + + HPE Synergy FlexFabric Ethernet module from Get-OVInterconnect. + + + + + + + + HPOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + Async task resource to monitor. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVInterconnect -Name "Enclosure1, interconnect 3" | Set-OVInterconnectName -Name enc1-fm3-dc1 + + + Set interconnect module hostname to the specific value. + + + + + + + + + + + + + Get-OVInterconnect + + + + Online: + https://hpe-docs.gitbook.io/posh-hpeoneview/cmdlets/v9.00/networking/set-ovinterconnectname + + + + + + + + Set-OVInterconnectNTPConfiguration + + Change the default time source policy for HPE Synergy interconnects. + + Set + OVInterconnectNTPConfiguration + + + When HPE OneView manages or monitors server or compute resources, it will automatically by default set the management processor NTP settings to the appliance's IP Address. Using this Cmdlet, you can get the current time synchronize policy of the managed and monitored server hardware on the appliance. When the global policy is set to sync with external NTP servers, a property is added to the returned object called NTPServers. The array contains the appliance configured NTP server(s). + +Minimum required privileges: + + * Infrastructure Administrator + + + + + Set-OVInterconnectNTPConfiguration + + SyncWithAppliance + + Configures managed and monitored server hardware devices to use the HPE OneView appliance as the NTP server. + + SwitchParameter + + + ApplianceConnection + + Specify one or more HPEOneView.Appliance.Connection object(s) or Name property value(s). + +Default Value: ${Global:ConnectedSessions} | ? Default + + Object + + + + Set-OVInterconnectNTPConfiguration + + SyncWithNTP + + Configures managed and monitored server hardware devices to use the same NTP servers as the HPE OneView appliance. + + SwitchParameter + + + ApplianceConnection + + Specify one or more HPEOneView.Appliance.Connection object(s) or Name property value(s). + +Default Value: ${Global:ConnectedSessions} | ? Default + + Object + + + + + + + ApplianceConnection + + Specify one or more HPEOneView.Appliance.Connection object(s) or Name property value(s). + +Default Value: ${Global:ConnectedSessions} | ? Default + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + SyncWithAppliance + + Configures managed and monitored server hardware devices to use the HPE OneView appliance as the NTP server. + + SwitchParameter + + SwitchParameter + + + + + SyncWithNTP + + Configures managed and monitored server hardware devices to use the same NTP servers as the HPE OneView appliance. + + SwitchParameter + + SwitchParameter + + + + + + + + + None. You cannot pipe objects to this cmdlet. + + + + + + + + + + + HPEOneView.Appliance.GlobalSetting + + + + Object resource with the global setting value + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Set-OVInterconnectNTPConfiguration -SyncWithAppliance + + + Change the interconnect policy to time sync with the appliance. + + + + + + + + + + + + + Get-OVInterconnectNTPConfiguration + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/set-ovinterconnectntpconfiguration + + + + + + + + Set-OVLdapDefaultDirectory + + Configure Authentication Directory default directory. + + Set + OVLdapDefaultDirectory + + + Use this Cmdlet to set the default Authentication Directory on the appliance. Use Get-OVLdapDirectory to pass in the directory to configure as the default. Once the Default Directory is set, the Cmdlet will configure a Registry Key (HKCU:\Software\Hewlett-Packard\HPOneView) called "AuthProvider#{ApplianceConnectionName}". The Library will read this value upon load and use it as the default value for the -AuthDirectory parameter in Connect-OVMgmt. + + + + + Set-OVLdapDefaultDirectory + + InputObject + + Aliases [-Directory] +Provide the Directory Name, URI or Object. If you want to set the Authentication Directory back to Local, specify LOCAL as the name. + + Object + + + DisableLocalLogin + + Use to disable appliance local login accounts. You cannot use this parameter if an Authentication Directory is not configured. + + SwitchParameter + + + EnableEmergencyLocalLogin + + Boolean value to enable ($true) or disable ($false) emergency local login. Must be set to $false when SmartCardLoginOnly is set and used from Set-OVApplianceTwoFactorAuthentication. + + Bool + + + EmergencyLoginAllowType + + Allow emergency login access if the configured authentication directory(ies) are unavailable. Highest security is obtained by restricting the local administrator account to "ApplianceConsoleOnly". Choose "NetworkAndApplianceConsole" to allow emergency access via the network. + + String + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + + WhatIf + + + + SwitchParameter + + + Confirm + + + + SwitchParameter + + + + Set-OVLdapDefaultDirectory + + InputObject + + Aliases [-Directory] +Provide the Directory Name, URI or Object. If you want to set the Authentication Directory back to Local, specify LOCAL as the name. + + Object + + + DisableLocalLogin + + Use to disable appliance local login accounts. You cannot use this parameter if an Authentication Directory is not configured. + + SwitchParameter + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + + WhatIf + + + + SwitchParameter + + + Confirm + + + + SwitchParameter + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Confirm + + + + SwitchParameter + + SwitchParameter + + + + + DisableLocalLogin + + Use to disable appliance local login accounts. You cannot use this parameter if an Authentication Directory is not configured. + + SwitchParameter + + SwitchParameter + + False + + + EmergencyLoginAllowType + + Allow emergency login access if the configured authentication directory(ies) are unavailable. Highest security is obtained by restricting the local administrator account to "ApplianceConsoleOnly". Choose "NetworkAndApplianceConsole" to allow emergency access via the network. + + String + + String + + + + + EnableEmergencyLocalLogin + + Boolean value to enable ($true) or disable ($false) emergency local login. Must be set to $false when SmartCardLoginOnly is set and used from Set-OVApplianceTwoFactorAuthentication. + + Bool + + Bool + + + + + InputObject + + Aliases [-Directory] +Provide the Directory Name, URI or Object. If you want to set the Authentication Directory back to Local, specify LOCAL as the name. + + Object + + Object + + + + + WhatIf + + + + SwitchParameter + + SwitchParameter + + + + + + + + + HPEOneView.Appliance.AuthDirectory [System.Management.Automation.PSCustomObject] + + + Authentication Directory retrieved using Get-OVLdapDirectory + + + + + + + + System.Management.Automation.PSCustomObject + + + + Appliance Authentication Directory setting + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Set-OVLdapDefaultDirectory -InputObject "Domain1" +# Cmdlet will create: +# HKCU:\Software\Hewlett-Packard\HPOneView\AuthProvider#MyAppliance.domain.com REG_SZ, value = "Domain1" + + Set "Domain1" as the default authentication directory for the appliance. Then, the Cmdlet will create the REG_SZ "AuthProvider#MyAppliance.domain.com" with a value of "Domain1". + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Set-OVLdapDefaultDirectory -InputObject (Get-OVLdapDirectory -Name MyDirectory) -DisableLocalLogin $true -EnableEmergencyLocalLogin + + Set "MyDirectory" as the default authentication directory for the appliance, disabling local logins and allowing emergency local login via appliance console only. + + + + + + + + + + -------------------------- EXAMPLE 3 -------------------------- + + + + Set-OVLdapDefaultDirectory -InputObject "LOCAL" + + Set "LOCAL" as the default authentication directory for the appliance. + + + + + + + + + + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/security/set-ovldapdefaultdirectory + + + + + + + + Set-OVLdapGroupRole + + Assign or change roles for LDAP Groups. + + Set + OVLdapGroupRole + + + Changes current roles of an LDAP Group with a given set of roles. You must provide the list of all roles the LDAP Group should be set to, and not a subset of roles. + + + + + Set-OVLdapGroupRole + + InputObject + + Directroy Group to add. + + Object + + + Roles + + The role(s) to assign to the Directroy Group, in System.Collections.ArrayList format. Accepted values are noted within the ApplianceRoles property of the HPEOneView.Appliance.Connection object stored in the $Global:ConnectedSessions variable. + +Example: $roles = "Server administrator","Network administrator" + + Array + + + Append + + Use to append roles and/or scope permissions update. If omitted, roles or scope permissions will be replaced. + + SwitchParameter + + + UserName + + Directory Username to authenticate with + + String + + + Password + + Directory User account password + + System.Security.SecureString + + + Credential + + Use this parameter if you want to provide a PSCredential object instead. + + PSCredential + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + Set-OVLdapGroupRole + + InputObject + + Directroy Group to add. + + Object + + + Roles + + The role(s) to assign to the Directroy Group, in System.Collections.ArrayList format. Accepted values are noted within the ApplianceRoles property of the HPEOneView.Appliance.Connection object stored in the $Global:ConnectedSessions variable. + +Example: $roles = "Server administrator","Network administrator" + + Array + + + ScopePermissions + + Array collection of Hashtable<Role; Scope>. Will overwrite existing scope to role mappings. To indiate all resouroures, use 'All' as the value. + +Example: -ScopePermissions @{Role = "Network administrator"; Scope = (Get-OVScope -Name CorpNetAdmins -ErrorAction Stop) } + + Array + + + Append + + Use to append roles and/or scope permissions update. If omitted, roles or scope permissions will be replaced. + + SwitchParameter + + + UserName + + Directory Username to authenticate with + + String + + + Password + + Directory User account password + + System.Security.SecureString + + + Credential + + Use this parameter if you want to provide a PSCredential object instead. + + PSCredential + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + Set-OVLdapGroupRole + + InputObject + + Directroy Group to add. + + Object + + + ScopePermissions + + Array collection of Hashtable<Role; Scope>. Will overwrite existing scope to role mappings. To indiate all resouroures, use 'All' as the value. + +Example: -ScopePermissions @{Role = "Network administrator"; Scope = (Get-OVScope -Name CorpNetAdmins -ErrorAction Stop) } + + Array + + + Append + + Use to append roles and/or scope permissions update. If omitted, roles or scope permissions will be replaced. + + SwitchParameter + + + UserName + + Directory Username to authenticate with + + String + + + Password + + Directory User account password + + System.Security.SecureString + + + Credential + + Use this parameter if you want to provide a PSCredential object instead. + + PSCredential + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + + + + Append + + Use to append roles and/or scope permissions update. If omitted, roles or scope permissions will be replaced. + + SwitchParameter + + SwitchParameter + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Credential + + Use this parameter if you want to provide a PSCredential object instead. + + PSCredential + + PSCredential + + + + + InputObject + + Directroy Group to add. + + Object + + Object + + + + + Password + + Directory User account password + + System.Security.SecureString + + System.Security.SecureString + + + + + Roles + + The role(s) to assign to the Directroy Group, in System.Collections.ArrayList format. Accepted values are noted within the ApplianceRoles property of the HPEOneView.Appliance.Connection object stored in the $Global:ConnectedSessions variable. + +Example: $roles = "Server administrator","Network administrator" + + Array + + Array + + + + + ScopePermissions + + Array collection of Hashtable<Role; Scope>. Will overwrite existing scope to role mappings. To indiate all resouroures, use 'All' as the value. + +Example: -ScopePermissions @{Role = "Network administrator"; Scope = (Get-OVScope -Name CorpNetAdmins -ErrorAction Stop) } + + Array + + Array + + + + + UserName + + Directory Username to authenticate with + + String + + String + + + + + + + + + System.Security.SecureString + + + Directory User Account password + + + + + + + + System.Management.Automation.PSCustomObject + + + + Updated LDAP Group object with new role assignment(s) + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Set-OVLdapGroupRole -d Domain1 -GroupName "MY Directory Group1" -roles "Server administrator" -u "Sarah Peterson" + + Add "MY Directory Group1" from Domain1 with Server Administrator role and prompt for password for group validation. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + $roles = "Server administrator","Backup administrator" +$password = ConvertTo-SecureString -asplaintext "password123890" -force +Set-OVLdapGroupRole -d Domain1 -GroupName "MY Directory Group1" -roles $roles -u "Sarah Peterson" -p $password + + Set "MY Directory Group1" from Domain1 with Server and Backup administrator roles, and specify password for group validation. + + + + + + + + + + -------------------------- EXAMPLE 3 -------------------------- + + + + $LdapDirectoryName = "CorpDomain" +$MyAdCreds = Get-Credential +Get-OVLdapGroup -Group $CorpNetworkAdmins -ErrorAction Stop | ? loginDomain -eq $LdapDirectoryName | Set-OVLdapGroupRole -ScopePermissions @{Role = "Network administrator"; Scope = $NewSBACScope } -Credential $MyAdCreds + + Change the Scope permissions for the specified authentication directory group. + + + + + + + + + + -------------------------- EXAMPLE 4 -------------------------- + + + + $scope = Get-OVScope -Name $scopename +$ScopePermissions = @{ Role = "Server administrator"; Scope = $scope +} +Get-OVLdapGroup -Name $scopename | Set-OVLdapGroupRole -ScopePermissions $ScopePermissions -Roles "Software administrator" -Credential $MyAdCreds + + Change the Scope permissions for the specified authentication directory group by using both ScopePermissions and Roles parameters. + + + + + + + + + + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/security/set-ovldapgrouprole + + + + + + + + Set-OVLogicalEnclosure + + Modify a configured Logical Enclosure resource. + + Set + OVLogicalEnclosure + + + A logical enclosure represents a logical view of a single enclosure with an enclosure group serving as a template. If the intended configuration in the logical enclosure does not match the actual configuration on the enclosures, the logical enclosure becomes inconsistent. Use the Logical Enclosures screen to manage firmware, configuration scripts, create a support dump, and to apply updates made from the Enclosure Groups screen to the enclosures in the logical enclosure. + +A logical enclosure is automatically created when a c7000 enclosure is added. + +Use this Cmdlet to modify an existing Logical Enclosure. + + + + + Set-OVLogicalEnclosure + + InputObject + + Logical Enclosure resource from Get-OVLogicalEnclosure. + + Object + + + EnclosureGroup + + Associate the Logical Enclosure with a new Enclosure Group. + + Object + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + + + Set-OVLogicalEnclosure + + InputObject + + Logical Enclosure resource from Get-OVLogicalEnclosure. + + Object + + + Name + + Specify a new Logical Enclosure name. + + String + + + ConfigurationScript + + Specify a new HPE BladeSystem c-Class Onboard Administrator configuration script to set. This is not supported with HPE Synergy. + + String[] + + + EnclosureGroup + + Associate the Logical Enclosure with a new Enclosure Group. + + Object + + + PowerMode + + Change the Power Mode of the Logical Enclosure. + +Allowed values: + + * RedundantPowerFeed - There are at least twice as many power supplies as are necessary (n + n). + * RedundantPowerSupply - There is at least 1 more power supply than is necessary (n + 1). + + String + + + AmbientTemperatureSetting + + The ambient temperature mode describing the environment in which the logical enclosure should be optimized to operate. When not specified, a default value of Standard is assumed. + +Allowed values: + + * ASHRAE_A3 - Extended ambient temperatures up to 40C/104F degrees. + * ASHRAE_A4 - Extended ambient temperatures up to 45C/113F degrees. + * Standard - Expected ambient temperatures up to 35C/95F degrees. + * Telco - Extended ambient temperatures up to 40C/104F degrees and operation extremes up to 55C/131F degrees. + + String + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + + + + + + AmbientTemperatureSetting + + The ambient temperature mode describing the environment in which the logical enclosure should be optimized to operate. When not specified, a default value of Standard is assumed. + +Allowed values: + + * ASHRAE_A3 - Extended ambient temperatures up to 40C/104F degrees. + * ASHRAE_A4 - Extended ambient temperatures up to 45C/113F degrees. + * Standard - Expected ambient temperatures up to 35C/95F degrees. + * Telco - Extended ambient temperatures up to 40C/104F degrees and operation extremes up to 55C/131F degrees. + + String + + String + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + Array + + (${Global:ConnectedSessions} | ? Default) + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + SwitchParameter + + False + + + ConfigurationScript + + Specify a new HPE BladeSystem c-Class Onboard Administrator configuration script to set. This is not supported with HPE Synergy. + + String[] + + String[] + + + + + EnclosureGroup + + Associate the Logical Enclosure with a new Enclosure Group. + + Object + + Object + + + + + InputObject + + Logical Enclosure resource from Get-OVLogicalEnclosure. + + Object + + Object + + + + + Name + + Specify a new Logical Enclosure name. + + String + + String + + + + + PowerMode + + Change the Power Mode of the Logical Enclosure. + +Allowed values: + + * RedundantPowerFeed - There are at least twice as many power supplies as are necessary (n + n). + * RedundantPowerSupply - There is at least 1 more power supply than is necessary (n + 1). + + String + + String + + + + + + + + + HPEOneView.LogicalEnclosure + + + HPE Syngery Logical Enclosure resource from Get-OVLogicalEnclosure. + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + Asynchronous task resource to monitor + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVLogicalEnclosure -Name OriginalName | Set-OVLogicalEnclosure -Name NewName + + Change the Logical Enclosure name. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Get-OVLogicalEnclosure -Name OriginalName | Set-OVLogicalEnclosure -AmbientTemperatureSetting ASHRAE_A3 + + Change the Logical Enclosure ambient temperature setting. + + + + + + + + + + + + + Get-OVLogicalEnclosure + + + + New-OVLogicalEnclosure + + + + Remove-OVLogicalEnclosure + + + + Update-OVLogicalEnclosure + + + + Update-OVLogicalEnclosureFirmware + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/servers/set-ovlogicalenclosure + + + + + + + + Set-OVLogicalJBOD + + Modify a logical JBOD resource. + + Set + OVLogicalJBOD + + + A logical JBOD is a group of physical drives that are dynamically defined as virtual drives. Logical JBOD uses the drives from the drive enclosures that are installed in the device bays of the enclosure and are associated with a SAS logical interconnect. You can assign or unassign a logical JBOD to a server hardware through the server profile. + +This Cmdlet will allow you to change the erase on delete option to False if the logical JBOD was created with the feature enabled (true). Data can also be erased on the logial drive by clearing the metadata. The number of assigned drives or type cannot be modified once the logical JBOD has been created. + +Minimum required privileges: Infrastructure administrator, server administrator, server profile architect, server profile administrator + + + + + Set-OVLogicalJBOD + + InputObject + + The logical JBOD resource from Get-OVLogicalJBOD. + + HPEOneView.Storage.LogicalJBOD[] + + + DisableEraseData + + Can only be used if the logical JBOD was created with EraseDataOnDelete parameter was used in the call to New-OVLogicalJBOD. + + SwitchParameter + + + ClearMetadata + + Clear metadata on the associated drives, effectively wiping the data on the drive. This is not a secure erase, and data recovery could be possible. + + SwitchParameter + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + SwitchParameter + + False + + + ClearMetadata + + Clear metadata on the associated drives, effectively wiping the data on the drive. This is not a secure erase, and data recovery could be possible. + + SwitchParameter + + SwitchParameter + + + + + DisableEraseData + + Can only be used if the logical JBOD was created with EraseDataOnDelete parameter was used in the call to New-OVLogicalJBOD. + + SwitchParameter + + SwitchParameter + + + + + InputObject + + The logical JBOD resource from Get-OVLogicalJBOD. + + HPEOneView.Storage.LogicalJBOD[] + + HPEOneView.Storage.LogicalJBOD[] + + + + + + + + + HPEOneView.Storage.LogicalJBOD + + + A logical JBOD resource from Get-OVLogicalJBOD. + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + Asynchronous task resource to monitor. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Set-OVLogicalJBOD -InputObject $MyLogicalJBOD -DisableEraseData + + Disable erase data on delete policy for the specific logical JBOD. This cannot be undone or reverted back. + + + + + + + + + + + + + Get-OVDriveEnclosure + + + + Get-OVDriveEnclosureInventory + + + + Get-OVLogicalJBOD + + + + New-OVLogicalJBOD + + + + Remove-OVLogicalJBOD + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/storage/set-ovlogicaljbod + + + + + + + + Set-OVLoginMessage + + Set appliance Login Message. + + Set + OVLoginMessage + + + Configure the Login Message for the connected appliance(s). You can also set the Acknowledgement to be required. + + + + + Set-OVLoginMessage + + Message + + The login message to set. The value can be null to clear the login message. + + String + + + Acknowledgment + + Set to True if the login message should be acknowledged before authentication completes. If set to True, the COnnect-OVMgmt Cmdlet will prompt the user to acknowledge the message, if -LoginAcknowledge is not provided in the Cmdlet parameters. + + Boolean + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + Set-OVLoginMessage + + Acknowledgment + + Set to True if the login message should be acknowledged before authentication completes. If set to True, the COnnect-OVMgmt Cmdlet will prompt the user to acknowledge the message, if -LoginAcknowledge is not provided in the Cmdlet parameters. + + Boolean + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + + + + Acknowledgment + + Set to True if the login message should be acknowledged before authentication completes. If set to True, the COnnect-OVMgmt Cmdlet will prompt the user to acknowledge the message, if -LoginAcknowledge is not provided in the Cmdlet parameters. + + Boolean + + Boolean + + False + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Message + + The login message to set. The value can be null to clear the login message. + + String + + String + + + + + + + + + None. You cannot pipe objects to this cmdlet. + + + + + + + + + + + HPEOneView.Appliance.LoginMessage + + + + Returns the login message configured on the appliance. + + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Set-OVLoginMessage -Message "************************************ +>> ***** WARNING ******** +>> ************************************ +>> Updated Message: This management appliance is a company owned asset and provided for the exclusive use of authorized personnel. Unauthorized use or +>> abuse of this system may lead to corrective action including termination, civil and/or criminal penalties." +>> -Acknowledgement $true + + Set the Login Message from all connected appliances. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + $Message = "************************************ +>> ***** WARNING ******** +>> ************************************ +>> Updated Message: This management appliance is a company owned asset and provided for the exclusive use of authorized personnel. Unauthorized use or +>> abuse of this system may lead to corrective action including termination, civil and/or criminal penalties." +>> +Set-OVLoginMessage -Message $Message -Acknowledgment $true + + Set the Login Message from the specified appliance connection. + + + + + + + + + + + + + Get-OVLoginMessage + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/security/set-ovloginmessage + + + + + + + + Set-OVManagedSan + + Enable or Disable Automated SAN Zoning. + + Set + OVManagedSan + + + This Cmdlet is used to Enable or Disable a Managed SAN resource on the appliance. Disabling a Managed SAN will prevent the appliance from configuring FC Zones. + + + + + Set-OVManagedSan + + InputObject + + Managed SAN Name or Object. + + Object + + + ZoningPolicy + + Policy setting that affects the way that zones are created. Allowed values: + + * NoZoning - Disable all automated zoning on the SAN and ignore policy settings related to zoning. + * SingleInitiatorAllTargets - Create one zone per initiator containing all targets connected to that initiator. + * SingleInitiatorSingleStorageSystem - Similar to SingleInitiatorAllTargets except that separate zones are created for targets that reside on different storage systems. + + String + + + EnableAutomatedZoning + + (DEPRICATED - Please use -ZoningPolicy parameter.) Enable Automated Zoning for the specified Managed SAN. When used, the default Zone Policy "SingleInitiatorAllTargets" is set. + + SwitchParameter + + + EnableAliasing + + Enable aliases to be created for initiators, targets and target groups based on the specified name formats + + SwitchParameter + + + InitiatorNameFormat + + Format to use for initiator alias names. The following built-in variables can be used: {hostName}, {initiatorName}, {initiatorWwn}. + +Example: "initiator_{hostname}_{initiatorName}" + + String + + + TargetGroupNameFormat + + Format to use for target group (ex. storage system port group) alias names. The following built-in variables can be used: {storageSystemName}, {targetGroupName}. + +Example: "TargetGroup_{storageSystemName}_{targetGroupName}" + + String + + + DisableTargetGroupAliasing + + When the zoning policy is not set to SingleInitiatorSingleTarget, Target Group Aliasing can be enabled or disabled. + + Bool + + + TargetNameFormat + + Format to use for target (ex. storage system port) alias names. The following built-in variables can be used: {storageSystemName}, {targetName}. + +Example: "Target_{storageSystemName}_{targetName}" + + String + + + ZoneNameFormat + + Format to use when naming new and updated zones. The following built-in variables can be used: {hostName}, {initiatorName}, {initiatorWwn}, {storageSystemName}, {targetName}, {targetGroupName} + +Example: "{initiatorWwn}_{initiatorName}" + + String + + + UpdateZoneNames + + Format to use when naming new and updated zones. The following built-in variables can be used: {hostName}, {initiatorName}, {initiatorWwn}, {storageSystemName}, {targetName}, {targetGroupName} + +Example: "{initiatorWwn}_{initiatorName}" + + Boolean + + + UpdateInitiatorAliases + + Format to use when naming new and updated zones. The following built-in variables can be used: {hostName}, {initiatorName}, {initiatorWwn}, {storageSystemName}, {targetName}, {targetGroupName} + +Example: "{initiatorWwn}_{initiatorName}" + + Boolean + + + UpdateTargetAliases + + Format to use when naming new and updated zones. The following built-in variables can be used: {hostName}, {initiatorName}, {initiatorWwn}, {storageSystemName}, {targetName}, {targetGroupName} + +Example: "{initiatorWwn}_{initiatorName}" + + Boolean + + + UpdateTargetGroupAliases + + When Enabled (True), target and target group aliases will be updated in the SAN whenever resources are renamed in OneView. + + Bool + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + +Default Value: ${Global:ConnectSessions} | ? Default + + Object + + + + Set-OVManagedSan + + InputObject + + Managed SAN Name or Object. + + Object + + + EnableAutomatedZoning + + (DEPRICATED - Please use -ZoningPolicy parameter.) Enable Automated Zoning for the specified Managed SAN. When used, the default Zone Policy "SingleInitiatorAllTargets" is set. + + SwitchParameter + + + ZoningPolicy + + Policy setting that affects the way that zones are created. Allowed values: + + * NoZoning - Disable all automated zoning on the SAN and ignore policy settings related to zoning. + * SingleInitiatorAllTargets - Create one zone per initiator containing all targets connected to that initiator. + * SingleInitiatorSingleStorageSystem - Similar to SingleInitiatorAllTargets except that separate zones are created for targets that reside on different storage systems. + + String + + + DisableAliasing + + Disable aliases to be created for initiators, targets and target groups based on the specified name formats + + SwitchParameter + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + +Default Value: ${Global:ConnectSessions} | ? Default + + Object + + + + Set-OVManagedSan + + InputObject + + Managed SAN Name or Object. + + Object + + + ZoningPolicy + + Policy setting that affects the way that zones are created. Allowed values: + + * NoZoning - Disable all automated zoning on the SAN and ignore policy settings related to zoning. + * SingleInitiatorAllTargets - Create one zone per initiator containing all targets connected to that initiator. + * SingleInitiatorSingleStorageSystem - Similar to SingleInitiatorAllTargets except that separate zones are created for targets that reside on different storage systems. + + String + + + DisableAutomatedZoning + + (DEPRICATED - Please use -ZoningPolicy parameter.) Disable Automated Zoning for the specified Managed SAN. + + SwitchParameter + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + +Default Value: ${Global:ConnectSessions} | ? Default + + Object + + + + + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + +Default Value: ${Global:ConnectSessions} | ? Default + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + DisableAliasing + + Disable aliases to be created for initiators, targets and target groups based on the specified name formats + + SwitchParameter + + SwitchParameter + + false + + + DisableAutomatedZoning + + (DEPRICATED - Please use -ZoningPolicy parameter.) Disable Automated Zoning for the specified Managed SAN. + + SwitchParameter + + SwitchParameter + + False + + + DisableTargetGroupAliasing + + When the zoning policy is not set to SingleInitiatorSingleTarget, Target Group Aliasing can be enabled or disabled. + + Bool + + Bool + + + + + EnableAliasing + + Enable aliases to be created for initiators, targets and target groups based on the specified name formats + + SwitchParameter + + SwitchParameter + + False + + + EnableAutomatedZoning + + (DEPRICATED - Please use -ZoningPolicy parameter.) Enable Automated Zoning for the specified Managed SAN. When used, the default Zone Policy "SingleInitiatorAllTargets" is set. + + SwitchParameter + + SwitchParameter + + False + + + InitiatorNameFormat + + Format to use for initiator alias names. The following built-in variables can be used: {hostName}, {initiatorName}, {initiatorWwn}. + +Example: "initiator_{hostname}_{initiatorName}" + + String + + String + + + + + InputObject + + Managed SAN Name or Object. + + Object + + Object + + + + + TargetGroupNameFormat + + Format to use for target group (ex. storage system port group) alias names. The following built-in variables can be used: {storageSystemName}, {targetGroupName}. + +Example: "TargetGroup_{storageSystemName}_{targetGroupName}" + + String + + String + + + + + TargetNameFormat + + Format to use for target (ex. storage system port) alias names. The following built-in variables can be used: {storageSystemName}, {targetName}. + +Example: "Target_{storageSystemName}_{targetName}" + + String + + String + + + + + UpdateInitiatorAliases + + Format to use when naming new and updated zones. The following built-in variables can be used: {hostName}, {initiatorName}, {initiatorWwn}, {storageSystemName}, {targetName}, {targetGroupName} + +Example: "{initiatorWwn}_{initiatorName}" + + Boolean + + Boolean + + + + + UpdateTargetAliases + + Format to use when naming new and updated zones. The following built-in variables can be used: {hostName}, {initiatorName}, {initiatorWwn}, {storageSystemName}, {targetName}, {targetGroupName} + +Example: "{initiatorWwn}_{initiatorName}" + + Boolean + + Boolean + + + + + UpdateTargetGroupAliases + + When Enabled (True), target and target group aliases will be updated in the SAN whenever resources are renamed in OneView. + + Bool + + Bool + + + + + UpdateZoneNames + + Format to use when naming new and updated zones. The following built-in variables can be used: {hostName}, {initiatorName}, {initiatorWwn}, {storageSystemName}, {targetName}, {targetGroupName} + +Example: "{initiatorWwn}_{initiatorName}" + + Boolean + + Boolean + + + + + ZoneNameFormat + + Format to use when naming new and updated zones. The following built-in variables can be used: {hostName}, {initiatorName}, {initiatorWwn}, {storageSystemName}, {targetName}, {targetGroupName} + +Example: "{initiatorWwn}_{initiatorName}" + + String + + String + + + + + ZoningPolicy + + Policy setting that affects the way that zones are created. Allowed values: + + * NoZoning - Disable all automated zoning on the SAN and ignore policy settings related to zoning. + * SingleInitiatorAllTargets - Create one zone per initiator containing all targets connected to that initiator. + * SingleInitiatorSingleStorageSystem - Similar to SingleInitiatorAllTargets except that separate zones are created for targets that reside on different storage systems. + + String + + String + + SingleInitiatorAllTargets + + + + + + + HPEOneView.Storage.ManagedSan [System.Management.Automation.PSCustomObject] + + + Single Resource + + + + + System.Collection.ArrayList <HPEOneView.Storage.ManagedSan> + + + Multiple Resources + + + + + + + + System.Management.Automation.PSCustomObject + + + + Single Resource + + + + + System.Collections.ArrayList + + + + Multiple Resources + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Set-OVManagedSan Fabric_A -ZoningPolicy SingleInitiatorAllTargets + + Enable Automated SAN Zoning for "Fabric_A" + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Set-OVManagedSan Fabric_A -ZoningPolicy NoZoning + + Disable Automated SAN Zoning for "Fabric_A" + + + + + + + + + + -------------------------- EXAMPLE 3 -------------------------- + + + + Get-OVManagedSan | Set-OVManagedSan -ZoningPolicy SingleInitiatorAllTargets + + Enable Automated SAN Zoning for all managed SAN Fabrics + + + + + + + + + + + + + Get-OVManagedSan + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/storage/set-ovmanagedsan + + + + + + + + Set-OVNetwork + + Modify an existing network. + + Set + OVNetwork + + + Modify a network and it"s attributes information. Use this Cmdlet to change the Network Name, Purpose, Enable or Disable Smartlink, Enable or Disable Private Network, and adjust the allocated bandwidth. + + + + + Set-OVNetwork + + InputObject + + The Name or Resource object of the network to be modified. + + Object + + + Name + + The network resource"s new Name value. + + String + + + Prefix + + Use this parameter to add a new prefix to the name. Will not change the original name value, simply add the prefix to the orignal name. Use the -Name parameter to adjust the entire name. + + String + + + Suffix + + Use this parameter to add a new suffix to the name. Will not change the original name value, simply add the suffix to the orignal name. Use the -Name parameter to adjust the entire name. + + String + + + Purpose + + A description of the network"s role within the logical interconnect. Accepted values in string format are: + + * General + * Management + * VMMigration + * FaultTolerance + + String + + + Smartlink + + Enable or Disable Smartlink within the Ethernet Network. + + Boolean + + + PrivateNetwork + + Enable or Disable Private Network within the Ethernet Network. + + Boolean + + + TypicalBandwidth + + Preferred amount of bandwidth to assign within the Server Profile Connection, specified in Mbps. + + Int32 + + + MaximumBandwidth + + The maximum bandwidth of a network connection, that will be allowed and reflected witin the Server Profile Connection, expressed in Mbps. In Flex10 adapters, the maximum supported Ethernet bandwidth is 10 Gbps. With 10Gb FlexFabric adapters, the maximum FCoE bandwidth is 8Gbps. With FlexFabric 20Gb adapters, the maximum Ethernet bandwidth is 20Gbps. + + Int32 + + + IPv4Subnet + + Use to specify the one IPv4 subnet the network should be associated with from Get-OVAddressPoolSubnet. + + Object + + + IPv6Subnet + + Use to specify the one IPv6 subnet the network should be associated with from Get-OVAddressPoolSubnet. + + Object + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + + + Set-OVNetwork + + InputObject + + The Name or Resource object of the network to be modified. + + Object + + + Name + + The network resource"s new Name value. + + String + + + Prefix + + Use this parameter to add a new prefix to the name. Will not change the original name value, simply add the prefix to the orignal name. Use the -Name parameter to adjust the entire name. + + String + + + Suffix + + Use this parameter to add a new suffix to the name. Will not change the original name value, simply add the suffix to the orignal name. Use the -Name parameter to adjust the entire name. + + String + + + TypicalBandwidth + + Preferred amount of bandwidth to assign within the Server Profile Connection, specified in Mbps. + + Int32 + + + MaximumBandwidth + + The maximum bandwidth of a network connection, that will be allowed and reflected witin the Server Profile Connection, expressed in Mbps. In Flex10 adapters, the maximum supported Ethernet bandwidth is 10 Gbps. With 10Gb FlexFabric adapters, the maximum FCoE bandwidth is 8Gbps. With FlexFabric 20Gb adapters, the maximum Ethernet bandwidth is 20Gbps. + + Int32 + + + LinkStabilityTime + + The time in seconds the appliance waits before reconnecting to a link that was previously offline (Login redistribution). This interval prevents connection loss due to reconnecting to a link that is unstable (going online and offline repeatedly). Parameter is only supported with FibreChannel network resources. + +Minimum Value: 1 +Maximum Value: 1800 + + Int32 + + + AutoLoginRedistribution + + Used for login balancing when logins are not distributed evenly over the Fibre Channel links (for example, when an uplink that was down becomes available). Parameter is only supported with FibreChannel network resources. + +True: Login redistribution is initiated automatically when the link stability time expires. +False: Login redistribution must be initiated manually. + + Boolean + + + ManagedSan + + Managed SAN Name or URI. + + Object + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + + + + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + AutoLoginRedistribution + + Used for login balancing when logins are not distributed evenly over the Fibre Channel links (for example, when an uplink that was down becomes available). Parameter is only supported with FibreChannel network resources. + +True: Login redistribution is initiated automatically when the link stability time expires. +False: Login redistribution must be initiated manually. + + Boolean + + Boolean + + + + + IPv4Subnet + + Use to specify the one IPv4 subnet the network should be associated with from Get-OVAddressPoolSubnet. + + Object + + Object + + + + + IPv6Subnet + + Use to specify the one IPv6 subnet the network should be associated with from Get-OVAddressPoolSubnet. + + Object + + Object + + + + + InputObject + + The Name or Resource object of the network to be modified. + + Object + + Object + + + + + LinkStabilityTime + + The time in seconds the appliance waits before reconnecting to a link that was previously offline (Login redistribution). This interval prevents connection loss due to reconnecting to a link that is unstable (going online and offline repeatedly). Parameter is only supported with FibreChannel network resources. + +Minimum Value: 1 +Maximum Value: 1800 + + Int32 + + Int32 + + 0 + + + ManagedSan + + Managed SAN Name or URI. + + Object + + Object + + + + + MaximumBandwidth + + The maximum bandwidth of a network connection, that will be allowed and reflected witin the Server Profile Connection, expressed in Mbps. In Flex10 adapters, the maximum supported Ethernet bandwidth is 10 Gbps. With 10Gb FlexFabric adapters, the maximum FCoE bandwidth is 8Gbps. With FlexFabric 20Gb adapters, the maximum Ethernet bandwidth is 20Gbps. + + Int32 + + Int32 + + 0 + + + Name + + The network resource"s new Name value. + + String + + String + + + + + Prefix + + Use this parameter to add a new prefix to the name. Will not change the original name value, simply add the prefix to the orignal name. Use the -Name parameter to adjust the entire name. + + String + + String + + + + + PrivateNetwork + + Enable or Disable Private Network within the Ethernet Network. + + Boolean + + Boolean + + + + + Purpose + + A description of the network"s role within the logical interconnect. Accepted values in string format are: + + * General + * Management + * VMMigration + * FaultTolerance + + String + + String + + + + + Smartlink + + Enable or Disable Smartlink within the Ethernet Network. + + Boolean + + Boolean + + + + + Suffix + + Use this parameter to add a new suffix to the name. Will not change the original name value, simply add the suffix to the orignal name. Use the -Name parameter to adjust the entire name. + + String + + String + + + + + TypicalBandwidth + + Preferred amount of bandwidth to assign within the Server Profile Connection, specified in Mbps. + + Int32 + + Int32 + + 0 + + + + + + + HPEOneView.Networking.EthernetNetwork [System.Management.Automation.PSCustomObject] + + + Ethernet Network resource object + + + + + HPEOneView.Networking.FCNetwork [System.Management.Automation.PSCustomObject] + + + FC Network resource object + + + + + HPEOneView.Networking.FCoENetwork [System.Management.Automation.PSCustomObject] + + + FCoE Network resource object + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + The Update Network Resource Task object + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVNetwork -Name "Net-11" | Set-OVNetwork -name NewNet-11 -Purpose Management -SmartLink $true -PrivateNetwork $false -TypicalBandwidth 500 -MaximumBandwidth 1500 | Wait-OVTaskComplete + + Get the "Net-11" Ethernet Network, pipe it to Set-OVNetwork to update values. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + $fabricAManagedSan = Get-OVManagedSan -Name "Fabric A" +Get-OVNetwork -Name "Prod Fabric A" | Set-OVNetwork -ManagedSan $fabricAManagedSan | Wait-OVTaskComplete + + Update "Prod Fabric A" FC Network with "Fabric a" Managed SAN resource. + + + + + + + + + + -------------------------- EXAMPLE 3 -------------------------- + + + + $NewSuffix = "-prod A" +Get-OVNetwork -type Ethernet | Set-OVNetwork -Suffix $NewSuffix + + Get all Ethernet networks, and add a Suffix to their names. + + + + + + + + + + + + + Get-OVNetwork + + + + Get-OVNetworkSet + + + + New-OVNetwork + + + + New-OVNetworkSet + + + + Remove-OVNetwork + + + + Remove-OVNetworkSet + + + + Set-OVNetworkSet + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/networking/set-ovnetwork + + + + + + + + Set-OVNetworkSet + + Modify an existing network set. + + Set + OVNetworkSet + + + A network set is a group of Ethernet L2/L3 networks assigned to one or more connections, giving each single connection access to multiple networks. A network set is a shared resource available to all logical interconnects. It is directly associated with a connection template governing the bandwidth permitted to connections that use the network set. + +Within a network set, all network frames are exchanged over the connection with their 802.1Q VLAN ID in place (in other words, network traffic is tagged with its VLAN ID). However, there is one exception to this rule: one network within the network set can be designated as the 'UntaggedNetwork', or Native VLAN. The 802.1Q VLAN ID is removed from 'UntaggedNetwork' traffic egressing the interconnect downlink (in other words, 'UntaggedNetwork' traffic is untagged). This allows a single connection to support multiple tagged networks plus a single untagged network over the same downlink. + +All Ethernet networks in a network set must have unique VLAN IDs. + +Use this Cmdlet to change the Name, add or remove Ethernet networks, switch to a Large network set resource, what is the untagged network and adjust the allocated bandwidth of an existing network set. + +Minimum required permissions: Infrastructure administrator, Network administrator + + + + + Set-OVNetworkSet + + InputObject + + The Network Set resource object to be modified. + + Object + + + Name + + The updated name value of the Network Set. + + String + + + Networks + + An array containing the updated list of networks. May contain Network objects, names or URI"s. + + Object[] + + + AddNetwork + + Specify 1 or more network resources to add to the specified network set. + + Object[] + + + RemoveNetwork + + Specify 1 or more network resources to remove from the specified network set. + + Object + + + UntaggedNetwork + + The Name or URI of the Untaggged, or Native Network for the Network Set. + + Object + + + TypicalBandwidth + + The updated Typical or Preferred bandwidth, in Mbps. + + Int32 + + + MaximumBandwidth + + The updated MAximum bandwidth, in Mbps. + + Int32 + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + + Large + + A "Regular" network set (-Large:$False) may contain up to 162 networks. "Large" network sets can contain up to 4000 networks and can only be used by server profile template connections or server profile connections assigned to rackmount or HPE Synergy server hardware. A network set cannot be converted from regular to large if the network set is already in use by a server profile or server profile template. + +By default, "Regular" Network Sets are created. + + SwitchParameter + + + + + + + AddNetwork + + Specify 1 or more network resources to add to the specified network set. + + Object[] + + Object[] + + + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + InputObject + + The Network Set resource object to be modified. + + Object + + Object + + + + + Large + + A "Regular" network set (-Large:$False) may contain up to 162 networks. "Large" network sets can contain up to 4000 networks and can only be used by server profile template connections or server profile connections assigned to rackmount or HPE Synergy server hardware. A network set cannot be converted from regular to large if the network set is already in use by a server profile or server profile template. + +By default, "Regular" Network Sets are created. + + SwitchParameter + + SwitchParameter + + + + + MaximumBandwidth + + The updated MAximum bandwidth, in Mbps. + + Int32 + + Int32 + + 0 + + + Name + + The updated name value of the Network Set. + + String + + String + + + + + Networks + + An array containing the updated list of networks. May contain Network objects, names or URI"s. + + Object[] + + Object[] + + + + + RemoveNetwork + + Specify 1 or more network resources to remove from the specified network set. + + Object + + Object + + + + + TypicalBandwidth + + The updated Typical or Preferred bandwidth, in Mbps. + + Int32 + + Int32 + + 0 + + + UntaggedNetwork + + The Name or URI of the Untaggged, or Native Network for the Network Set. + + Object + + Object + + + + + + + + + HPEOneView.Networking.NetworkSet [System.Management.Automation.PSCustomObject] + + + Single Network Set resource + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + Update Network Set resource task + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + $netset = Get-OVNetworkSet -Name "Set-1" +$netset.maximumBandwidth = 5000 +$netset.typicalBandwidth = 3000 +Set-OVNetworkSet $netset + + Modify "Set-1" to be maximum bandwidth of 5000. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Get-OVNetworkSet -Name NetSet-1 | Set-OVNetworkSet -name NewNetSet-1 -networks @(bluenet,rednet,greennet) -untagged bluenet + + Update "NetSet-1" with a new name, adjust the networks, and set "bluenet" as the Untagged Network. + + + + + + + + + + -------------------------- EXAMPLE 3 -------------------------- + + + + $NetworkToAdd = Get-OVNetwork -Name "Prod 442 VLAN" +Get-OVNetworkSet -Name NetSet-1 | Set-OVNetworkSet -AddNetwork $NetworkToAdd + + Add the specified network to the existing network set. + + + + + + + + + + -------------------------- EXAMPLE 4 -------------------------- + + + + $NetworksToRemove = Get-OVNetwork -Name "Dev 45*" +Get-OVNetworkSet -Name NetSet-2 | Set-OVNetworkSet -RemoveNetwork $NetworksToRemove + + Remove the specified networks from the existing network set. + + + + + + + + + + + + + Get-OVNetworkSet + + + + New-OVNetworkSet + + + + Remove-OVNetworkSet + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/networking/set-ovnetworkset + + + + + + + + Set-OVRack + + Modify an existing rack resource. + + Set + OVRack + + + A rack is a physical structure that contains IT equipment such as enclosures, servers, power delivery devices, and unmanaged devices (an unmanaged device uses slots in the rack and consumes power or exhausts heat, but it is not managed by the appliance). You can manage your racks and the equipment in them by adding them to the appliance. Having your racks managed by the appliance enables you to use the appliance for space and power planning. The appliance also gathers statistical data and monitors the power and temperature of the racks it manages. + +When you add an enclosure to the appliance, it automatically creates a rack and places the enclosure in it. The appliance places into the rack all enclosures connected by management link cables. When enclosures are added, the appliance places them in the rack from top to bottom. When an enclosure is placed in an Intelligent Series Rack, the enclosure slots are automatically detected. For other racks, to accurately depict the layout of your enclosures within the rack you must edit the rack to place the enclosure in the proper slots. + +You can use the appliance to view and manage your rack configuration and power delivery topology. You can specify the physical dimensions of the rack (width, height, and depth), the number of U slots, and the location of each piece of equipment in the rack. You can specify the rack PDUs that provide power to the rack, and their physical position in the rack or on either side. You can also describe how the devices in the rack are connected to those PDUs. + +The appliance automatically discovers the rack height and rack model for a ProLiant server with Location Discovery Services and updates the physical locations of devices when they are relocated within and between racks for c7000 enclosures. + +This Cmdlet will update existing rack resources with updated properties. This includes updating the name, part number, serial number, model, supported thermal capacity, rack dimensions including rack units, height, width and depth. + +Minimum required privileges: Infrastructure administrator or Server administrator + + + + + Set-OVRack + + InputObject + + The rack object from Get-OVRack. + + Object + + + Name + + Name of resource. + + string + + + ThermalLimit + + Thermal limit supported by the rack, in BTU"s. + + int + + + SerialNumber + + Serial number of the rack resource. + + string + + + PartNumber + + Part number of the rack resource. + + string + + + Model + + Provide the model of the rack to add. + + string + + + Depth + + Rack depth, in millimeters. + + int + + + Height + + Height of rack, in millimeters. + + int + + + UHeight + + The rack unit height of the rack. + + int + + + Width + + Width of rack, in millimeters. + + int + + + ApplianceConnection + + Specify one or more HPEOneView.Appliance.Connection object(s) or Name property value(s). + +Default Value: ${Global:ConnectedSessions} | ? Default + + Object + + + + + + + ApplianceConnection + + Specify one or more HPEOneView.Appliance.Connection object(s) or Name property value(s). + +Default Value: ${Global:ConnectedSessions} | ? Default + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Depth + + Rack depth, in millimeters. + + int + + int + + + + + Height + + Height of rack, in millimeters. + + int + + int + + + + + InputObject + + The rack object from Get-OVRack. + + Object + + Object + + + + + Model + + Provide the model of the rack to add. + + string + + string + + + + + Name + + Name of resource. + + string + + string + + + + + PartNumber + + Part number of the rack resource. + + string + + string + + + + + SerialNumber + + Serial number of the rack resource. + + string + + string + + + + + ThermalLimit + + Thermal limit supported by the rack, in BTU"s. + + int + + int + + + + + UHeight + + The rack unit height of the rack. + + int + + int + + + + + Width + + Width of rack, in millimeters. + + int + + int + + + + + + + + + HPEOneView.Facilities.Rack [System.Management.Automation.PSCustomObject] + + + Rack resource from Get-OVRack. + + + + + + + + HPEOneView.Facilities.Rack [System.Management.Automation.PSCustomObject] + + + + Updated rack resource. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVRack -Name Rack-1 | Set-OVRack -ThermalLimit 15000 + + + Update the specific rack resource thermal limit to 15kW. + + + + + + + + + + + + + Add-OVRackManager + + + + Add-OVRackToDataCenter + + + + Get-OVRack + + + + Get-OVRackManager + + + + Get-OVRackMember + + + + New-OVRack + + + + Remove-OVRack + + + + Remove-OVRackManager + + + + Remove-OVRackMember + + + + Set-OVRackMemberLocation + + + + Update-OVRackManager + + + + Online: + https://hpe-docs.gitbook.io/posh-hpeoneview/cmdlets/v9.00/facilities/set-ovrack + + + + + + + + Set-OVRackMemberLocation + + Modify an existing rack member U location. + + Set + OVRackMemberLocation + + + A rack is a physical structure that contains IT equipment such as enclosures, servers, power delivery devices, and unmanaged devices (an unmanaged device uses slots in the rack and consumes power or exhausts heat, but it is not managed by the appliance). You can manage your racks and the equipment in them by adding them to the appliance. Having your racks managed by the appliance enables you to use the appliance for space and power planning. The appliance also gathers statistical data and monitors the power and temperature of the racks it manages. +When you add an enclosure to the appliance, it automatically creates a rack and places the enclosure in it. The appliance places into the rack all enclosures connected by management link cables. When enclosures are added, the appliance places them in the rack from top to bottom. When an enclosure is placed in an Intelligent Series Rack, the enclosure slots are automatically detected. For other racks, to accurately depict the layout of your enclosures within the rack you must edit the rack to place the enclosure in the proper slots. + +You can use the appliance to view and manage your rack configuration and power delivery topology. You can specify the physical dimensions of the rack (width, height, and depth), the number of U slots, and the location of each piece of equipment in the rack. You can specify the rack PDUs that provide power to the rack, and their physical position in the rack or on either side. You can also describe how the devices in the rack are connected to those PDUs. + +The appliance automatically discovers the rack height and rack model for a ProLiant server with Location Discovery Services and updates the physical locations of devices when they are relocated within and between racks for c7000 enclosures. + +This Cmdlet will modify an existing rack member U Location within the rack it is located. + + + + + Set-OVRackMemberLocation + + InputObject + + The rack member to modify from Get-OVRackMember. + + HPEOneView.Facilities.RackMember + + + ULocation + + The new Rack Unit location where the resource is located. + + Int + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + InputObject + + The rack member to modify from Get-OVRackMember. + + HPEOneView.Facilities.RackMember + + HPEOneView.Facilities.RackMember + + + + + ULocation + + The new Rack Unit location where the resource is located. + + Int + + Int + + + + + + + + + HPEOneView.Facilities.RackMember + + + DataCenter facility object from Get-OVDataCenter. + + + + + + + + HPEOneView.Facilities.RackMember + + + + Modified rack member object with the updated Rack Unit location. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + $RackMember = Get-OVRack -Name "Rack-221" -ErrorAction Stop | Get-OVRackMember -Name "DL380 1" -ErrorAction Stop +Set-OVRackMemberLocation -InputObject $RackMember -ULocation ($RackMember.ULocation + 5) + + Update the "DL380 1" rack member raising its current rack unit location by 5. + + + + + + + + + + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/facilities/set-ovrackmemberlocation + + + + + + + + Set-OVRemoteSupport + + Configure Remote Support and authorize appliance. + + Set + OVRemoteSupport + + + Register with Hewlett Packard Enterprise to allow automatic case creation for hardware failures on servers and enclosures and to enable Proactive Care. Once enabled, all eligible devices added in the future will be automatically enabled for remote support. + Eligible devices are Gen8 and newer blades and enclosures. +NOTE: Servers must be at iLO 2.1 firmware level or above to be enabled for remote support + Hewlett Packard Enterprise will contact you to ship a replacement part or send an engineer for devices that are under warranty or support contract. + Remote support enables Proactive Care services including Proactive Scan reports and Firmware/Software Analysis reports with recommendations that are based on collected configuration data. + Remote support is secure. No business data is collected, only device-specific configuration and fault data. All communications are outbound only and use industry standard TLS encryption ensuring confidentiality and integrity of the information. + Once the appliance is configured, it cannot be unauthorized or disabled. + + + + + Set-OVRemoteSupport + + CompanyName + + The company name Remote Support will be authorized for. + + String + + + OptimizeOptIn + + Opt-in to allow HPE marketing to discuss datacenter optimization. + + SwitchParameter + + + AutoEnableDevices + + Choose to allow the appliance to auto enable remote support for all and devices added in the future. + + Bool + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + Set-OVRemoteSupport + + CompanyName + + The company name Remote Support will be authorized for. + + String + + + OptimizeOptIn + + Opt-in to allow HPE marketing to discuss datacenter optimization. + + SwitchParameter + + + AutoEnableDevices + + Choose to allow the appliance to auto enable remote support for all and devices added in the future. + + Bool + + + InsightOnlineUsername + + OBSOLETE - HPE Insight Online is a deprecated and unavailable service. It is no longer supports. + + String + + + InsightOnlinePassword + + OBSOLETE - HPE Insight Online is a deprecated and unavailable service. It is no longer supports. + + System.Security.SecureString + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + Set-OVRemoteSupport + + Enable + + Use this parameter to enable remote support on an appliance, only if the appliance was previously configured for Remote Support and it was disabled. + + SwitchParameter + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + Set-OVRemoteSupport + + Disable + + Use this parameter to disable remote support globally on the appliance. Use the -Enable parameter to re-enable Remote Support. + + SwitchParameter + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + SwitchParameter + + False + + + AutoEnableDevices + + Choose to allow the appliance to auto enable remote support for all and devices added in the future. + + Bool + + Bool + + + + + CompanyName + + The company name Remote Support will be authorized for. + + String + + String + + + + + Disable + + Use this parameter to disable remote support globally on the appliance. Use the -Enable parameter to re-enable Remote Support. + + SwitchParameter + + SwitchParameter + + + + + Enable + + Use this parameter to enable remote support on an appliance, only if the appliance was previously configured for Remote Support and it was disabled. + + SwitchParameter + + SwitchParameter + + + + + InsightOnlinePassword + + OBSOLETE - HPE Insight Online is a deprecated and unavailable service. It is no longer supports. + + System.Security.SecureString + + System.Security.SecureString + + + + + InsightOnlineUsername + + OBSOLETE - HPE Insight Online is a deprecated and unavailable service. It is no longer supports. + + String + + String + + + + + OptimizeOptIn + + Opt-in to allow HPE marketing to discuss datacenter optimization. + + SwitchParameter + + SwitchParameter + + False + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + HPEOneView.Appliance.RemoteSupportConfig [System.Management.Automation.PSCustomObject] + + + + The appliance Remote Support configuration applied. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Set-OVRemoteSupport -CompanyName MyCompany + + Configure and register the appliance for Remote Support. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Set-OVRemoteSupport -Disable + + Disable Remote Support on the appliance. + + + + + + + + + + -------------------------- EXAMPLE 3 -------------------------- + + + + Set-OVRemoteSupport -Enable -ApplianceConnection $Appliance2 + + Enable Remote Support after it was previously disabled for the specific appliance. + + + + + + + + + + + + + Disable-OVRemoteSupport + + + + Enable-OVRemoteSupport + + + + Get-OVRemoteSupport + + + + Get-OVRemoteSupportContact + + + + Get-OVRemoteSupportDataCollectionSchedule + + + + Get-OVRemoteSupportDefaultSite + + + + Get-OVRemoteSupportEntitlementStatus + + + + Get-OVRemoteSupportPartner + + + + Get-OVRemoteSupportSetting + + + + New-OVRemoteSupportContact + + + + New-OVRemoteSupportPartner + + + + Remove-OVRemoteSupportContact + + + + Remove-OVRemoteSupportPartner + + + + Set-OVRemoteSupportDataCollectionSchedule + + + + Set-OVRemoteSupportDefaultSite + + + + Set-OVRemoteSupportPrimaryContact + + + + Set-OVRemoteSupportSetting + + + + Start-OVRemoteSupportCollection + + + + Update-OVRemoteSupportEntitlement + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/set-ovremotesupport + + + + + + + + Set-OVRemoteSupportDataCollectionSchedule + + Modify Remote Support Schedule settings on an appliance. + + Set + OVRemoteSupportDataCollectionSchedule + + + Use this Cmdlet to set a new schedule to collect Remote Support logs. There are two defined schedules: Active Health scheduled on a weekly basis, and Server Basic Configuration scheduled on a monthly basis. Either scheduled collection task can be modified, to set the Day of Week, Day of Month, Hour and Minute. +When supplying a DateTime value, the Day will be converted to the Day of Month, and Day of the Week respectively. For instance, if "Oct 30, 2016 13:00" is provided, Day of Month will be every "30th" day, and Day of Week will be every "Sunday" (which Oct 30th 2016 is a Sunday). +To schedule different Day of the Month and Day of the Week, use the -Type paramter to specify AHS or Basic. The -DateTime paramter value will only be applied to that schedule. + + + + + Set-OVRemoteSupportDataCollectionSchedule + + DateTime + + Specify a DateTime value for the schedule to execute. AHS schedule is executed on a weekly basis, and Server Basic Configuration is executed on a monthly basis. When needing to configure a schedule for AHS log collection, the Month Day"s week day name will be used. For instance, if "Oct 30, 2016" is provided and scheduling for AHS log collection, the task will execute every Sunday, which October 30th 2016 is on a Sunday. When providing the hour of the day to execute, the value must be in 24hr time. + + DateTime + + + Type + + Specify the schedule type to modify. Allowed value is: + * AHS + *Basic +If no value is provided, both schedules will be modified. + + String + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + SwitchParameter + + False + + + DateTime + + Specify a DateTime value for the schedule to execute. AHS schedule is executed on a weekly basis, and Server Basic Configuration is executed on a monthly basis. When needing to configure a schedule for AHS log collection, the Month Day"s week day name will be used. For instance, if "Oct 30, 2016" is provided and scheduling for AHS log collection, the task will execute every Sunday, which October 30th 2016 is on a Sunday. When providing the hour of the day to execute, the value must be in 24hr time. + + DateTime + + DateTime + + + + + Type + + Specify the schedule type to modify. Allowed value is: + * AHS + *Basic +If no value is provided, both schedules will be modified. + + String + + String + + + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + Async task Resource object for modifying the Remote Support Collection schedules. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Set-OVRemoteSupportDataCollectionSchedule -DateTime "11/01/2016 20:00" + + Set a new Remote Support schedule for November 11, 2016, which is a Monday, at 20:00 (8:00pm). + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Set-OVRemoteSupportDataCollectionSchedule -Type AHS -DateTime "11/01/2016 20:00" + + Set a new schedule to collect AHS logs every Monday of every week, at 20:00 (8:00pm). + + + + + + + + + + + + + Get-OVRemoteSupportDataCollectionSchedule + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/set-ovremotesupportdatacollectionschedule + + + + + + + + Set-OVRemoteSupportDefaultSite + + Define the Remote Support Default Site. + + Set + OVRemoteSupportDefaultSite + + + Use this Cmdlet to set the default data center site used for Remote Support. All resources defined will use this data center site. + + + + + Set-OVRemoteSupportDefaultSite + + AddressLine1 + + Aliases [-a1] +Primary Address line 1. + + String + + + City + + City. + + String + + + State + + Aliases [-Provence] +State or Provence. + + String + + + Country + + 2-letter country code. + + String + + + TimeZone + + Timezone of the data center, in ISO-3166 location format (e.g. US/Central). + + String + + + AddressLine2 + + Aliases [-a2] +Primary Address line 2. + + String + + + PostalCode + + Postal or zip code. + + String + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + + + + AddressLine1 + + Aliases [-a1] +Primary Address line 1. + + String + + String + + + + + AddressLine2 + + Aliases [-a2] +Primary Address line 2. + + String + + String + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + City + + City. + + String + + String + + + + + Country + + 2-letter country code. + + String + + String + + + + + PostalCode + + Postal or zip code. + + String + + String + + + + + State + + Aliases [-Provence] +State or Provence. + + String + + String + + + + + TimeZone + + Timezone of the data center, in ISO-3166 location format (e.g. US/Central). + + String + + String + + + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + System.Management.Automation.PSCustomObject + + + + Configured Remote Support default site. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Set-OVRemoteSupportDefaultSite -AddressLine1 "3000 Hanover St." -City "Palo Alto" -State CA -PostalCode 94304 -Country US -TimeZone "US/Pacific" + + Get the configured Remote Support default site. + + + + + + + + + + + + + Get-OVRemoteSupportDefaultSite + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/set-ovremotesupportdefaultsite + + + + + + + + Set-OVRemoteSupportPrimaryContact + + Set HPE OneView Remote Support default primary contact. + + Set + OVRemoteSupportPrimaryContact + + + Register with Hewlett Packard Enterprise to allow automatic case creation for hardware failures on servers and enclosures and to enable Proactive Care. Once enabled, all eligible devices added in the future will be automatically enabled for remote support. + +Use this Cmdlet to change or update the HPE OneView Remote Support primary Contact. + +Minimum required privileges: Infrastructure administrator + + + + + Set-OVRemoteSupportPrimaryContact + + InputObject + + HPE OneView Remote Support contact from Get-OVRemoteSupportContact. + + Object + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + WhatIf + + + + SwitchParameter + + + Confirm + + + + SwitchParameter + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Confirm + + + + SwitchParameter + + SwitchParameter + + + + + InputObject + + HPE OneView Remote Support contact from Get-OVRemoteSupportContact. + + Object + + Object + + + + + WhatIf + + + + SwitchParameter + + SwitchParameter + + + + + + + + + HPEOneView.Appliance.RemoteSupport.Contact [System.Management.Automation.PSCustomObject] + + + Remote support contact from Get-OVRemoteSupportContact. + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + Asynchronous task resource to monitor + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + $PrimaryContact = Get-OVRemoteSupportContact -Name "Bob Smith" +Set-OVRemoteSupportPrimaryContact -InputObject $PrimaryContact + + Set a new HPE OneView Remote Support primary contact on the appliance. + + + + + + + + + + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/set-ovremotesupportprimarycontact + + + Set-OVRemoteSupportSecondaryContact + + + + + + + + + Set-OVRemoteSupportSecondaryContact + + Set HPE OneView Remote Support default secondary contact. + + Set + OVRemoteSupportSecondaryContact + + + Register with Hewlett Packard Enterprise to allow automatic case creation for hardware failures on servers and enclosures and to enable Proactive Care. Once enabled, all eligible devices added in the future will be automatically enabled for remote support. + +Use this Cmdlet to change or update the HPE OneView Remote Support secondary Contact. + +Minimum required privileges: Infrastructure administrator + + + + + Set-OVRemoteSupportSecondaryContact + + InputObject + + HPE OneView Remote Support contact from Get-OVRemoteSupportContact. + + Object + + + ApplianceConnection + + Aliases [-Appliance] + +Specify one or more HPEOneView.Appliance.Connection object(s) or Name property value(s). + + Object + + + WhatIf + + + + + + + Confirm + + + + + + + + + + + ApplianceConnection + + Aliases [-Appliance] + +Specify one or more HPEOneView.Appliance.Connection object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Confirm + + + + + + + + + + + InputObject + + HPE OneView Remote Support contact from Get-OVRemoteSupportContact. + + Object + + Object + + + + + WhatIf + + + + + + + + + + + + + + + HPEOneView.Appliance.RemoteSupport.Contact [System.Management.Automation.PSCustomObject] + + + Remote support contact from Get-OVRemoteSupportContact. + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + Asynchronous task resource to monitor + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + $PrimaryContact = Get-OVRemoteSupportContact -Name "Susan Jones" +Set-OVRemoteSupportSecondaryContact -InputObject $SecondaryContact + + Set a new HPE OneView Remote Support secondary contact on the appliance. + + + + + + + + + + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/set-ovremotesupportsecondarycontact + + + Set-OVRemoteSupportPrimaryContact + + + + + + + + + Set-OVRemoteSupportSetting + + Configure supported resource Remote Support settings. + + Set + OVRemoteSupportSetting + + + Use this Cmdlet to configure a supported resources Remote Support collection settings. + + + + + Set-OVRemoteSupportSetting + + InputObject + + Either a Server Hardware or Enclosure resource to get the configured Remote Support collection settings. + + Object + + + PrimaryContact + + Primary Remote Support Contact user object. + + Object + + + SecondaryContact + + Secondary Remote Support Contact user object. + + Object + + + ServicePartner + + Authorized HPE service partner object from Get-OVRemoteSupportPartner. + + Object + + + Reseller + + Authorized HPE reseller partner object from Get-OVRemoteSupportPartner. + + Object + + + ContractType + + Use to override the contract type. If specifying a different contract type, you must supply the SupportID. Allowed values are: + + * SupportAgreement + * PackagedSupport. + + String + + + SupportID + + The support Contract ID. You must specify the type of contract by using the -ContractType parameter. + + String + + + NewSerialNumber + + Use to update the HPE support backend with an updated serial number. + + String + + + NewProductNumber + + Use to update the HPE support backend with an updated product number + + String + + + Enabled + + Use to enable HPE OneView Remote Support configuration on the appliance. + + SwitchParameter + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + Set-OVRemoteSupportSetting + + InputObject + + Either a Server Hardware or Enclosure resource to get the configured Remote Support collection settings. + + Object + + + Disabled + + Use to disable HPE OneView Remote Support configuration on the appliance. + + SwitchParameter + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + SwitchParameter + + False + + + ContractType + + Use to override the contract type. If specifying a different contract type, you must supply the SupportID. Allowed values are: + + * SupportAgreement + * PackagedSupport. + + String + + String + + + + + Disabled + + Use to disable HPE OneView Remote Support configuration on the appliance. + + SwitchParameter + + SwitchParameter + + + + + Enabled + + Use to enable HPE OneView Remote Support configuration on the appliance. + + SwitchParameter + + SwitchParameter + + + + + InputObject + + Either a Server Hardware or Enclosure resource to get the configured Remote Support collection settings. + + Object + + Object + + + + + NewProductNumber + + Use to update the HPE support backend with an updated product number + + String + + String + + + + + NewSerialNumber + + Use to update the HPE support backend with an updated serial number. + + String + + String + + + + + PrimaryContact + + Primary Remote Support Contact user object. + + Object + + Object + + + + + Reseller + + Authorized HPE reseller partner object from Get-OVRemoteSupportPartner. + + Object + + Object + + + + + SecondaryContact + + Secondary Remote Support Contact user object. + + Object + + Object + + + + + ServicePartner + + Authorized HPE service partner object from Get-OVRemoteSupportPartner. + + Object + + Object + + + + + SupportID + + The support Contract ID. You must specify the type of contract by using the -ContractType parameter. + + String + + String + + + + + + + + + HPEOneView.ServerHardware [System.Management.Automation.PSCustomObject] + + + Server hardware resource object. + + + + + HPEOneView.Enclosure [System.Management.Automation.PSCustomObject] + + + Enclosure resource object. + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + Asynchronous task resource to monitor + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + $NewReseller = Get-OVRemoteSupportContact -Name "New Reseller Name" +Get-OVEnclosure -Name Encl1 | Set-OVRemoteSupportSetting -Reseller $NewReseller + + Update "Encl1" with a new reseller contact that was added to the appliance. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Get-OVServer -Name Prd-host-* | Set-OVRemoteSupportSetting -ContractType SupportAgreement -SupportID 111199990 + + Update the servers with a new support agreement. + + + + + + + + + + -------------------------- EXAMPLE 3 -------------------------- + + + + PrimaryContact = Get-OVRemoteSupportContact -Name "Gladi Chua" +$SecondaryContact = Get-OVRemoteSupportContact -Name "Luke Smith" +Get-OVEnclosure -Name Prod* | Set-OVRemoteSupportSetting -PrimaryContact $PrimaryContact -SecondaryContact $SecondaryContact -Async -OutVariable Tasks + + Update the Enclosures with new primary and secondary contacts, returning async tasks to monitor using the OutVariable Common Parameter. + + + + + + + + + + + + + Get-OVRemoteSupportSetting + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/set-ovremotesupportsetting + + + + + + + + Set-OVRemoteSyslog + + Configure remote syslog. + + Set + OVRemoteSyslog + + + The remoteSyslog API provides the ability to configure remote logging on devices managed by OneView. This Cmdlet handles setting or updating the remote syslog configuration. Only a single destination can be set. When configured, the HPE OneView appliance will deploy the SysLog settings to managed resources automatically. + + + + + Set-OVRemoteSyslog + + Destination + + Destination IPv4 Address of the Remote SysLog. + + IPAddress + + + Port + + The destination TCP port. + +Default value: 514 + + Int32 + + + SendTestMessage + + Use to generate a syslog test message after the managed endpoint has finished configuring. + + SwitchParameter + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + SwitchParameter + + False + + + Destination + + Destination IPv4 Address of the Remote SysLog. + + IPAddress + + IPAddress + + + + + Port + + The destination TCP port. + +Default value: 514 + + Int32 + + Int32 + + 514 + + + SendTestMessage + + Use to generate a syslog test message after the managed endpoint has finished configuring. + + SwitchParameter + + SwitchParameter + + False + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + None. You cannot pipe objects to this Cmdlet + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + If successful, returns Appliance Async Task object to monitor + + + + + System.Collections.ArrayList <HPEOneView.Appliance.TaskResource> + + + + Collection of Appliance Async Task objects to monitor + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Set-OVRemoteSyslog -Destination 10.150.20.1 -SendTestMessage -Async | Wait-OVTaskComplete + + Set the remote syslog to the provided destination, using the default destination TCP port, and send a test message for all connected appliances. + + + + + + + + + + + + + Disable-OVRemoteSyslog + + + + Enable-OVRemoteSyslog + + + + Get-OVRemoteSyslog + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/set-ovremotesyslog + + + + + + + + Set-OVReservedVlanRange + + Modify the reserved VLAN range for HPE Synergy. + + Set + OVReservedVlanRange + + + A reserved VLAN pool is a range of VLANs used for allocation of non-tagged networks: + + * Tunnel + * Untagged + * Fibre Channel (FC) + +Tagged networks and FCoE networks use VLANs outside of the reserved pool. You cannot use a reserved VLAN for tagged or FCoE networks. + +The VLAN pool allows the number of available VLANs to be segregated between tagged and non-tagged networks. Because non-tagged networks use VLANs for internal translation resources, a reserved VLAN pool can provide a sufficient number of VLANs available for allocation of those internal VLANs. In addition, the reserved pool range removes the need for translation resources to be used on tagged networks. + +For the maximum number of VLANs per physical downlink port, see the HPE OneView Support Matrix for HPE Synergy. + +Creating and managing a reserved VLAN pool + +A reserved VLAN pool is unique within a fabric, but independently allocated within each logical interconnect. The reserved range is identical across all logical interconnects within a fabric. The remaining VLANs (outside of the pool) are shared among all the logical interconnects within the fabric. + +For HPE OneView running embedded on a HPE Synergy 12000 Frame, the default range starts at 3967 and the size is 128. The minimum size of the pool must be 60 VLANs to ensure the pool is not exhausted. + +The size of the pool cannot exceed 128 VLANs. + +Minimum required privileges: Infrastructure administrator, Network administrator + + + + + Set-OVReservedVlanRange + + Start + + The starting VLAN ID. + + Int + + + Length + + Must not exceed 128. + + Int + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Length + + Must not exceed 128. + + Int + + Int + + + + + Start + + The starting VLAN ID. + + Int + + Int + + + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + Async task Resource object for configuring port monitoring on the requested logical intercinnect. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Set-OVReservedVlanRange -Start 2700 -Length 128 + + Change the reserved VLAN range to start at 2700, and end at 2828. + + + + + + + + + + + + + Get-OVReservedVlanRange + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/set-ovreservedvlanrange + + + + + + + + Set-OVResource + + Update existing resource(s). + + Set + OVResource + + + This Cmdlet will assist the user to update an existing resource. The resource should first be retrieved with a "Get-OV[resourcename]" Cmdlet. The PowerShell resource may then be modified, followed by this "Set-OVResource" Cmdlet. + + + + + Set-OVResource + + InputObject + + The modified resource that is to be updated. Can be resource object, name or URI. + + Object + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + + Force + + Set to $true to force-update the resource. Not all resources support force-update. + + String + + + + + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Force + + Set to $true to force-update the resource. Not all resources support force-update. + + String + + String + + False + + + InputObject + + The modified resource that is to be updated. Can be resource object, name or URI. + + Object + + Object + + + + + + + + + System.Management.Automation.PSCustomObject + + + Resource Object to modify by either using Send-OVRequest with the resource URI, or the resource GET Cmdlet + + + + + + + + System.Management.Automation.PSCustomObject + + + + The modified resource or async task depending on the resource being modified + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + $profile = Get-OVServerProfile -Name "Profile 1" +$profile.name = "New Name" +Set-OVResource $profile + + Updates the name of the Server Profile resource. + + + + + + + + + + + + + Add-OVResourceToLabel + + + + Add-OVResourceToRack + + + + Add-OVResourceToScope + + + + New-OVResource + + + + Remove-OVResource + + + + Remove-OVResourceFromLabel + + + + Remove-OVResourceFromScope + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/library/set-ovresource + + + + + + + + Set-OVRotateMPPasswordPolicy + + Configure management processor password rotation policy. + + Set + OVRotateMPPasswordPolicy + + + You can enable and set up a schedule for automatic rotation of passwords for HPE OneView administrator accounts on managed devices. Based on the security policy of the organization, you can set the timeframe for the password rotation from 1-365 days. This security practice of setting a timeframe for enforcing password change reduces password-based attacks. + +You can schedule password rotation for the following accounts: + + * HPE iLO: hpOneViewAdmin + * HPE Compute Scale-up Server 3200: HPEOneViewMonitor + * HPE Superdome Flex Servers Family: HPEOneViewMonitor + +Considerations + +If devices have accounts set up with LDAP or Microsoft Active Directory, the password cannot be rotated. + +If a server is engaged in another task, password rotation is skipped for the server, and rotation is done in the next schedule. + +Only non-HPE Synergy Servers are supported. + +Use this Cmdlet to enable or disable a password rotation policy. + +Minimum required privileges: + + * Infrastructure administrator + + + + + Set-OVRotateMPPasswordPolicy + + Frequency + + The number of days to perform the password rotation. Must be between 1 and 365 days. + + int + + + Time + + The time of day to execute in a TimeSpan object. Only hours and minutes are supported, and in 24 hour time. This time will be set to UTC on the appliance. + + TimeSpan + + + ApplianceConnection + + Specify one or more HPEOneView.Appliance.Connection object(s) or Name property value(s). + +Default Value: ${Global:ConnectedSessions} | ? Default + + Object + + + WhatIf + + + + SwitchParameter + + + Confirm + + + + SwitchParameter + + + + Set-OVRotateMPPasswordPolicy + + Disable + + Disable password rotation for HPE OneView administrator account on managed devices. + + SwitchParameter + + + ApplianceConnection + + Specify one or more HPEOneView.Appliance.Connection object(s) or Name property value(s). + +Default Value: ${Global:ConnectedSessions} | ? Default + + Object + + + WhatIf + + + + SwitchParameter + + + Confirm + + + + SwitchParameter + + + + + + + ApplianceConnection + + Specify one or more HPEOneView.Appliance.Connection object(s) or Name property value(s). + +Default Value: ${Global:ConnectedSessions} | ? Default + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Confirm + + + + SwitchParameter + + SwitchParameter + + + + + Disable + + Disable password rotation for HPE OneView administrator account on managed devices. + + SwitchParameter + + SwitchParameter + + + + + Frequency + + The number of days to perform the password rotation. Must be between 1 and 365 days. + + int + + int + + + + + Time + + The time of day to execute in a TimeSpan object. Only hours and minutes are supported, and in 24 hour time. This time will be set to UTC on the appliance. + + TimeSpan + + TimeSpan + + + + + WhatIf + + + + SwitchParameter + + SwitchParameter + + + + + + + + + None. You cannot pipe objects to this cmdlet. + + + + + + + + + + + HPEOneView.Appliance.RotateMPPasswordPolicy + + + + The class object containing the password rotation policy configuration. + + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Set-OVRotateMPPasswordPolicy -Days 30 -Timespan (New-Timespan -Hours 01 -Minutes 00) + + + Enable or change the password rotation policy on the appliance to every 30 days at 01:00 local time of the user. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Set-OVRotateMPPasswordPolicy -Disable + + + Disable the password rotation policy on the appliance. + + + + + + + + + + + + + Get-OVRotateMPPasswordPolicy + + + + Get-OVRotateMPPasswordPolicyReport + + + + Online: + https://hpe-docs.gitbook.io/posh-hpeoneview/cmdlets/v9.00/appliance/set-ovrotatemppasswordpolicy + + + + + + + + Set-OVSanManager + + Update SAN Manager configuration + + Set + OVSanManager + + + Updates an existing SAN Manager configuration. Can update the hostname/IP Address and credentials. At least one optional parameter must be provided. + + + + + Set-OVSanManager + + InputObject + + Resource Object (from Get-OVSanManager) or Name of the SAN Manager to update. If specifying a resource Name, the ApplianceConnection parameter is required. + + Object + + + Username + + Updated Username used to authenticate and manage the SAN Manager. + + String + + + Password + + Updated Password used to authenticate and manage the SAN Manager. Can either be a String or System.Security.SecureString value. + + Object + + + Hostname + + Updated Hostname or IP Address of the SAN Manager. + + String + + + Port + + Updated TCP Port of the SAN Manager. + + Int32 + + + EnableSsl + + Enable Secure WBEM communications to Brocade SAN Network Advisor. + + SwitchParameter + + + DisableSsl + + Enable Secure WBEM communications to Brocade SAN Network Advisor. + + SwitchParameter + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + +Default Value: ${Global:ConnectSessions} | ? Default + + Object + + + + Set-OVSanManager + + InputObject + + Resource Object (from Get-OVSanManager) or Name of the SAN Manager to update. If specifying a resource Name, the ApplianceConnection parameter is required. + + Object + + + Username + + Updated Username used to authenticate and manage the SAN Manager. + + String + + + Password + + Updated Password used to authenticate and manage the SAN Manager. Can either be a String or System.Security.SecureString value. + + Object + + + Hostname + + Updated Hostname or IP Address of the SAN Manager. + + String + + + Port + + Updated TCP Port of the SAN Manager. + + Int32 + + + SnmpUserName + + The SNMPv3 Community User Name. + + String + + + SnmpAuthLevel + + The SNMPv3 Authentication Level. Allowed values are: + + * None - No Security is required, only the SNMPv3 UserName is provided. + * AuthOnly - SNMPv3 Authentication Encryption Security Level only. Must also provide -SnmpAuthProtocol and -SnmpAuthPassword parameters. + * AuthAndPriv - SNMPv3 Authentication Encryption Security and Privacy Levels. Must also provide -SnmpAuthProtocol, -SnmpAuthPassword, -SnmpPrivProtocol and -SnmpPrivPassword parameters. + + String + + + SnmpAuthProtocol + + SNMPv3 Password Encryption Protocol. Allowed values are: + + * SHA + * MD5 + + String + + + SnmpAuthPassword + + SNMPv3 UserName Password. Can either be a System.String or System.Security.SecureString value. + + Object + + + SnmpPrivProtocol + + SNMPv3 Privacy Protocol. Allowed values are: + + * AES + * DES + + String + + + SnmpPrivPassword + + SNMPv3 Privacy Encryption Password. Can either be a System.String or System.Security.SecureString value. + + Object + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + +Default Value: ${Global:ConnectSessions} | ? Default + + Object + + + + + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + +Default Value: ${Global:ConnectSessions} | ? Default + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + SwitchParameter + + False + + + DisableSsl + + Enable Secure WBEM communications to Brocade SAN Network Advisor. + + SwitchParameter + + SwitchParameter + + False + + + EnableSsl + + Enable Secure WBEM communications to Brocade SAN Network Advisor. + + SwitchParameter + + SwitchParameter + + False + + + Hostname + + Updated Hostname or IP Address of the SAN Manager. + + String + + String + + + + + InputObject + + Resource Object (from Get-OVSanManager) or Name of the SAN Manager to update. If specifying a resource Name, the ApplianceConnection parameter is required. + + Object + + Object + + + + + Password + + Updated Password used to authenticate and manage the SAN Manager. Can either be a String or System.Security.SecureString value. + + Object + + Object + + + + + Port + + Updated TCP Port of the SAN Manager. + + Int32 + + Int32 + + 0 + + + SnmpAuthLevel + + The SNMPv3 Authentication Level. Allowed values are: + + * None - No Security is required, only the SNMPv3 UserName is provided. + * AuthOnly - SNMPv3 Authentication Encryption Security Level only. Must also provide -SnmpAuthProtocol and -SnmpAuthPassword parameters. + * AuthAndPriv - SNMPv3 Authentication Encryption Security and Privacy Levels. Must also provide -SnmpAuthProtocol, -SnmpAuthPassword, -SnmpPrivProtocol and -SnmpPrivPassword parameters. + + String + + String + + None + + + SnmpAuthPassword + + SNMPv3 UserName Password. Can either be a System.String or System.Security.SecureString value. + + Object + + Object + + + + + SnmpAuthProtocol + + SNMPv3 Password Encryption Protocol. Allowed values are: + + * SHA + * MD5 + + String + + String + + + + + SnmpPrivPassword + + SNMPv3 Privacy Encryption Password. Can either be a System.String or System.Security.SecureString value. + + Object + + Object + + + + + SnmpPrivProtocol + + SNMPv3 Privacy Protocol. Allowed values are: + + * AES + * DES + + String + + String + + + + + SnmpUserName + + The SNMPv3 Community User Name. + + String + + String + + + + + Username + + Updated Username used to authenticate and manage the SAN Manager. + + String + + String + + + + + + + + + HPEOneView.Storage.SanManager [System.Management.Automation.PSCustomObject] + + + SAN Manager resource from Get-OVSanManager + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + Update async task + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + $task = Get-OVSanManager bna.domain.com -ApplianceConnection hpov.domain.com | Set-OVSanManager -hostname bna.newdomain.com | Wait-OVTaskComplete + + Get the SAN Manager using Get-OVSanManager, and pipling the resource in order to update the hostname value. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + $task = Set-OVSanManager -name BNA.contoso.com -hostname bna.newdomain.com -ApplianceConnection hpov.domain.com | Wait-OVTaskComplete + + Update the existing Brocade Network Advisor SAN Manager"s hostname with the new value. + + + + + + + + + + -------------------------- EXAMPLE 3 -------------------------- + + + + $task = Set-OVSanManager -name BNA.contoso.com -username newadmin -password updatedpassword -ApplianceConnection hpov.domain.com | Wait-OVTaskComplete + + Update the existing Brocade Network Advisor SAN Manager"s username and password. + + + + + + + + + + + + + Add-OVSanManager + + + + Get-OVSanManager + + + + Remove-OVSanManager + + + + Update-OVSanManager + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/storage/set-ovsanmanager + + + + + + + + Set-OVServerHardwareType + + Rename or set a description to a Server Hardware Type resource. + + Set + OVServerHardwareType + + + Use this Cmdlet to rename or set a description to one or more Server Hardware Type resource(s). + +Minimum required privileges: Server administrator + + + + + Set-OVServerHardwareType + + InputObject + + HPEOneView.ServerHardwareType resource from Get-OVServerHardwareType. + + Object + + + Name + + Set a new name. + + String + + + Description + + Set a new description. + + String + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + Array + + (${Global:ConnectedSessions} | ? Default) + + + Description + + Set a new description. + + String + + String + + + + + InputObject + + HPEOneView.ServerHardwareType resource from Get-OVServerHardwareType. + + Object + + Object + + + + + Name + + Set a new name. + + String + + String + + + + + + + + + HPEOneView.ServerHardwareType + + + Resource from Get-OVServerHardwareType. + + + + + + + + HPEOneView.ServerHardwareType + + + + The updated resource object. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVServerHardwareType -Name "BL460c Gen9 1" -ErrorAction Stop | Set-OVServerHardwareType -Name "Corp Hypervisor Host Type" + + Rename the default "BL460c Gen9 1" server hardware type resource to a new name. + + + + + + + + + + + + + Get-OVServerHardwareType + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/servers/set-ovserverhardwaretype + + + + + + + + Set-OVServerNTPConfiguration + + Change the default time source policy for servers. + + Set + OVServerNTPConfiguration + + + When HPE OneView manages or monitors server or compute resources, it will automatically by default set the management processor NTP settings to the appliance's IP Address. Using this Cmdlet, you can set the current time synchronize policy of the managed and monitored server hardware on the appliance. SyncWithNtp will use the NTP server(s) configured on the appliance. + +Minimum required privileges: + + * Infrastructure Administrator + + + + + Set-OVServerNTPConfiguration + + SyncWithAppliance + + Configures managed and monitored server hardware devices to use the HPE OneView appliance as the NTP server. + + SwitchParameter + + + ApplianceConnection + + Specify one or more HPEOneView.Appliance.Connection object(s) or Name property value(s). + +Default Value: ${Global:ConnectedSessions} | ? Default + + Object + + + + Set-OVServerNTPConfiguration + + SyncWithNTP + + Configures managed and monitored server hardware devices to use the same NTP servers as the HPE OneView appliance. + + SwitchParameter + + + ApplianceConnection + + Specify one or more HPEOneView.Appliance.Connection object(s) or Name property value(s). + +Default Value: ${Global:ConnectedSessions} | ? Default + + Object + + + + + + + ApplianceConnection + + Specify one or more HPEOneView.Appliance.Connection object(s) or Name property value(s). + +Default Value: ${Global:ConnectedSessions} | ? Default + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + SyncWithAppliance + + Configures managed and monitored server hardware devices to use the HPE OneView appliance as the NTP server. + + SwitchParameter + + SwitchParameter + + + + + SyncWithNTP + + Configures managed and monitored server hardware devices to use the same NTP servers as the HPE OneView appliance. + + SwitchParameter + + SwitchParameter + + + + + + + + + None. You cannot pipe objects to this cmdlet. + + + + + + + + + + + HPEOneView.Appliance.GlobalSetting + + + + Object resource with the global setting value + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Set-OVServerNTPConfiguration -SyncWithNTP + + + Change the policy to time sync with NTP server(s) defined on the appliance. + + + + + + + + + + + + + Get-OVServerNTPConfiguration + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/set-ovserverntpconfiguration + + + + + + + + Set-OVServerOneTimeBoot + + Modify a servers current One Time Boot setting. + + Set + OVServerOneTimeBoot + + + HPE OneView allows you to set a one-time boot option for the server hardware. You can set the one-time boot option to any of the following: + + * Keep current settings—Keeps the previously chosen settings. + * No one-time boot—Normal boot is used when this option is selected. + * PXE—Boots from the PXE server on the network. + * Hard disk—Boots from the first local disk. + * CD—Boots from a local or virtual optical drive. + * USB—Boots from a physical or virtual USB drive. + +Other one-time boot options are available through the HPE iLO interface; however, HPE OneView offers only a common subset of one-time boot options. The one-time boot option requires the server hardware to be powered off and powered back on. If you set the one-time boot option while the server power is on, the one-time boot value is remembered until the server is powered off and then powered back on. HPE OneView does not support setting of the one-time boot option while the server is in power-on self-test (POST). + +After setting the one-time boot option, when the server hardware is powered off and powered on, HPE iLO attempts to boot the server using the selected boot option. If the selected boot option is not available, HPE iLO attempts to boot the server using the boot order defined in the server profile. After using or attempting to use the one-time boot value, the one-time boot value is reset to No one-time boot and the server boots using the boot order defined in its server profile or through HPE iLO. + +Minimum required privileges: Server administrator + + + + + Set-OVServerOneTimeBoot + + InputObject + + The server hardware or server profile resource object from Get-OVServer or Get-OVServerProfile. If providing a server profile resource, it must be assigned to a server in order for one time boot settings to be returned. + + Object + + + Setting + + The intended one time boot setting. Allowed values: + + * Normal - Normal boot, or to disable one time boot on a server that has a different value set. + * PXE - Network boot from the default PXE adapter device. + * HDD - instruct the server to find the first bootable disk drive. + * CD - instruct the server to boot from an available CD/DVD drive, including iLO Virtual Media + * USB - boot from a USB removal storage device. + + String + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + PowerOn + + If the server is already powered off, instruct OneView to power on the server once the one time boot setting has been applied. + + SwitchParameter + + + WhatIf + + + + SwitchParameter + + + Confirm + + + + SwitchParameter + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Confirm + + + + SwitchParameter + + SwitchParameter + + + + + InputObject + + The server hardware or server profile resource object from Get-OVServer or Get-OVServerProfile. If providing a server profile resource, it must be assigned to a server in order for one time boot settings to be returned. + + Object + + Object + + + + + PowerOn + + If the server is already powered off, instruct OneView to power on the server once the one time boot setting has been applied. + + SwitchParameter + + SwitchParameter + + + + + Setting + + The intended one time boot setting. Allowed values: + + * Normal - Normal boot, or to disable one time boot on a server that has a different value set. + * PXE - Network boot from the default PXE adapter device. + * HDD - instruct the server to find the first bootable disk drive. + * CD - instruct the server to boot from an available CD/DVD drive, including iLO Virtual Media + * USB - boot from a USB removal storage device. + + String + + String + + + + + WhatIf + + + + SwitchParameter + + SwitchParameter + + + + + + + + + HPEOneView.ServerHardware [System.Management.Automation.PSCustomObject] + + + Server hardware resource object from Get-OVServer. + + + + + HPEOneView.ServerProfile [System.Management.Automation.PSCustomObject] + + + Server profile resource object from Get-OVServerProfile. + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + Asynchronous task resource to monitor. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVServer -Name MyServer1 | Set-OVServerOneTimeBoot -Setting PXE + + Set the specific server to PXE boot. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Get-OVServer -Name MyServer* | ? powerState -eq On | Stop-OVServer -Confirm:$false +Get-OVServer -Name MyServer* | Set-OVServerOneTimeBoot -Setting PXE -PowerOn + + Power off the servers that need to be powered off. The set those servers to PXE boot and power on. + + + + + + + + + + -------------------------- EXAMPLE 3 -------------------------- + + + + Get-OVServer -Name MyOtherServer | Set-OVServerOneTimeBoot -Setting Normal + + Set the specified server to boot normally, clearing the one time boot value. + + + + + + + + + + + + + Get-OVServer + + + + Get-OVServerProfile + + + + Get-OVServerOneTimeBoot + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/servers/set-ovserveronetimeboot + + + + + + + + Set-OVServerPower + + [DEPRECATED] Set the power state of a server. + + Set + OVServerPower + + + This Cmdlet is now deprecated. Please use the Start-OVServer, Stop-OVServer or Restart-OVServer Cmdlets. + + + + + Set-OVServerPower + + Server + + The server object, URI or Name, or can be a Server Profile object. + + Object + + + State + + Optional power state. Default is On, other option is Off + + String + + + powerControl + + Optional setting to control the virtual power button. + + String + + + ApplianceConnection + + The name of the appliance or list of appliances to execute the command against. + + Object + + + WhatIf + + + + SwitchParameter + + + Confirm + + + + SwitchParameter + + + + + + + ApplianceConnection + + The name of the appliance or list of appliances to execute the command against. + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Confirm + + + + SwitchParameter + + SwitchParameter + + + + + Server + + The server object, URI or Name, or can be a Server Profile object. + + Object + + Object + + + + + State + + Optional power state. Default is On, other option is Off + + String + + String + + On + + + WhatIf + + + + SwitchParameter + + SwitchParameter + + + + + powerControl + + Optional setting to control the virtual power button. + + String + + String + + MomentaryPress + + + + + + + None + + + None + + + + + + + + None + + + + None + + + + + + + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/servers/set-ovserverpower + + + + + + + + Set-OVSmtpAlertEmailFilter + + Modify an existing SMTP email alert filter. + + Set + OVSmtpAlertEmailFilter + + + Email alerting feature notifies specified recipients when a certain alert occurs. When this feature is configured and enabled, the appliance performs these steps in addition to posting the alert: + + * The appliance compares the alert to configured search criteria. + * If the alert matches, it creates an email message containing the text of the alert. + * The appliance sends the email message to designated recipients in both plain text and HTML MIME types. Sending in both types allows the recipient?s mail application to determine the display. + +You can enable or disable this email notification feature, or you can enable or disable individual filter notifications, as required. + +The appliance provides for as many as 100 recipient and filter combinations, and allows as many as 50 recipients in a single email message. This flexibility lets you fine-tune which alert messages are sent and to whom. For example, you can configure the appliance to send Warning alerts to one recipient and Critical alerts to another. + +This Cmdlet will allow you to modify an existing alert filter. Parameters will replace the existing value if specified in the Cmdlet call. + +Minimum required privileges: Infrastructure administrator. + + + + + Set-OVSmtpAlertEmailFilter + + InputObject + + The email alert filter from Get-OVSmtpAlertEmailFilter. + + Object + + + Name + + Name of the Filter you want to change to. + + String + + + Disable + + Disable the selected email alert filter. + + bool + + + Filter + + REST API filter specifying the resource category, URI, name, and severity. + +Example: CPU status:"warning" or status:"critical" + + String + + + Emails + + Destination EMail address(es). + + Net.Mail.MailAddress[] + + + EnableSenderEmailAddress + + Specify a boolean value to enable or disable the alert filter sender email address. When enabling (True), you must provide the sender email parameter. + + bool + + + SenderEmail + + Sending email address option to set filters-specific email sender address. + + mailaddress + + + SenderEmailPassword + + Sending email address option is provided, you can optionally specify an email address password to authenticate with. + + securestring + + + Scope + + Scope(s) the Filter should apply to. + + HPEOneView.Appliance.ScopeCollection[] + + + ScopeMatchPreference + + If providing multiple Scope resources, specify AND or OR to indicate match preference. + + String + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + SwitchParameter + + + + + Disable + + Disable the selected email alert filter. + + bool + + bool + + + + + Emails + + Destination EMail address(es). + + Net.Mail.MailAddress[] + + Net.Mail.MailAddress[] + + + + + EnableSenderEmailAddress + + Specify a boolean value to enable or disable the alert filter sender email address. When enabling (True), you must provide the sender email parameter. + + bool + + bool + + + + + Filter + + REST API filter specifying the resource category, URI, name, and severity. + +Example: CPU status:"warning" or status:"critical" + + String + + String + + + + + InputObject + + The email alert filter from Get-OVSmtpAlertEmailFilter. + + Object + + Object + + + + + Name + + Name of the Filter you want to change to. + + String + + String + + + + + Scope + + Scope(s) the Filter should apply to. + + HPEOneView.Appliance.ScopeCollection[] + + HPEOneView.Appliance.ScopeCollection[] + + + + + ScopeMatchPreference + + If providing multiple Scope resources, specify AND or OR to indicate match preference. + + String + + String + + OR + + + SenderEmail + + Sending email address option to set filters-specific email sender address. + + mailaddress + + mailaddress + + + + + SenderEmailPassword + + Sending email address option is provided, you can optionally specify an email address password to authenticate with. + + securestring + + securestring + + + + + + + + + HPEOneView.Appliance.AlertEmailFilter [System.Management.Automation.PSCustomObject] + + + The configured email alert filter on the appliance. + + + + + + + + + HPEOneView.Appliance.TaskResource {System.Management.Automation.PSCustomObject} + + + + Returns an async task resource to monitor. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Add-OVSmtpAlertEmailFilter -Name "Monitor CPU Error and Warning conditions" -query "CPU status:warning or status:critical" -emails admin1@domain.com,admin2@domain.com + + Set SMTP Alert to notify when system CPU status is either "warning" or "critical", and email 2 addresses. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Add-OVSmtpAlertEmailFilter -Name "My Test Filter 3" -Filter "status:critical" -Emails "user1@domain.com","user2@domain.com" -Scope "My new Scope","My new Scope2" -Async + + Create a new email critical alert for the two scope names, and return the Async Task object without waiting. + + + + + + + + + + -------------------------- EXAMPLE 3 -------------------------- + + + + Add-OVSmtpAlertEmailFilter -RemoteSupportFilter + + Create OneView Remote Support filter on the appliance. + + + + + + + + + + + + + Get-OVSMTPConfig + + + + Set-OVSMTPConfig + + + + Test-OVEmailAlert + + + + Add-OVSmtpAlertEmailFilter + + + + Get-OVSmtpAlertEmailFilter + + + + Remove-OVSmtpAlertEmailFilter + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/set-ovsmtpalertemailfilter + + + + + + + + Set-OVSmtpConfig + + Configure appliance SMTP Reporting settings. + + Set + OVSmtpConfig + + + This Cmdlet configures the SMTP settings for the appliance. SMTP settings include deining the Sender EMAIL Address, SMTP relay server address, SMTP relay server TCP port, optional password, and if SMTP alerting is enabled or disabled. + +Currently, HPE OneView does not support Secure SMTP, even though the TCP Port can be modified. Using the SmtpPort parameter is to specify an alternate TCP Port than the default TCP/25. + + + + + Set-OVSmtpConfig + + SenderEmailAddress + + Specify the Sender Email Address for the appliance. + + String + + + Server + + Specify the SMTP Relay Server if DNS does not contain a valid DNS MX record for the sender email address domain name. + + String + + + Port + + Provide an alternate TCP port number than the default SMTP port value 25/TCP. + + Int32 + + + ConnectionSecurity + + Use to specify if the target SMTP server requires TLS security/authentication. Supported values: + + * None + * TLS + * StartTls + + + + + Password + + Provide an SMTP Password to authenticate to the SMTP Server. This password will be sent in clear text to the SMTP server. + + String + + + AlertEmailEnabled + + Enable SMTP Email Alerting + + SwitchParameter + + + UseMXRecordLookup + + Specify to use DNS MX record resolution for the domain in the email address provided. + + SwitchParameter + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + Set-OVSmtpConfig + + AlertEmailDisabled + + Disable SMTP Email Alerting. + + SwitchParameter + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + + + + AlertEmailDisabled + + Disable SMTP Email Alerting. + + SwitchParameter + + SwitchParameter + + False + + + AlertEmailEnabled + + Enable SMTP Email Alerting + + SwitchParameter + + SwitchParameter + + False + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + SwitchParameter + + False + + + ConnectionSecurity + + Use to specify if the target SMTP server requires TLS security/authentication. Supported values: + + * None + * TLS + * StartTls + + + + + + None + + + Password + + Provide an SMTP Password to authenticate to the SMTP Server. This password will be sent in clear text to the SMTP server. + + String + + String + + + + + Port + + Provide an alternate TCP port number than the default SMTP port value 25/TCP. + + Int32 + + Int32 + + 25 + + + SenderEmailAddress + + Specify the Sender Email Address for the appliance. + + String + + String + + + + + Server + + Specify the SMTP Relay Server if DNS does not contain a valid DNS MX record for the sender email address domain name. + + String + + String + + + + + UseMXRecordLookup + + Specify to use DNS MX record resolution for the domain in the email address provided. + + SwitchParameter + + SwitchParameter + + + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + The finished Task object that includes the task result + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Set-OVSMTPConfig -SenderEmailAddress hpov-alerts@contoso.com -alertEmailEnabled + + Set the appliance"s SMTP Sender Email Address to "hpov-alerts@contoso.com" and enable SMTP Email Alerting. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Set-OVSMTPConfig -SenderEmailAddress hpov-alerts@contoso.com -alertEmailEnabled + + Set the appliance"s SMTP Sender Email Address to "hpov-alerts@contoso.com" and enable SMTP Email Alerting. + + + + + + + + + + -------------------------- EXAMPLE 3 -------------------------- + + + + Set-OVSMTPConfig -SenderEmailAddress hpov-alerts@contoso.com -AlertEmailEnabled -ConnectionSecurity StartTls + + Set the appliance"s SMTP Sender Email Address to "hpov-alerts@contoso.com", enabling SMTP Email Alerting and specifying StartTls connection security. + + + + + + + + + + + + + Get-OVSMTPConfig + + + + Add-OVSmtpAlertEmailFilter + + + + Get-OVSmtpAlertEmailFilter + + + + Set-OVSmtpAlertEmailFilter + + + + Remove-OVSmtpAlertEmailFilter + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/set-ovsmtpconfig + + + + + + + + Set-OVSnmpReadCommunity + + Set SNMP Read Community. + + Set + OVSnmpReadCommunity + + + Set a new SNMP Read Community value on the appliance. Updating this value will cause the appliance to refresh the managed devices with the updated Read-Only SNMP Community string. This does not update the SNMP trap destination(s) for Logical Interconnects or Logical Interconnect Groups. + + + + + Set-OVSnmpReadCommunity + + Name + + The name of the new SNMP Read-Only Community. + + String + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Name + + The name of the new SNMP Read-Only Community. + + String + + String + + + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + None. You cannot pipe objects to this Cmdlet + + + + + + + + None. + + + + None + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Set-OVSnmpReadCommunity -name "MySNMPC0mmunity" + + Set the appliance SNMP Read Community string to the new value. + + + + + + + + + + + + + Get-OVSnmpReadCommunity + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/set-ovsnmpreadcommunity + + + + + + + + Set-OVStoragePool + + Modify storage pool managed state. + + Set + OVStoragePool + + + A reserved VLAN pool is a range of VLANs used for allocation of non-tagged networks: + + * Tunnel + * Untagged + * Fibre Channel (FC) + +Tagged networks and FCoE networks use VLANs outside of the reserved pool. You cannot use a reserved VLAN for tagged or FCoE networks. + +The VLAN pool allows the number of available VLANs to be segregated between tagged and non-tagged networks. Because non-tagged networks use VLANs for internal translation resources, a reserved VLAN pool can provide a sufficient number of VLANs available for allocation of those internal VLANs. In addition, the reserved pool range removes the need for translation resources to be used on tagged networks. + +For the maximum number of VLANs per physical downlink port, see the HPE OneView Support Matrix for HPE Synergy. + +Creating and managing a reserved VLAN pool + +A reserved VLAN pool is unique within a fabric, but independently allocated within each logical interconnect. The reserved range is identical across all logical interconnects within a fabric. The remaining VLANs (outside of the pool) are shared among all the logical interconnects within the fabric. + +For HPE OneView running embedded on a HPE Synergy 12000 Frame, the default range starts at 3967 and the size is 128. The minimum size of the pool must be 60 VLANs to ensure the pool is not exhausted. + +The size of the pool cannot exceed 128 VLANs. + +Minimum required privileges: Infrastructure administrator, Network administrator + + + + + Set-OVStoragePool + + InputObject + + One or more HPEOneView.Storage.StoragePool resources from Get-OVStoragePool. + + HPEOneView.Storage.StoragePool[] + + + Managed + + Specify a boolean value to modify the storage pools managed state. + + Bool + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + Array + + (${Global:ConnectedSessions} | ? Default) + + + InputObject + + One or more HPEOneView.Storage.StoragePool resources from Get-OVStoragePool. + + HPEOneView.Storage.StoragePool[] + + HPEOneView.Storage.StoragePool[] + + + + + Managed + + Specify a boolean value to modify the storage pools managed state. + + Bool + + Bool + + + + + + + + + HPEOneView.Storage.StoragePool + + + Storage pool resource(s) from Get-OVStoragePool. + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + Async task Resource object for configuring port monitoring on the requested logical intercinnect. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + $StoragePool = Get-OVStoragePool -Name "r5_cpg1" -ErrorAction Stop Set-OVStoragePool -InputObject $StoragePool -Managed $true + + Manage the specified storage pool to provision volumes. + + + + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVStoragePool -Name r5_* -ErrorAction Stop | Set-OVStoragePool -Managed $false + + Change the managed state to "unmanaged" of the specified storage pools. + + + + + + + + + + + + + Add-OVStoragePool + + + + Get-OVStoragePool + + + + Remove-OVStoragePool + + + + Update-OVStoragePool + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/storage/set-ovstoragepool + + + + + + + + Set-OVStorageVolume + + Modify an existing Storage Volume resource. + + Set + OVStorageVolume + + + This Cmdlet will help modify an existing Storage Volume resource. Only the Volume Name, Description, Capcity, volume shared state and permenance can be modified. + + + + + Set-OVStorageVolume + + InputObject + + Source Storage Volume resource object. + + Object + + + Name + + Updated Storage Volume Name. + + String + + + Description + + Updated description for the volume. + + String + + + Capacity + + New Max volume capacity in GB. Volume capacity can be increased to maximum of 16 TiB. Decreasing the capacity of volume is not supported. + +Before increasing the capacity of fully provisioned volumes, ensure that the storage pool has enough capacity to support the operation. The update operation might fail if there is not enough space available in the storage pool. + +e.g. 20 to specify 20GB. + + Int64 + + + SnapShotStoragePool + + The Storage Pool Name, URI or Object to be used for Volume Snapshots. + + Object + + + PermitAdaptiveOptimization + + Include this switch to mark the Storage Volume as a Shareable resource for shared volume access. +Default: Private + + Boolean + + + Shared + + Include this switch to mark the Storage Volume as a Shareable resource for shared volume access. +Default: Private + + Boolean + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + + + + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Capacity + + New Max volume capacity in GB. Volume capacity can be increased to maximum of 16 TiB. Decreasing the capacity of volume is not supported. + +Before increasing the capacity of fully provisioned volumes, ensure that the storage pool has enough capacity to support the operation. The update operation might fail if there is not enough space available in the storage pool. + +e.g. 20 to specify 20GB. + + Int64 + + Int64 + + 0 + + + Description + + Updated description for the volume. + + String + + String + + + + + InputObject + + Source Storage Volume resource object. + + Object + + Object + + + + + Name + + Updated Storage Volume Name. + + String + + String + + + + + PermitAdaptiveOptimization + + Include this switch to mark the Storage Volume as a Shareable resource for shared volume access. +Default: Private + + Boolean + + Boolean + + False + + + Shared + + Include this switch to mark the Storage Volume as a Shareable resource for shared volume access. +Default: Private + + Boolean + + Boolean + + False + + + SnapShotStoragePool + + The Storage Pool Name, URI or Object to be used for Volume Snapshots. + + Object + + Object + + + + + + + + + HPEOneView.Storage.Volume [System.Management.Automation.PSCustomObject] + + + Storage Volume resource object + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + Async create task + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVStorageVolume ProdVol1 | Set-OVStorageVolume -Size 160 + + Update "ProdVol1" volume size to 160GB. + + + + + + + + + + + + + Add-OVStorageVolume + + + + ConvertTo-OVStorageVolume + + + + Get-OVStorageVolume + + + + Get-OVStorageVolumeSet + + + + Get-OVStorageVolumeSnapShot + + + + Get-OVStorageVolumeTemplate + + + + Get-OVStorageVolumeTemplatePolicy + + + + New-OVStorageVolume + + + + New-OVStorageVolumeSnapshot + + + + New-OVStorageVolumeTemplate + + + + Remove-OVStorageVolume + + + + Remove-OVStorageVolumeSnapshot + + + + Remove-OVStorageVolumeTemplate + + + + Set-OVStorageVolumeTemplate + + + + Set-OVStorageVolumeTemplatePolicy + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/storage/set-ovstoragevolume + + + + + + + + Set-OVStorageVolumeTemplate + + Modify an existing Storage Volume Template resource. + + Set + OVStorageVolumeTemplate + + + This Cmdlet will help modify an existing Storage Volume Template resource. Only the Volume Name, Description, Capcity, Snapshot Storage Pool, volume shared state and permenance can be modified. + + + + + Set-OVStorageVolumeTemplate + + InputObject + + Source Storage Volume Template resource object. + + Object + + + Name + + Updated Storage Volume Template Name. + + String + + + Description + + Updated description for the volume. + + String + + + SnapshotStoragePool + + The Storage Pool Name, URI or Object to be used for Volume Snapshots. + + Object + + + LockSnapShotStoragePool + + Specify to lock the SnapshotStoragePool value in the template. + + SwitchParameter + + + StorageSystem + + When the Storage Pool name is not unique, specify the Storage System name the pool is managed/associate with. + + Object + + + Capacity + + New Max volume capacity in GB. Volume capacity can be increased to maximum of 16 TiB. Decreasing the capacity of volume is not supported. + +Before increasing the capacity of fully provisioned volumes, ensure that the storage pool has enough capacity to support the operation. The update operation might fail if there is not enough space available in the storage pool. + +e.g. 20 to specify 20GB. + + Int64 + + + LockCapacity + + Specify to lock the Capacity value in the template. + + SwitchParameter + + + Thin + + NOTE: This parameter is being deprecated for the -ProvisionType parameter. Please update your scripts. + +Include to change the provisioned type to Thin. + + SwitchParameter + + + Full + + NOTE: This parameter is being deprecated for the -ProvisionType parameter. Please update your scripts. + +Include to change the provisioned type to Full. + + SwitchParameter + + + ProvisioningType + + Specify the type of volume to provision. Allowed values are: + + * Thin + * Full + * TPDD (Thin Provision Dedup) - Only available for HPE StoreServ storage systems with SSD storage pools (aka CPG"s). + + String + + + LockProvisionType + + Specify to lock the ProvisionType value in the template. + + SwitchParameter + + + Shared + + Include this switch to mark the Storage Volume as a Shareable resource for shared volume access. +Default: Private + + Boolean + + + LockProvisionMode + + Specify to lock the Provision Mode (Shared or Private) value in the template. + + SwitchParameter + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + + + Set-OVStorageVolumeTemplate + + InputObject + + Source Storage Volume Template resource object. + + Object + + + Name + + Updated Storage Volume Template Name. + + String + + + Description + + Updated description for the volume. + + String + + + StorageSystem + + When the Storage Pool name is not unique, specify the Storage System name the pool is managed/associate with. + + Object + + + Capacity + + New Max volume capacity in GB. Volume capacity can be increased to maximum of 16 TiB. Decreasing the capacity of volume is not supported. + +Before increasing the capacity of fully provisioned volumes, ensure that the storage pool has enough capacity to support the operation. The update operation might fail if there is not enough space available in the storage pool. + +e.g. 20 to specify 20GB. + + Int64 + + + LockCapacity + + Specify to lock the Capacity value in the template. + + SwitchParameter + + + ProvisioningType + + Specify the type of volume to provision. Allowed values are: + + * Thin + * Full + * TPDD (Thin Provision Dedup) - Only available for HPE StoreServ storage systems with SSD storage pools (aka CPG"s). + + String + + + PerformancePolicy + + A Nimble Performance Policy is associated with a storage system. Using the Show-OVStorageSystemPerformancePolicy, choose an available performance policy. + +Example: + + Get-OVStorageSystem -Name MyNimbleSys | Show-OVStorageSystemPerformancePolicy + + HPEOneView.Storage.PerformancePolicy + + + LockPerformancePolicy + + Lock the PerformancePolicy value. + + SwitchParameter + + + EnableEncryption + + When the storage system has encryption enabled, the volume can also be encrypted. Specify if the volume should be encrypted during creation. + + Bool + + + LockEnableEncryption + + Lock the EnableEncryption value. + + SwitchParameter + + + CachePinning + + This is applicable for hybrid (a mix of flash and mechanical storage) arrays, and provides a 100 percent cache hit rate for specific volumes (for example, volumes dedicated to critical applications), and delivers the response times of an all-flash storage system. A volume is pinned when the entire active volume is placed in cache; associated snapshot (inactive) blocks are not pinned. All incoming data after that point is pinned. The number of volumes that can be pinned is limited by the size of the volumes and amount of available cache. + +When defined in the Performance Profile, select to enable Cache Pinnning for the Nimble volume to be created. + + Bool + + + LockCachePinning + + Lock the CachePinning value. + + SwitchParameter + + + VolumeSet + + Use to specify a Volume Set the volume will be associated with, from Get-OVStorageVolumeSet. + + HPEOneView.Storage.VolumeSet + + + LockVolumeSet + + Lock the VolumeSet value. + + SwitchParameter + + + EnableIOPSLimit + + Set to enable or disable IOPS limit. If enabled, the -IOPSLimit parameter must be set. By default, IOPS limit is not set. + + Bool + + + IOPSLimit + + When enabling IOPS limit, provide a value that is greater than or equal to 256. + + Int + + + LockIOPSLimit + + Lock the IOPSLimit value. + + SwitchParameter + + + EnableDataTransferLimit + + Enable data transfer limit. If enabled, the -DataTransferLimit parameter must be set. By default, data transfer limit is not set. + + Bool + + + DataTransferLimit + + Specify the data transfer limit in MiB/S. + + Int + + + LockDataTransferLimit + + Lock the DataTransferLimit value. + + SwitchParameter + + + Folder + + Specify the Nimble folder where the volume should be created. To get availabe folder objects, use the Get-OVStoragePool Cmdlet. Folders are defined as a device specific attribute. + +Example: + + (Get-OVStoragePool -name default).DeviceSpecificAttributes.Folders + +ID Name +-- ---- +2f1ca8a5d76e271722000000000000000000000001 POSH + + HPEOneView.Storage.NimbleFolder + + + LockFolder + + Lock the Folder value. + + SwitchParameter + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + + + + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + CachePinning + + This is applicable for hybrid (a mix of flash and mechanical storage) arrays, and provides a 100 percent cache hit rate for specific volumes (for example, volumes dedicated to critical applications), and delivers the response times of an all-flash storage system. A volume is pinned when the entire active volume is placed in cache; associated snapshot (inactive) blocks are not pinned. All incoming data after that point is pinned. The number of volumes that can be pinned is limited by the size of the volumes and amount of available cache. + +When defined in the Performance Profile, select to enable Cache Pinnning for the Nimble volume to be created. + + Bool + + Bool + + + + + Capacity + + New Max volume capacity in GB. Volume capacity can be increased to maximum of 16 TiB. Decreasing the capacity of volume is not supported. + +Before increasing the capacity of fully provisioned volumes, ensure that the storage pool has enough capacity to support the operation. The update operation might fail if there is not enough space available in the storage pool. + +e.g. 20 to specify 20GB. + + Int64 + + Int64 + + 0 + + + DataTransferLimit + + Specify the data transfer limit in MiB/S. + + Int + + Int + + + + + Description + + Updated description for the volume. + + String + + String + + + + + EnableDataTransferLimit + + Enable data transfer limit. If enabled, the -DataTransferLimit parameter must be set. By default, data transfer limit is not set. + + Bool + + Bool + + + + + EnableEncryption + + When the storage system has encryption enabled, the volume can also be encrypted. Specify if the volume should be encrypted during creation. + + Bool + + Bool + + + + + EnableIOPSLimit + + Set to enable or disable IOPS limit. If enabled, the -IOPSLimit parameter must be set. By default, IOPS limit is not set. + + Bool + + Bool + + + + + Folder + + Specify the Nimble folder where the volume should be created. To get availabe folder objects, use the Get-OVStoragePool Cmdlet. Folders are defined as a device specific attribute. + +Example: + + (Get-OVStoragePool -name default).DeviceSpecificAttributes.Folders + +ID Name +-- ---- +2f1ca8a5d76e271722000000000000000000000001 POSH + + HPEOneView.Storage.NimbleFolder + + HPEOneView.Storage.NimbleFolder + + + + + Full + + NOTE: This parameter is being deprecated for the -ProvisionType parameter. Please update your scripts. + +Include to change the provisioned type to Full. + + SwitchParameter + + SwitchParameter + + False + + + IOPSLimit + + When enabling IOPS limit, provide a value that is greater than or equal to 256. + + Int + + Int + + + + + InputObject + + Source Storage Volume Template resource object. + + Object + + Object + + + + + LockCachePinning + + Lock the CachePinning value. + + SwitchParameter + + SwitchParameter + + + + + LockCapacity + + Specify to lock the Capacity value in the template. + + SwitchParameter + + SwitchParameter + + False + + + LockDataTransferLimit + + Lock the DataTransferLimit value. + + SwitchParameter + + SwitchParameter + + + + + LockEnableEncryption + + Lock the EnableEncryption value. + + SwitchParameter + + SwitchParameter + + + + + LockFolder + + Lock the Folder value. + + SwitchParameter + + SwitchParameter + + + + + LockIOPSLimit + + Lock the IOPSLimit value. + + SwitchParameter + + SwitchParameter + + + + + LockPerformancePolicy + + Lock the PerformancePolicy value. + + SwitchParameter + + SwitchParameter + + + + + LockProvisionMode + + Specify to lock the Provision Mode (Shared or Private) value in the template. + + SwitchParameter + + SwitchParameter + + False + + + LockProvisionType + + Specify to lock the ProvisionType value in the template. + + SwitchParameter + + SwitchParameter + + + + + LockSnapShotStoragePool + + Specify to lock the SnapshotStoragePool value in the template. + + SwitchParameter + + SwitchParameter + + False + + + LockVolumeSet + + Lock the VolumeSet value. + + SwitchParameter + + SwitchParameter + + + + + Name + + Updated Storage Volume Template Name. + + String + + String + + + + + PerformancePolicy + + A Nimble Performance Policy is associated with a storage system. Using the Show-OVStorageSystemPerformancePolicy, choose an available performance policy. + +Example: + + Get-OVStorageSystem -Name MyNimbleSys | Show-OVStorageSystemPerformancePolicy + + HPEOneView.Storage.PerformancePolicy + + HPEOneView.Storage.PerformancePolicy + + + + + ProvisioningType + + Specify the type of volume to provision. Allowed values are: + + * Thin + * Full + * TPDD (Thin Provision Dedup) - Only available for HPE StoreServ storage systems with SSD storage pools (aka CPG"s). + + String + + String + + + + + Shared + + Include this switch to mark the Storage Volume as a Shareable resource for shared volume access. +Default: Private + + Boolean + + Boolean + + False + + + SnapshotStoragePool + + The Storage Pool Name, URI or Object to be used for Volume Snapshots. + + Object + + Object + + + + + StorageSystem + + When the Storage Pool name is not unique, specify the Storage System name the pool is managed/associate with. + + Object + + Object + + + + + Thin + + NOTE: This parameter is being deprecated for the -ProvisionType parameter. Please update your scripts. + +Include to change the provisioned type to Thin. + + SwitchParameter + + SwitchParameter + + False + + + VolumeSet + + Use to specify a Volume Set the volume will be associated with, from Get-OVStorageVolumeSet. + + HPEOneView.Storage.VolumeSet + + HPEOneView.Storage.VolumeSet + + + + + + + + + HPEOneView.Storage.VolumeTemplate [System.Management.Automation.PSCustomObject] + + + Storage Volume Template resource. + + + + + + + + HPEOneView.Storage.VolumeTemplate [System.Management.Automation.PSCustomObject] + + + + Updated Storage Volume Template object. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVStorageVolumeTemplate -Name MyProdVolTemplate | Set-OVStorageVolumeTemplate -Size 160 + + Update "MyProdVolTemplate" volume size to 160GB. + + + + + + + + + + + + + Get-OVStorageVolumeTemplate + + + + Get-OVStorageVolumeTemplatePolicy + + + + New-OVStorageVolumeTemplate + + + + Remove-OVStorageVolumeTemplate + + + + Set-OVStorageVolumeTemplatePolicy + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/storage/set-ovstoragevolumetemplate + + + + + + + + Set-OVStorageVolumeTemplatePolicy + + Set Storage Volume Template Global Policy + + Set + OVStorageVolumeTemplatePolicy + + + By default, Storage Volumes can be created without reference to a Storage Volume Template. This Cmdlet will allow the administrator to change the global policy setting. Use with caution, as this will prevent copying Server Profiles that contain attached Storage Volumes. + + + + + Set-OVStorageVolumeTemplatePolicy + + Enable + + Switch to enable the policy + + SwitchParameter + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + +Default Value: ${Global:ConnectSessions} | ? Default + + Array + + + + Set-OVStorageVolumeTemplatePolicy + + Disable + + Switch to disable the policy + + SwitchParameter + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + +Default Value: ${Global:ConnectSessions} | ? Default + + Array + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + +Default Value: ${Global:ConnectSessions} | ? Default + + Array + + Array + + (${Global:ConnectedSessions} | ? Default) + + + Disable + + Switch to disable the policy + + SwitchParameter + + SwitchParameter + + False + + + Enable + + Switch to enable the policy + + SwitchParameter + + SwitchParameter + + False + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + None. You cannot pipe objects to this Cmdlet + + + + + + + + System.Boolean + + + + Returned boolean value after changing policy + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVStorageVolumeTemplatePolicy +Appliance Name Value +--------- ---- ----- +MyAppliance.domain.com StorageVolumeTemplateRequired true + +Set-OVStorageVolumeTemplatePolicy -disable -ApplianceConnection $ConnectedSessions + +Appliance Name Value +--------- ---- ----- +MyAppliance.domain.com StorageVolumeTemplateRequired false +MyAppliance2.domain.com StorageVolumeTemplateRequired false + + Get the Storage Volume Template Global Policy setting, then disable it for all connected appliances. + + + + + + + + + + + + + Get-OVStorageVolumeTemplatePolicy + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/storage/set-ovstoragevolumetemplatepolicy + + + + + + + + Set-OVUplinkSet + + Update an uplink set resource + + Set + OVUplinkSet + + + Interconnect uplinks are grouped into an uplink set and managed as a unit, with an assigned set of one or more networks. The traffic carried over the uplinks is determined by the network assignment of the uplink set. Uplink sets can support either Ethernet or Fibre Channel networks. Depending on the type of the assigned networks, uplink sets can support both an automatic and a selective failover or distribution strategy. The uplink port state is monitored, which contributes to the overall reachability status of the assigned networks. For each port belonging to the uplink set, the assigned port speed can be monitored. + +Uplink Sets can be created for Logical Interconnect Groups or Logical Interconnects. When creating a new Uplink Set, either the Logical Interconnect Group or Logical Interconnect must exist. + +Please know that the UplinkPorts parameter syntax is different between HPE BladeSystem and HPE Synergy Virtual Connect. + +Use this Cmdlet to modify an existing Logical Interconect Group uplink set, or Logical Interconnect uplink set. Logical Interconnect Group uplink sets are a poperty of the Logical Interconnect Group resource. Logical Interconnect uplink sets are a different resource, and are not directly a member of the Logical Interconnect. + +Minimum required privileges: Infrastructure administrator, Network administrator + + + + + Set-OVUplinkSet + + InputObject + + Either a Logical Interconnect Group from Get-OVLogicalInterconnectGroup or Uplink Set Get-OVUplinkSet resource. + + Object + + + UplinkSetName + + When providing a Logical Interconnect Group resource, you must specify the name of the uplink set to modify. + + String + + + Name + + Specify the new name of the resource. + + String + + + AddNetwork + + Specify the networks to add to the specified uplink set. + + Object[] + + + RemoveNetwork + + An array of networks to remove from the uplink set. + + Object[] + + + AddNetworkSet + + Specify one or more network set objects to add to an uplink set. + + Object[] + + + RemoveNetworkSet + + Specify one or more network set objects to remove from an uplink set. + + Object[] + + + AddPorts + + Array of uplink ports to add with "BAYID:FacePlatePortID". When configuring a Synergy infrastructure, the Uplink Port format needs to be "EnclosureID:BayID:FacePlatePortID". + +FlexFabric e.g. @("BAY1:X1","BAY1:X2") or "BAY1:X5","BAY2:X5" +VC Fibre Channel e.g. @("BAY3:1","BAY3:2") or "BAY3:1","BAY3:2" +Synergy VC Ethernet e.g. "Enclosure1:Bay3:Q1","Enclosure1:Bay3:Q2","Enclosure2:Bay6:Q1","Enclosure2:Bay6:Q2" +Synergy VC Sub-Interface e.g. "Enclosure1:Bay3:Q1.1","Enclosure1:Bay3:Q2.1","Enclosure2:Bay6:Q1.2","Enclosure2:Bay6:Q2.2" +Synergy VC FC Primary Port e.g. "Bay2:Q1","Bay2:Q2" or "Bay5:Q1","Bay5:Q2" +Synergy VC FC Sub-Interface e.g. "Bay2:Q1.1","Bay2:Q2.1" or "Bay5:Q1.2","Bay5:Q2.2" + + Object[] + + + RemovePorts + + Array of uplink ports to remove with "BAYID:FacePlatePortID". When configuring a Synergy infrastructure, the Uplink Port format needs to be "EnclosureID:BayID:FacePlatePortID". + +FlexFabric e.g. @("BAY1:X1","BAY1:X2") or "BAY1:X5","BAY2:X5" +VC Fibre Channel e.g. @("BAY3:1","BAY3:2") or "BAY3:1","BAY3:2" +Synergy VC Ethernet e.g. "Enclosure1:Bay3:Q1","Enclosure1:Bay3:Q2","Enclosure2:Bay6:Q1","Enclosure2:Bay6:Q2" +Synergy VC Sub-Interface e.g. "Enclosure1:Bay3:Q1.1","Enclosure1:Bay3:Q2.1","Enclosure2:Bay6:Q1.2","Enclosure2:Bay6:Q2.2" +Synergy VC FC Primary Port e.g. "Bay2:Q1","Bay2:Q2" or "Bay5:Q1","Bay5:Q2" +Synergy VC FC Sub-Interface e.g. "Bay2:Q1.1","Bay2:Q2.1" or "Bay5:Q1.2","Bay5:Q2.2" + + Object[] + + + UntaggedNetwork + + Specify the network object that will be set as the untagged network. + + Object + + + LacpTimer + + Set the LACP Timer value, which sets the lacpdu frequecy to the LACP peer. Accepted values: + + * Long + * Short (Default) + + String + + + PortSpeed + + The allowed uplink port speed by the fabric module and traceiver type. When specifying a port speed, this value will be set for all ports. This parameter applies to Ethernet or FCoE uplink ports only. Allowed values: + + * Auto + * 100M + * 1G + * 10G + * 40G + * 100G + + String + + + FecMode + + Specify the forward error correction mode. This paraemter is only supported with Virtual Connect SE 100Gb F32 Module for Synergy modules. When configuring, the following values are supported with parent ports: + + * Auto + * Cl74 + * Cl108 + * None + +The following values are supported with sub-ports: + + * Auto + * Cl74 + * Cl91 + * None + + String + + + ConsistencyChecking + + Use to indicate if the group policy will be tracked to with the deployed and configured resource. Allowed values: + + * None + * Exact + +Default: Exact + + String + + + ApplianceConnection + + Aliases [-Appliance] + +Specify one or more HPEOneView.Appliance.Connection object(s) or Name property value(s). + +Default Value: ${Global:ConnectedSessions} | ? Default + + Object + + + + Set-OVUplinkSet + + InputObject + + Either a Logical Interconnect Group from Get-OVLogicalInterconnectGroup or Uplink Set Get-OVUplinkSet resource. + + Object + + + UplinkSetName + + When providing a Logical Interconnect Group resource, you must specify the name of the uplink set to modify. + + String + + + Name + + Specify the new name of the resource. + + String + + + AddPorts + + Array of uplink ports to add with "BAYID:FacePlatePortID". When configuring a Synergy infrastructure, the Uplink Port format needs to be "EnclosureID:BayID:FacePlatePortID". + +FlexFabric e.g. @("BAY1:X1","BAY1:X2") or "BAY1:X5","BAY2:X5" +VC Fibre Channel e.g. @("BAY3:1","BAY3:2") or "BAY3:1","BAY3:2" +Synergy VC Ethernet e.g. "Enclosure1:Bay3:Q1","Enclosure1:Bay3:Q2","Enclosure2:Bay6:Q1","Enclosure2:Bay6:Q2" +Synergy VC Sub-Interface e.g. "Enclosure1:Bay3:Q1.1","Enclosure1:Bay3:Q2.1","Enclosure2:Bay6:Q1.2","Enclosure2:Bay6:Q2.2" +Synergy VC FC Primary Port e.g. "Bay2:Q1","Bay2:Q2" or "Bay5:Q1","Bay5:Q2" +Synergy VC FC Sub-Interface e.g. "Bay2:Q1.1","Bay2:Q2.1" or "Bay5:Q1.2","Bay5:Q2.2" + + Object[] + + + RemovePorts + + Array of uplink ports to remove with "BAYID:FacePlatePortID". When configuring a Synergy infrastructure, the Uplink Port format needs to be "EnclosureID:BayID:FacePlatePortID". + +FlexFabric e.g. @("BAY1:X1","BAY1:X2") or "BAY1:X5","BAY2:X5" +VC Fibre Channel e.g. @("BAY3:1","BAY3:2") or "BAY3:1","BAY3:2" +Synergy VC Ethernet e.g. "Enclosure1:Bay3:Q1","Enclosure1:Bay3:Q2","Enclosure2:Bay6:Q1","Enclosure2:Bay6:Q2" +Synergy VC Sub-Interface e.g. "Enclosure1:Bay3:Q1.1","Enclosure1:Bay3:Q2.1","Enclosure2:Bay6:Q1.2","Enclosure2:Bay6:Q2.2" +Synergy VC FC Primary Port e.g. "Bay2:Q1","Bay2:Q2" or "Bay5:Q1","Bay5:Q2" +Synergy VC FC Sub-Interface e.g. "Bay2:Q1.1","Bay2:Q2.1" or "Bay5:Q1.2","Bay5:Q2.2" + + Object[] + + + EnableTrunking + + Use this parameter to enable or disable FC port trunking. This parameter is only supported with HPE 16Gb or newer Virtual Connect Fibre Channel fabric modules. + + Bool + + + ConsistencyChecking + + Use to indicate if the group policy will be tracked to with the deployed and configured resource. Allowed values: + + * None + * Exact + +Default: Exact + + String + + + ApplianceConnection + + Aliases [-Appliance] + +Specify one or more HPEOneView.Appliance.Connection object(s) or Name property value(s). + +Default Value: ${Global:ConnectedSessions} | ? Default + + Object + + + + + + + AddNetwork + + Specify the networks to add to the specified uplink set. + + Object[] + + Object[] + + + + + AddNetworkSet + + Specify one or more network set objects to add to an uplink set. + + Object[] + + Object[] + + + + + AddPorts + + Array of uplink ports to add with "BAYID:FacePlatePortID". When configuring a Synergy infrastructure, the Uplink Port format needs to be "EnclosureID:BayID:FacePlatePortID". + +FlexFabric e.g. @("BAY1:X1","BAY1:X2") or "BAY1:X5","BAY2:X5" +VC Fibre Channel e.g. @("BAY3:1","BAY3:2") or "BAY3:1","BAY3:2" +Synergy VC Ethernet e.g. "Enclosure1:Bay3:Q1","Enclosure1:Bay3:Q2","Enclosure2:Bay6:Q1","Enclosure2:Bay6:Q2" +Synergy VC Sub-Interface e.g. "Enclosure1:Bay3:Q1.1","Enclosure1:Bay3:Q2.1","Enclosure2:Bay6:Q1.2","Enclosure2:Bay6:Q2.2" +Synergy VC FC Primary Port e.g. "Bay2:Q1","Bay2:Q2" or "Bay5:Q1","Bay5:Q2" +Synergy VC FC Sub-Interface e.g. "Bay2:Q1.1","Bay2:Q2.1" or "Bay5:Q1.2","Bay5:Q2.2" + + Object[] + + Object[] + + + + + ApplianceConnection + + Aliases [-Appliance] + +Specify one or more HPEOneView.Appliance.Connection object(s) or Name property value(s). + +Default Value: ${Global:ConnectedSessions} | ? Default + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + ConsistencyChecking + + Use to indicate if the group policy will be tracked to with the deployed and configured resource. Allowed values: + + * None + * Exact + +Default: Exact + + String + + String + + + + + EnableTrunking + + Use this parameter to enable or disable FC port trunking. This parameter is only supported with HPE 16Gb or newer Virtual Connect Fibre Channel fabric modules. + + Bool + + Bool + + + + + FecMode + + Specify the forward error correction mode. This paraemter is only supported with Virtual Connect SE 100Gb F32 Module for Synergy modules. When configuring, the following values are supported with parent ports: + + * Auto + * Cl74 + * Cl108 + * None + +The following values are supported with sub-ports: + + * Auto + * Cl74 + * Cl91 + * None + + String + + String + + + + + InputObject + + Either a Logical Interconnect Group from Get-OVLogicalInterconnectGroup or Uplink Set Get-OVUplinkSet resource. + + Object + + Object + + + + + LacpTimer + + Set the LACP Timer value, which sets the lacpdu frequecy to the LACP peer. Accepted values: + + * Long + * Short (Default) + + String + + String + + + + + Name + + Specify the new name of the resource. + + String + + String + + + + + PortSpeed + + The allowed uplink port speed by the fabric module and traceiver type. When specifying a port speed, this value will be set for all ports. This parameter applies to Ethernet or FCoE uplink ports only. Allowed values: + + * Auto + * 100M + * 1G + * 10G + * 40G + * 100G + + String + + String + + + + + RemoveNetwork + + An array of networks to remove from the uplink set. + + Object[] + + Object[] + + + + + RemoveNetworkSet + + Specify one or more network set objects to remove from an uplink set. + + Object[] + + Object[] + + + + + RemovePorts + + Array of uplink ports to remove with "BAYID:FacePlatePortID". When configuring a Synergy infrastructure, the Uplink Port format needs to be "EnclosureID:BayID:FacePlatePortID". + +FlexFabric e.g. @("BAY1:X1","BAY1:X2") or "BAY1:X5","BAY2:X5" +VC Fibre Channel e.g. @("BAY3:1","BAY3:2") or "BAY3:1","BAY3:2" +Synergy VC Ethernet e.g. "Enclosure1:Bay3:Q1","Enclosure1:Bay3:Q2","Enclosure2:Bay6:Q1","Enclosure2:Bay6:Q2" +Synergy VC Sub-Interface e.g. "Enclosure1:Bay3:Q1.1","Enclosure1:Bay3:Q2.1","Enclosure2:Bay6:Q1.2","Enclosure2:Bay6:Q2.2" +Synergy VC FC Primary Port e.g. "Bay2:Q1","Bay2:Q2" or "Bay5:Q1","Bay5:Q2" +Synergy VC FC Sub-Interface e.g. "Bay2:Q1.1","Bay2:Q2.1" or "Bay5:Q1.2","Bay5:Q2.2" + + Object[] + + Object[] + + + + + UntaggedNetwork + + Specify the network object that will be set as the untagged network. + + Object + + Object + + + + + UplinkSetName + + When providing a Logical Interconnect Group resource, you must specify the name of the uplink set to modify. + + String + + String + + + + + + + + + HPEOneView.Networking.LogicalInterconnectGroup [System.Management.Automation.PSCustomObject] + + + Logical Interconnect Group resource from Get-OVLogicalInterconnectGroup. + + + + + HPEOneView.Networking.UplinkSet [System.Management.Automation.PSCustomObject] + + + Uplink set resource from Get-OVUplinkSet. + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + Async task resource object to monitor. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + $NetworkToRemove = Get-OVNetwork -Name NetworkToRemove +Get-OVLogicalInterconnectGroup -Name "My Production LIG" -ErrorAction Stop | Set-OVUplinkSet -UplinkSetName "Production Uplink Set 1-A" -RemoveNetwork $NetworkToRemove + + Remove the specific network from the created logical interconnect group's uplink set. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Get-OVLogicalInterconnectGroup -Name "My Production LIG" -ErrorAction Stop | Set-OVUplinkSet -UplinkSetName "Production Uplink Set" -AddPort "Enclosure1:Bay3:Q1.1", "Enclosure2:Bay6:Q1.1" + + Add the specific ports from the created logical interconnect group's uplink set. + + + + + + + + + + -------------------------- EXAMPLE 3 -------------------------- + + + + Get-OVUplinkSet -Name "Uplink Set 1" -ErrorAction Stop | Set-OVUplinkSet -AddPort "Enclosure1:Bay3:Q1.1", "Enclosure2:Bay6:Q1.1" -LacpTimer Short + + Add the specific ports to the created uplink set, and change the LACP Timer to "Short". + + + + + + + + + + + + + Get-OVUplinkSet + + + + Get-OVLogicalInterconnectGroup + + + + New-OVUplinkSet + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/networking/set-ovuplinkset + + + + + + + + Set-OVUser + + Modify an existing user account. + + Set + OVUser + + + Modify or update an existing local user account on the management appliance. This Cmdlet will not update the password or roles of the currently logged in user account. To update your HPE OneView appliance local account"s password, please use the Set-OVUserPassword Cmdlet. + + + + + Set-OVUser + + UserName + + The name or object of the user account to be updated. + + String + + + Password + + New password for the user account. Passwords must be at least 8 characters. + + String + + + FullName + + Updated Full Name of the User Account. + + String + + + Roles + + The role(s) to assign to the Directroy Group, in System.Collections.ArrayList format. Accepted values are noted within the ApplianceRoles property of the HPEOneView.Appliance.Connection object stored in the $Global:ConnectedSessions variable. + +Example: $roles = "Server administrator","Network administrator" + + Array + + + Append + + Use to append roles and/or scope permissions update. If omitted, roles or scope permissions will be replaced. + + SwitchParameter + + + ScopePermissions + + Array collection of Hashtable<Role; Scope>. Will overwrite existing scope to role mappings. + +Example: -ScopePermissions @{Role = "Network administrator"; Scope = (Get-OVScope -Name CorpNetAdmins -ErrorAction Stop) } + + Array + + + EmailAddress + + Updated Email Address of the User Account. + + String + + + OfficePhone + + Updated office phone of the User Account. + + String + + + MobilePhone + + Updated mobile phone number + + String + + + Enabled + + Enable the local user account. + + SwitchParameter + + + Disabled + + Disable the local user account. + + SwitchParameter + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + + + Set-OVUser + + UserObject + + The object of the user account to be updated. + + Object + + + Password + + New password for the user account. Passwords must be at least 8 characters. + + String + + + FullName + + Updated Full Name of the User Account. + + String + + + Roles + + The role(s) to assign to the Directroy Group, in System.Collections.ArrayList format. Accepted values are noted within the ApplianceRoles property of the HPEOneView.Appliance.Connection object stored in the $Global:ConnectedSessions variable. + +Example: $roles = "Server administrator","Network administrator" + + Array + + + Append + + Use to append roles and/or scope permissions update. If omitted, roles or scope permissions will be replaced. + + SwitchParameter + + + ScopePermissions + + Array collection of Hashtable<Role; Scope>. Will overwrite existing scope to role mappings. + +Example: -ScopePermissions @{Role = "Network administrator"; Scope = (Get-OVScope -Name CorpNetAdmins -ErrorAction Stop) } + + Array + + + EmailAddress + + Updated Email Address of the User Account. + + String + + + OfficePhone + + Updated office phone of the User Account. + + String + + + MobilePhone + + Updated mobile phone number + + String + + + Enabled + + Enable the local user account. + + SwitchParameter + + + Disabled + + Disable the local user account. + + SwitchParameter + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + + + + + + Append + + Use to append roles and/or scope permissions update. If omitted, roles or scope permissions will be replaced. + + SwitchParameter + + SwitchParameter + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Disabled + + Disable the local user account. + + SwitchParameter + + SwitchParameter + + False + + + EmailAddress + + Updated Email Address of the User Account. + + String + + String + + + + + Enabled + + Enable the local user account. + + SwitchParameter + + SwitchParameter + + False + + + FullName + + Updated Full Name of the User Account. + + String + + String + + + + + MobilePhone + + Updated mobile phone number + + String + + String + + + + + OfficePhone + + Updated office phone of the User Account. + + String + + String + + + + + Password + + New password for the user account. Passwords must be at least 8 characters. + + String + + String + + + + + Roles + + The role(s) to assign to the Directroy Group, in System.Collections.ArrayList format. Accepted values are noted within the ApplianceRoles property of the HPEOneView.Appliance.Connection object stored in the $Global:ConnectedSessions variable. + +Example: $roles = "Server administrator","Network administrator" + + Array + + Array + + + + + ScopePermissions + + Array collection of Hashtable<Role; Scope>. Will overwrite existing scope to role mappings. + +Example: -ScopePermissions @{Role = "Network administrator"; Scope = (Get-OVScope -Name CorpNetAdmins -ErrorAction Stop) } + + Array + + Array + + + + + UserName + + The name or object of the user account to be updated. + + String + + String + + + + + UserObject + + The object of the user account to be updated. + + Object + + Object + + + + + + + + + HPEOneView.Appliance.User [System.Management.Automation.PSCustomObject] + + + HPE OneView User Account object created on an appliance + + + + + + + + HPEOneView.Appliance.User [System.Management.Automation.PSCustomObject] + + + + If successful, returns a user resource + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Set-OVUser -username Sally -roles @("server administrator","network administrator") + + Update the user account "Sally" with new roles. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Set-OVUser -username Sally -password NewP@ssw0rd + + Update the user account "Sally" with a new password. + + + + + + + + + + -------------------------- EXAMPLE 3 -------------------------- + + + + $Scope = Get-OVScope -Name Scope1 -ErrorAction Stop +Get-OVUser -Username Sally | Set-OVUser -Roles "Server administrator" -ScopePermissions @{Role = "Network administrator"; Scope = $Scope } + + Modify the user account with the new role and scope permissions. + + + + + + + + + + + + + Get-OVUser + + + + New-OVUser + + + + Remove-OVUser + + + + Set-OVUserPassword + + + + Set-OVUserRole + + + + Show-OVUserSession + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/security/set-ovuser + + + + + + + + Set-OVUserPassword + + Update current user account password. + + Set + OVUserPassword + + + This Cmdlet provides the ability to update the current user account password. Only HPE OneView appliance local account passwords will be changed. This Cmdlet does not assist with modifying or updating an LDAP or Active Directory user account"s password. + + + + + Set-OVUserPassword + + Current + + The current password of the user account. If omitted, the Cmdlet will prompt for the users password as a secure string. + + String + + + New + + The new password to be set for the user account. If omitted, the Cmdlet will prompt for the users password as a secure string. + + String + + + ApplianceConnection + + +Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + +Default Value: ${Global:ConnectedSessions} | ? Default + + Object + + + + + + + ApplianceConnection + + +Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + +Default Value: ${Global:ConnectedSessions} | ? Default + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Current + + The current password of the user account. If omitted, the Cmdlet will prompt for the users password as a secure string. + + String + + String + + + + + New + + The new password to be set for the user account. If omitted, the Cmdlet will prompt for the users password as a secure string. + + String + + String + + + + + + + + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Set-OVUserPassword MyCurrentPass NewP@ssw0rd + + Update your HPE OneView account password to the new value on all connected appliances. + + + + + + + + + + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/security/set-ovuserpassword + + + + + + + + Set-OVUserRole + + (Deprecated) Assign or change roles for an existing user. + + Set + OVUserRole + + + This Cmdlet is now deprecated. Please use the Set-OVUser Cmdlet to modify user accounts and associated roles/permissions + + + + + Set-OVUserRole + + Name + + The name of the user account to have a role assigned. + + Object + + + Roles + + The role(s) to assign to the Directroy Group, in System.Collections.ArrayList format. Accepted values are noted within the ApplianceRoles property of the HPEOneView.Appliance.Connection object stored in the $Global:ConnectedSessions variable. + +Example: $roles = "Server administrator","Network administrator" + + Array + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Name + + The name of the user account to have a role assigned. + + Object + + Object + + + + + Roles + + The role(s) to assign to the Directroy Group, in System.Collections.ArrayList format. Accepted values are noted within the ApplianceRoles property of the HPEOneView.Appliance.Connection object stored in the $Global:ConnectedSessions variable. + +Example: $roles = "Server administrator","Network administrator" + + Array + + Array + + + + + + + + + HPEOneView.Appliance.User [System.Management.Automation.PSCustomObject] + + + HPE OneView appliance user account + + + + + + + + HPEOneView.Appliance.User [System.Management.Automation.PSCustomObject] + + + + Updated user account with new role(s) + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Set-OVUserRole -user Sally -roleName "Server Administrator" + + Set the Server Administrator role for Sally"s user account. + + + + + + + + + + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/security/set-ovuserrole + + + + + + + + Show-OVActiveUser + + Display active and connected users. + + Show + OVActiveUser + + + Use this Cmdlet to display active and connected users to an HPE OneView or Synergy management appliance. Infrastructure administrator or Security administrator role is required in order to view all connected users. + + + + + Show-OVActiveUser + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + HPEOneView.Appliance.ActiveUserSession + + + + Connected user session and its details. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVActiveUser UserName LoginDomain ClientHost LoginTime -------- ----------- ---------- --------- BobSmith@domain.local doctors-lab.local 192.168.19.3 11/1/2018 9: 39: 34 PM administrator Local 192.168.19.20 11/7/2018 1: 58: 48 PM Administrator Local 192.168.19.3 11/10/2018 5: 36: 39 AM + + Display connected active users to the appliance. + + + + + + + + + + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/security/show-ovactiveuser + + + + + + + + Show-OVApplianceSecurityModeCompatibilityReport + + Generate or show security mode compatability report. + + Show + OVApplianceSecurityModeCompatibilityReport + + + When you are considering switching the cryptography mode for your appliance, Hewlett Packard Enterprise recommends that you run the compatibility report to check for compatibility issues for a chosen cryptography mode. Compatibility reports contain information about the behavior of devices and external servers managed or configured by HPE OneView. The report lists the various resources (storage devices, network devices, servers, enclosures) managed by HPE OneView that are not compatible with the chosen cryptography mode. You can use the compatibility reports to: + + * Determine the impact of the mode switch on various resources, such as, the appliance certificates, external servers and managed devices. + * Understand the actions recommended to be taken before switching the cryptography mode of the appliance. Examples: + + * Re-importing a higher strength certificate signed by your certificate authority (CA). + * Configuring the managed device or external server to be compliant with the cryptography mode of HPE OneView. + + * Determine the devices or class of devices that cannot be managed by HPE OneView in the target mode. Running this Cmdlet will generate a new compatibility report if one does not exist. Use the -UpdateReport switch to generate a new report. + + + + + Show-OVApplianceSecurityModeCompatibilityReport + + TargetSecurityMode + + Specify the target security mode to test resources from Get-OVApplianceAvailableSecurityMode. + + HPEOneView.Appliance.SecurityMode + + + UpdateReport + + Specify to regenerate the report. + + SwitchParameter + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + Array + + (${Global:ConnectedSessions} | ? Default) + + + TargetSecurityMode + + Specify the target security mode to test resources from Get-OVApplianceAvailableSecurityMode. + + HPEOneView.Appliance.SecurityMode + + HPEOneView.Appliance.SecurityMode + + + + + UpdateReport + + Specify to regenerate the report. + + SwitchParameter + + SwitchParameter + + + + + + + + + HPEOneView.Appliance.SecurityMode + + + Available security mode from Get-OVApplianceAvailableSecurityMode. + + + + + + + + HPEOneView.Appliance.SecurityModeCompatibilityReport + + + + Security mode compatibility report. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + $TargetSecurityMode = Get-OVApplianceAvailableSecurityMode -ModeName CNSA +Show-OVApplianceSecurityModeCompatibilityReport -TargetSecurityMode $TargetSecurityMode + + Generate a compatibility report for changing the appliance mode to CNSA. + + + + + + + + + + + + + Get-OVApplianceAvailableSecurityMode + + + + Get-OVApplianceCurrentSecurityMode + + + + Set-OVApplianceCurrentSecurityMode + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/show-ovappliancesecuritymodecompatibilityreport + + + + + + + + Show-OVFirmwareReport + + Generate firmware report + + Show + OVFirmwareReport + + + This Cmdlet will generate a CSV-compliance firmware report for various resources. Enclosure Groups, Enclosures, Server Hardware and Interconnects are all suported resources. If an Enclosure Group is provided, all associated Logical Enclosures and Enclosures are examined, with their embedded resources like fabric modules, enclosure managers (Synergy FLM and BladeSystem Onboard Administrator), and server hardware. If a baseline is associated with an Enclosure Group, or server profile, it is used to compare what is expected, versus what the actual installed component is. The baseline can be overridden by specifying a different baseline resource object from Get-OVBaseline. + +The genrated report can be exported. + +Minimum required permissions: Infrastructure administrator, Server administrator, Network administrator + + + + + Show-OVFirmwareReport + + InputObject + + The managed resource object to generate the report for. Allowed resource object types are: + + * EG (Enclosure Group) + * Enclosure + * Server + * Interconnect + +By specifying an Enclosure Group, all associated Enclosures will be included in the report. + + Object + + + Baseline + + Resource Object or Name of the Firmware Baseline to report against what is installed. + + Object + + + InstallationPolicy + + The Installation policy option is only available for Gen10 and later servers. The option is available for Gen10 or later server hardware types only. Installation policy enables you to choose if a component needs to be updated or downgraded when its version does not match the baseline. An alert is generated when the installed version on one or more components is inconsistent with the selected installation policy. + +You can choose one of the following two policy options: + + * LowerThanBaseline (Default) - Updates only the components that have a version lower than the firmware baseline version. + * NotEqualToBaseline - Updates or downgrades components whose installed version does not match the firmware baseline version. The components with a version lower than the firmware baseline version are upgraded, and the components with a version higher than the firmware baseline version are downgraded to match the baseline. + + string + + + Location + + File system location where to save the exported report to. + +Default: Current Working Directory + + String + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + + Export + + Indicate to export the report to a CSV file. + + SwitchParameter + + + + + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Baseline + + Resource Object or Name of the Firmware Baseline to report against what is installed. + + Object + + Object + + + + + Export + + Indicate to export the report to a CSV file. + + SwitchParameter + + SwitchParameter + + False + + + InputObject + + The managed resource object to generate the report for. Allowed resource object types are: + + * EG (Enclosure Group) + * Enclosure + * Server + * Interconnect + +By specifying an Enclosure Group, all associated Enclosures will be included in the report. + + Object + + Object + + + + + InstallationPolicy + + The Installation policy option is only available for Gen10 and later servers. The option is available for Gen10 or later server hardware types only. Installation policy enables you to choose if a component needs to be updated or downgraded when its version does not match the baseline. An alert is generated when the installed version on one or more components is inconsistent with the selected installation policy. + +You can choose one of the following two policy options: + + * LowerThanBaseline (Default) - Updates only the components that have a version lower than the firmware baseline version. + * NotEqualToBaseline - Updates or downgrades components whose installed version does not match the firmware baseline version. The components with a version lower than the firmware baseline version are upgraded, and the components with a version higher than the firmware baseline version are downgraded to match the baseline. + + string + + string + + + + + Location + + File system location where to save the exported report to. + +Default: Current Working Directory + + String + + String + + (get-location).Path + + + + + + + HPEOneView.EnclosureGroup or HPEOneView.Enclosure or HPEOneView.ServerHardware or HPEOneView.Networking.Interconnect + + + HPE OneView Managed Resource object + + + + + + + + System.Object + + + + Firmware report + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVEnclosureGroup "Production EG" | Show-OVFirmwareReport + + Display a firmware report of all associated enclosures to "Production EG" Enclosure Group currently managed by the appliance. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + $Baseline = Get-OVBaseline -SppName "Production EG" +Get-OVEnclosureGroup "Production EG" | Show-OVFirmwareReport -Baseline $Baseline + + Display a firmware report of the "Production EG" resource, and components (servers, interconnects and Onboard Administrators) currently managed by the appliance, and compare to the provided Baseline. + + + + + + + + + + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/servers/show-ovfirmwarereport + + + + + + + + Show-OVHypervisorCluster + + Default content + + Show + OVHypervisorCluster + + + Default content + + + + + Show-OVHypervisorCluster + + Name + + + + String + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Name + + + + String + + String + + + + + + + + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Show-OVHypervisorCluster + + Default example + + + + + + + + + + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/cluster/show-ovhypervisorcluster + + + + + + + + Show-OVLdapGroups + + List Directory Groups from the configured LDAP Directory. + + Show + OVLdapGroups + + + This Cmdlet will display the available Authentication Directory security groups. The displayed Directory Groups can then be used to define new Directory Group Role assignment on the appliance with the New-OVLdapGroup Cmdlet. + + + + + Show-OVLdapGroups + + Directory + + The configured LDAP Directory object on the appliance. + + Object + + + UserName + + Username to authenticate with + + String + + + Password + + User account password + + System.Security.SecureString + + + GroupName + + Provide the name of the Directory Group to search for. If omitted, all found Directory Groups will be returned. + + String + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + Show-OVLdapGroups + + Directory + + The configured LDAP Directory object on the appliance. + + Object + + + Credential + + Use this parameter if you want to provide a PSCredential object instead. + + PSCredential + + + GroupName + + Provide the name of the Directory Group to search for. If omitted, all found Directory Groups will be returned. + + String + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Credential + + Use this parameter if you want to provide a PSCredential object instead. + + PSCredential + + PSCredential + + + + + Directory + + The configured LDAP Directory object on the appliance. + + Object + + Object + + + + + GroupName + + Provide the name of the Directory Group to search for. If omitted, all found Directory Groups will be returned. + + String + + String + + + + + Password + + User account password + + System.Security.SecureString + + System.Security.SecureString + + + + + UserName + + Username to authenticate with + + String + + String + + + + + + + + + System.Security.SecureString + + + Directory User Account password + + + + + + + + HPEOneView.Appliance.AuthDirectoryGroup [System.Management.Automation.PSCustomObject] + + + + Authentication Directory Group + + + + + System.Collections.ArrayList<HPEOneView.Appliance.AuthDirectoryGroup> + + + + Array of Authentication Directory Groups found + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Show-OVLdapGroups -u "Sarah Peterson" -d Domain1 + + Get list of Directory Groups from Domain1 and prompt for password. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + $password = ConvertTo-SecureString -asplaintext "password123890" -force +$Directory = Get-OVLdapDirectory "Domain99" +Show-OVLdapGroups -u "Sarah Peterson" -p $password -d $Directory + + Automate list of Directory Groups from Domain99 with the provided password. + + + + + + + + + + -------------------------- EXAMPLE 3 -------------------------- + + + + $password = ConvertTo-SecureString -asplaintext "password123890" -force +$Directory = Get-OVLdapDirectory "Domain99" +Show-OVLdapGroups -u "Sarah Peterson" -p $password -d $Directory -GroupName "Admins" + + Automate list of Directory Groups from Domain99 with the provided password, searching for group names that contain "Admins". + + + + + + + + + + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/security/show-ovldapgroups + + + + + + + + Show-OVLogicalInterconnectMacTable + + Show the MAC Table for Logical Interconnect resource(s). + + Show + OVLogicalInterconnectMacTable + + + This Cmdlet will help show the MAC Table of Logical Interconnect resources. The REST API currently limits the first 100 MAC addresses from the MAC table, regardless of the number of MAC Addresses learned in the table. + +Use the -Network parameter to specify the Network Name to display learned MAC Addresses. You can export the results to a CSV file, by providing the full path and filename to export to, using the -ExportFile parameter. + +To display the results in a formatted list, use the -List parameter. + + + + + Show-OVLogicalInterconnectMacTable + + InputObject + + The Name, URI, Logical Interconnect Resource or an array of either to display the MAC Address tables from. + + Object + + + network + + Provide the Network Name to filter the MAC Table results for. + + String + + + Export + + Export to a CSV, provide the full path and filename. + + String + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + + + Show-OVLogicalInterconnectMacTable + + InputObject + + The Name, URI, Logical Interconnect Resource or an array of either to display the MAC Address tables from. + + Object + + + MacAddress + + Provide a MAC Address to locate in the MAC Table. + + String + + + Export + + Export to a CSV, provide the full path and filename. + + String + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Export + + Export to a CSV, provide the full path and filename. + + String + + String + + + + + InputObject + + The Name, URI, Logical Interconnect Resource or an array of either to display the MAC Address tables from. + + Object + + Object + + + + + MacAddress + + Provide a MAC Address to locate in the MAC Table. + + String + + String + + + + + network + + Provide the Network Name to filter the MAC Table results for. + + String + + String + + + + + + + + + System.Collections.ArrayList + + + An Array of Logical Interconnect resource URI"s, Names or Objects + + + + + System.Management.Automation.PSCustomObject + + + Logical Interconnect Resource Object + + + + + + + + System.Collections.ArrayList + + + + Collection of MAC Address Table entries + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Show-OVLogicalInterconnectMacTable + + Return as many MAC Addresses allowed by the API for all Logical Interconnect resources. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Show-OVLogicalInterconnectMacTable -network VLAN100 +Enclosure Interconnect Interface Address Type Network VLAN +--------- ------------ --------- ------- ---- ------- ---- +Encl1 interconnect 2 LAG 27 38:22:D6:35:5A:62 Learned VLAN100 30 +Encl1 interconnect 1 LAG 26 38:22:D6:35:5A:62 Learned VLAN100 30 +Encl1 interconnect 1 LAG 26 78:AC:C0:72:E5:D9 Learned VLAN100 30 + + Display all available MAC Addresses learned in "VLAN100" network in all Logical Interconnect resources, and display in a formatted table. + + + + + + + + + + -------------------------- EXAMPLE 3 -------------------------- + + + + Show-OVLogicalInterconnectMacTable -network VLAN100 -exportfile C:\reports\Encl1-LI_vlan100_mactable.csv + + Retrieve the available MAC Addresses learned in "VLAN100" network, and export to C:\reports\Encl1-LI_vlan100_mactable.csv + + + + + + + + + + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/networking/show-ovlogicalinterconnectmactable + + + + + + + + Show-OVPortStatistics + + Display Interconnect Port Statistics. + + Show + OVPortStatistics + + + This Cmdlet will display the utilization (Format-Table view) or error (Format-List) statistics of a given Interconnect or Interconnect Port. The default view is Format-Table. Piping output to Format-List will display error statistics. + + + + + Show-OVPortStatistics + + Interconnect + + The Interconnect resource the Port ID is a member of. + + Object + + + Port + + The name of the Interconnect Port ID (i.e. X1 or D5) to retrieve. If no Port ID is provided, all Ports of the Interconnect will be returned. + + Object + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + + + Show-OVPortStatistics + + Port + + The name of the Interconnect Port ID (i.e. X1 or D5) to retrieve. If no Port ID is provided, all Ports of the Interconnect will be returned. + + Object + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + + + + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Interconnect + + The Interconnect resource the Port ID is a member of. + + Object + + Object + + + + + Port + + The name of the Interconnect Port ID (i.e. X1 or D5) to retrieve. If no Port ID is provided, all Ports of the Interconnect will be returned. + + Object + + Object + + + + + + + + + HPEOneView.Netwroking.Interconnect.Port [System.Management.Automation.PSCustomObject] + + + An Interconnect Port object + + + + + + + + HPEOneView.Networking.PortStatistics.Ethernet [System.Management.Automation.PSCustomObject] + + + + Ethernet Uplink Port statistics + + + + + HPEOneView.Networking.PortStatistics.FibreChannel [System.Management.Automation.PSCustomObject] + + + + Ethernet Uplink Port statistics + + + + + System.Collections.ArrayList + + + + Collection of multiple Interconnect Port statistics + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Show-OVPortStatistics -interconnect "Encl1, Interconnect 1" -port X1 +Port Type: Ethernet + +Name Rx Kb/s Tx Kb/s Rx Packets Tx Packets Rx Non-Unicast PPS Tx Non-Unicast PPS +---- ------- ------- ---------- ---------- ------------------ ------------------ +X1 5Kbps (1min) 0Kbps (1min) 6pps (1min) 0pps (1min) 6pps (1min) 0pps (1min) + + Displays the interface throughput statistics for X1 in a Format-Table display. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Show-OVPortStatistics -interconnect "Encl1, Interconnect 1" -port X1 | FL +Port Type: Ethernet + + +Name : X4 +Rx Kb/s : 5Kbps (1min) +Tx Kb/s : 0Kbps (1min) +In Discards : +Out Discards : +In Errors : +Out Errors : +CRC Errors Rx/Tx : +MTU Exceeded Discards Rx/Tx : +Giants Rx/Tx : + + Displays the interface error statistics for X1 in a Format-List display. + + + + + + + + + + -------------------------- EXAMPLE 3 -------------------------- + + + + (Get-OVInterconnect "Encl1, Interconnect 1").ports | ? name -eq X1 | Show-OVPortStatistics + + Pipe an Interconnect Port object to Show-OVPortStatistics and show the interface throughput statistics. + + + + + + + + + + -------------------------- EXAMPLE 4 -------------------------- + + + + Show-OVPortStatistics -interconnect "Encl1, Interconnect 1" +Port Type: Ethernet + +Name Rx Kb/s Tx Kb/s Rx Packets Tx Packets Rx Non-Unicast PPS Tx Non-Unicast PPS +---- ------- ------- ---------- ---------- ------------------ ------------------ +d1 0Kbps (1min) 8Kbps (1min) 0pps (1min) 6pps (1min) 0pps (1min) 5pps (1min) +d10 0Kbps (1min) 0Kbps (1min) 0pps (1min) 0pps (1min) 0pps (1min) 0pps (1min) +d11 0Kbps (1min) 0Kbps (1min) 0pps (1min) 0pps (1min) 0pps (1min) 0pps (1min) +d12 0Kbps (1min) 0Kbps (1min) 0pps (1min) 0pps (1min) 0pps (1min) 0pps (1min) +d13 0Kbps (1min) 0Kbps (1min) 0pps (1min) 0pps (1min) 0pps (1min) 0pps (1min) +d14 0Kbps (1min) 0Kbps (1min) 0pps (1min) 0pps (1min) 0pps (1min) 0pps (1min) +d15 0Kbps (1min) 0Kbps (1min) 0pps (1min) 0pps (1min) 0pps (1min) 0pps (1min) +d16 0Kbps (1min) 0Kbps (1min) 0pps (1min) 0pps (1min) 0pps (1min) 0pps (1min) +d2 0Kbps (1min) 0Kbps (1min) 0pps (1min) 0pps (1min) 0pps (1min) 0pps (1min) +d3 0Kbps (1min) 0Kbps (1min) 0pps (1min) 0pps (1min) 0pps (1min) 0pps (1min) +d4 0Kbps (1min) 0Kbps (1min) 0pps (1min) 0pps (1min) 0pps (1min) 0pps (1min) +d5 0Kbps (1min) 0Kbps (1min) 0pps (1min) 0pps (1min) 0pps (1min) 0pps (1min) +d6 0Kbps (1min) 0Kbps (1min) 0pps (1min) 0pps (1min) 0pps (1min) 0pps (1min) +d7 0Kbps (1min) 0Kbps (1min) 0pps (1min) 0pps (1min) 0pps (1min) 0pps (1min) +d8 0Kbps (1min) 0Kbps (1min) 0pps (1min) 0pps (1min) 0pps (1min) 0pps (1min) +d9 0Kbps (1min) 0Kbps (1min) 0pps (1min) 0pps (1min) 0pps (1min) 0pps (1min) +X4 6Kbps (1min) 0Kbps (1min) 6pps (1min) 0pps (1min) 6pps (1min) 0pps (1min) +X5 6Kbps (1min) 0Kbps (1min) 4pps (1min) 0pps (1min) 4pps (1min) 0pps (1min) +X6 4Kbps (1min) 0Kbps (1min) 3pps (1min) 0pps (1min) 3pps (1min) 0pps (1min) +X7 0Kbps (1min) 0Kbps (1min) 0pps (1min) 0pps (1min) 0pps (1min) 0pps (1min) +X8 6Kbps (1min) 11Kbps (1min) 7pps (1min) 14pps (1min) 7pps (1min) 14pps (1min) + + + + + Port Type: FibreChannel + +Name Rx Throughput Tx Throughput Rx Frames (Total) Tx Frames (Total) Rx Bytes (Total) Tx Bytes (Total) +---- ------------- ------------- ----------------- ----------------- ---------------- ---------------- +X1 0 MB/s 0 MB/s 56868 85074 84809592 146546884 +X2 0 MB/s 0 MB/s 7999 7999 579644 622152 +X3 0 MB/s 0 MB/s 0 0 0 0 + + Display all available ports of the provided Interconnect, using the Interconnect Name. + + + + + + + + + + -------------------------- EXAMPLE 5 -------------------------- + + + + $Interconnect = Get-OVInterconnect "Encl1, Interconnect 1" +Show-OVPortStatistics $Interconnect + + Display all available ports of the provided Interconnect, using an Interconnect PowerShell object. + + + + + + + + + + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/networking/show-ovportstatistics + + + + + + + + Show-OVSanEndpoint + + View Managed SAN FC Endpoints. + + Show + OVSanEndpoint + + + This Cmdlet will dispay the Managed SAN endpoints, or FC addresses, their node information, and Zone Name. By default, all SAN endpoints will be returned. You can filter the results based on Managed SAN resource or WWN address. + + + + + Show-OVSanEndpoint + + SAN + + The Managed SAN Resource Object or Name. Cannot be combined with the WWN parameter. + + Object + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + + + Show-OVSanEndpoint + + WWN + + The WWN of the node you are looking for. Cannot be combined with the SAN parameter. + + String + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + SAN + + The Managed SAN Resource Object or Name. Cannot be combined with the WWN parameter. + + Object + + Object + + + + + WWN + + The WWN of the node you are looking for. Cannot be combined with the SAN parameter. + + String + + String + + + + + + + + + HPEOneView.Storage.ManagedSan + + + Managed SAN resource from Get-OVManagedSan + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + Async task + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Show-OVSanEndpoint +Appliance WWN Port Type Online SAN Name Zone Name +--------- --- --------- ------ -------- --------- +hpov-tot2 10:00:F6:9F:5F:70:00:02 N_Port False SAN1_1 Node_1_8 +hpov-tot2 20:00:00:02:AC:00:08:DF N_Port True SAN1_1 Node_1_8 +hpov-tot2 20:00:00:02:AC:00:08:E3 N_Port True SAN1_1 Node_1_8 +hpov-tot2 10:00:F6:9F:5F:70:00:00 N_Port False SAN1_0 Node_1_7 +hpov-tot2 20:00:00:02:AC:00:08:E2 N_Port True SAN1_0 Node_1_7 +hpov-tot2 20:00:00:02:AC:00:08:DE N_Port True SAN1_0 Node_1_7 +hpov-tot2 AA:AA:AA:AA:AA:AA:AA:AA N_Port False SAN1_0 dummy_zone +hpov-tot2 20:00:00:02:AC:00:09:03 N_Port True SAN1_0 +hpov-tot2 00:00:4A:2B:21:E0:00:1B N_Port True SAN1_1 +hpov-tot2 20:00:00:02:AC:00:09:04 N_Port True SAN1_1 +hpov-tot2 00:00:4A:2B:21:E0:00:14 N_Port True SAN1_0 +hpov-tot2 00:00:4A:2B:21:E0:00:0D N_Port True SAN1_1 +hpov-tot2 20:00:00:02:AC:00:09:00 N_Port True SAN1_1 +hpov-tot2 20:00:00:02:AC:00:08:FF N_Port True SAN1_0 +hpov-tot2 00:00:4A:2B:21:E0:00:06 N_Port True SAN1_0 + + Return all SAN Endpoints from the appliance. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Get-OVManagedSan SAN1_1 | Show-OVSanEndpoint +Appliance WWN Port Type Online SAN Name Zone Name +--------- --- --------- ------ -------- --------- +hpov-tot2 20:00:00:02:AC:00:08:E3 N_Port True SAN1_1 Node_1_8 +hpov-tot2 10:00:F6:9F:5F:70:00:02 N_Port False SAN1_1 Node_1_8 +hpov-tot2 20:00:00:02:AC:00:08:DF N_Port True SAN1_1 Node_1_8 +hpov-tot2 00:00:4A:2B:21:E0:00:1B N_Port True SAN1_1 +hpov-tot2 20:00:00:02:AC:00:09:04 N_Port True SAN1_1 +hpov-tot2 00:00:4A:2B:21:E0:00:0D N_Port True SAN1_1 +hpov-tot2 20:00:00:02:AC:00:09:00 N_Port True SAN1_1 + + Return all SAN Endpoints for the specified Managed SAN resource from the appliance. + + + + + + + + + + -------------------------- EXAMPLE 3 -------------------------- + + + + Show-OVSanEndpoint -WWN 10:00:F6:9F:5F:70:00:02 +Appliance WWN Port Type Online SAN Name Zone Name +--------- --- --------- ------ -------- --------- +hpov-tot2 10:00:F6:9F:5F:70:00:02 N_Port False SAN1_1 Node_1_8 + + Return the specific SAN Endpoint from the appliance. + + + + + + + + + + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/storage/show-ovsanendpoint + + + + + + + + Show-OVStorageSystemPerformancePolicy + + Show available Nimble Performance Policies. + + Show + OVStorageSystemPerformancePolicy + + + Use this Cmdlet to show available Nimble Performance Policies in order to set a desired perforamnce policy value when provisioning a new volume or creating a new volume template. + + + + + Show-OVStorageSystemPerformancePolicy + + InputObject + + One or more storage systems from Get-OVStorageSystem. + + Object + + + Name + + Provide a name of the performance policy to return. + + String + + + + + + + InputObject + + One or more storage systems from Get-OVStorageSystem. + + Object + + Object + + + + + Name + + Provide a name of the performance policy to return. + + String + + String + + + + + + + + + HPEOneView.Storage.System [System.Management.Automation.PSCustomObject] + + + + + + + + + + + HPEOneView.Storage.PerformancePolicy + + + + One or more available storage system performance policy objects. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Show-OVStorageSystemPerformancePolicy + + Default example + + + + + + + + + + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/storage/show-ovstoragesystemperformancepolicy + + + + + + + + Show-OVUserSession + + Display user logon sessions. + + Show + OVUserSession + + + This Cmdlet is decprecated as of v2.0. Please use the $ConnectedSessions Global variable for appliance session information. + + + + + Show-OVUserSession + + + + + + + + + + None. + + + None + + + + + + + + None. + + + + None + + + + + + + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/show-ovusersession + + + + + + + + Show-OVUtilization + + Report server and enclosure supported utilization metrics. + + Show + OVUtilization + + + For resources such as Enclosures and Server Hardware, the appliance collects CPU, power, and temperature utilization statistics from the management processors (iLO, OA, FLM). Utilization statistics are not instantaneous-data is gathered and reported every five minutes. + +The fields that are displayed in the available statistics vary from component to component. + +CPU + +Server hardware CPU utilization statistics are gathered from the historical data stored on an iLO every five minutes. + +CPU utilization is expressed as a percentage. A high percentage indicates that one or more processes running on the device are consuming a considerable amount of CPU resources. If the percentage appears frozen at or near 100%, a process might not be responding. + +CPU utilziation is only supported with server hardware resources, and are contained within the CPUCurrent, CPUAverage and CPUPeak properties. + +Power + +Power capacity is the calibrated maximum power that a device can consume. The power utilization metrics refresh every five minutes. + +You can see the power utilization data for a component within the objects PowerCurrent, PowerAverage and PowerPeak properties. The value contained will be in Watts. + +Use this data to determine how much power your facility is consuming and the resources that are consuming it. The appliance reports alerts for devices that exceed their power capacity. + +PowerCurrent +The current power reported by the device. + +PowerAverage +The average amount of power the resource is consuming. + +PowerPeak +The peak amount of power consumed by the resource. + +Temperature + +Temperature utilization graphs display the ambient/inlet air temperature of your data center. The air temperature is detected by sensors embedded on the front of enclosures and other hardware devices. + +The operating threshold is 10┬░C to 35┬░C (50┬░F to 95┬░F). When the device reaches a threshold, it generates temperature alerts. The appliance displays these alerts in the notification banner and in the Activity sidebar. + +You can see the temperature utilization data for a component within the AmbientTemperature and AmbientTemperatureAverage properties. + +NOTE: The temperature properties are displayed in degrees Celsius or Fahrenheit, depending upon the locale or regional settings of your PC. + + + + + Show-OVUtilization + + InputObject + + A server hardware, server profile or enclosure resource. IF a server profile is unassigned, it will be skipped. + + Object + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliansce.Connection] object(s) or Name property value(s). + + Array + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliansce.Connection] object(s) or Name property value(s). + + Array + + Array + + (${Global:ConnectedSessions} | ? Default) + + + InputObject + + A server hardware, server profile or enclosure resource. IF a server profile is unassigned, it will be skipped. + + Object + + Object + + + + + + + + + HPEOneView.ServerHardware [System.Management.Automation.PSCustomObject] + + + A server hardware resource from Get-OVServer. + + + + + HPEOneView.ServerProfile [System.Management.Automation.PSCustomObject] + + + A server profile from Get-OVServerProfile that is assigned to a physical server resource. If the profile is not assigned to a server hardware resource, it is skipped. + + + + + HPEOneView.Enclosure [System.Management.Automation.PSCustomObject] + + + An enclosure resource from Get-OVEnclosure. + + + + + + + + HPEOneView.ServerUtilization + + + + Server utilization object. + + + + + + HPEOneView.EnclosureUtilization + + + + Enclosure utilization object. + + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVServer | Show-OVUtilization + + Get all available server resources, and collect utilization data to report. + + + + + + + + + + + + + Get-OVEnclosure + + + + Get-OVServer + + + + Get-OVServerProfile + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/servers/show-ovutilization + + + + + + + + Start-OVEnclosureAppliance + + Power on HPE Synergy appliance device. + + Start + OVEnclosureAppliance + + + This Cmdlet will assist server administrators in powering on appliance devices within HPE Synergy frames. Additional power operations for Frame devices are provided by Reset-OVEnclosureDevice. + +Minimum required privileges: Infrastructure administrator, Server administrator + + + + + Start-OVEnclosureAppliance + + InputObject + + The HPE Synergy frame resource from Get-OVEnclosure. + + Object + + + BayID + + The specified appliance bay ID of the provided enclosure resource. Only ID's 1 or 2 are allowed. + + int + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + ApplianceConnection + + Specify one or more HPEOneView.Appliance.Connection object(s) or Name property value(s). + +Default Value: ${Global:ConnectedSessions} | ? Default + + Object + + + + + + + ApplianceConnection + + Specify one or more HPEOneView.Appliance.Connection object(s) or Name property value(s). + +Default Value: ${Global:ConnectedSessions} | ? Default + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + SwitchParameter + + False + + + BayID + + The specified appliance bay ID of the provided enclosure resource. Only ID's 1 or 2 are allowed. + + int + + int + + + + + InputObject + + The HPE Synergy frame resource from Get-OVEnclosure. + + Object + + Object + + + + + + + + + HPEOneView.Enclosure [System.Management.Automation.PSCustomObject] + + + Enclosure resource from Get-OVEnclosure. + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + Async task resource to monitor. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Start-OVEnclosureAppliance -InputObject (Get-OVEnclosure -Name Enclosure-2) -BayID 1 + + Start the appliance device in bay 1 of the specified enclosure. + + + + + + + + + + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/servers/start-ovenclosureappliance + + + Get-OVEnclosure + + + + Reset-OVEnclosureDevice + + + + Stop-OVAppliance + + + + + + + + + Start-OVLibraryTrace + + Start HPOV Library Verbose Trace. + + Start + OVLibraryTrace + + + This Cmdlet is deprecated. Please use Get-OVCommandTrace. + + + + + Start-OVLibraryTrace + + Location + + Location where to store the log file. + + String + + + + + + + Location + + Location where to store the log file. + + String + + String + + + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + None + + + + + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Stop-OVLibraryTrace + + Transcript stopped, output file is C:\Users\Administrator\1604251128_HPOV_transcript.trace + + + + + + + + + + + + + Stop-OVLibraryTrace + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/library/start-ovlibrarytrace + + + + + + + + Start-OVRemoteSupportCollection + + Begin Remote Support collection from endpoints. + + Start + OVRemoteSupportCollection + + + Use this Cmdlet to initiate colleciton of remote support data. This will help send collection reports back to HPE that are in between the default scheduled task. + + + + + Start-OVRemoteSupportCollection + + InputObject + + A supported Gen8 or newer compute, HPE BladeSystem enclosure, or HPE Synergy frame. + + Object + + + Type + + Used to specify the type of remote support collection to start. Allowed values are: + + * AHS - Active Health Service collection + * Basic - Basic server configuration collection + + Object + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + SwitchParameter + + False + + + InputObject + + A supported Gen8 or newer compute, HPE BladeSystem enclosure, or HPE Synergy frame. + + Object + + Object + + + + + Type + + Used to specify the type of remote support collection to start. Allowed values are: + + * AHS - Active Health Service collection + * Basic - Basic server configuration collection + + Object + + Object + + + + + + + + + HPEOneView.ServerHardware [System.Management.Automation.PSCustomObject] + + + A Gen8 or newer generation server hardware resource object from Get-OVServer. + + + + + HPEOneView.Enclosure [System.Management.Automation.PSCustomObject] + + + A Gen8 or newer generation server hardware resource object from Get-OVServer. + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + Asynchronous task resource to monitor + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVServer -Name Prod-Sql-01 | Start-OVRemoteSupportCollection -Type AHS + + Start the collection of AHS logs immediately for the specified server. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Get-OVEnclosure | Start-OVRemoteSupportCollection -Type Basic + + Start the collection of basic server configuration immediately. + + + + + + + + + + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/start-ovremotesupportcollection + + + + + + + + Start-OVServer + + Power on Server Resource. + + Start + OVServer + + + Start the power state of the server using the virtual power button. + + + + + Start-OVServer + + InputObject + + A Server hardware or Server Profile resource object. + + Object + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + + + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + SwitchParameter + + False + + + InputObject + + A Server hardware or Server Profile resource object. + + Object + + Object + + + + + + + + + HPEOneView.ServerHardware [System.Management.Automation.PSCustomObject] + + + Server Hardware Resource + + + + + HPEOneView.ServerProfile [System.Management.Automation.PSCustomObject] + + + Server Profile Resource + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + Async task that tracks the power state change + + + + + System.Collections.ArrayList <HPEOneView.Appliance.TaskResource> + + + + Multiple Async tasks + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVServer -Name "Encl1, Bay 1" | Start-OVServer + + Power on the specific server device by passing the Server Object via pipeline. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Get-OVServer -Name "Encl1, *" | Start-OVServer -Async + + Power on the server devices found by passing the Server Object via pipeline, and return the async task immediately. + + + + + + + + + + -------------------------- EXAMPLE 3 -------------------------- + + + + Get-OVServerProfile -Name "MyWebServer 1" | Start-OVServer + + Power on the specific server device by passing the Server Profile Object via pipeline. + + + + + + + + + + + + + Add-OVServer + + + + Convert-OVServerProfile + + + + Convert-OVServerProfileTemplate + + + + ConvertTo-OVServerProfileTemplate + + + + Copy-OVServerProfile + + + + Get-OVServer + + + + Get-OVServerHardwareType + + + + Get-OVServerProfile + + + + Get-OVServerProfileConnectionList + + + + Get-OVServerProfileMessage + + + + Get-OVServerProfileTemplate + + + + Join-OVServerProfileToTemplate + + + + New-OVServerProfile + + + + New-OVServerProfileAssign + + + + New-OVServerProfileAttachVolume + + + + New-OVServerProfileConnection + + + + New-OVServerProfileLogicalDisk + + + + New-OVServerProfileLogicalDiskController + + + + New-OVServerProfileTemplate + + + + Remove-OVServer + + + + Remove-OVServerProfile + + + + Remove-OVServerProfileTemplate + + + + Restart-OVServer + + + + Save-OVServerProfile + + + + Save-OVServerProfileTemplate + + + + Set-OVServerHardwareType + + + + Set-OVServerPower + + + + Set-OVServerProfile + + + + Set-OVServerProfileTemplate + + + + Stop-OVServer + + + + Update-OVServer + + + + Update-OVServerHardwareLicenseIntent + + + + Update-OVServerProfile + + + + Get-OVServerOneTimeBoot + + + + Set-OVServerOneTimeBoot + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/servers/start-ovserver + + + + + + + + Stop-OVAppliance + + Stop an HPE OneView appliance. + + Stop + OVAppliance + + + This Cmdlet will allow the administrator to stop/shutdown the appliance. Shutdown of the appliance will cause all users to be disconnected and all ongoing tasks to be interrupted. + +Only the Infrastructure (Full) Administrator may restart the appliance. + + + + + Stop-OVAppliance + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + +Default Value: ${Global:ConnectSessions} | ? Default + + Array + + + WhatIf + + + + SwitchParameter + + + Confirm + + + + SwitchParameter + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + +Default Value: ${Global:ConnectSessions} | ? Default + + Array + + Array + + (${Global:ConnectedSessions} | ? Default) + + + Confirm + + + + SwitchParameter + + SwitchParameter + + + + + WhatIf + + + + SwitchParameter + + SwitchParameter + + + + + + + + + HPEOneView.Appliance.Connection + + + Connected Appliance Session + + + + + System.Collections.ArrayList + + + Collection of HPEOneView.Appliance.Connection objects + + + + + + + + System.String + + + + Warning message the appliance is stopping + + + + + Management.Automation.ErrorRecord + + + + Generated error message + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Connect-OVMgmt appliance.contoso.com Administrator P@ssw0rd +Stop-OVAppliance + + Shutdown the appliance. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Stop-OVAppliance -confirm:$false + + Shutdown all connected appliances, disable confirmation. + + + + + + + + + + + + + Add-OVApplianceTrustedCertificate + + + + Disable-OVApplianceComplexPasswords + + + + Disable-OVApplianceServiceConsoleAccess + + + + Disable-OVApplianceSshAccess + + + + Disable-OVApplianceTwoFactorAuthentication + + + + Enable-OVApplianceComplexPasswords + + + + Enable-OVApplianceServiceConsoleAccess + + + + Enable-OVApplianceSshAccess + + + + Get-OVApplianceAuditLogForwarding + + + + Get-OVApplianceAvailableSecurityMode + + + + Get-OVApplianceCertificateStatus + + + + Get-OVApplianceCurrentSecurityMode + + + + Get-OVApplianceDateTime + + + + Get-OVApplianceGlobalSetting + + + + Get-OVApplianceNetworkConfig + + + + Get-OVApplianceProxy + + + + Get-OVApplianceSecurityProtocol + + + + Get-OVApplianceServiceConsoleAccess + + + + Get-OVApplianceSnmpV3EngineId + + + + Get-OVApplianceSshAccess + + + + Get-OVApplianceTrapDestination + + + + Get-OVApplianceTrustedCertificate + + + + Get-OVApplianceTwoFactorAuthentication + + + + Install-OVApplianceCertificate + + + + New-OVApplianceCsr + + + + New-OVApplianceSelfSignedCertificate + + + + New-OVApplianceTrapDestination + + + + Pop-OVAppliancePermission + + + + Push-OVAppliancePermission + + + + Remove-OVApplianceProxy + + + + Remove-OVApplianceTrapDestination + + + + Remove-OVApplianceTrustedCertificate + + + + Restart-OVAppliance + + + + Set-OVApplianceAuditLogForwarding + + + + Set-OVApplianceCurrentSecurityMode + + + + Set-OVApplianceDateTime + + + + Set-OVApplianceDefaultConnection + + + + Set-OVApplianceGlobalSetting + + + + Set-OVApplianceNetworkConfig + + + + Set-OVApplianceProxy + + + + Set-OVApplianceSecurityProtocol + + + + Set-OVApplianceSnmpV3EngineId + + + + Set-OVApplianceTwoFactorAuthentication + + + + Show-OVApplianceSecurityModeCompatibilityReport + + + + Test-OVApplianceAuditLogForwarding + + + + Update-OVApplianceTrustedAuthorityCrl + + + + Wait-OVApplianceStart + + + + Start-OVEnclosureAppliance + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/stop-ovappliance + + + + + + + + Stop-OVLibraryTrace + + Stop HPOV Library Verbose Trace. + + Stop + OVLibraryTrace + + + This Cmdlet is deprecated. Please use Get-OVCommandTrace. + + + + + Stop-OVLibraryTrace + + + + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + + + + + + + + + System.IO.File + + + + {filename}.trace file is generated in the location specified in the Start-OVLibraryTrace Cmdlet + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Stop-OVLibraryTrace + + Transcript stopped, output file is C:\Users\Administrator\1604251128_HPOV_transcript.trace + + + + + + + + + + + + + Start-OVLibraryTrace + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/library/stop-ovlibrarytrace + + + + + + + + Stop-OVServer + + Power off Server Resource. + + Stop + OVServer + + + Stop the power state of the server using the virtual power button. By default, the Cmdlet will request a "Momentary Press" request to initiate a server to shutdown. + + + + + Stop-OVServer + + InputObject + + A Server hardware or Server Profile resource object. + + Object + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + + WhatIf + + + + SwitchParameter + + + Confirm + + + + SwitchParameter + + + + Stop-OVServer + + InputObject + + A Server hardware or Server Profile resource object. + + Object + + + Force + + Use this parameter to request the "Press and Hold" virtual power button method, which will forcable power off a server without a graceful shutdown. + + SwitchParameter + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + + WhatIf + + + + SwitchParameter + + + Confirm + + + + SwitchParameter + + + + + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + SwitchParameter + + False + + + Confirm + + + + SwitchParameter + + SwitchParameter + + + + + Force + + Use this parameter to request the "Press and Hold" virtual power button method, which will forcable power off a server without a graceful shutdown. + + SwitchParameter + + SwitchParameter + + False + + + InputObject + + A Server hardware or Server Profile resource object. + + Object + + Object + + + + + WhatIf + + + + SwitchParameter + + SwitchParameter + + + + + + + + + HPEOneView.ServerHardware [System.Management.Automation.PSCustomObject] + + + Server Hardware Resource + + + + + HPEOneView.ServerProfile [System.Management.Automation.PSCustomObject] + + + Server Profile Resource + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + Async task that tracks the power state change + + + + + System.Collections.ArrayList <HPEOneView.Appliance.TaskResource> + + + + Multiple Async tasks + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVServer -Name "Encl1, Bay 1" | Stop-OVServer | Wait-OVTaskComplete + + Power off the specific server device by passing the Server Object via pipeline. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Get-OVServerProfile -Name "MyWebServer 1" | Stop-OVServer | Wait-OVTaskComplete + + Power off the specific server device by passing the Server Profile Object via pipeline. + + + + + + + + + + -------------------------- EXAMPLE 3 -------------------------- + + + + Get-OVServer -Name "Encl1, Bay 1" | Stop-OVServer -Force | Wait-OVTaskComplete + + Power off the specific server device by passing the Server Object via pipeline, and forcably power off. + + + + + + + + + + + + + Add-OVServer + + + + Convert-OVServerProfile + + + + Convert-OVServerProfileTemplate + + + + ConvertTo-OVServerProfileTemplate + + + + Copy-OVServerProfile + + + + Get-OVServer + + + + Get-OVServerHardwareType + + + + Get-OVServerProfile + + + + Get-OVServerProfileConnectionList + + + + Get-OVServerProfileMessage + + + + Get-OVServerProfileTemplate + + + + Join-OVServerProfileToTemplate + + + + New-OVServerProfile + + + + New-OVServerProfileAssign + + + + New-OVServerProfileAttachVolume + + + + New-OVServerProfileConnection + + + + New-OVServerProfileLogicalDisk + + + + New-OVServerProfileLogicalDiskController + + + + New-OVServerProfileTemplate + + + + Remove-OVServer + + + + Remove-OVServerProfile + + + + Remove-OVServerProfileTemplate + + + + Restart-OVServer + + + + Save-OVServerProfile + + + + Save-OVServerProfileTemplate + + + + Set-OVServerHardwareType + + + + Set-OVServerPower + + + + Set-OVServerProfile + + + + Set-OVServerProfileTemplate + + + + Start-OVServer + + + + Update-OVServer + + + + Update-OVServerHardwareLicenseIntent + + + + Update-OVServerProfile + + + + Get-OVServerOneTimeBoot + + + + Set-OVServerOneTimeBoot + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/servers/stop-ovserver + + + + + + + + Test-OVApplianceAuditLogForwarding + + Generate test audit log forward message. + + Test + OVApplianceAuditLogForwarding + + + This Cmdlet will generate a syslog message to test connectivity to the appliance configured remote Syslog server. + +Minimum required privileges: Infrastructure administrator + + + + + Test-OVApplianceAuditLogForwarding + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + None. You cannot pipe objects to this Cmdlet + + + + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Test-OVApplianceAuditLogForwarding + + Generate audit log test message. + + + + + + + + + + + + + Get-OVApplianceAuditLogForwarding + + + + Set-OVApplianceAuditLogForwarding + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/test-ovapplianceauditlogforwarding + + + + + + + + Test-OVEmailAlert + + Test appliance Email Alerting configuration. + + Test + OVEmailAlert + + + This Cmdlet will generate a test email message. + + + + + Test-OVEmailAlert + + Recipients + + Specify the Sender Email Address for the appliance. + + Array + + + Subject + + Provide a custom subject for the email message. + + String + + + Body + + Provide a custom message body. Can be either a plan text or HTML message. + + String + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Body + + Provide a custom message body. Can be either a plan text or HTML message. + + String + + String + + Test email message from HPE OneView appliance. + + + Recipients + + Specify the Sender Email Address for the appliance. + + Array + + Array + + + + + Subject + + Provide a custom subject for the email message. + + String + + String + + This is a test message. + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + None. You cannot pipe objects to this Cmdlet + + + + + + + + System.Management.Automation.PSCustomObject + + + + If successful, returns an object with the test message details. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Test-OVEmailAlert -Recipients user1@contoso.com + + Generate a test email message to "user1@contoso.com". + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Test-OVEmailAlert -Recipients user1@contoso.com.,user2@contoso.com -Subject "This is a test email message." + + Generate a test email message to multiple recipients with a custom subject. + + + + + + + + + + + + + Add-OVSmtpAlertEmailFilter + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/test-ovemailalert + + + + + + + + Test-OVRemoteSupportEvent + + Initiate remote support test event. + + Test + OVRemoteSupportEvent + + + Register with Hewlett Packard Enterprise to allow automatic case creation for hardware failures on servers and enclosures and to enable Proactive Care. Once enabled, all eligible devices added in the future will be automatically enabled for remote support. + +Hewlett Packard Enterprise recommends enabling all features and benefits provided by HPE OneView Remote Support so you can receive fast, accurate 'phone home' support and service per your contractual terms with Hewlett Packard Enterprise. Hewlett Packard Enterprise securely collects your HPE IT hardware diagnostics, configuration and telemetry information to provide you with remote support and services. The data is handled and managed to respect your privacy. For more information, Hewlett Packard Enterprise's Privacy Statement can be found at http://privacy.hpe.com. + +Enabling Remote Support configures your devices being remotely supported to securely send support or service events, IT configuration information, diagnostic, and telemetry information to Hewlett Packard Enterprise, together with your support contact information. No other business information is collected and the data is managed according to the Hewlett Packard Enterprise's Privacy Statement. + +This Cmdlet will initiate a Remote Support test event for supported servers and compute modules. Remote Support must be enabled globally on the appliance in order to use this Cmdlet. Either basic connectivity (omitting -CreateTestCase parameter) or a support case (-CreateTestCase parameter) can be requested. Requesting a test event may take up to 20 minutes and will send data back to Hewlett Packard Enterprise. + +Minimum required privileges: Infrastructure administrator, Server administrator, or Server firmware operator + + + + + Test-OVRemoteSupportEvent + + InputObject + + A support server hardware resource from Get-OVServer. + + Object + + + CreateTestCase + + Request a test support caes be created during test event. + + SwitchParameter + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + ApplianceConnection + + Specify one or more HPEOneView.Appliance.Connection object(s) or Name property value(s). + +Default Value: ${Global:ConnectedSessions} | ? Default + + Object + + + + + + + ApplianceConnection + + Specify one or more HPEOneView.Appliance.Connection object(s) or Name property value(s). + +Default Value: ${Global:ConnectedSessions} | ? Default + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + SwitchParameter + + False + + + CreateTestCase + + Request a test support caes be created during test event. + + SwitchParameter + + SwitchParameter + + + + + InputObject + + A support server hardware resource from Get-OVServer. + + Object + + Object + + + + + + + + + HPEOneView.ServerHardware [System.Management.Automation.PSCustomObject] + + + Supported server hardware from Get-OVServer Cmdlet. + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + Async task resource to monitor. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Test-OVRemoteSupportEvent + + Request a remote support test event without creating a test support case. + + + + + + + + + + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/test-ovremotesupportevent + + + + + + + + Unregister-OVRemoteSupportPortalConnection + + Unregister appliance from the HPE Support Center + + Unregister + OVRemoteSupportPortalConnection + + + The Hewlett Packard Enterprise Support Center (HPESC) integration enables you to securely register the HPE OneView Remote Support client with your HPESC group. It can be a private or shared group. Registering remote support with HPESC improves case visibility for the cases originating from the client. After registration, all the group members can view the cases originating from the client. + +This feature provides an improvement over the existing contact-based access. It does not require explicit contact matching and allows you to share case content with all the HPESC group members. + +Use this Cmdlet to unregister the appliance from the HPESC. + +Minimum required privileges: + + * Infrastructure Administrator + + + + + Unregister-OVRemoteSupportPortalConnection + + ApplianceConnection + + Specify one or more HPEOneView.Appliance.Connection object(s) or Name property value(s). + +Default Value: ${Global:ConnectedSessions} | ? Default + + Object + + + WhatIf + + + + SwitchParameter + + + Confirm + + + + SwitchParameter + + + + + + + ApplianceConnection + + Specify one or more HPEOneView.Appliance.Connection object(s) or Name property value(s). + +Default Value: ${Global:ConnectedSessions} | ? Default + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Confirm + + + + SwitchParameter + + SwitchParameter + + + + + WhatIf + + + + SwitchParameter + + SwitchParameter + + + + + + + + + None. You cannot pipe objects to this cmdlet. + + + + + + + + + + + HPEOneView.Appliance.RemoteSupport.PortalConnection + + + + The current appliance secure connection status to the HPE Support Center. + + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Unregister-OVRemoteSupportPortalConnection + + + Unregister appliance with HPESC. + + + + + + + + + + + + + Get-OVRemoteSupportPortalConnectionStatus + + + + Register-OVRemoteSupportPortalConnection + + + + Online: + https://hpe-docs.gitbook.io/posh-hpeoneview/cmdlets/v9.00/appliance/unregister-ovremotesupportportalconnection + + + + + + + + Update-OVApplianceTrustedAuthorityCrl + + Update appliance certificate authority revocation list. + + Update + OVApplianceTrustedAuthorityCrl + + + HPE OneView enables users to import a CA CRL file and to perform the appropriate revocation checking on existing certificates in the trust store and for certificates received during communication with a managed device or external server. Certificate revocation checks are enabled by default. However, if a matching CRL has not been imported for a CA-issued certificate, or if a CRL has expired, the appliance bypasses the revocation check for the associated certificate when performing an HTTPS connection. If you want to restrict (or relax) revocation checking, use the options below on the edit screen. + +The Cmdlet will attempt to download the CRL from the HTTP location specified within the TrustedCertificateAuthority object. You can manually download the updated CRL and use the -Path paramter to specify the offline CRL. + + + + + Update-OVApplianceTrustedAuthorityCrl + + InputObject + + HPEOneView.Appliance.TrustedCertificateAuthority resource from Get-OVApplianceTrustedCertificate. + + HPEOneView.Appliance.TrustedCertificateAuthority[] + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + + + Update-OVApplianceTrustedAuthorityCrl + + InputObject + + HPEOneView.Appliance.TrustedCertificateAuthority resource from Get-OVApplianceTrustedCertificate. + + HPEOneView.Appliance.TrustedCertificateAuthority[] + + + Path + + Path to manually downloaded CRL. + + FileInfo + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + Array + + (${Global:ConnectedSessions} | ? Default) + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + SwitchParameter + + False + + + InputObject + + HPEOneView.Appliance.TrustedCertificateAuthority resource from Get-OVApplianceTrustedCertificate. + + HPEOneView.Appliance.TrustedCertificateAuthority[] + + HPEOneView.Appliance.TrustedCertificateAuthority[] + + + + + Path + + Path to manually downloaded CRL. + + FileInfo + + FileInfo + + + + + + + + + HPEOneView.Appliance.TrustedCertificateAuthority + + + resource from Get-OVApplianceTrustedCertificate. + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + Async task Resource object for configuring port monitoring on the requested logical intercinnect. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVApplianceTrustedCertificate -Name "VeriSign Class 3 Public Primary Certification Authority - G5" | Update-OVApplianceTrustedAuthorityCrl + + Update the built-in certificate authority resource. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + # Download CA CRL for offline use +$CA = Get-OVApplianceTrustedCertificate -CertificateAuthoritiesOnly -Name "DigiCert Global CA G2" +Invoke-WebRequest -Uri $CA.CRLInfo.EndPointList[0] -OutFile C:\Directory\CA-updated.crl + +# Copy offline CRL to other PC +Get-OVApplianceTrustedCertificate -CertificateAuthoritiesOnly -Name "DigiCert Global CA G2" | Update-OVApplianceTrustedAuthorityCrl -Path C:\Directory\CA-updated.crl + + Update the built-in certificate authority resource. + + + + + + + + + + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/update-ovappliancetrustedauthoritycrl + + + + + + + + Update-OVClusterNode + + Default content + + Update + OVClusterNode + + + Default content + + + + + Update-OVClusterNode + + InputObject + + + + Object + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + WhatIf + + + + SwitchParameter + + + Confirm + + + + SwitchParameter + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + SwitchParameter + + False + + + Confirm + + + + SwitchParameter + + SwitchParameter + + + + + InputObject + + + + Object + + Object + + + + + WhatIf + + + + SwitchParameter + + SwitchParameter + + + + + + + + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Update-OVClusterNode + + Default example + + + + + + + + + + + + + Add-OVClusterNode + + + + Add-OVClusterNodeToCluster + + + + Enter-OVClusterNodeMaintenanceMode + + + + Exit-OVClusterNodeMaintenanceMode + + + + Get-OVClusterNode + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/cluster/update-ovclusternode + + + + + + + + Update-OVClusterProfile + + Default content + + Update + OVClusterProfile + + + Default content + + + + + Update-OVClusterProfile + + InputObject + + + + Object + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + WhatIf + + + + SwitchParameter + + + Confirm + + + + SwitchParameter + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + SwitchParameter + + False + + + Confirm + + + + SwitchParameter + + SwitchParameter + + + + + InputObject + + + + Object + + Object + + + + + WhatIf + + + + SwitchParameter + + SwitchParameter + + + + + + + + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Update-OVClusterProfile + + Default example + + + + + + + + + + + + + Get-OVClusterProfile + + + + New-OVClusterProfile + + + + New-OVClusterProfileMember + + + + Remove-OVClusterProfile + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/cluster/update-ovclusterprofile + + + + + + + + Update-OVEnclosure + + Update or Refresh an enclosure. + + Update + OVEnclosure + + + This Cmdlet will update or refresh an enclosure. An Enclosure Refresh will instruct HPE OneView to go inventory the enclosure and update any missing management configurations. + +Use the -Refresh switch for scenarios where adding an enclosure results in a warning or critical error when a BL server cannot be managed due to an existing _HPOneViewAdmin account that cannot be reset or too many HP SSO Certificates are configured (iLO supports no more than 5) and you have manually cleared the HP SSO list and/or removed the _HPOneViewAdmin account. + + + + + Update-OVEnclosure + + Refresh + + Refresh the enclosure to fix configuration issues. + + SwitchParameter + + + InputObject + + Aliases [-Enclosure] +Provide the Enclosure name or Object, or [System.Collections.ArrayList] of names or Objects to refresh/update. + + Object + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Array + + + Hostname + + When an Enclosure is in an Error state where the Primary Onboard Administrator IP Address changed, or the HPE OneView managed configuration is no longer present, you will need to provide the IP Address or FQDN of one of the Onboard Administrators in the target enclosure. You will be prompted for this value if needed. + + String + + + Username + + Provide the Username of an Onboard Administrator administrator account to re-apply the configuration if the enclosure is in an error state and the HPE OneView managed configuration is no longer present. You will be prompted for this value if needed. + + String + + + Password + + Provide the password of the Onboard Administrator administrator account to re-apply the configuration if the enclosure is in an error state and the HPE OneView managed configuration is no longer present. You will be prompted for this value if needed. + + String + + + Credential + + Use this parameter if you want to provide a PSCredential object instead. + + PSCredential + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + WhatIf + + + + SwitchParameter + + + Confirm + + + + SwitchParameter + + + + Update-OVEnclosure + + Reapply + + Reapply the Enclosure Configuration. + + SwitchParameter + + + InputObject + + Aliases [-Enclosure] +Provide the Enclosure name or Object, or [System.Collections.ArrayList] of names or Objects to refresh/update. + + Object + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Array + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + WhatIf + + + + SwitchParameter + + + Confirm + + + + SwitchParameter + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Array + + Array + + (${Global:ConnectedSessions} | ? Default) + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + SwitchParameter + + False + + + Confirm + + + + SwitchParameter + + SwitchParameter + + + + + Credential + + Use this parameter if you want to provide a PSCredential object instead. + + PSCredential + + PSCredential + + + + + Hostname + + When an Enclosure is in an Error state where the Primary Onboard Administrator IP Address changed, or the HPE OneView managed configuration is no longer present, you will need to provide the IP Address or FQDN of one of the Onboard Administrators in the target enclosure. You will be prompted for this value if needed. + + String + + String + + + + + InputObject + + Aliases [-Enclosure] +Provide the Enclosure name or Object, or [System.Collections.ArrayList] of names or Objects to refresh/update. + + Object + + Object + + + + + Password + + Provide the password of the Onboard Administrator administrator account to re-apply the configuration if the enclosure is in an error state and the HPE OneView managed configuration is no longer present. You will be prompted for this value if needed. + + String + + String + + + + + Reapply + + Reapply the Enclosure Configuration. + + SwitchParameter + + SwitchParameter + + False + + + Refresh + + Refresh the enclosure to fix configuration issues. + + SwitchParameter + + SwitchParameter + + False + + + Username + + Provide the Username of an Onboard Administrator administrator account to re-apply the configuration if the enclosure is in an error state and the HPE OneView managed configuration is no longer present. You will be prompted for this value if needed. + + String + + String + + + + + WhatIf + + + + SwitchParameter + + SwitchParameter + + + + + + + + + System.Management.Automation.PSCustomObject + + + Single Enclosure resource + + + + + System.Collections.ArrayList + + + Multiple Enclosure resources + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + Async task Resource object for monitoring the enclosure import process + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVEnclosure | Update-OVEnclosure -Refresh + + Refresh all available enclosures, from all connected sessions. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Get-OVEnclosure -Name Enclosure1 | Update-OVEnclosure -Refresh + + Refresh "Enclosure1" enclosure. + + + + + + + + + + -------------------------- EXAMPLE 3 -------------------------- + + + + $TaskResourceToMonitor = Get-OVEnclosure -Name Enclosure1 | Update-OVEnclosure -Refresh -Hostname UpdatedOAFQDN.domain.local -Username Administrator -Password MyOAPassw0rd -Async + + Refresh "Enclosure1" enclosure, supplying the updated OA FQDN and administrator credentials + + + + + + + + + + + + + Add-OVEnclosure + + + + Get-OVEnclosure + + + + Get-OVEnclosureGroup + + + + New-OVEnclosureGroup + + + + Remove-OVEnclosure + + + + Remove-OVEnclosureGroup + + + + Reset-OVEnclosureDevice + + + + Set-OVEnclosure + + + + Set-OVEnclosureActiveFLM + + + + Set-OVEnclosureGroup + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/servers/update-ovenclosure + + + + + + + + Update-OVExternalRepository + + Refresh an existing external baseline repository. + + Update + OVExternalRepository + + + A firmware repository enables you to store firmware bundles and deploy them across your environment. An externally managed HTTP/HTTPS web server can be added to the appliance as a repository. It is a user-maintained HTTP/HTTPS web server. You can upload firmware bundles in a specific directory and then register the HTTP/HTTPS server with HPE OneView. This functionality is supported for Linux and Windows systems. + +The recommended types of external web servers to use with the repository follow: + + * Apache + * Internet Information Services (IIS) + +NOTE: Only one external repository can be added. + +This Cmdlet supports refreshing an existing external repository. Use this Cmdlet to refresh the details(advertized repo size) and contents of an external repository. + + + + + Update-OVExternalRepository + + InputObject + + Provide the external repository object to refresh. + + Object + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + WhatIf + + + + + + + Confirm + + + + + + + + Update-OVExternalRepository + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + + WhatIf + + + + + + + Confirm + + + + + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + Array + + (${Global:ConnectedSessions} | ? Default) + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + SwitchParameter + + + + + Confirm + + + + + + + + + + + InputObject + + Provide the external repository object to refresh. + + Object + + Object + + + + + WhatIf + + + + + + + + + + + + + + + HPEOneView.Appliance.BaselineRepository [System.Management.Automation.PSCustomObject] + + + The external repository object from Get-OVBaselineRepository + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + The async task for the caller to monitor. + + + + + System.Collections.ArrayList <HPEOneView.Appliance.TaskResource> + + + + Multiple async task resource objects. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVBaselineRepository -Name MyRepoName -ErrorAction Stop | Update-OVExternalRepository + + Refresh an existing external repository. + + + + + + + + + + + + + New-OVExternalRepository + + + + Remove-OVExternalRepository + + + + Set-OVExternalRepository + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/update-ovexternalrepository + + + + + + + + Update-OVLogicalEnclosure + + Update or Refresh a Logical Enclosure. + + Update + OVLogicalEnclosure + + + This Cmdlet will update or refresh a Logical Enclosure. A Refresh will instruct HPE OneView to go inventory the enclosure and update any missing management configurations. An Update will perform Logical Enclosure compliance remediation with the parent Enclosure Group. + +Use the -Refresh switch for scenarios where adding an enclosure results in a warning or critical error when a BL server cannot be managed due to an existing _HPOneViewAdmin account that cannot be reset or too many HP SSO Certificates are configured (iLO supports no more than 5) and you have manually cleared the HP SSO list and/or removed the _HPOneViewAdmin account. + + + + + Update-OVLogicalEnclosure + + Reapply + + Reapply the Enclosure Configuration. + + SwitchParameter + + + InputObject + + Provide the Logical Enclosure name, URI or Object, or [System.Collections.ArrayList ] of names, URIs or Objects to refresh/update. + + Object + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Array + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + WhatIf + + Use this parameter to identify what is different or changed from the parent group policy. + + SwitchParameter + + + Confirm + + + + SwitchParameter + + + + Update-OVLogicalEnclosure + + Update + + Useing this switch will update the Logical Enclosure to be compliant with the Parent Enclosure Group. Can be combined with the -WhatIf parameter to perform a Compare with group and return object with differences. + + SwitchParameter + + + InputObject + + Provide the Logical Enclosure name, URI or Object, or [System.Collections.ArrayList ] of names, URIs or Objects to refresh/update. + + Object + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Array + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + WhatIf + + Use this parameter to identify what is different or changed from the parent group policy. + + SwitchParameter + + + Confirm + + + + SwitchParameter + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Array + + Array + + (${Global:ConnectedSessions} | ? Default) + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + SwitchParameter + + False + + + Confirm + + + + SwitchParameter + + SwitchParameter + + + + + InputObject + + Provide the Logical Enclosure name, URI or Object, or [System.Collections.ArrayList ] of names, URIs or Objects to refresh/update. + + Object + + Object + + + + + Reapply + + Reapply the Enclosure Configuration. + + SwitchParameter + + SwitchParameter + + False + + + Update + + Useing this switch will update the Logical Enclosure to be compliant with the Parent Enclosure Group. Can be combined with the -WhatIf parameter to perform a Compare with group and return object with differences. + + SwitchParameter + + SwitchParameter + + False + + + WhatIf + + Use this parameter to identify what is different or changed from the parent group policy. + + SwitchParameter + + SwitchParameter + + + + + + + + + HPEOneView.LogicalEnclosure [System.Management.Automation.PSCustomObject] + + + Single Logical Enclosure resource + + + + + System.Collections.ArrayList + + + Multiple Logical Enclosure resources + + + + + HPEOneView.Library.CompareObject + + + The Cmdlet will return a compare object with the Parent and Child object and settings that are different. Otherwise, no object is returned. + + Property Name | Description + ========================================================== + InputObject | Compared Object Property or Setting Value + ---------------------------------------------------------- + ParentSetting | Name of Property or Setting + ---------------------------------------------------------- + ChildSetting | Name of Property or Setting + ---------------------------------------------------------- + Parent | Name of Parent Object + ---------------------------------------------------------- + Child | Name of Child Object + ---------------------------------------------------------- + Description | Description Name of difference + ---------------------------------------------------------- + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + Async task Resource object for monitoring the enclosure import process + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVLogicalEnclosure | Update-OVLogicalEnclosure -Refresh + + Refresh all available Logical Enclosures, for the default connected session. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Get-OVLogicalEnclosure -ApplianceConnect $ConnectedSessions | Update-OVLogicalEnclosure -Update + + Refresh all available Logical Enclosures, for the all connected sessions. + + + + + + + + + + -------------------------- EXAMPLE 3 -------------------------- + + + + Get-OVLogicalEnclosure -Name LogicalEnclosure1 | Update-OVLogicalEnclosure -Refresh + + Refresh "LogicalEnclosure1" Logical Enclosure. + + + + + + + + + + -------------------------- EXAMPLE 4 -------------------------- + + + + Get-OVLogicalEnclosure -Name Encl1 | Update-OVLogicalEnclosure -Update -WhatIf +What if: Performing the operation "Update Logical Enclosure configuration. WARNING: Depending on this action, there might be a brief outage." on target "Encl1". + +InputObject SideIndicator ParentSetting ChildSetting Parent Child Description +----------- ------------- ------------- ------------ ------ ----- ----------- +macRefreshInterval <=> 7 5 Default VC FF LIG Encl1-Default VC FF LIG SETTING_MISMATCH +enablePauseFloodProtection <=> False True Default VC FF LIG Encl1-Default VC FF LIG SETTING_MISMATCH +enableRichTLV <=> True False Default VC FF LIG Encl1-Default VC FF LIG SETTING_MISMATCH +enableTaggedLldp <=> True False Default VC FF LIG Encl1-Default VC FF LIG SETTING_MISMATCH +ActiveQosConfig <= CustomWithFCoE Passthrough Default VC FF LIG Encl1-Default VC FF LIG SETTING_MISMATCH +Uplink Set 2 <= Heartbeat Default VC FF LIG Encl1-Default VC FF LIG MISSING_NETWORK +FC Fabric B => Bay2:X8 Default VC FF LIG Encl1-Default VC FF LIG ADDITIONAL_UPLINKPORT +FC Fabric B:Bay2:X7 <=> Auto 2Gb Default VC FF LIG Encl1-Default VC FF LIG LINKSPEED_MISMATCH +UplinkSets <= New Uplink Set Default VC FF LIG Encl1-Default VC FF LIG MISSING_UPLINKSET +InternalNetworks => Heartbeat Default VC FF LIG Encl1-Default VC FF LIG EXTRA_NETWORK +InternalNetworks <= Dev VLAN 103-A Default VC FF LIG Encl1-Default VC FF LIG MISSING_NETWORK + + Refresh "LogicalEnclosure1" Logical Enclosure. + + + + + + + + + + + + + Get-OVLogicalEnclosure + + + + New-OVLogicalEnclosure + + + + Remove-OVLogicalEnclosure + + + + Set-OVLogicalEnclosure + + + + Update-OVLogicalEnclosureFirmware + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/servers/update-ovlogicalenclosure + + + + + + + + Update-OVLogicalEnclosureFirmware + + Initiate Logical Enclosure Firmware update. + + Update + OVLogicalEnclosureFirmware + + + You can update firmware from a logical enclosure for shared infrastructure, shared infrastructure and profiles, and OA (Onboard Administrators) only, if any. When you update the firmware for an enclosure associated with a logical enclosure, the firmware baseline configured for the logical enclosure sets the baseline on the enclosure and each of the logical interconnects in the enclosure, as well as the OA. Firmware is updated in the following order: + + * Onboard Administrators + * Logical interconnects + * Server hardware and their associated server profiles The Orchestrated activation option allows nondisruptive updates of interconnects in a production ready, properly configured, and redundant environment. Orchestrated firmware updates do not affect the network traffic and no outages are caused while the update process is in progress as one virtual connect module is always forwarding network traffic, with no or minimal impact to application network connection. A default delay of 8 minutes is set between activating or rebooting interconnect modules. Hypervisor clusters are updated nondisruptively when the orchestrated activation option is chosen. If the logical enclosure contains one or more hypervisor profiles, each hypervisor is serially placed into a maintenance mode before updating. It can take up to 90 minutes to place a hypervisor into the maintenance mode, perform the firmware update, and take it back out of the maintenance mode. Parallel activation activates all the interconnect modules at the same time, resulting in disruption of the network and storage connectivity. It is recommended to perform parallel activation during a maintenance window when you can better coordinate the downtime. When selecting "SharedInfrastructureAndServerProfiles" firmware update process, any servers without profiles will perform an automated offline firmware update. Assigned Server Profiles will require HPE Smart Update Tools (HPSUT, iSUT) to be installed and available. Minimum required privileges: Infrastructure administrator or Server administrator + + + + + Update-OVLogicalEnclosureFirmware + + InputObject + + The HPEOneView.LogicalEnclosure from Get-OVLogicalEnclosure. + + Object + + + Baseline + + The firmware bundle or baseline to install. + + HPEOneView.Appliance.Baseline + + + FirmwareUpdateProcess + + Specify the type of firmware update to invoke. Allowed values: + + * EnclosureOnly - Will only upgrade enclosure or frame components (c-Class Onboard Administrator, Synergy Frame Link Module) + * SharedInfrastructureOnly + * SharedInfrastructureAndServerProfiles + + String + + + InterconnectActivationMode + + Specify the logical interconnect activation mode. Choosing "Parallel" is the fastest update operation but will require downtime and servers to be powered off. Allowed values: + + * Orchestrated + * Parallel Default: Orchestrated + + String + + + ForceInstallation + + Force the re-installation or downgrade of components within the baseline. + + SwitchParameter + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + + WhatIf + + + + + + + Confirm + + + + + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + Array + + (${Global:ConnectedSessions} | ? Default) + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + SwitchParameter + + False + + + Baseline + + The firmware bundle or baseline to install. + + HPEOneView.Appliance.Baseline + + HPEOneView.Appliance.Baseline + + + + + Confirm + + + + + + + + + + + FirmwareUpdateProcess + + Specify the type of firmware update to invoke. Allowed values: + + * EnclosureOnly - Will only upgrade enclosure or frame components (c-Class Onboard Administrator, Synergy Frame Link Module) + * SharedInfrastructureOnly + * SharedInfrastructureAndServerProfiles + + String + + String + + + + + ForceInstallation + + Force the re-installation or downgrade of components within the baseline. + + SwitchParameter + + SwitchParameter + + + + + InputObject + + The HPEOneView.LogicalEnclosure from Get-OVLogicalEnclosure. + + Object + + Object + + + + + InterconnectActivationMode + + Specify the logical interconnect activation mode. Choosing "Parallel" is the fastest update operation but will require downtime and servers to be powered off. Allowed values: + + * Orchestrated + * Parallel Default: Orchestrated + + String + + String + + + + + WhatIf + + + + + + + + + + + + + + + HPEOneView.LogicalEnclosure [System.Management.Automation.PSCustomObject] + + + Logical enclosure resource from Get-OVLogicalEnclosure. + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + Async task Resource object for configuring port monitoring on the requested logical intercinnect. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + $Basline = Get-OVBaseline -Name "HPE Service Pack for ProLiant" -ErrorAction Stop Get-OVLogicalEnclosure -Name Encl1 -ErrorAction Stop | Update-OVLogicalEnclosureFirmware -Baseline $Basline -FirmwareUpdateProcess SharedInfrastructureOnly + + Get the specified baseline, and update the specified logical enclosure's shared infrastructure only. + + + + + + + + + + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/networking/update-ovlogicalenclosurefirmware + + + + + + + + Update-OVLogicalInterconnect + + Updates a Logical Interconnect. + + Update + OVLogicalInterconnect + + + When a Logical Interconnect is inconsistent with its parent Logical Interconnect Group, it can be made consistent with this Cmdlet. Updating the Logical Interconnect with its parent could cause an network outage depending on the changes about to be applied. + + + + + Update-OVLogicalInterconnect + + InputObject + + The Logical Interconnect object(s), name(s) or uris(s) to be updated. + + Object + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + + WhatIf + + Use this parameter to identify what is different or changed from the parent group policy. + + SwitchParameter + + + Confirm + + + + SwitchParameter + + + + Update-OVLogicalInterconnect + + FactoryReset + + Use to factory reset the HPE Synergy Fabric module. Do know that an outage will happen while the fabric modules are reset. Their configuration will need to be re-applied or deployed after task has completed. + + SwitchParameter + + + InputObject + + The Logical Interconnect object(s), name(s) or uris(s) to be updated. + + Object + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + + WhatIf + + Use this parameter to identify what is different or changed from the parent group policy. + + SwitchParameter + + + Confirm + + + + SwitchParameter + + + + Update-OVLogicalInterconnect + + Reapply + + Switch to reapply the Logical Interconnect configuration. This does NOT update the Logical Interconnect from the parent Logical Interconnect Group. + + SwitchParameter + + + InputObject + + The Logical Interconnect object(s), name(s) or uris(s) to be updated. + + Object + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + + WhatIf + + Use this parameter to identify what is different or changed from the parent group policy. + + SwitchParameter + + + Confirm + + + + SwitchParameter + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Confirm + + + + SwitchParameter + + SwitchParameter + + + + + FactoryReset + + Use to factory reset the HPE Synergy Fabric module. Do know that an outage will happen while the fabric modules are reset. Their configuration will need to be re-applied or deployed after task has completed. + + SwitchParameter + + SwitchParameter + + + + + InputObject + + The Logical Interconnect object(s), name(s) or uris(s) to be updated. + + Object + + Object + + + + + Reapply + + Switch to reapply the Logical Interconnect configuration. This does NOT update the Logical Interconnect from the parent Logical Interconnect Group. + + SwitchParameter + + SwitchParameter + + False + + + WhatIf + + Use this parameter to identify what is different or changed from the parent group policy. + + SwitchParameter + + SwitchParameter + + + + + + + + + HPEOneView.Networking.LogicalInterconnect [System.Management.Automation.PSCustomObject] + + + Single Logical Interconnect resource object + + + + + System.Collections.ArrayList <HPEOneView.Networking.LogicalInterconnect> + + + Collection of Logical Interconnect Names, URIs or System.Management.Automation.PSCustomObject + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + Single async Update Task + + + + + System.Collections.ArrayList <HPEOneView.Appliance.TaskResource> + + + + Multiple async Update Tasks + + + + + HPEOneView.Library.CompareObject + + + + The Cmdlet will return a compare object with the Parent and Child object and settings that are different. Otherwise, no object is returned. + + Property Name | Description + ========================================================== + InputObject | Compared Object Property or Setting Value + ---------------------------------------------------------- + ParentSetting | Name of Property or Setting + ---------------------------------------------------------- + ChildSetting | Name of Property or Setting + ---------------------------------------------------------- + Parent | Name of Parent Object + ---------------------------------------------------------- + Child | Name of Child Object + ---------------------------------------------------------- + Description | Description Name of difference + ---------------------------------------------------------- + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + $task = Update-OVLogicalInterconnect -name Encl1-LI +Wait-OVTaskComplete $task + + + Perform an update of the Encl1-LI Logical Interconnect. Will be prompted for confirmation. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + $task = Update-OVLogicalInterconnect -name Encl1-LI -confirm:$false | Wait-OVTaskComplete + + Perform an update of the Encl1-LI Logical Interconnect. Disable confirmation prompt. + + + + + + + + + + -------------------------- EXAMPLE 3 -------------------------- + + + + Get-OVLogicalInterconnect | Update-OVLogicalInterconnect + + Search for all Logical Interconnects and update them. + + + + + + + + + + -------------------------- EXAMPLE 4 -------------------------- + + + + Get-OVLogicalInterconnect -Name Encl1-Default VC FF LIG | Update-OVLogicalInterconnect -WhatIf +What if: Performing the operation "Update Logical Interconnect from Group "Default VC FF LIG". WARNING: Depending on the Update, there might be a brief outage." on target "Encl1-Default VC FF LIG". + +InputObject SideIndicator ParentSetting ChildSetting Parent Child Description +----------- ------------- ------------- ------------ ------ ----- ----------- +macRefreshInterval <=> 7 5 Default VC FF LIG Encl1-Default VC FF LIG SETTING_MISMATCH +enablePauseFloodProtection <=> False True Default VC FF LIG Encl1-Default VC FF LIG SETTING_MISMATCH +enableRichTLV <=> True False Default VC FF LIG Encl1-Default VC FF LIG SETTING_MISMATCH +enableTaggedLldp <=> True False Default VC FF LIG Encl1-Default VC FF LIG SETTING_MISMATCH +ActiveQosConfig <= CustomWithFCoE Passthrough Default VC FF LIG Encl1-Default VC FF LIG SETTING_MISMATCH +Uplink Set 2 <= Heartbeat Default VC FF LIG Encl1-Default VC FF LIG MISSING_NETWORK +FC Fabric B => Bay2:X8 Default VC FF LIG Encl1-Default VC FF LIG ADDITIONAL_UPLINKPORT +FC Fabric B:Bay2:X7 <=> Auto 2Gb Default VC FF LIG Encl1-Default VC FF LIG LINKSPEED_MISMATCH +UplinkSets <= New Uplink Set Default VC FF LIG Encl1-Default VC FF LIG MISSING_UPLINKSET +InternalNetworks => Heartbeat Default VC FF LIG Encl1-Default VC FF LIG EXTRA_NETWORK +InternalNetworks <= Dev VLAN 103-A Default VC FF LIG Encl1-Default VC FF LIG MISSING_NETWORK + + Refresh "LogicalEnclosure1" Logical Enclosure. + + + + + + + + + + + + + Disable-OVLogicalInterconnectPortMonitoring + + + + Enable-OVLogicalInterconnectPortMonitoring + + + + Get-OVLogicalInterconnect + + + + Get-OVLogicalInterconnectGroup + + + + Get-OVLogicalInterconnectPortMonitoring + + + + Install-OVLogicalInterconnectFirmware + + + + New-OVLogicalInterconnectGroup + + + + Remove-OVLogicalInterconnectGroup + + + + Show-OVLogicalInterconnectMacTable + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/networking/update-ovlogicalinterconnect + + + + + + + + Update-OVLogicalSwitch + + Refresh a new Logical Switch resource. + + Update + OVLogicalSwitch + + + A logical switch is based on a logical switch group configuration. If the logical switch transitions to an "Inconsistent with group state", due to changes in either the logical switch or the logical switch group, this Cmdlet will update (or refresh) the logical switch configuration based on the logical switch group and return to a consistent state. Minimum required privileges: Infrastructure administrator or Network administrator + + + + + Update-OVLogicalSwitch + + InputObject + + The Logical Switch resource Name or Object to update. + + Object + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + WhatIf + + + + + + + Confirm + + Bypass the confirmation prompt, and process all of the objects. + + SwitchParameter + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + SwitchParameter + + + + + Confirm + + Bypass the confirmation prompt, and process all of the objects. + + SwitchParameter + + SwitchParameter + + + + + InputObject + + The Logical Switch resource Name or Object to update. + + Object + + Object + + + + + WhatIf + + + + + + + + + + + + + + + HPEOneView.Networking.LogicalSwitch [System.Management.Automation.PSCustomObject] + + + Logical Switch resource. + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + The async task resource object to monitor (if -Async was used) or results. + + + + + System.Collections.ArrayList <HPEOneView.Appliance.TaskResource> + + + + Collection of Update Logical Switch async task resources. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVLogicalSwitch | Update-OVLogicalSwitch + + Update all logical switch resources found on the default appliance connection. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Get-OVLogicalSwitch -Name "My Logical Switch 1" | Update-OVLogicalSwitch -confirm:$false + + Update the "My Logical Switch 1" resource. + + + + + + + + + + + + + Get-OVLogicalSwitch + + + + Get-OVLogicalSwitchGroup + + + + New-OVLogicalSwitch + + + + New-OVLogicalSwitchGroup + + + + Remove-OVLogicalSwitch + + + + Remove-OVLogicalSwitchGroup + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/networking/update-ovlogicalswitch + + + + + + + + Update-OVRackManager + + Refresh or reconnect a rack manager resource. + + Update + OVRackManager + + + A rack manager platform is a multinode system. The nodes are housed within a rack or across racks, and are centrally managed by a management controller. The Rack Managers screen enables you to manage and visualize the physical location of rack manager platforms within a rack. This Cmdlet will perform a refresh of the claimed rack manager. If there is a communication issue, the -Hostname and -Crednetial parameters will need to be provided, which will then re-establish communication to the rack manager. Minimum required privileges: Infrastructure administrator or Server administrator. + + + + + Update-OVRackManager + + InputObject + + The HPEOneView.Servers.RackManager resource to refresh. + + HPEOneView.Servers.RackManager[] + + + Force + + ****WARNING**** +Please use with caution. Using this parameter will force delete a resource for any reason and cannot be undone. + +Force update the resource. + + SwitchParameter + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + + + Update-OVRackManager + + InputObject + + The HPEOneView.Servers.RackManager resource to refresh. + + HPEOneView.Servers.RackManager[] + + + Hostname + + The FQDN or IP Address of the rack manager. + + String + + + Credential + + Use this parameter if you want to provide a PSCredential object instead. + + PSCredential + + + Force + + ****WARNING**** +Please use with caution. Using this parameter will force delete a resource for any reason and cannot be undone. + +Force update the resource. + + SwitchParameter + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + + Update-OVRackManager + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Array + + Array + + (${Global:ConnectedSessions} | ? Default) + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + SwitchParameter + + False + + + Credential + + Use this parameter if you want to provide a PSCredential object instead. + + PSCredential + + PSCredential + + + + + Force + + ****WARNING**** +Please use with caution. Using this parameter will force delete a resource for any reason and cannot be undone. + +Force update the resource. + + SwitchParameter + + SwitchParameter + + + + + Hostname + + The FQDN or IP Address of the rack manager. + + String + + String + + + + + InputObject + + The HPEOneView.Servers.RackManager resource to refresh. + + HPEOneView.Servers.RackManager[] + + HPEOneView.Servers.RackManager[] + + + + + + + + + HPEOneView.Servers.RackManager + + + The rack manager resource from Get-OVRackManager. + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + Async task Resource object for configuring port monitoring on the requested logical intercinnect. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVRackManager -Name rackmanager1.domain.com -ErrorAction Stop | Update-OVRackManager + + Refresh the specified rack manager resource. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + $RackManager = Get-OVRackManager -Name rackmanager1.domain.com -ErrorAction Stop $Credential = Get-Credential Administrator -Message "Password" $RefreshParams = @{ InputObject = $RackManager} +# Check the rack manager for its state and refresh state reason if ($RackManager.State -eq 'Unmanaged' -and $RackManager.RefreshState -eq 'RefreshFailed') { # Add the "Credential" parameter to the Hashtable splat $RackManager.Add("Credential", $Credential) + # Add the Hostname to the Hashtable splat $RackManager.Add("Hostname", $RackManager.SubResources.Managers[0].Hostname) } Update-OVRackManager @RefreshParams + + Refresh the specified rack manager resource, and provide the credentials to restablish. + + + + + + + + + + + + + Add-OVRackManager + + + + Get-OVRackManager + + + + Remove-OVRackManager + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/servers/update-ovrackmanager + + + + + + + + Update-OVRemoteSupportEntitlement + + Refresh Remote Support entitlement for a supported resource. + + Update + OVRemoteSupportEntitlement + + + This Cmdlet will initiate a refresh of the Remote Support entitlement for a compute or enclosure resource. If remote support has not been globally enabled and configured on the appliance, this Cmdlet will fail. + + + + + Update-OVRemoteSupportEntitlement + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + SwitchParameter + + False + + + + + + + HPEOneView.ServerHardware [System.Management.Automation.PSCustomObject] + + + A Gen8 or newer generation server hardware resource object from Get-OVServer. + + + + + HPEOneView.Enclosure [System.Management.Automation.PSCustomObject] + + + A Gen8 or newer generation server hardware resource object from Get-OVServer. + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + Async task Resource object for monitoring. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVServer -Name Prod* | Update-OVRemoteSupportEntitlement + + Get the servers with their name matching "Prod" and refresh their Remote Support entitlement. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + $Enclosure = Get-OVEnclosure -Name Enclosure-1A +Update-OVRemoteSupportEntitlement -InputObject $Enclusre + + Get the specific enclosure resource and refresh Remote Support entitlement. + + + + + + + + + + + + + Get-OVRemoteSupportEntitlementStatus + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/update-ovremotesupportentitlement + + + + + + + + Update-OVSanManager + + Refresh SAN Manager and it"s configuration. + + Update + OVSanManager + + + This Cmdlet is used to refresh a SAN Managers configuration. You can provide the Name or Object of a single or multiple SAN Managers. + + + + + Update-OVSanManager + + InputObject + + Managed SAN Object to update. + + Object + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + InputObject + + Managed SAN Object to update. + + Object + + Object + + + + + + + + + HPEOneView.Storage.SanManager [System.Management.Automation.PSCustomObject] + + + SAN Manager resource object from Get-OVSanManager + + + + + System.Collections.ArrayList <HPEOneView.Storage.SanManager> + + + Multiple SAN Manager resource objects from Get-OVSanManager + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + Async Task to update SAN Manager + + + + + System.Collections.ArrayList <HPEOneView.Appliance.TaskResource> + + + + Single or Multiple Resources + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVSanManager -name bna.contoso.com | Update-OVSanManager | Wait-OVTaskComplete + + Refreshes the SAN Manager. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Get-OVSanManager | Update-OVSanManager | Wait-OVTaskComplete + + Refreshes all SAN Managers on the appliance. + + + + + + + + + + + + + Add-OVSanManager + + + + Get-OVSanManager + + + + Remove-OVSanManager + + + + Set-OVSanManager + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/storage/update-ovsanmanager + + + + + + + + Update-OVServer + + Refresh the state of a server resource. + + Update + OVServer + + + By using this Cmdlet, you can manually refresh the connection between the appliance and server hardware by using the Refresh option on the Actions menu. You must refresh server hardware if it has lost connectivity or if it is not synchronized with the appliance. Connectivity loss can occur during normal appliance operation. A device can become unsynchronized if you make changes to it outside of the appliance + + + + + Update-OVServer + + InputObject + + The Server object or Name, or can be a Server Profile object. + + Object + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + + + Update-OVServer + + InputObject + + The Server object or Name, or can be a Server Profile object. + + Object + + + Credential + + Provide a PSCredential object instead of the Username and Password. + + String + + + Hostname + + When a server hardware resource is in an Error state where the iLO IP Address or FQDN has changed, or the HPE OneView managed configuration is no longer present, you will need to provide the IP Address or FQDN. + + String + + + Force + + If the target server resource is repoting to be claimed by another external manager, use this parameter to force claim from the connected appliance. + + SwitchParameter + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + + + + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + SwitchParameter + + False + + + Credential + + Provide a PSCredential object instead of the Username and Password. + + String + + String + + + + + Force + + If the target server resource is repoting to be claimed by another external manager, use this parameter to force claim from the connected appliance. + + SwitchParameter + + SwitchParameter + + + + + Hostname + + When a server hardware resource is in an Error state where the iLO IP Address or FQDN has changed, or the HPE OneView managed configuration is no longer present, you will need to provide the IP Address or FQDN. + + String + + String + + + + + InputObject + + The Server object or Name, or can be a Server Profile object. + + Object + + Object + + + + + + + + + System.String + + + Server Hardware Name + + + + + System.Management.Automation.PSCustomObject + + + Server Hardware Resource + + + + + System.Management.Automation.PSCustomObject + + + Server Profile Resource + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + Async task that tracks the server refresh request + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVServer -Name "Encl1, Bay 1" | Update-OVServer | Wait-OVTaskComplete + + Refresh the state of the provided server hardware device. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + $task = Get-OVServerProfile -Name "Profile1" | Update-OVServer + + Refresh the state of the server hardware device assigned to the Server Profile object. + + + + + + + + + + + + + Add-OVServer + + + + Convert-OVServerProfile + + + + Convert-OVServerProfileTemplate + + + + ConvertTo-OVServerProfileTemplate + + + + Copy-OVServerProfile + + + + Get-OVServer + + + + Get-OVServerHardwareType + + + + Get-OVServerProfile + + + + Get-OVServerProfileConnectionList + + + + Get-OVServerProfileMessage + + + + Get-OVServerProfileTemplate + + + + Join-OVServerProfileToTemplate + + + + New-OVServerProfile + + + + New-OVServerProfileAssign + + + + New-OVServerProfileAttachVolume + + + + New-OVServerProfileConnection + + + + New-OVServerProfileLogicalDisk + + + + New-OVServerProfileLogicalDiskController + + + + New-OVServerProfileTemplate + + + + Remove-OVServer + + + + Remove-OVServerProfile + + + + Remove-OVServerProfileTemplate + + + + Restart-OVServer + + + + Save-OVServerProfile + + + + Save-OVServerProfileTemplate + + + + Set-OVServerHardwareType + + + + Set-OVServerPower + + + + Set-OVServerProfile + + + + Set-OVServerProfileTemplate + + + + Start-OVServer + + + + Stop-OVServer + + + + Update-OVServerHardwareLicenseIntent + + + + Update-OVServerProfile + + + + Get-OVServerOneTimeBoot + + + + Set-OVServerOneTimeBoot + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/servers/update-ovserver + + + + + + + + Update-OVServerFirmware + + Install SPP baseline to server hardware. + + Update + OVServerFirmware + + + A firmware bundle is a comprehensive collection of firmware and system software components that enable you to update the firmware of the devices managed by the appliance. The firmware bundle includes drivers, agents, utilities, and firmware packages. Deploying a firmware bundle (SPP) to a server hardware resource is only supported with Gen10 or newer server platforms, excluding HPE Synergy and Superdome Flex partitions. + +Supported servers must not have an assigned server profile, and only supports Gen10 and newer volume servers (not HPE Synergy). Installing a supported firmware bundle requires either an HPE iLO Advanced, HPE OneView Advanced or HPE OneView Advanced without iLO Advanced license. + +The following installation modes are supported: + +* FirmwareAndOSDrivers or FirmwareAndSoftware - Updates the firmware and OS drivers without powering down the server hardware using Smart Update Tool. +* FirmwareOnly - Updates the firmware without powering down the server hardware using Smart Update Tool. +* FirmwareOnlyOfflineMode or FirmwareOffline - Manages the firmware through HPE OneView. Selecting this option requires the server hardware to be powered down. + +Minimum required privileges: Infrastructure administrator or Server administrator or Server firmware operator + + + + + Update-OVServerFirmware + + InputObject + + Server hardware resource from Get-OVServer. + + Object + + + Baseline + + Baseline object from Get-OVBaseline. + +Examples: + +$FileName = "bp-hp-service-pack-for-proliant-oneview-2014-11-30-05.iso" +$Name = "HPE Service Pack For ProLiant OneView 2014 11 13" + + Object + + + PatchLevel + + The patch or supplement to the Update Bundle. Within the Update Bundle contains a property called Supplements ([Array] of [System.Version]). + + System.Version + + + FirmwareInstallationPolicy + + Select the installation policy for the firmware bundle. Allowed values: + + * LowerThanBaseline (Default) - Updates only the components with an installed version lower than the firmware baseline version. + * NotEqualToBaseline - Updates or downgrades components whose installed version does not match the firmware baseline version. + + String + + + FirmwareInstallMode + + Specify the Firmware Baseline Policy mode. Avialable options are: + + * FirmwareOnly - Updates the system firmware without powering down the server hardware using using HP Smart Update Tools. + * FirmwareAndSoftware - Updates the firmware and OS drivers without powering down the server hardware using HP Smart Update Tools. + * FirmwareOffline - Manages the firmware through HPE OneView. Selecting this option requires the server hardware to be powered down. + + String + + + ReinstallFirmware + + Option to reinstall the components that already match the firmware baseline. + + SwitchParameter + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + ApplianceConnection + + Specify one or more HPEOneView.Appliance.Connection object(s) or Name property value(s). + +Default Value: ${Global:ConnectedSessions} | ? Default + + Object + + + + + + + ApplianceConnection + + Specify one or more HPEOneView.Appliance.Connection object(s) or Name property value(s). + +Default Value: ${Global:ConnectedSessions} | ? Default + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + SwitchParameter + + False + + + Baseline + + Baseline object from Get-OVBaseline. + +Examples: + +$FileName = "bp-hp-service-pack-for-proliant-oneview-2014-11-30-05.iso" +$Name = "HPE Service Pack For ProLiant OneView 2014 11 13" + + Object + + Object + + + + + FirmwareInstallMode + + Specify the Firmware Baseline Policy mode. Avialable options are: + + * FirmwareOnly - Updates the system firmware without powering down the server hardware using using HP Smart Update Tools. + * FirmwareAndSoftware - Updates the firmware and OS drivers without powering down the server hardware using HP Smart Update Tools. + * FirmwareOffline - Manages the firmware through HPE OneView. Selecting this option requires the server hardware to be powered down. + + String + + String + + FirmwareAndSoftware + + + FirmwareInstallationPolicy + + Select the installation policy for the firmware bundle. Allowed values: + + * LowerThanBaseline (Default) - Updates only the components with an installed version lower than the firmware baseline version. + * NotEqualToBaseline - Updates or downgrades components whose installed version does not match the firmware baseline version. + + String + + String + + + + + InputObject + + Server hardware resource from Get-OVServer. + + Object + + Object + + + + + PatchLevel + + The patch or supplement to the Update Bundle. Within the Update Bundle contains a property called Supplements ([Array] of [System.Version]). + + System.Version + + System.Version + + + + + ReinstallFirmware + + Option to reinstall the components that already match the firmware baseline. + + SwitchParameter + + SwitchParameter + + + + + + + + + HPEOneView.ServerHardware [System.Management.Automation.PSCustomObject] + + + Server hardware resource from Get-OVServer. + + + + + + + + HPEOneView.Servers.ServerHardware+FirmwareCompliancePreview + + + + A collection of server firmware installation report. Will contain identified installed components and which have available updates from the supplied baseline. + + + + + HPOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + Async task resource to monitor. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Update-OVServerFirmware -InputObject $Server -Baseline $Baseline -PreviewOnly + + + Generate a report of installed components to the server and available firmware within the specified baseline. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + $Servers = Get-OVServer | ? generation -eq "Gen10" +$Baseline = Get-OVBaseline -Name "Custom Baseline 2022 11 4" +Update-OVServerFirmware -InputObject $Servers -Baseline $Baseline + + + Get a collection of Gen10 servers and install the specific baseline. + + + + + + + + + + -------------------------- EXAMPLE 3 -------------------------- + + + + # Get the latest firmware bundles from HPE +$FirmwareBundleUpdates = Get-OVFirmwareBundleUpdate -GetLatestUpdates + +# Get all of the HPE ProLiant DL380 Gen11 servers from inventory +$Servers = Get-OVServer -Query "shortModel:'DL380 Gen11'" + +# Use the most current +$Baseline = $FirmwareBundleUpdates | ? bundleGeneration -contains "Gen11" | Sort -Property version -Descending | Select -First 1 + +# If there is a patch available, use the most recent version +if ($Baseline.Supplements.Count -gt 0) { + $Servers | Update-OVServerFirmware -Baseline $Baseline -PatchLevel ($Baseline.Supplements | Sort -Descending | Select -First 1) +} else { + $Servers | Update-OVServerFirmware -Baseline $Baseline +} + + Get the most current firmware bundle available for Gen11, and use the most current patch level if available. + + + + + + + + + + + + + Wait-OVTaskStart + + + + Wait-OVTaskComplete + + + + Online: + https://hpe-docs.gitbook.io/posh-hpeoneview/cmdlets/v9.00/servers/update-ovserverfirmware + + + + + + + + Update-OVServerHardwareLicenseIntent + + Change the license intent of a server. + + Update + OVServerHardwareLicenseIntent + + + The licensing intent of a server may be changed to either "OneView" (HPE OneView Advanced) or "OneViewNoiLO" (HPE OneView Advanced w/o iLO). The server must be unlicensed and managed in order to be able to update the licensing intent. In addition, a server licensed with "OneViewNoiLO" may be upgraded to "OneView", provided a "OneView" license is available and the server does not already have an embedded or "iLO Advanced" license installed. + + + + + Update-OVServerHardwareLicenseIntent + + InputObject + + A server hardware resource from Get-OVServer. + + Object + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + SwitchParameter + + False + + + InputObject + + A server hardware resource from Get-OVServer. + + Object + + Object + + + + + + + + + HPEOneView.ServerHardware [System.Management.Automation.PSCustomObject] + + + A server hardware resource from Get-OVServer. + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + Async task Resource object for configuring port monitoring on the requested logical intercinnect. + + + + + null + + + + If the resource is already assigned a valid upgraded license, a null response is returned. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + $Server = Get-OVServer -Name iLO123.domain.com -ErrorAction Stop +Update-OVServerHardwareLicenseIntent -InputObject $Server + + Get the specific server resource, and attempt upgrading the license to "OneView". + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + $Servers = Get-OVServer | ? licensingIntent -eq "OneViewNoIlo" +$Tasks = $Servers | Update-OVServerHardwareLicenseIntent -async + + Get server resources with "OneViewNoIlo" license, and attempt upgrading the license to "OneView". + + + + + + + + + + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/servers/update-ovserverhardwarelicenseintent + + + + + + + + Update-OVServerProfile + + Update Server Profile from Template + + Update + OVServerProfile + + + This Cmdlet performs one of two different operations. By default, it will perform the "Update from Server Profile Template" operation on 1 or more Server Profile resources. You can use Update from template to update the configuration of the server profile to make it consistent with its parent server profile template. + +To bring an inconsistent (Inconsistent with template) server profile configuration back into consistency (Consistent) with the server profile template, you must reapply the settings from the server profile template either manually or automatically. Some server profile updates can be automatically performed when the server hardware is powered on and some updates can only be performed when the server hardware is powered off. You can now defer the automatic updates until the next hardware maintenance window or cancel them if you do not want to proceed with the updates. If a Server Profile is already in a "Compliant" state, then no action will be taken + +The second operation is Reapply, using the -Reapply parameter. You can reapply a server profile to resolve errors or to ensure that the server hardware configuration matches the server profile. To reduce the time required to reapply a profile, individual components can be omitted from the reapply operation by clearing those components by omitting their switch parameter. Profiles that are in an error state can be reapplied, but individual components cannot be omitted. + +Minimum required permissions: (Update from Template) Infrastructure administrator or Server administrator. (Reapply a server profile) Infrastructure administrator, Server administrator, or Server firmware operator. + + + + + Update-OVServerProfile + + InputObject + + The resource object of the specific Server Profile to update. + + Object + + + Stage + + If a setting requires the server tobe powered off, certain updates can be staged. + + SwitchParameter + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + WhatIf + + + + + + + Confirm + + + + + + + + Update-OVServerProfile + + InputObject + + The resource object of the specific Server Profile to update. + + Object + + + Refresh + + Choose to refresh the server profile state. This does not perform re-apply or update from template operation. + + SwitchParameter + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + WhatIf + + + + + + + Confirm + + + + + + + + Update-OVServerProfile + + InputObject + + The resource object of the specific Server Profile to update. + + Object + + + Reapply + + Use to perform the Reapply Server Profile operation. Server should be powered off to perform certain operations. + + SwitchParameter + + + Baseline + + Re-apply Baseline. If setting is Firmware only, the associated server hardware must be powered off. + + SwitchParameter + + + AdapterAndBoot + + Re-apply Boot settings, including adapter boot preference. + + SwitchParameter + + + Connections + + Re-apply Vitual Connect connections. Will re-provision downlink ports and connection templates for the provided server profile. + + SwitchParameter + + + LocalStorage + + Re-apply Local Storage settings. This will cause the SmartArray to rescan for disks that should be part of the configured Logical Disk. Server Hardware must be powered off in order for operation to be successful. + + SwitchParameter + + + SANStorage + + Re-apply SAN storage settings. Only applies to SAN zoning and volume presentation, and not recreating SAN volumes. + + SwitchParameter + + + BIOS + + Re-apply BIOS settings. Gen8 server hardware must be powered off for this operation to be allowed. Gen9 and newer can be performed while the server hardware is powered on. + + SwitchParameter + + + Ilo + + Re-apply iLO settings that are defined in the profile. + + SwitchParameter + + + OSDeployment + + Re-apply OS Deployment Plan settings. + + SwitchParameter + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + + WhatIf + + + + + + + Confirm + + + + + + + + + + + AdapterAndBoot + + Re-apply Boot settings, including adapter boot preference. + + SwitchParameter + + SwitchParameter + + False + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + Async + + Use this parameter to immediately return the async task. By default, the Cmdlet will wait for the task to complete. + + SwitchParameter + + SwitchParameter + + False + + + BIOS + + Re-apply BIOS settings. Gen8 server hardware must be powered off for this operation to be allowed. Gen9 and newer can be performed while the server hardware is powered on. + + SwitchParameter + + SwitchParameter + + False + + + Baseline + + Re-apply Baseline. If setting is Firmware only, the associated server hardware must be powered off. + + SwitchParameter + + SwitchParameter + + False + + + Confirm + + + + + + + + + + + Connections + + Re-apply Vitual Connect connections. Will re-provision downlink ports and connection templates for the provided server profile. + + SwitchParameter + + SwitchParameter + + False + + + Ilo + + Re-apply iLO settings that are defined in the profile. + + SwitchParameter + + SwitchParameter + + + + + InputObject + + The resource object of the specific Server Profile to update. + + Object + + Object + + + + + LocalStorage + + Re-apply Local Storage settings. This will cause the SmartArray to rescan for disks that should be part of the configured Logical Disk. Server Hardware must be powered off in order for operation to be successful. + + SwitchParameter + + SwitchParameter + + False + + + OSDeployment + + Re-apply OS Deployment Plan settings. + + SwitchParameter + + SwitchParameter + + False + + + Reapply + + Use to perform the Reapply Server Profile operation. Server should be powered off to perform certain operations. + + SwitchParameter + + SwitchParameter + + False + + + Refresh + + Choose to refresh the server profile state. This does not perform re-apply or update from template operation. + + SwitchParameter + + SwitchParameter + + + + + SANStorage + + Re-apply SAN storage settings. Only applies to SAN zoning and volume presentation, and not recreating SAN volumes. + + SwitchParameter + + SwitchParameter + + False + + + Stage + + If a setting requires the server tobe powered off, certain updates can be staged. + + SwitchParameter + + SwitchParameter + + + + + WhatIf + + + + + + + + + + + + + + + HPEOneView.ServerProfile [System.Management.Automation.PSCustomObject] + + + One or more Server Profile resources from Get-OVServerProfile. + + + + + + + + HPEOneView.ServerProfile.CompliancePreview + + + + Object containing the operations to be performed when the Server Profile object is not compliant. + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + Async task Resource object to monitoring. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVServerProfile -Name "My Profile 1" | Update-OVServerProfile + + Get all storage system resource objects managed by the appliance. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Get-OVServerProfile | Update-OVServerProfile + + Get all Server Profile resources and perform the Update from Server Profile Template action. + + + + + + + + + + + + + Convert-OVServerProfile + + + + Convert-OVServerProfileTemplate + + + + ConvertTo-OVServerProfileTemplate + + + + Copy-OVServerProfile + + + + Get-OVServerProfile + + + + Get-OVServerProfileConnectionList + + + + Get-OVServerProfileMessage + + + + Get-OVServerProfileTemplate + + + + Join-OVServerProfileToTemplate + + + + New-OVServerProfile + + + + New-OVServerProfileAssign + + + + New-OVServerProfileAttachVolume + + + + New-OVServerProfileConnection + + + + New-OVServerProfileLogicalDisk + + + + New-OVServerProfileLogicalDiskController + + + + New-OVServerProfileTemplate + + + + Remove-OVServerProfile + + + + Remove-OVServerProfileTemplate + + + + Save-OVServerProfile + + + + Save-OVServerProfileTemplate + + + + Set-OVServerProfile + + + + Set-OVServerProfileTemplate + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/servers/update-ovserverprofile + + + + + + + + Update-OVStoragePool + + Refresh a storage pool. + + Update + OVStoragePool + + + Use this Cmdlet to refresh a storage pool when it's associated policies have been updated within the storage system external management console. Can be used to collect new Nimble Volume Sets. + + + + + Update-OVStoragePool + + InputObject + + The storage pool object to update or refresh. + + HPEOneView.Storage.StoragePool[] + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + + + + + + ApplianceConnection + + Specify one or more [HPEOneView.Appliance.Connection] object(s) or Name property value(s). + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + InputObject + + The storage pool object to update or refresh. + + HPEOneView.Storage.StoragePool[] + + HPEOneView.Storage.StoragePool[] + + + + + + + + + HPEOneView.Storage.StoragePool + + + One or more storage pool resources from Get-OVStoragePool. + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + Asynchronous task resource to monitor. + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVStoragePool -Name default | Update-OVStoragePool + + Update the Nimble storage pool 'default' to refresh available policies. + + + + + + + + + + + + + Add-OVStoragePool + + + + Get-OVStoragePool + + + + Remove-OVStoragePool + + + + Set-OVStoragePool + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/storage/update-ovstoragepool + + + + + + + + Update-OVStorageSystem + + Update/Refresh available Storage Systems + + Update + OVStorageSystem + + + This Cmdlet will update or refresh the specific storage system(s) configured on the HPE OneView appliance. Refreshing the storage system will cause HPE OneView to validate connectivity, the addition of any new CPG"s, and any Storage System Host Port configuration changes. + + + + + Update-OVStorageSystem + + InputObject + + The Storage System resource object to update/refresh. + + Object + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + + + + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + InputObject + + The Storage System resource object to update/refresh. + + Object + + Object + + + + + + + + + HPEOneView.Storage.System [System.Management.Automation.PSCustomObject] + + + Single Storage System + + + + + System.Collections.ArrayList <HPEOneView.Storage.System> + + + Multiple Storage Systems + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + Update Storage System async task object + + + + + System.Collections.ArrayList <HPEOneView.Appliance.TaskResource> + + + + Multiple Update Storage System async task objects + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Get-OVStorageSystem | Update-OVStorageSystem + + Get all managed Storage Systems and refresh them. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Get-OVStorageSystem -Name MyStorageSystem | Update-OVStorageSystem + + Get the "MyStorageSystem" managed Storage Systems and refresh it. + + + + + + + + + + + + + Add-OVStorageSystem + + + + Get-OVStorageSystem + + + + Remove-OVStorageSystem + + + + Show-OVStorageSystemPerformancePolicy + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/storage/update-ovstoragesystem + + + + + + + + Update-OVUserScript + + Update user scripts with updated Cmdlet and class names. + + Update + OVUserScript + + + The HPE OneVIew 5.30 PowerShell library has gone through a major change, in that all Cmdlet and the C# base class name have changed. PowerShell Cmdlet nouns used the HPOV vendor prefix. This is now OV. The C# based class namespace was HPOneView, and is now HPEOneView. + +This script will process a user created script to find references to the original Cmdlet and Class names, and update them acordingly. By default, this Cmdlet will only output to the console the changes it would make. Use the -Replace parameter to commit those changes to the orignal file. + + + + + Update-OVUserScript + + Path + + The path and file to be process. + + FileInfo + + + Replace + + Use to save the changes to the original file. + + SwitchParameter + + + + + + + Path + + The path and file to be process. + + FileInfo + + FileInfo + + + + + Replace + + Use to save the changes to the original file. + + SwitchParameter + + SwitchParameter + + + + + + + + + System.IO.FileInfo + + + The file object to parse and update. + + + + + + + + System.String + + + + Output of script that would have been modified. Using the -Replace parameter will generate no output. + + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Update-OVUserScript -Path .\MyScript.ps1 + + + Process the MyScript.ps1 script present in the working directory. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + Get-ChildItem -Path C:\MyDir -Include *.ps1 | Update-OVUserScript -Replace + + + Process scripts (.ps1) found in the specified directory, and save them. + + + + + + + + + + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/library/update-ovuserscript + + + + + + + + Wait-OVApplianceStart + + Wait for Appliance services to start. + + Wait + OVApplianceStart + + + Internal module helper function to wait for the appliance services to start. This helper function will be called by Send-OVRequest when the [System.Net.WebRequest] GetResponse() client generates an [Net.WebException] exception. Then, this function will be called to provide the caller with an indication that the appliance is starting its services. This will display two prompts: + +1. An initial text-based progress bar while the System.Net.WebRequest is able to access the web service on the appliance to begin polling for service startup status. +2. Write-Progress indicator displaying the overall service startup. + +If any service fails to startup, this function will cause a terminating error, informing the caller to go visit the appliance kiosk console to get more information about the startup error. + +When the appliance successfully starts, this function will return. + + + + + Wait-OVApplianceStart + + Hostname + + Specify the appliance FQDN or IP Address without a valid connection created by using Connect-OVMgmt. + + String + + + + + + + Hostname + + Specify the appliance FQDN or IP Address without a valid connection created by using Connect-OVMgmt. + + String + + String + + + + + + + + + None. You cannot pipe objects to this Cmdlet. + + + None. You cannot pipe objects to this Cmdlet + + + + + + + + Write-Progress + + + + The Write-Progress Cmdlet is used to display the startup progress + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Wait-OVApplianceStart -Appliance appliance.contoso.com + + Wait for the appliance to start, and specify the appliance name. + + + + + + + + + + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/library/wait-ovappliancestart + + + + + + + + Wait-OVTaskComplete + + Wait for a task to complete. + + Wait + OVTaskComplete + + + HPE OneView utilizes a task subsystem for operations that will take longer than 200ms, and will execute them Asyncrounously. An async task resource object is created and returned to the caller once the request has passed validation. + +This blocking Cmdlet assists a caller with monitoring a specific task resource, and will wait for the given task to "complete" (get to a terminal state, including error) or timeout. The Cmdlet accepts either the task URI or resource object via pipeline. + +Once the task is no longer in a running state, the cmlet will return the task resource object. The caller should examine the taskState property/key for the final task status. + + + + + Wait-OVTaskComplete + + InputObject + + The uri of the task resource to wait for. + + Object + + + Timeout + + The timespan to wait for the task to complete. Default is to wait for 20 minutes. + + TimeSpan + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + + ApplianceWillReboot + + Internal use: to indicate if a task will cause appliance to reboot. + + SwitchParameter + + + + + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + ApplianceWillReboot + + Internal use: to indicate if a task will cause appliance to reboot. + + SwitchParameter + + SwitchParameter + + + + + InputObject + + The uri of the task resource to wait for. + + Object + + Object + + + + + Timeout + + The timespan to wait for the task to complete. Default is to wait for 20 minutes. + + TimeSpan + + TimeSpan + + $DefaultTimeout + + + + + + + System.String + + + Task URI + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + Task resource object + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + The finished Task object that includes the task result + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + Wait-OVTaskComplete -InputObject $task -timeout (New-TimeSpan -minute 10) +Waiting for task to complete..Task completed successfully! + + Wait for task to complete, modifying the default timeout to 10 minutes. + + + + + + + + + + -------------------------- EXAMPLE 2 -------------------------- + + + + $svr = Get-OVServer -Name "ServerA" +$taskResults = New-OVServerProfile -name "Profile 1" -server $svr | Wait-OVTaskComplete + + Retrieve the server details for ServerA, create a Server Profile and pass via pipeline the task resource object. + + + + + + + + + + + + + Get-OVTask + + + + Wait-OVTaskStart + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/wait-ovtaskcomplete + + + + + + + + Wait-OVTaskStart + + Wait for a task to start. + + Wait + OVTaskStart + + + HPE OneView utilizes a task subsystem for operations that will take longer than 200ms, and will execute them Asyncrounously. An async task resource object is created and returned to the caller once the request has passed validation. + +This blocking Cmdlet assists a caller with waiting for the given task to "start" (get beyond validation phase) or timeout. + +Once the task enters the running state, the Cmdlet will return the task resource object. The caller could then use Wait-OVTaskComplete to further monitor the task progression. + + + + + Wait-OVTaskStart + + InputObject + + The object of the task resource to wait for. + + Object + + + resourceName + + Specify the associated ResourceName to the task in order to display in the Write-Progress -activity parameter. + + String + + + Timeout + + The time or object to wait for the task to start. Default is to wait for 20 minutes. + + TimeSpan + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + + + + + + ApplianceConnection + + Specify one HPEOneView.Appliance.Connection object or Name property value. If Resource object is provided via Pipeline, the ApplianceConnection property of the object will be used. + + Object + + Object + + (${Global:ConnectedSessions} | ? Default) + + + InputObject + + The object of the task resource to wait for. + + Object + + Object + + + + + Timeout + + The time or object to wait for the task to start. Default is to wait for 20 minutes. + + TimeSpan + + TimeSpan + + $script:defaultTimeout + + + resourceName + + Specify the associated ResourceName to the task in order to display in the Write-Progress -activity parameter. + + String + + String + + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + Task async object + + + + + + + + HPEOneView.Appliance.TaskResource [System.Management.Automation.PSCustomObject] + + + + Task async object + + + + + + + -------------------------- EXAMPLE 1 -------------------------- + + + + $Task = Add-OVServer -Hostname MyiLO.domain.com -Username Administrator -Password password | Wait-OVTaskStart + + Add a new Server Device to the appliance, wait for the Asynchronous task to enter Starting State, and save the task object. + + + + + + + + + + + + + Get-OVTask + + + + Wait-OVTaskComplete + + + + Online: + https://hpe-docs.gitbook.io/posh-hponeview/cmdlets/v9.00/appliance/wait-ovtaskstart + + + + + \ No newline at end of file diff --git a/en-US/about_Appliance_Connection_Permissions.help.txt b/en-US/about_Appliance_Connection_Permissions.help.txt new file mode 100644 index 0000000..468e161 --- /dev/null +++ b/en-US/about_Appliance_Connection_Permissions.help.txt @@ -0,0 +1,120 @@ +TOPIC + + about_Appliance_Connection_Permissions + +SHORT DESCRIPTION + + Explains how HPE OneView 4.00 and newer session permissions can be changed. + +LONG DESCRIPTION + + Permissions are used to control a user's access to the appliance and the resources + managed by the appliance. Permissions consist of a role and an optional scope. The + permission role grants the user access to resource categories. For example, the "Server + administrator" role grants read, create, delete, update and use rights to the "server + hardware" category. Specifying a permission scope further restricts the rights granted + by the role to a subset of instances within a resource category. For example, a scope + called "Test" can be created by the Infrastructure Administrator or Scope Administrator, + and be used to restrict the server hardware rights granted by the "Server administrator" + role to only the servers in the Test scope. + + A user or group may be assigned multiple permissions. Use the Set-OVUser or + Set-OVLdapGroupRole to manage the roles and permissions assigned to a user or group. + + You create a login session when you log in to the appliance using Connect-OVMgmt. Upon + successful login, the session grants the user all permissions assigned by the + Infrastructure Administrator or Scope Administrator. These permissions are called + [HPEOneView.Appliance.ConnectionPermission]. Each permission provided by the appliance are + stored within the [HPEOneView.Appliance.Connection] AcivePermissions property. The Active + property indicates if the permission is active. + + A user granted multiple permissions can disable certain permissions. When operating with + reduced permissions, the user is only allowed to perform actions authorized for the selected + permission. + + Allowing a user to operate in a least privilege mode is a security best practice. It + allows the user to reduce the risk of making an unintended change. + +CHANGING ACTIVE PERMISSIONS + + Upon successful login, the caller can change their active permissions, and operate in + a less priviledge mode at anytime. The Push-OVAppliancePermission Cmdlet will accept a + single or collection of [HPEOneView.Appliance.ConnectionPermission] objects. A new SessionID + token will be stored within the ApplianceConnection, and the ConnectionPermissions within + the ActivePermissions property that were not provided will have the Active property set to + "false". + + For example, to change the active permissions to the assigned "Network administrator" role: + + PS C:\> # Show current SessionID + PS C:\> $ConnectedSessions[0].SessionID + MzA3MzkzNDY4Mjc3tG-DBtvzHwq51sBGY1zk-7Uw1eT17BbJ + PS C:\> Connect-OVMgmt hpov1.domain.com administrator MyPassw0rd + PS C:\> $ConnectedSessions[0].ActivePermissions + + RoleName ScopeName Active + -------- --------- ------ + Network administrator Site A Admins True + Server administrator AllResources True + + PS C:\> $NewPermissions = $ConnectedSessions[0].ActivePermissions | ? RoleName -match 'Network' + PS C:\> Push-OVAppliancePermission -SetActivePermissions $NewPermissions + + RoleName ScopeName Active + -------- --------- ------ + Network administrator Site A Admins True + Server administrator AllResources False + + PS C:\> # Show updated SessionID + PS C:\> $ConnectedSessions[0].SessionID + OTA0Mjg2Nzc5Nzk1FVcdSabKJ5wqD-ScZKYOHsJk8WqWDRYX + ... + + For example, to change the active permissions to the assigned "Site A Admins" scope: + + PS C:\> # Show current SessionID + PS C:\> $ConnectedSessions[0].SessionID + NzI2MTMxNzEzMjQztb0Rj0hqWwiLa3qFWgKvo13Qn5vs4k1r + PS C:\> $ConnectedSessions[0].ActivePermissions + + RoleName ScopeName Active + -------- --------- ------ + Network administrator Site A Admins True + Server administrator AllResources True + Server administrator AllResources True + + PS C:\> $NewPermissions = $ConnectedSessions[0].ActivePermissions | ? ScopeName -match 'Site A Admins' + PS C:\> Push-OVAppliancePermission -SetActivePermissions $NewPermissions + + RoleName ScopeName Active + -------- --------- ------ + Network administrator Site A Admins True + Server administrator AllResources False + Server administrator AllResources False + + PS C:\> # Show updated SessionID + PS C:\> $ConnectedSessions[0].SessionID + ATh0MjQ5MjM1ODE0fFqfxUPWWGo4Y-QsPWRpZDsYxmy8Xejb + ... + + If the caller would like to reset their active permissions back to the original state, use + the Pop-OVAppliancePermission Cmdlet. + + +SEE ALSO + + https://github.com/HewlettPackard/POSH-HPOneView + https://hpe-docs.gitbook.io/posh-hpeoneview + http://hp.com/go/oneviewcommunity + Get-Help about_HPEOneView.900 + Get-Help about_Appliance_Connections + Get-Help Push-OVAppliancePermission + Get-Help Pop-OVAppliancePermission + + + + + + + + diff --git a/en-US/about_Appliance_Connections.help.txt b/en-US/about_Appliance_Connections.help.txt new file mode 100644 index 0000000..59cf6f0 --- /dev/null +++ b/en-US/about_Appliance_Connections.help.txt @@ -0,0 +1,162 @@ +TOPIC + + about_Appliance_Connections + +SHORT DESCRIPTION + + Explains how Multiple Appliance Connections are handled with the + HPE OneView 2.00 and newer PowerShell Library. + +LONG DESCRIPTION + + In the HPE OneView 2.0 or newer PowerShell library is the ability to + initiate multiple appliance connections to script or automate operations. + To support this capability, the library utilizes three features: + + -- When using Connect-OVMgmt, an [HPEOneView.Appliance.Connection] object + is returned to the caller. + + -- The [HPEOneView.Appliance.Connection] object is stored in a global variable + accessible by any caller: $ConnectedSessions + + -- Within the [HPEOneView.Appliance.Connection] object is a property called + Default. This boolean value is what controls which appliance + to execute against if the caller does not specify which appliance + connection to use. + +GLBOAL CONNECTION TRACKING OBJECT + + Contained in the $ConnectedSessions Global varilable, will be each + successful appliance connection object, HPEOneView.Appliance.Connection. + The object contains the following properties: + + -- ConnectID - Unique per PowerShell library session + -- Name - Hostname of the appliance connection, specified by the + 'Hostname' parameter in Connect-OVMgmt. + -- SessionID - Appliance API Auth session ID + -- UserName - Username that was authenticated with to the appliance + -- AuthLoginDomain - Authentication Directory resource name used to + authenticate user. + -- Default - Boolean value that tracks which connection is the default. + Use the Set-OVApplianceDefaultConnection Cmdlet to control the value + -- SSLChecked - library specific property to handle SSL certificate + verification. (DEPRECATED and no longer valid) + -- ApplianceType - Indicates connected appliance type. Used for cetain + Cmdlet validation. + -- AuthType - Credential or Certificate/Two-Factor authentication. + -- ActivePermissions - A collection of HPOnewView.Appliance.ConnectionPermission + objects that contain the Scope and Role available to the authenticated + user. + -- ApplianceSecurityRoles - The allowed roles by the connected appliance. + Property value is used to validate roles when assigning to Directory + groups or local user accounts. + -- Default - used to define which connection is the 'default' for Cmdlet + processing. Use the Set-OVApplianceDefaultConnection Cmdlet to modify + this value. + + After successfully authenticating to an appliance, the + HPEOneView.Appliance.Connection object is added to the global session + tracker, $ConnectedSessions. + +HOW TO USE CONNECTION IN CMDLETS + + The PowerShell user can store the returned HPEOneView.Appliance.Connection + object in their own local, script-runspace variable, and pass it as the + ApplianceConnection parameter value in supported CMDLETs. + + Some CMDLETs will default to using all connections within $ConnectedSessions, + and can be overridden by referencing the specific connection Name or + object. + + For instance, Get-OVNetwork will default to processing all appliance + connections, as the -ApplianceConnection parameter default value is + $ConnectedSessions. To override its default value, you can either specify + the object, or the appliance connection Name property value. + + + This example shows how to use the connection 'object': + + PS C:\> $Connection1 = Connect-OVMgmt hpov1.domain.com administrator MyPassw0rd + PS C:\> $Connection2 = Connect-OVMgmt hpov2.domain.com administrator MyPassw0rd + PS C:\> $ConnectedSessions + + ConnectionID Name UserName AuthLoginDomain Default + ------------ ---- -------- --------------- ------- + 1 hpov1.domain.com Administrator LOCAL True + 2 hpov2.domain.com Administrator LOCAL False + + PS C:\> Get-OVNetwork -ApplianceConnection $Connection1 + ... + + + This example shows how to use the connection 'name': + + PS C:\> $Connection1 = Connect-OVMgmt hpov1.domain.com administrator MyPassw0rd + PS C:\> $Connection2 = Connect-OVMgmt hpov2.domain.com administrator MyPassw0rd + PS C:\> $ConnectedSessions + + ConnectionID Name UserName AuthLoginDomain Default + ------------ ---- -------- --------------- ------- + 1 hpov1.domain.com Administrator LOCAL True + 2 hpov2.domain.com Administrator LOCAL False + + PS C:\> Get-OVNetwork -ApplianceConnection hpov1.domain.com + ... + +SETTING DEFAULT APPLIANCE CONNECTION + + When authenticating to your first appliance, the 'Default' property is automatically + set to True. Additional Appliance Connections are candidates to set as your new + default appliance connection. To do this, use the Set-OVApplianceDefaultConnection + Cmdlet. You will specify either an HPEOneView.Appliance.Connection object (either from + ${Global:ConnectedSessions} or the saved object returned from Connect-OVMgmt) or + connection Name. + + This example shows how to modify your default appliance connection after successfully + authenticating to them: + + PS C:\> $Connection1 = Connect-OVMgmt hpov1.domain.com administrator MyPassw0rd + PS C:\> $Connection2 = Connect-OVMgmt hpov2.domain.com administrator MyPassw0rd + PS C:\> $ConnectedSessions + + ConnectionID Name UserName AuthLoginDomain Default + ------------ ---- -------- --------------- ------- + 1 hpov1.domain.com Administrator LOCAL True + 2 hpov2.domain.com Administrator LOCAL False + + PS C:\> $Connection2 | Set-OVApplianceDefaultConnection + + ConnectionID Name UserName AuthLoginDomain Default + ------------ ---- -------- --------------- ------- + 1 hpov1.domain.com Administrator LOCAL False + 2 hpov2.domain.com Administrator LOCAL True + +APPLIANCECONNECTION PROPERTY VALUE IN OBJECTS + + When using the various CMDLETs, the returned resource object(s) will contain a + property called ApplianceConnection [HPEOneView.Library.ApplianceConnection]: + + ----------------------- + | ApplianceConnection | + ----------------------- + | + | ---------------------- + |---| [int] ConnectionID | + | ---------------------- + | ----------------- + |---| [string] Name | + | ----------------- + + The 'ConnectionID' and 'Name' sub-properties reference the Appliance Connection + contained within ${Global:ConnectedSessions}. These are used to identify resources + that originate from the correct appliance, as each object is unique per appliance. + To use these properties with Send-OVRequest, they can be referenced with their dot + name reference (e.g. $ServerProfile.ApplianceConnection.Name). + +SEE ALSO + + https://github.com/HewlettPackard/POSH-HPEOneView + https://hpe-docs.gitbook.io/posh-hpeoneview + http://hpe.com/go/oneviewcommunity + Get-Help about_HPEOneView.900 + Get-Help about_Appliance_Connection_Permissions diff --git a/en-US/about_HPEOneView.900.help.txt b/en-US/about_HPEOneView.900.help.txt new file mode 100644 index 0000000..aaa3132 --- /dev/null +++ b/en-US/about_HPEOneView.900.help.txt @@ -0,0 +1,90 @@ +TOPIC + + about_HPEOneView.900 + +COPYRIGHT + + (C) Copyright 2013-2024 Hewlett Packard Enterprise Development LP + +LICENSE + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + +SHORT DESCRIPTION + + PowerShell library for HPE OneView 9.00 + +WHAT'S NEW + + Release 9.00.4010.1835 + + -- Initial HPE OneView 9.00 library release. + -- Added Get-OVRotateMPPasswordPolicy and Set-OVRotateMPPasswordPolicy cmdlets + that will rotate the priviledged user account OneView deploys to a servers + embedded management processor (i.e. iLO). + -- Added Firmware Bundle Updates to New-OVServerProfileTemplate and + New-OVServerProfile Cmdlets. + -- Added server profile support to Update-OVServerFirmware Cmdlet. This will + modify the server profile resource directly, and not invoke the process + with the server hardware resource. + -- Added Get-OVRemoteSupportPortalConnection, Register-OVRemoteSupportPortalConnection, + Unregister-OVRemoteSupportPortalConnection Cmdlets to manage registering the + appliance with the HPE Support Center for enhanced support case vibility. + -- Fixed New-OVRemoteSupportContact returning the correct object type. + -- Remove-OVRemoteSupportPartner API returns an Async task. + +LONG DESCRIPTION + + This library provides HP OneView management capabilities for Windows PowerShell. + The library can be used as either a CLI or using the core cmdlets to call from + wrapper scripts. The core cmdlets are: + + -- Connect-OVMgmt + -- Send-OVRequest + -- New-OVResource + -- Set-OVResource + -- Remove-OVResource + + A set of sample scripts are also provided, that show how to fully configure an + HP OneView appliance from the ground up. + + For information regarding this project, to request features or report + issues, please see: https://github.com/HewlettPackard/POSH-HPEOneView/issues + + +SEE ALSO + + https://github.com/HewlettPackard/POSH-HPEOneView + https://hpe-docs.gitbook.io/posh-hpeoneview + http://hpe.com/info/oneviewcommunity + Update-Help HPEOneView.900 + Get-Help about_Appliance_Connections + Get-Help about_Appliance_Connection_Permissions + Get-Help about_Two_Factor_Authentication + Get-Help Connect-OVmgmt + Get-Help Send-OVRequest + [install_dir]\Samples + + + + + + + + diff --git a/en-US/about_Two_Factor_Authentication.help.txt b/en-US/about_Two_Factor_Authentication.help.txt new file mode 100644 index 0000000..5492a64 --- /dev/null +++ b/en-US/about_Two_Factor_Authentication.help.txt @@ -0,0 +1,180 @@ +TOPIC + + about_Two_Factor_Authentication + +SHORT DESCRIPTION + + How to utilize two factor authentication with the HPE Oneview PowerShell + library. + +LONG DESCRIPTION + + Passwords, no matter how complex, provide insufficient security for many + applications. For additional security, use two-factor authentication. With + two-factor authentication, two factors are required for HPE OneView authentication. + The two factors are something the user possesses (a smart card), and something the + user knows (a personal identification number). + + HPE OneView user/password authentication + ---------------------------------------- + + Users can be configured in HPE OneView as local users, or remotely in an + enterprise directory. + + The traditional user name and password login sequence is as follows: + + 1. The user types their user name and password. + 2. HPE OneView authenticates the user name and password. + + * If the user name is that of a local user configured in HPE OneView, HPE + OneView validates a manually specified user name and password using the HPE + OneView database. + * If your environment is configured to use an enterprise directory, HPE OneView + immediately forwards the user name and password to a configured directory + server for authentication. + + 3. Once authentication is successful, HPE OneView determines the authorization + permissions for the user. + + * If it is a local user login, authorization permissions are decided based + on the roles associated with the user. + * If it is an enterprise directory login, HPE OneView sends a request to the + directory server to retrieve the group name associated with the user. It uses + the group name to determine the authorization permission for the user configured + in HPE OneView. + + HPE OneView two-factor authentication + ------------------------------------- + + Enabling two-factor authentication allows you to use smart cards — for example, + Common Access Cards (CAC), or Personal Identity Verification (PIV) cards — to + authenticate within HPE OneView. The client certificate embedded in the smart + card is presented to HPE OneView by the library. The client certificate must be + signed by a root or intermediate Certificate Authority (CA) that has been + previously imported into HPE OneView. The appliance authenticates the client + certificate to validate that the user name specified in the certificate is that + of a valid user recognized by the directory server configuration in HPE OneView. + + When two-factor authentication is enabled, HPE OneView uses a Microsoft Active + Directory service account set up and owned by the user to access an Active Directory + entry for the user, rather than using an account associated with the user name + received during first time login. + + The certificates stored on CAC/PIV cards are X.509 security certificates. They + contain fields of information used to identify the certificate owner, the + certificate issuer, and other certificate identification elements. When you + enable two-factor authentication, you can specify which certificate fields HPE + OneView must use to validate a user. + + An Infrastructure administrator also has the flexibility to customize the rules + HPE OneView applies during client certificate authentication. The Infrastructure + administrator can configure the locations within the certificate from which HPE + OneView retrieves the user name, domain name and the OIDs that must be present + for the certificate to be valid. See Set-OVApplianceTwoFactorAuthentication + help. + +AUTHENTICATING USING A SMARTCARD + + The users smart card or digital badge must be present on the PC. Using PowrShell's + native Certificate provider, the smart card can be accessed using the following: + + PS C:\> $MyCertificate = gci Cert:\CurrentUser\my | ? { $_.EnhancedKeyUsageList.FriendlyName -match 'Smart Card Logon' } + + Then, the $MyCertificate object can be passed into the Connect-OVMgmt + Cmdlet: + + PS C:\> Connect-OVMgmt -Hostname Myappliance.domain.com -Certificate $MyCertificate + +GLBOAL CONNECTION TRACKING OBJECT AND 2FA PROPERTIES + + Contained in the $ConnectedSessions Global varilable, will be each + successful appliance connection object, HPEOneView.Appliance.Connection. + When authenticating with a smart card, the AuthType property of the + HPEOneView.Appliance.Connection object will be set to "Certificate". + The "Authentication" property will be set to the Active Directory + authentication directory that authenticated the request. The + "ActivePermissions" property will contain the available Scopes and + Roles. + + To examine which Roles and Scopes are available for the logged in + account, examine the [HPEOneView.Appliance.Connect].ActivePermissions + property. This property is a collection of HPEOneView.Appliance.ActivePermissions + objects. The [String]ScopeName, [String]RoleName, and [Bool]Active + properties + + The SessionID within HPEOneView.Appliance.Connection object contains + the current users active permission set. To modify the active permission + set, use either the Pop-OVAppliancePermission or Push-OVAppliancePermission + Cmdlets. + +HOW TO USE SCOPES IN CMDLETS + + Scopes by default are managed by Infrastructure administrators, unless + the HPEOneView.Appliance.ScopeCollection resource has been scoped to a + local user or directory user with Scope administrator role. Once a + scope has been created, it can be used to filter for supported resource + objets: + + * Enclosures + * Server Hardware + * Networks (Ethernet, FC, and FCoE) + * Network Sets + * Interconnects, excluding SAS resources + * Logical Interconnects, excluding SAS resources + * Logical Interconnect Groups, excluding SAS resources + * Switches + * Logical Switches + * Logical Switch Groups + + The supporting Cmdlets for the above resources include a -Scope parameter + that allowed the caller to supply one or more HPEOneView.Appliance.ScopeCollection + resources to filter. By default, the appliance will return all available + resources that are part of the users Active Permissions Set. + + For instance, Get-OVNetwork -Scope $MyScopeObject will return only the + network objects that are a member of the scope within the $MyScopeObject + variable: + + PS C:\> $MyScopeObject = Get-OVScope -Name MyScope -ErrorAction Stop + PS C:\> Get-OVNetwork -Scope $MyScopeObject + + Type: Ethernet + + + Name Status Purpose Type VlanID IPv4Subnet Smartlink PrivateNetwork PreferredBandwidth MaxBandwidth + ---- ------ ------- ---- ------ ---------- --------- -------------- ------------------ ------------ + Dev VLAN 101-A OK General Tagged 101 None True False 2500 20000 + Dev VLAN 101-B OK General Tagged 101 None True False 2500 20000 + Dev VLAN 102-A OK General Tagged 102 None True False 2500 20000 + Dev VLAN 102-B OK General Tagged 102 None True False 2500 20000 + Dev VLAN 103-A OK General Tagged 103 None True False 2500 20000 + Dev VLAN 103-B OK General Tagged 103 None True False 2500 20000 + Dev VLAN 104-A OK General Tagged 104 None True False 2500 20000 + Dev VLAN 104-B OK General Tagged 104 None True False 2500 20000 + Dev VLAN 105-A OK General Tagged 105 None True False 2500 20000 + Dev VLAN 105-B OK General Tagged 105 None True False 2500 20000 + + Type: Fibre Channel + + + Name Status Type TypicalBandwidth MaxBandwidth AutoLoginRedistribution LinkStabilityInterval ManagedSAN + ---- ------ ---- ---------------- ------------ ----------------------- --------------------- ---------- + Fabric A OK FabricAttach 4000 20000 True 30 SA + Fabric B OK FabricAttach 4000 20000 True 30 SA + + ... + +SEE ALSO + + https://github.com/HewlettPackard/POSH-HPEOneView + https://hpe-docs.gitbook.io/posh-hpeoneview + http://hp.com/go/oneviewcommunity + Get-Help about_HPEOneView.900 + + + + + + + +